Changeset 394 for trunk/admin


Ignore:
Timestamp:
Mar 26, 2004, 6:08:09 PM (20 years ago)
Author:
gweltas
Message:
  • Template migration
  • Admin Control Panel migration
  • Category management
Location:
trunk/admin
Files:
1 added
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/cat_list.php

    r362 r394  
    2525// | USA.                                                                  |
    2626// +-----------------------------------------------------------------------+
    27 include_once( './admin/include/isadmin.inc.php' );
    28 
    29 //----------------------------------------------------- template initialization
    30 $sub = $vtp->Open( './template/'.$user['template'].'/admin/cat_list.vtp' );
    31 $tpl = array( 'cat_edit','cat_up','cat_down','cat_image_info',
    32               'cat_permission','cat_update','cat_add','cat_parent','submit',
    33               'cat_virtual','delete','cat_first','cat_last','errors_title' );
    34 templatize_array( $tpl, 'lang', $sub );
    35 $vtp->setGlobalVar( $sub, 'user_template', $user['template'] );
    36 //--------------------------------------------------- adding a virtual category
     27
     28if( !defined("PHPWG_ROOT_PATH") )
     29{
     30        die ("Hacking attempt!");
     31}
     32include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' );
     33
    3734$errors = array();
    38 if ( isset( $_POST['submit'] ) )
     35$categories=array();
     36$navigation=$lang['gallery_index'];
     37
     38//---------------------------------------------------  virtual categories
     39if ( isset( $_GET['delete'] ) && is_numeric( $_GET['delete'] ) )
     40{
     41  delete_category( $_GET['delete'] );
     42  synchronize_all_users();
     43}
     44elseif ( isset( $_POST['submit'] ) )
    3945{
    4046  // is the given category name only containing blank spaces ?
    4147  if ( preg_match( '/^\s*$/', $_POST['virtual_name'] ) )
    4248    array_push( $errors, $lang['cat_error_name'] );
    43   // does the uppercat id exists in the database ?
    44   if ( $_POST['associate'] == '' )
    45   {
    46     $_POST['associate'] = -1;
    47   }
    48   else if ( !is_numeric( $_POST['associate'] ) )
    49   {
    50     array_push( $errors, $lang['cat_unknown_id'] );
    51   }
    52   else
    53   {
    54     $query = 'SELECT id';
    55     $query.= ' FROM '.PREFIX_TABLE.'categories';
    56     $query.= ' WHERE id = '.$_POST['associate'];
    57     $query.= ';';
    58     if ( mysql_num_rows( mysql_query( $query ) ) == 0 )
    59       array_push( $errors, $lang['cat_unknown_id'] );
    60   }
     49       
     50  if ( !count( $errors ))
     51  {
     52    // we have then to add the virtual category
     53        $parent_id = !empty($_GET['parent_id'])?$_GET['parent_id']:'NULL';
     54    $query = 'INSERT INTO '.CATEGORIES_TABLE;
     55    $query.= ' (name,id_uppercat,rank) VALUES ';
     56    $query.= " ('".$_POST['virtual_name']."',".$parent_id.",".$_POST['rank'].")";
     57    $query.= ';';
     58    mysql_query( $query );
     59    synchronize_all_users();
     60  }
     61}
     62
     63// Cache management
     64
     65$query = 'SELECT * FROM '.CATEGORIES_TABLE;
     66if ( !isset($_GET['parent_id']))
     67{
     68  $query.= ' WHERE id_uppercat IS NULL';
     69}
     70else
     71{
     72  $query.= ' WHERE id_uppercat = '.$_GET['parent_id'];
     73}
     74$query.= ' ORDER BY rank ASC';
     75$query.= ';';
     76$result = mysql_query( $query );
     77while ( $row = mysql_fetch_assoc( $result ) )
     78{
     79  $categories[$row['rank']]=$row;
     80}
     81
     82// Navigation path
     83if (isset($_GET['parent_id']))
     84{
     85  $current_category = get_cat_info($_GET['parent_id']);
     86  $url = PHPWG_ROOT_PATH.'admin.php?page=cat_list&parent_id=';
     87  $navigation = '<a class="" href="'.add_session_id(PHPWG_ROOT_PATH.'admin.php?page=cat_list').'">';
     88  $navigation.= $lang['gallery_index'].'</a>-&gt;';
     89  $navigation.= get_cat_display_name($current_category['name'], '-&gt;', $url);
     90}
     91
     92//---------------------------------------------------------------  rank updates
     93$current_rank=0;
     94if ( isset( $_GET['up'] ) && is_numeric( $_GET['up'] ))
     95{
     96  // 1. searching the id of the category just above at the same level
     97  while (list ($id,$current) = each($categories))
     98  {
     99    if ($current['id'] == $_GET['up'])
     100        {
     101          $current_rank = $current['rank'];
     102          break;
     103    }
     104  }
     105  if ($current_rank>1)
     106  {
     107    // 2. Exchanging ranks between the two categories
     108    $query = 'UPDATE '.CATEGORIES_TABLE;
     109    $query.= ' SET rank = '.($current_rank-1);
     110    $query.= ' WHERE id = '.$_GET['up'];
     111    $query.= ';';
     112    mysql_query( $query );
     113    $query = 'UPDATE '.CATEGORIES_TABLE;
     114    $query.= ' SET rank = '.$current_rank;
     115    $query.= ' WHERE id = '.$categories[($current_rank-1)]['id'];
     116    $query.= ';';
     117    mysql_query( $query );
     118        // 3. Updating the cache array
     119        $categories[$current_rank]=$categories[($current_rank-1)];
     120        $categories[($current_rank-1)] = $current;
     121  }
     122  else
     123  {
     124    // 2. Updating the rank of our category to be after the previous max rank
     125    $query = 'UPDATE '.CATEGORIES_TABLE;
     126    $query.= ' SET rank = '.(count($categories) + 1);
     127    $query.= ' WHERE id = '.$_GET['up'];
     128    $query.= ';';
     129    mysql_query( $query );
     130    $query = 'UPDATE '.CATEGORIES_TABLE;
     131    $query.= ' SET rank = rank-1';
     132        $query.= ' WHERE id_uppercat ';
     133        $query.= empty($_GET['parent_id'])?'IS NULL':('= '.$_GET['parent_id']);
     134        $query.= ';';
     135    mysql_query( $query );
     136        // 3. Updating the cache array
     137        array_push($categories, $current);
     138        array_shift($categories);
     139  }
     140}
     141elseif ( isset( $_GET['down'] ) && is_numeric( $_GET['down'] ) )
     142{
     143  // 1. searching the id of the category just above at the same level
     144  while (list ($id,$current) = each($categories))
     145  {
     146    if ($current['id'] == $_GET['down'])
     147        {
     148          $current_rank = $current['rank'];
     149          break;
     150        }
     151  }
     152  if ($current_rank < count($categories))
     153  {
     154    // 2. Exchanging ranks between the two categories
     155    $query = 'UPDATE '.CATEGORIES_TABLE;
     156    $query.= ' SET rank = '.($current_rank+1);
     157    $query.= ' WHERE id = '.$_GET['down'];
     158    $query.= ';';
     159    mysql_query( $query );
     160    $query = 'UPDATE '.CATEGORIES_TABLE;
     161    $query.= ' SET rank = '.$current_rank;
     162    $query.= ' WHERE id = '.$categories[($current_rank+1)]['id'];
     163    $query.= ';';
     164    mysql_query( $query );
     165        // 3. Updating the cache array
     166        $categories[$current_rank]=$categories[($current_rank+1)];
     167        $categories[($current_rank+1)] = $current;
     168  }
     169  else
     170  {
     171    // 2. updating the rank of our category to be the first one
     172    $query = 'UPDATE '.CATEGORIES_TABLE;
     173    $query.= ' SET rank = 0';
     174    $query.= ' WHERE id = '.$_GET['down'];
     175    $query.= ';';
     176    mysql_query( $query );
     177    $query = 'UPDATE '.CATEGORIES_TABLE;
     178    $query.= ' SET rank = (rank+1)';
     179        $query.= ' WHERE id_uppercat ';
     180        $query.= empty($_GET['parent_id'])?'IS NULL':('= '.$_GET['parent_id']);
     181        $query.= ';';
     182    mysql_query( $query );
     183        // 3. Updating the cache array
     184        array_unshift($categories, $current);
     185        array_pop($categories);
     186  }
     187}
     188reset($categories);
     189
     190//----------------------------------------------------- template initialization
     191$template->set_filenames( array('categories'=>'admin/cat_list.tpl') );
     192
     193$template->assign_vars(array(
     194  'CATEGORIES_NAV'=>$navigation,
     195  'NEXT_RANK'=>count($categories)+1,
    61196 
    62   if ( count( $errors ) == 0 )
    63   {
    64     // we have then to add the virtual category
    65     $query = 'INSERT INTO '.PREFIX_TABLE.'categories';
    66     $query.= ' (name,id_uppercat) VALUES ';
    67     if ( $_POST['associate'] == -1 )
    68     {
    69       $_POST['associate'] = 'NULL';
    70     }
    71     $query.= " ('".$_POST['virtual_name']."',".$_POST['associate'].")";
    72     $query.= ';';
    73     mysql_query( $query );
    74     synchronize_all_users();
    75   }
    76 }
    77 //---------------------------------------------------------------  rank updates
    78 if ( isset( $_GET['up'] ) and is_numeric( $_GET['up'] ) )
    79 {
    80   // 1. searching level (id_uppercat)
    81   //    and rank of the category to move
    82   $query = 'SELECT id_uppercat,rank';
    83   $query.= ' FROM '.PREFIX_TABLE.'categories';
    84   $query.= ' WHERE id = '.$_GET['up'];
    85   $query.= ';';
    86   $row = mysql_fetch_array( mysql_query( $query ) );
    87   $level = $row['id_uppercat'];
    88   $rank  = $row['rank'];
    89   // 2. searching the id and the rank of the category
    90   //    just above at the same level
    91   $query = 'SELECT id,rank';
    92   $query.= ' FROM '.PREFIX_TABLE.'categories';
    93   $query.= ' WHERE rank < '.$rank;
    94   if ( $level == '' )
    95   {
    96     $query.= ' AND id_uppercat IS NULL';
    97   }
    98   else
    99   {
    100     $query.= ' AND id_uppercat = '.$level;
    101   }
    102   $query.= ' ORDER BY rank DESC';
    103   $query.= ' LIMIT 0,1';
    104   $query.= ';';
    105   $row = mysql_fetch_array( mysql_query( $query ) );
    106   $new_rank     = $row['rank'];
    107   $replaced_cat = $row['id'];
    108   // 3. exchanging ranks between the two categories
    109   $query = 'UPDATE '.PREFIX_TABLE.'categories';
    110   $query.= ' SET rank = '.$new_rank;
    111   $query.= ' WHERE id = '.$_GET['up'];
    112   $query.= ';';
    113   mysql_query( $query );
    114   $query = 'UPDATE '.PREFIX_TABLE.'categories';
    115   $query.= ' SET rank = '.$rank;
    116   $query.= ' WHERE id = '.$replaced_cat;
    117   $query.= ';';
    118   mysql_query( $query );
    119 }
    120 if ( isset( $_GET['down'] ) and is_numeric( $_GET['down'] ) )
    121 {
    122   // 1. searching level (id_uppercat)
    123   //    and rank of the category to move
    124   $query = 'SELECT id_uppercat,rank';
    125   $query.= ' FROM '.PREFIX_TABLE.'categories';
    126   $query.= ' WHERE id = '.$_GET['down'];
    127   $query.= ';';
    128   $row = mysql_fetch_array( mysql_query( $query ) );
    129   $level = $row['id_uppercat'];
    130   $rank  = $row['rank'];
    131   // 2. searching the id and the rank of the category
    132   //    just below at the same level
    133   $query = 'SELECT id,rank';
    134   $query.= ' FROM '.PREFIX_TABLE.'categories';
    135   $query.= ' WHERE rank > '.$rank;
    136   if ( $level == '' )
    137   {
    138     $query.= ' AND id_uppercat IS NULL';
    139   }
    140   else
    141   {
    142     $query.= ' AND id_uppercat = '.$level;
    143   }
    144   $query.= ' ORDER BY rank ASC';
    145   $query.= ' LIMIT 0,1';
    146   $query.= ';';
    147   $row = mysql_fetch_array( mysql_query( $query ) );
    148   $new_rank     = $row['rank'];
    149   $replaced_cat = $row['id'];
    150   // 3. exchanging ranks between the two categories
    151   $query = 'UPDATE '.PREFIX_TABLE.'categories';
    152   $query.= ' SET rank = '.$new_rank;
    153   $query.= ' WHERE id = '.$_GET['down'];
    154   $query.= ';';
    155   mysql_query( $query );
    156   $query = 'UPDATE '.PREFIX_TABLE.'categories';
    157   $query.= ' SET rank = '.$rank;
    158   $query.= ' WHERE id = '.$replaced_cat;
    159   $query.= ';';
    160   mysql_query( $query );
    161 }
    162 if ( isset( $_GET['last'] ) and is_numeric( $_GET['last'] ) )
    163 {
    164   // 1. searching level (id_uppercat) of the category to move
    165   $query = 'SELECT id_uppercat,rank';
    166   $query.= ' FROM '.PREFIX_TABLE.'categories';
    167   $query.= ' WHERE id = '.$_GET['last'];
    168   $query.= ';';
    169   $row = mysql_fetch_array( mysql_query( $query ) );
    170   $level = $row['id_uppercat'];
    171   // 2. searching the highest rank of the categories of the same parent
    172   $query = 'SELECT MAX(rank) AS max_rank';
    173   $query.= ' FROM '.PREFIX_TABLE.'categories';
    174   $query.= ' WHERE id_uppercat';
    175   if ( $level == '' ) $query.= ' IS NULL';
    176   else                $query.= ' = '.$level;
    177   $query.= ';';
    178   $row = mysql_fetch_array( mysql_query( $query ) );
    179   $max_rank = $row['max_rank'];
    180   // 3. updating the rank of our category to be after the previous max rank
    181   $query = 'UPDATE '.PREFIX_TABLE.'categories';
    182   $query.= ' SET rank = '.($max_rank + 1);
    183   $query.= ' WHERE id = '.$_GET['last'];
    184   $query.= ';';
    185   mysql_query( $query );
    186 }
    187 if ( isset( $_GET['first'] ) and is_numeric( $_GET['first'] ) )
    188 {
    189   // to place our category as first, we simply say that is rank is 0, then
    190   // reordering will move category ranks correctly (first rank should be 1
    191   // and not 0)
    192   $query = 'UPDATE '.PREFIX_TABLE.'categories';
    193   $query.= ' SET rank = 0';
    194   $query.= ' WHERE id = '.$_GET['first'];
    195   $query.= ';';
    196   mysql_query( $query );
    197 }
    198 if ( isset( $_GET['delete'] ) and is_numeric( $_GET['delete'] ) )
    199 {
    200   delete_category( $_GET['delete'] );
    201   synchronize_all_users();
    202 }
    203 //------------------------------------------------------------------ reordering
    204 function ordering( $id_uppercat )
    205 {
    206   $rank = 1;
    207                
    208   $query = 'SELECT id';
    209   $query.= ' FROM '.PREFIX_TABLE.'categories';
    210   if ( !is_numeric( $id_uppercat ) )
    211   {
    212     $query.= ' WHERE id_uppercat IS NULL';
    213   }
    214   else
    215   {
    216     $query.= ' WHERE id_uppercat = '.$id_uppercat;
    217   }
    218   $query.= ' ORDER BY rank ASC, dir ASC';
    219   $query.= ';';
    220   $result = mysql_query( $query );
    221   while ( $row = mysql_fetch_array( $result ) )
    222   {
    223     $query = 'UPDATE '.PREFIX_TABLE.'categories';
    224     $query.= ' SET rank = '.$rank;
    225     $query.= ' WHERE id = '.$row['id'];
    226     $query.= ';';
    227     mysql_query( $query );
    228     $rank++;
    229     ordering( $row['id'] );
    230   }
    231 }
    232 ordering( 'NULL' );
     197  'L_ADD_VIRTUAL'=>$lang['cat_add'],
     198  'L_SUBMIT'=>$lang['submit'],
     199  'L_STORAGE'=>$lang['storage'],
     200  'L_NB_IMG'=>$lang['pictures'],
     201  'L_MOVE_UP'=>$lang['cat_up'],
     202  'L_MOVE_DOWN'=>$lang['cat_down'],
     203  'L_EDIT'=>$lang['edit'],
     204  'L_INFO_IMG'=>$lang['cat_image_info'],
     205  'L_DELETE'=>$lang['delete']
     206  ));
     207 
     208$tpl = array( 'cat_first','cat_last');
     209                         
    233210//-------------------------------------------------------------- errors display
    234 if ( count( $errors ) != 0 )
    235 {
    236   $vtp->addSession( $sub, 'errors' );
    237   foreach ( $errors as $error ) {
    238     $vtp->addSession( $sub, 'li' );
    239     $vtp->setVar( $sub, 'li.content', $error );
    240     $vtp->closeSession( $sub, 'li' );
    241   }
    242   $vtp->closeSession( $sub, 'errors' );
    243 }
    244 //---------------------------------------------------------------- page display
    245 function display_cat_manager( $id_uppercat, $indent,
    246                               $uppercat_visible, $level )
    247 {
    248   global $lang,$conf,$sub,$vtp,$page;
    249                
    250   // searching the min_rank and the max_rank of the category
    251   $query = 'SELECT MIN(rank) AS min, MAX(rank) AS max';
    252   $query.= ' FROM '.PREFIX_TABLE.'categories';
    253   if ( !is_numeric( $id_uppercat ) )
    254   {
    255     $query.= ' WHERE id_uppercat IS NULL';
    256   }
    257   else
    258   {
    259     $query.= ' WHERE id_uppercat = '.$id_uppercat;
    260   }
    261   $query.= ';';
    262   $result = mysql_query( $query );
    263   $row    = mysql_fetch_array( $result );
    264   if ( !isset( $row['min'] ) ) $row['min'] = 0;
    265   if ( !isset( $row['max'] ) ) $row['max'] = 0;
    266   $min_rank = $row['min'];
    267   $max_rank = $row['max'];
    268                
    269   // will we use <th> or <td> lines ?
    270   $td    = 'td';
    271   $class = '';
    272   if ( $level > 0 ) $class = 'row'.$level;
    273   else              $td = 'th';
    274                
    275   $query = 'SELECT id,name,dir,nb_images,status,rank,site_id,visible';
    276   $query.= ' FROM '.PREFIX_TABLE.'categories';
    277   if ( !is_numeric( $id_uppercat ) )
    278   {
    279     $query.= ' WHERE id_uppercat IS NULL';
    280   }
    281   else
    282   {
    283     $query.= ' WHERE id_uppercat = '.$id_uppercat;
    284   }
    285   $query.= ' ORDER BY rank ASC';
    286   $query.= ';';
    287   $result = mysql_query( $query );
    288   while ( $row = mysql_fetch_array( $result ) )
    289   {
    290     $subcat_visible = true;
    291     if ( !isset( $row['dir'] ) ) $row['dir'] = '';
    292 
    293     $vtp->addSession( $sub, 'cat' );
    294     // is the category expanded or not ?
    295     if ( isset($page['expand']) && $page['expand'] == 'all' )
    296     {
    297       $vtp->addSession( $sub, 'bullet_wo_link' );
    298       $vtp->closeSession( $sub, 'bullet_wo_link' );
    299     }
    300     else if ( isset($page['tab_expand']) && in_array( $row['id'], $page['tab_expand'] ) )
    301     {
    302       $vtp->addSession( $sub, 'bullet_expanded' );
    303       $tab_expand = array_diff( $page['tab_expand'], array( $row['id'] ) );
    304       $expand = implode( ',', $tab_expand );
    305       $url = './admin.php?page=cat_list&amp;expand='.$expand;
    306       $vtp->setVar( $sub, 'bullet_expanded.link', add_session_id( $url ) );
    307       $vtp->closeSession( $sub, 'bullet_expanded' );
    308     }
    309     else
    310     {
    311       $vtp->addSession( $sub, 'bullet_collapsed' );
    312       $tab_expand = array_merge( $page['tab_expand'], array( $row['id'] ) );
    313       $expand = implode( ',', $tab_expand );
    314       $url = './admin.php?page=cat_list&amp;expand='.$expand;
    315       $vtp->setVar( $sub, 'bullet_collapsed.link', add_session_id( $url ) );
    316       $vtp->closeSession( $sub, 'bullet_collapsed' );
    317     }
    318    
    319     $vtp->setVar( $sub, 'cat.td', $td );
    320     $vtp->setVar( $sub, 'cat.class', $class );
    321     $vtp->setVar( $sub, 'cat.indent', $indent );
    322     $vtp->setVar( $sub, 'cat.name', $row['name'] );
    323 
    324     if ( $row['dir'] != '' )
    325     {
    326       $vtp->addSession( $sub, 'storage' );
    327       $vtp->setVar( $sub, 'storage.dir', $row['dir'] );
    328       $vtp->closeSession( $sub, 'storage' );
    329       // category can't be deleted
    330       $vtp->addSession( $sub, 'no_delete' );
    331       $vtp->closeSession( $sub, 'no_delete' );
    332     }
    333     else
    334     {
    335       $vtp->addSession( $sub, 'virtual' );
    336       $vtp->closeSession( $sub, 'virtual' );
    337       // category can be deleted
    338       $vtp->addSession( $sub, 'delete' );
    339       $url = './admin.php?page=cat_list&amp;expand='.$page['expand'];
    340       $url.= '&amp;delete='.$row['id'];
    341       $vtp->setVar( $sub, 'delete.delete_url', add_session_id( $url ) );
    342       $vtp->closeSession( $sub, 'delete' );
    343     }
    344     if ( $row['visible'] == 'false' or !$uppercat_visible )
    345     {
    346       $subcat_visible = false;
    347       $vtp->setVar( $sub, 'cat.invisible', $lang['cat_invisible'] );
    348     }
    349     if ( $row['status'] == 'private' )
    350     {
    351       $vtp->setVar( $sub, 'cat.private', $lang['private'] );
    352     }
    353     $vtp->setVar( $sub, 'cat.nb_picture', $row['nb_images'] );
    354     $url = add_session_id( './admin.php?page=cat_modify&amp;cat='.$row['id'] );
    355     $vtp->setVar( $sub, 'cat.edit_url', $url );
    356     if ( $row['rank'] != $min_rank )
    357     {
    358       $vtp->addSession( $sub, 'up' );
    359       $url = './admin.php?page=cat_list&amp;expand='.$page['expand'];
    360       $url.= '&amp;up='.$row['id'];
    361       $vtp->setVar( $sub, 'up.up_url', add_session_id( $url ) );
    362       $vtp->closeSession( $sub, 'up' );
    363     }
    364     else if ( $min_rank != $max_rank )
    365     {
    366       $vtp->addSession( $sub, 'no_up' );
    367       $url = './admin.php?page=cat_list&amp;expand='.$page['expand'];
    368       $url.= '&amp;last='.$row['id'];
    369       $vtp->setVar( $sub, 'no_up.last_url', add_session_id( $url ) );
    370       $vtp->closeSession( $sub, 'no_up' );
    371     }
    372     if ( $row['rank'] != $max_rank )
    373     {
    374       $vtp->addSession( $sub, 'down' );
    375       $url = './admin.php?page=cat_list&amp;expand='.$page['expand'];
    376       $url.= '&amp;down='.$row['id'];
    377       $vtp->setVar( $sub, 'down.down_url', add_session_id( $url ) );
    378       $vtp->closeSession( $sub, 'down' );
    379     }
    380     else if ( $min_rank != $max_rank )
    381     {
    382       $vtp->addSession( $sub, 'no_down' );
    383       $url = './admin.php?page=cat_list&amp;expand='.$page['expand'];
    384       $url.= '&amp;first='.$row['id'];
    385       $vtp->setVar( $sub, 'no_down.first_url', add_session_id( $url ) );
    386       $vtp->closeSession( $sub, 'no_down' );
    387     }
    388     if ( $row['nb_images'] > 0 )
    389     {
    390       $vtp->addSession( $sub, 'image_info' );
    391       $url = './admin.php?page=infos_images&amp;cat_id='.$row['id'];
    392       $vtp->setVar( $sub, 'image_info.image_info_url', add_session_id($url) );
    393       $vtp->closeSession( $sub, 'image_info' );
    394     }
    395     else
    396     {
    397       $vtp->addSession( $sub, 'no_image_info' );
    398       $vtp->closeSession( $sub, 'no_image_info' );
    399     }
    400     if ( $row['status'] == 'private' )
    401     {
    402       $vtp->addSession( $sub, 'permission' );
    403       $url=add_session_id('./admin.php?page=cat_perm&amp;cat_id='.$row['id']);
    404       $vtp->setVar( $sub, 'permission.url', $url );
    405       $vtp->closeSession( $sub, 'permission' );
    406     }
    407     else
    408     {
    409       $vtp->addSession( $sub, 'no_permission' );
    410       $vtp->closeSession( $sub, 'no_permission' );
    411     }
    412     // you can individually update a category only if it is on the main site
    413     // and if it's not a virtual category (a category is virtual if there is
    414     // no directory associated)
    415     if ( $row['site_id'] == 1 and $row['dir'] != '' )
    416     {
    417       $vtp->addSession( $sub, 'update' );
    418       $url = add_session_id('./admin.php?page=update&amp;update='.$row['id']);
    419       $vtp->setVar( $sub, 'update.update_url', $url );
    420       $vtp->closeSession( $sub, 'update' );
    421     }
    422     else
    423     {
    424       $vtp->addSession( $sub, 'no_update' );
    425       $vtp->closeSession( $sub, 'no_update' );
    426     }
    427 
    428     $vtp->closeSession( $sub, 'cat' );
    429 
    430     if ( in_array( $row['id'], $page['tab_expand'] )
    431          or $page['expand'] == 'all')
    432       display_cat_manager( $row['id'], $indent.str_repeat( '&nbsp', 4 ),
    433                            $subcat_visible, $level + 1 );
    434   }
    435 }
    436 display_cat_manager( 'NULL', str_repeat( '&nbsp', 4 ), true, 0 );
    437 // add a virtual category ?
    438 // We only show a List Of Values if the number of categories is less than
    439 // $conf['max_LOV_categories']
    440 $query = 'SELECT COUNT(id) AS nb_total_categories';
    441 $query.= ' FROM '.PREFIX_TABLE.'categories';
    442 $query.= ';';
    443 $row = mysql_fetch_array( mysql_query( $query ) );
    444 if ( $row['nb_total_categories'] < $conf['max_LOV_categories'] )
    445 {
    446   $vtp->addSession( $sub, 'associate_LOV' );
    447   $vtp->addSession( $sub, 'associate_cat' );
    448   $vtp->setVar( $sub, 'associate_cat.value', '-1' );
    449   $vtp->setVar( $sub, 'associate_cat.content', '' );
    450   $vtp->closeSession( $sub, 'associate_cat' );
    451   $page['plain_structure'] = get_plain_structure( true );
    452   $structure = create_structure( '', array() );
    453   display_categories( $structure, '&nbsp;' );
    454   $vtp->closeSession( $sub, 'associate_LOV' );
    455 }
    456 // else, we only display a small text field, we suppose the administrator
    457 // knows the id of its category
    458 else
    459 {
    460   $vtp->addSession( $sub, 'associate_text' );
    461   $vtp->closeSession( $sub, 'associate_text' );
    462 }
     211if ( sizeof( $errors ) != 0 )
     212{
     213  $template->assign_block_vars('errors',array());
     214  for ( $i = 0; $i < sizeof( $errors ); $i++ )
     215  {
     216    $template->assign_block_vars('errors.error',array('ERROR'=>$errors[$i]));
     217  }
     218}
     219//----------------------------------------------------------- Categories display
     220while (list ($id,$category) = each($categories))
     221{
     222
     223  if ($category['status'] == 'private')
     224  {
     225    $category_image = '<img src="'.PHPWG_ROOT_PATH.'template/'.$user['template'].'/admin/images/icon_folder_lock.gif"
     226          width="46" height="25" alt="'.$lang['cat_private'].'" title="'.$lang['cat_private'].'"/>';
     227  }
     228  elseif (empty($category['dir']))
     229  {
     230    $category_image = '<img src="'.PHPWG_ROOT_PATH.'template/'.$user['template'].'/admin/images/icon_folder_link.gif"
     231          width="46" height="25" alt="'.$lang['cat_virtual'].'" title="'.$lang['cat_virtual'].'"/>';
     232  }
     233  else
     234  {
     235        // May be should we have to introduce a computed field in the table to avoid this query
     236    $query = 'SELECT COUNT(id) as sub_cats FROM ' . CATEGORIES_TABLE . ' WHERE id_uppercat = '.$category['id'];
     237    $result = mysql_fetch_array(mysql_query( $query ));
     238        $category_image = ($result['sub_cats']) ?
     239          '<img src="'.PHPWG_ROOT_PATH.'template/'.$user['template'].'/admin/images/icon_subfolder.gif" width="46" height="25" alt="" />' :
     240          '<img src="'.PHPWG_ROOT_PATH.'template/'.$user['template'].'/admin/images/icon_folder.gif" width="46" height="25" alt="" />';
     241  }
     242 
     243  if ( !isset( $category['dir'] ) ) $category['dir'] = '';
     244  $simple_url = PHPWG_ROOT_PATH.'admin.php?page=cat_list&amp;';
     245  $url = $simple_url;
     246  if (isset($_GET['parent_id']))
     247    $url = $simple_url.'parent_id='.$_GET['parent_id'].'&amp;';
     248
     249  $template->assign_block_vars('category' ,array(
     250    'CATEGORY_IMG'=>$category_image,
     251    'CATEGORY_NAME'=>$category['name'],
     252        'CATEGORY_DIR'=>$category['dir'],
     253        'CATEGORY_NB_IMG'=>$category['nb_images'],
     254       
     255        'U_CATEGORY'=>add_session_id( $simple_url.'parent_id='.$category['id']),
     256        'U_MOVE_UP'=>add_session_id( $url.'up='.$category['id'] ),
     257        'U_MOVE_DOWN'=>add_session_id( $url.'down='.$category['id'] ),
     258        'U_CAT_EDIT'=>add_session_id( PHPWG_ROOT_PATH.'admin.php?page=cat_modify&amp;cat_id='.$row['id'] ),
     259        'U_CAT_DELETE'=>add_session_id( $url.'delete='.$category['id'] ),
     260        'U_INFO_IMG'=>add_session_id( PHPWG_ROOT_PATH.'admin.php?page=infos_images&amp;cat_id='.$row['id'] ),
     261        'U_CAT_UPDATE'=>add_session_id( PHPWG_ROOT_PATH.'admin.php?page=update&amp;update='.$row['id'] )
     262        ));
     263       
     264  if ( !empty($category['dir']))
     265  {
     266    $template->assign_block_vars('category.storage' ,array());
     267  }
     268  else
     269  {
     270        $template->assign_block_vars('category.virtual' ,array());
     271  }
     272  $url = add_session_id( './admin.php?page=cat_modify&amp;cat='.$row['id'] );
     273  if ( $category['nb_images'] > 0 )
     274  {
     275    $template->assign_block_vars('category.image_info' ,array());
     276  }
     277  else
     278  {
     279    $template->assign_block_vars('category.no_image_info' ,array());
     280  }
     281}
     282
    463283//----------------------------------------------------------- sending html code
    464 $vtp->Parse( $handle , 'sub', $sub );
     284$template->assign_var_from_handle('ADMIN_CONTENT', 'categories');
    465285?>
  • trunk/admin/cat_modify.php

    r364 r394  
    130130$result = get_cat_info( $row['id'] );
    131131// cat name
    132 $cat_name = get_cat_display_name( $result['name'], ' - ', '' );
     132$cat_name = get_cat_display_name( $result['name'], ' - ' );
    133133$vtp->setVar( $sub, 'cat:name', $cat_name );
    134134// cat dir
  • trunk/admin/configuration.php

    r393 r394  
    250250  'L_ACCESS_FREE'=>$lang['conf_general_access_1'],
    251251  'L_ACCESS_RESTRICTED'=>$lang['conf_general_access_2'],
    252   'L_HISTORY'=>$lang['conf_general_log'],
    253   'L_HISTORY_INFO'=>$lang['conf_general_log_info'],
     252  'L_CONF_HISTORY'=>$lang['history'],
     253  'L_CONF_HISTORY_INFO'=>$lang['conf_general_log_info'],
    254254  'L_MAIL_NOTIFICATION'=>$lang['conf_general_mail_notification'],
    255255  'L_MAIL_NOTIFICATION_INFO'=>$lang['conf_general_mail_notification_info'],
     
    280280  'L_NB_COMMENTS'=>$lang['customize_show_nb_comments'],
    281281  'L_NB_COMMENTS_INFO'=>$lang['conf_default_show_nb_comments_info'],
    282   'L_UPLOAD'=>$lang['conf_upload_available'],
    283   'L_UPLOAD_INFO'=>$lang['conf_upload_available_info'],
     282  'L_AUTH_UPLOAD'=>$lang['conf_upload_available'],
     283  'L_AUTH_UPLOAD_INFO'=>$lang['conf_upload_available_info'],
    284284  'L_CONF_UPLOAD'=>$lang['conf_upload_title'],
    285285  'L_UPLOAD_MAXSIZE'=>$lang['conf_upload_maxfilesize'],
     
    307307  ));
    308308
    309 $tpl = array( 'conf_confirmation','remote_site','delete',
    310               'conf_remote_site_delete_info','submit','errors_title' );
    311 
    312309//-------------------------------------------------------------- errors display
    313310if ( sizeof( $error ) != 0 )
  • trunk/admin/include/functions.php

    r393 r394  
    137137  // destruction of the categories of the site
    138138  $query = 'SELECT id';
    139   $query.= ' FROM '.PREFIX_TABLE.'categories';
     139  $query.= ' FROM '.CATEGORIES_TABLE;
    140140  $query.= ' WHERE site_id = '.$id;
    141141  $query.= ';';
     
    191191  // destruction of the sub-categories
    192192  $query = 'SELECT id';
    193   $query.= ' FROM '.PREFIX_TABLE.'categories';
     193  $query.= ' FROM '.CATEGORIES_TABLE;
    194194  $query.= ' WHERE id_uppercat = '.$id;
    195195  $query.= ';';
     
    201201
    202202  // destruction of the category
    203   $query = 'DELETE FROM '.PREFIX_TABLE.'categories';
     203  $query = 'DELETE FROM '.CATEGORIES_TABLE;
    204204  $query.= ' WHERE id = '.$id;
    205205  $query.= ';';
     
    374374  if ( $id == 'all' )
    375375  {
    376     $query = 'SELECT id';
    377     $query.= ' FROM '.PREFIX_TABLE.'categories';
    378     $query.= ';';
     376    $query = 'SELECT id FROM '.CATEGORIES_TABLE.';';
    379377    $result = mysql_query( $query );
    380378    while ( $row = mysql_fetch_array( $result ) )
     
    400398    list( $date_available ) = mysql_fetch_array( mysql_query( $query ) );
    401399   
    402     $query = 'UPDATE '.PREFIX_TABLE.'categories';
     400    $query = 'UPDATE '.CATEGORIES_TABLE;
    403401    $query.= " SET date_last = '".$date_available."'";
    404402    $query.= ', nb_images = '.$nb_images;
     
    411409    // have to set representative_picture_id to NULL
    412410    $query = 'SELECT representative_picture_id';
    413     $query.= ' FROM '.PREFIX_TABLE.'categories';
     411    $query.= ' FROM '.CATEGORIES_TABLE;
    414412    $query.= ' WHERE id = '.$id;
    415413    $row = mysql_fetch_array( mysql_query( $query ) );
     
    426424      if ( mysql_num_rows( $result ) == 0 )
    427425      {
    428         $query = 'UPDATE '.PREFIX_TABLE.'categories';
     426        $query = 'UPDATE '.CATEGORIES_TABLE;
    429427        $query.= ' SET representative_picture_id = NULL';
    430428        $query.= ' WHERE id = '.$id;
     
    525523  $query = 'SELECT id,id_uppercat';
    526524  if ( $use_name ) $query.= ',name';
    527   $query.= ' FROM '.PREFIX_TABLE.'categories';
     525  $query.= ' FROM '.CATEGORIES_TABLE;
    528526  $query.= ' ORDER BY id_uppercat ASC, rank ASC';
    529527  $query.= ';';
     
    712710
    713711  $string_uppercats = implode( ',', array_reverse( $uppercats ) );
    714   $query = 'UPDATE '.PREFIX_TABLE.'categories';
     712  $query = 'UPDATE '.CATEGORIES_TABLE;
    715713  $query.= ' SET uppercats = '."'".$string_uppercats."'";
    716714  $query.= ' WHERE id = '.$final_id;
  • trunk/admin/update.php

    r393 r394  
    2828include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' );
    2929//------------------------------------------------------------------- functions
     30function ordering( $id_uppercat )
     31{
     32  $rank = 1;
     33               
     34  $query = 'SELECT id';
     35  $query.= ' FROM '.CATEGORIES_TABLE;
     36  if ( !is_numeric( $id_uppercat ) )
     37  {
     38    $query.= ' WHERE id_uppercat IS NULL';
     39  }
     40  else
     41  {
     42    $query.= ' WHERE id_uppercat = '.$id_uppercat;
     43  }
     44  $query.= ' ORDER BY rank ASC, dir ASC';
     45  $query.= ';';
     46  $result = mysql_query( $query );
     47  while ( $row = mysql_fetch_array( $result ) )
     48  {
     49    $query = 'UPDATE '.CATEGORIES_TABLE;
     50    $query.= ' SET rank = '.$rank;
     51    $query.= ' WHERE id = '.$row['id'];
     52    $query.= ';';
     53    mysql_query( $query );
     54    $rank++;
     55    ordering( $row['id'] );
     56  }
     57}
     58
    3059function insert_local_category( $id_uppercat )
    3160{
     
    678707  ));
    679708 
    680 $tpl = array('remote_site');
    681709//-------------------------------------------- introduction : choices of update
    682710// Display choice if "update" var is not specified
     
    733761  $start = get_moment();
    734762  update_category( 'all' );
     763  ordering('NULL');
    735764  $end = get_moment();
    736765  echo get_elapsed_time( $start, $end ).' for update_category( all )<br />';
Note: See TracChangeset for help on using the changeset viewer.