Changeset 638 for trunk


Ignore:
Timestamp:
Dec 5, 2004, 11:47:46 PM (20 years ago)
Author:
plg
Message:
  • ordering function moved from admin/update to admin/include/function
  • remote_site uses ordering and update_global_rank
Location:
trunk/admin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions.php

    r637 r638  
    11651165  mass_updates(CATEGORIES_TABLE, $fields, $datas);
    11661166}
     1167
     1168/**
     1169 * order categories (update categories.rank and global_rank database fields)
     1170 *
     1171 * the purpose of this function is to give a rank for all categories
     1172 * (insides its sub-category), even the newer that have none at te
     1173 * beginning. For this, ordering function selects all categories ordered by
     1174 * rank ASC then name ASC for each uppercat.
     1175 *
     1176 * @returns void
     1177 */
     1178function ordering()
     1179{
     1180  $current_rank = 0;
     1181  $current_uppercat = '';
     1182               
     1183  $query = '
     1184SELECT id, if(id_uppercat is null,\'\',id_uppercat) AS id_uppercat
     1185  FROM '.CATEGORIES_TABLE.'
     1186  ORDER BY id_uppercat,rank,name
     1187;';
     1188  $result = pwg_query($query);
     1189  $datas = array();
     1190  while ($row = mysql_fetch_array($result))
     1191  {
     1192    if ($row['id_uppercat'] != $current_uppercat)
     1193    {
     1194      $current_rank = 0;
     1195      $current_uppercat = $row['id_uppercat'];
     1196    }
     1197    $data = array('id' => $row['id'], 'rank' => ++$current_rank);
     1198    array_push($datas, $data);
     1199  }
     1200
     1201  $fields = array('primary' => array('id'), 'update' => array('rank'));
     1202  mass_updates(CATEGORIES_TABLE, $fields, $datas);
     1203}
    11671204?>
  • trunk/admin/remote_site.php

    r610 r638  
    136136    insert_remote_category($xml_content, $site_id, 'NULL', 0);
    137137    update_category();
     138    ordering();
     139    update_global_rank();
    138140       
    139141    $template->assign_block_vars(
  • trunk/admin/update.php

    r633 r638  
    3636// |                              functions                                |
    3737// +-----------------------------------------------------------------------+
    38 
    39 /**
    40  * order categories (update categories.rank and global_rank database fields)
    41  *
    42  * the purpose of this function is to give a rank for all categories
    43  * (insides its sub-category), even the newer that have none at te
    44  * beginning. For this, ordering function selects all categories ordered by
    45  * rank ASC then name ASC for each uppercat.
    46  *
    47  * @returns void
    48  */
    49 function ordering()
    50 {
    51   $current_rank = 0;
    52   $current_uppercat = '';
    53                
    54   $query = '
    55 SELECT id, if(id_uppercat is null,\'\',id_uppercat) AS id_uppercat
    56   FROM '.CATEGORIES_TABLE.'
    57   ORDER BY id_uppercat,rank,name
    58 ;';
    59   $result = pwg_query($query);
    60   $datas = array();
    61   while ($row = mysql_fetch_array($result))
    62   {
    63     if ($row['id_uppercat'] != $current_uppercat)
    64     {
    65       $current_rank = 0;
    66       $current_uppercat = $row['id_uppercat'];
    67     }
    68     $data = array('id' => $row['id'], 'rank' => ++$current_rank);
    69     array_push($datas, $data);
    70   }
    71 
    72   $fields = array('primary' => array('id'), 'update' => array('rank'));
    73   mass_updates(CATEGORIES_TABLE, $fields, $datas);
    74 }
    7538
    7639function insert_local_category($id_uppercat)
Note: See TracChangeset for help on using the changeset viewer.