Changeset 386


Ignore:
Timestamp:
Mar 5, 2004, 11:54:53 PM (20 years ago)
Author:
z0rglub
Message:
  • deletion of expand string in $_GET array
  • refactoring of display_category function (no tab in code, please)
  • displays always number of sub-categories for each category in the menu
  • in the menu, special style only for the opened category
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/category.php

    r375 r386  
    5353function display_category( $category, $indent )
    5454{
    55   global $user,$lang,$template, $handle;
    56  
    57   $style='';
     55  global $user,$template,$page;
     56 
    5857  $url = './category.php?cat='.$category['id'];
    59   $url.= '&expand='.$category['expand_string'];
     58
     59  $style = '';
     60  if ( isset( $page['cat'] )
     61       and is_numeric( $page['cat'] )
     62       and $category['id'] == $page['cat'] )
     63  {
     64    $style = 'font-weight:normal;color:yellow;';
     65  }
     66 
    6067  $name = $category['name'];
    6168  if ( $name == '' ) $name = str_replace( '_', ' ', $category['dir'] );
    62   if ( $category['id_uppercat'] == '' )
    63   {
    64     $style = 'font-weight:bold;';
    65   }
    66  
    67   $template->assign_block_vars('category', array(
    68     'LINK_NAME' => $name,
    69         'INDENT' => $indent,
    70         'NB_SUBCATS'=>$category['nb_sub_categories'],
    71         'TOTAL_CAT'=>$category['nb_images'],
    72         'CAT_ICON'=>get_icon($category['date_last']),
    73        
    74         'T_NAME'=>$style,
    75     'U_LINK' => add_session_id($url)));
    76 
     69 
     70  $template->assign_block_vars(
     71    'category',
     72    array(
     73      'T_NAME' => $style,
     74      'LINK_NAME' => $name,
     75      'INDENT' => $indent,
     76      'NB_SUBCATS'=>$category['nb_sub_categories'],
     77      'TOTAL_CAT'=>$category['nb_images'],
     78      'CAT_ICON'=>get_icon($category['date_last']),
     79     
     80      'U_LINK' => add_session_id($url))
     81    );
     82 
    7783  if ( $user['expand'] or $category['nb_sub_categories'] == 0 )
    7884  {
    79         $template->assign_block_vars('category.bulletnolink', array('BULLET_IMAGE' =>  $user['lien_collapsed']));
     85    $template->assign_block_vars(
     86      'category.bulletnolink',
     87      array('BULLET_IMAGE' => $user['lien_collapsed'])
     88      );
    8089  }
    8190  else
    8291  {
    83         $url = './category.php';
    84         if (isset($page['cat']))
    85         {
    86           $url .='?cat='.$page['cat'];
    87       $url.= '&expand='.$category['expand_string'];
    88         }
    89         else if ($category['expand_string']<>'')
    90         {
    91           $url.= '?expand='.$category['expand_string'];
    92         }
    93        
    94         if ( $category['expanded'] )
     92    $url = './category.php';
     93    if (isset($page['cat']))
     94    {
     95      $url .='?cat='.$page['cat'];
     96    }
     97   
     98    if ( $category['expanded'] )
    9599    {
    96100      $img=$user['lien_expanded'];
     
    100104      $img=$user['lien_collapsed'];
    101105    }
    102        
    103     $template->assign_block_vars('category.bulletlink', array(
    104       'BULLET_IMAGE' =>  $img,
    105           'U_BULLET_LINK'=>  add_session_id($url)               
    106         ));
    107   }
    108 
     106   
     107    $template->assign_block_vars(
     108      'category.bulletlink',
     109      array(
     110        'BULLET_IMAGE' =>  $img,
     111        'U_BULLET_LINK'=>  add_session_id($url))
     112      );
     113  }
     114 
    109115  // recursive call
    110116  if ( $category['expanded'] )
    111117  {
    112118    foreach ( $category['subcats'] as $subcat ) {
    113           $template->assign_block_vars('category.subcat', array());
     119      $template->assign_block_vars('category.subcat', array());
    114120      display_category( $subcat, $indent.str_repeat( '&nbsp', 2 ));
    115121    }
     
    131137// $page['expand'] contains the string to display in URL with comma
    132138$page['tab_expand'] = array();
    133 if ( isset ( $_GET['expand'] ) and $_GET['expand'] != 'all' )
    134 {
    135   $tab_expand = explode( ',', $_GET['expand'] );
    136   foreach ( $tab_expand as $id ) {
    137     if ( is_numeric( $id ) ) array_push( $page['tab_expand'], $id );
    138   }
    139 }
    140 if ( isset($page['cat']) && is_numeric( $page['cat'] ) )
     139if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) )
    141140{
    142141  // the category displayed (in the URL cat=23) must be seen in the menu ->
     
    147146  }
    148147}
    149 $page['tab_expand'] = array_unique( $page['tab_expand'] );
    150 $page['expand'] = implode( ',', $page['tab_expand'] );
    151 // in case of expanding all authorized cats
    152 // The $page['expand'] equals 'all' and
    153 // $page['tab_expand'] contains all the authorized cat ids
    154 if ( $user['expand']
    155      or ( isset( $_GET['expand'] ) and $_GET['expand'] == 'all' ) )
     148// in case of expanding all authorized cats $page['tab_expand'] is empty
     149if ( $user['expand'] )
    156150{
    157151  $page['tab_expand'] = array();
    158   $page['expand'] = 'all';
    159 }
     152}
     153
    160154// Sometimes, a "num" is provided in the URL. It is the number
    161155// of the picture to show. This picture must be in the thumbnails page.
     
    247241
    248242  'U_HOME' => add_session_id( PHPWG_ROOT_PATH.'category.php' ),
    249   'U_FAVORITE' => add_session_id( PHPWG_ROOT_PATH.'category.php?cat=fav&amp;expand='.$page['expand'] ),
    250   'U_MOST_VISITED'=>add_session_id( PHPWG_ROOT_PATH.'category.php?cat=most_visited&amp;expand='.$page['expand'] ),
    251   'U_RECENT'=>add_session_id( PHPWG_ROOT_PATH.'category.php?cat=recent&amp;expand='.$page['expand'] ),
     243  'U_FAVORITE' => add_session_id( PHPWG_ROOT_PATH.'category.php?cat=fav' ),
     244  'U_MOST_VISITED'=>add_session_id( PHPWG_ROOT_PATH.'category.php?cat=most_visited' ),
     245  'U_RECENT'=>add_session_id( PHPWG_ROOT_PATH.'category.php?cat=recent' ),
    252246  'U_LOGOUT' => add_session_id( PHPWG_ROOT_PATH.'category.php?act=logout' ),
    253247  'U_ADMIN'=>add_session_id( PHPWG_ROOT_PATH.'admin.php' ),
     
    363357    // url link on picture.php page
    364358    $url_link = './picture.php?cat='.$page['cat'];
    365     $url_link.= '&amp;image_id='.$row['id'].'&amp;expand='.$page['expand'];
     359    $url_link.= '&amp;image_id='.$row['id'];
    366360    if ( $page['cat'] == 'search' )
    367361    {
     
    454448
    455449    $url_link = './category.php?cat='.$subcat_id;
    456     if ( isset($page['cat'])&& !in_array( $page['cat'], $page['tab_expand'] ) )
    457     {
    458       array_push( $page['tab_expand'], $page['cat'] );
    459       $page['expand'] = implode( ',', $page['tab_expand'] );
    460     }
    461     $url_link.= '&amp;expand='.$page['expand'];
    462     // we add the category to explore in the expand list
    463     if ( $page['expand'] != '' ) $url_link.= ',';
    464     $url_link.= $subcat_id;
    465450
    466451    $date = $page['plain_structure'][$subcat_id]['date_last'];
     
    499484         and $page['cat_uploadable'] )
    500485    {
    501       $url = './upload.php?cat='.$page['cat'].'&amp;expand='.$page['expand'];
     486      $url = './upload.php?cat='.$page['cat'];
    502487          $template->assign_block_vars('upload',array('U_UPLOAD'=>add_session_id( $url )));
    503488    }
Note: See TracChangeset for help on using the changeset viewer.