Plugin Directory

Changeset 507146


Ignore:
Timestamp:
02/19/2012 01:02:29 AM (14 years ago)
Author:
Codevendor
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • token-manager/trunk/tokens.php

    r506738 r507146  
    8585    //get the number of records in the database table
    8686    $pagination_count = 0;
     87    $startid = 0;
     88    $endid = 0;
    8789    if(!empty($filt))
    8890    {
     91      $startid = $wpdb->get_var($wpdb->prepare("SELECT a.id     
     92                                 FROM $tablename1 a
     93                                 LEFT JOIN $tablename2 b ON a.typeid = b.id
     94                                 LEFT JOIN $tablename3 c ON a.authorid = c.ID
     95                                WHERE a.active = 1 AND b.active = 1 AND a.siteid='$siteid' AND a.blogid='$blogid' order by a.processorder DESC LIMIT 1"));
     96
     97      $endid = $wpdb->get_var($wpdb->prepare("SELECT a.id     
     98                                 FROM $tablename1 a
     99                                 LEFT JOIN $tablename2 b ON a.typeid = b.id
     100                                 LEFT JOIN $tablename3 c ON a.authorid = c.ID
     101                                 WHERE a.active = 1 AND b.active = 1 AND a.siteid='$siteid' AND a.blogid='$blogid' order by a.processorder ASC LIMIT 1"));
     102
    89103      $pagination_count = $wpdb->get_var($wpdb->prepare("SELECT count(*)     
    90104                                 FROM $tablename1 a
     
    95109    else
    96110    {
     111      $startid = $wpdb->get_var($wpdb->prepare("SELECT a.id     
     112                                 FROM $tablename1 a
     113                                 LEFT JOIN $tablename2 b ON a.typeid = b.id
     114                                 LEFT JOIN $tablename3 c ON a.authorid = c.ID
     115                                 WHERE a.active = 1 AND b.active = 1 AND a.siteid='$siteid' AND a.blogid='$blogid' order by a.processorder DESC LIMIT 1"));
     116
     117      $endid = $wpdb->get_var($wpdb->prepare("SELECT a.id     
     118                                 FROM $tablename1 a
     119                                 LEFT JOIN $tablename2 b ON a.typeid = b.id
     120                                 LEFT JOIN $tablename3 c ON a.authorid = c.ID
     121                                 WHERE a.active = 1 AND b.active = 1 AND a.siteid='$siteid' AND a.blogid='$blogid' order by a.processorder ASC LIMIT 1"));
     122
    97123      $pagination_count = $wpdb->get_var($wpdb->prepare("SELECT count(*)     
    98124                                 FROM $tablename1 a
     
    109135    $list_start = $paging->get_rangestart()-1;
    110136    $results = $paging->render('Find Token') . '<table class="widefat">
    111                 <thead><tr><th></th><th></th><th></th><th></th><th></th><th>Token ID</th><th>Token Name</th><th>Token Type</th><th></th><th></th></tr></thead>
    112                 <tfoot><tr><th></th><th></th><th></th><th></th><th></th><th>Token ID</th><th>Token Name</th><th>Token Type</th><th></th><th></th></tr></tfoot><tbody>';
     137                <thead><tr><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th>Order</th><th>Token ID</th><th>Token Name</th><th>Token Type</th><th></th><th></th></tr></thead>
     138                <tfoot><tr><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th>Order</th><th>Token ID</th><th>Token Name</th><th>Token Type</th><th></th><th></th></tr></tfoot><tbody>';
    113139
    114140    if(!empty($filt))
    115141    {
    116       $items = $wpdb->get_results("SELECT a.id as id, a.tokenname as tokenname, a.frontpage as frontpage, a.allpages as allpages,  b.tokentype as tokentype, FROM_UNIXTIME(a.datecreated) as datecreated,
     142      $items = $wpdb->get_results("SELECT a.id as id, a.processorder as processorder, a.tokenname as tokenname, a.frontpage as frontpage, a.allpages as allpages,  b.tokentype as tokentype, FROM_UNIXTIME(a.datecreated) as datecreated,
    117143                                 FROM_UNIXTIME(a.lastupdated) as lastupdated, a.description as description, c.user_login as author, a.authorid as authorid, a.version as version     
    118144                                 FROM $tablename1 a
     
    120146                                 LEFT JOIN $tablename3 c ON a.authorid = c.ID
    121147                                 WHERE a.active = 1 AND b.active = 1 AND a.siteid='$siteid' AND a.blogid='$blogid' $filt
    122                                  ORDER BY a.datecreated DESC LIMIT $list_start, $list_end");
     148                                 ORDER BY a.processorder DESC LIMIT $list_start, $list_end");
    123149     }
    124150     else
    125151     {
    126        $items = $wpdb->get_results("SELECT a.id as id, a.tokenname as tokenname, a.frontpage as frontpage, a.allpages as allpages,  b.tokentype as tokentype, FROM_UNIXTIME(a.datecreated) as datecreated,
     152       $items = $wpdb->get_results("SELECT a.id as id, a.processorder as processorder, a.tokenname as tokenname, a.frontpage as frontpage, a.allpages as allpages,  b.tokentype as tokentype, FROM_UNIXTIME(a.datecreated) as datecreated,
    127153                                 FROM_UNIXTIME(a.lastupdated) as lastupdated, a.description as description, c.user_login as author, a.authorid as authorid, a.version as version     
    128154                                 FROM $tablename1 a
     
    130156                                 LEFT JOIN $tablename3 c ON a.authorid = c.ID
    131157                                 WHERE a.active = 1 AND b.active = 1 AND a.siteid='$siteid' AND a.blogid='$blogid'
    132                                  ORDER BY a.datecreated DESC LIMIT $list_start, $list_end");
     158                                 ORDER BY a.processorder DESC LIMIT $list_start, $list_end");
    133159     }
    134160
     
    140166      $alttext = ($alt) ? 'alternate' : '';
    141167      $id = $item->id;
     168      $processorder = $item->processorder;
    142169      $tokenname = '{' . $item->tokenname . '}';
    143170      $tokentype = $item->tokentype;
     
    148175      $authorid = $item->authorid;
    149176      $version = $item->version;
     177      $moveup = ($id!=$startid) ? "<td style=\"width: 16px; cursor: pointer;\"><a href=\"javascript:void(0);\" onclick=\"moveup($id);\"><img src=\"" . plugin_dir_url( __FILE__ )  . "icons/up.png\" alt=\"Process Token After\" title=\"Process Token After\" /></a></td>" : "<td style=\"width: 16px;\"></td>";
     178      $movedown = ($id!=$endid) ? "<td style=\"width: 16px; cursor: pointer;\"><a href=\"javascript:void(0);\" onclick=\"movedown($id);\"><img src=\"" . plugin_dir_url( __FILE__ )  . "icons/down.png\" alt=\"Process Token Before\" title=\"Process Token Before\" /></a></td>" : "<td style=\"width: 16px;\"></td>";
    150179      $results .= "<tr class=\"" . $alttext . "\">
     180                   $moveup
     181                   $movedown
    151182                   <td style=\"width: 16px; cursor: pointer;\"><a href=\"admin.php?page=tokenmanageredit&tid=$id\"><img src=\"" . plugin_dir_url( __FILE__ )  . "icons/edit.png\" alt=\"Edit Token ($id)\" title=\"Edit Token ($id)\" /></a></td>
    152183                   <td style=\"width: 16px;\"><img src=\"" . plugin_dir_url( __FILE__ )  . "icons/stats.png\" alt=\"Date Created: $datecreated  |  Last Updated: $lastupdated\" title=\"Date Created: $datecreated  |  Last Updated: $lastupdated\" /></td>
     
    154185                   <td style=\"width: 16px;\"><img src=\"" . plugin_dir_url( __FILE__ )  . "icons/description.png\" alt=\"$description\" title=\"$description\" /></td>
    155186                   <td style=\"width: 16px; cursor: pointer;\"><a href=\"javascript:void(0);\" onclick=\"loadpopup($id);\"><img src=\"" . plugin_dir_url( __FILE__ )  . "icons/pages.png\" alt=\"Attached Pages\" title=\"Attached Pages\" /></a></td>
     187                   <td style=\"width: 85px;\">$processorder</td>
    156188                   <td style=\"width: 85px;\">$id</td>
    157189                   <td>$tokenname</td>
     
    311343    document.getElementById('tokenid').value=id;
    312344    document.getElementById('myfrom').submit();
     345  }
     346}
     347
     348function moveup(tid)
     349{
     350  if(tid)
     351  {
     352    var a = new System.Net.Ajax.Request("POST","admin.php?page=tokenmanagerjson", pocb, true);
     353    a.AddParam("json","moveup");
     354    a.AddParam("tid",tid);
     355    var b = new System.Net.Ajax.PageRequests(a);
     356    var c = new System.Net.Ajax.Connection(b);
     357    c.Open();
     358  }
     359}
     360
     361function movedown(tid)
     362{
     363  if(tid)
     364  {
     365    var a = new System.Net.Ajax.Request("POST","admin.php?page=tokenmanagerjson", pocb, true);
     366    a.AddParam("json","movedown");
     367    a.AddParam("tid",tid);
     368    var b = new System.Net.Ajax.PageRequests(a);
     369    var c = new System.Net.Ajax.Connection(b);
     370    c.Open();
     371  }
     372}
     373
     374function pocb(src)
     375{
     376  if(src.ReadyState==4 && src.Status==200)
     377  {
     378    window.location.href=window.location.href;
    313379  }
    314380}
Note: See TracChangeset for help on using the changeset viewer.