Ignore:
Timestamp:
Nov 23, 2004, 11:31:24 PM (19 years ago)
Author:
plg
Message:
  • global categories' options : instead of N horizontal tabs on a single page, N options in the left menu (but the same backend)
  • categories.global_rank : new calculated field. It gives a global rank of the category among all others (updated during ordering)
  • category.php page : menu is generated faster thanks to categories.global_rank, recursivity becomes useless :-)
  • new function to display select box with a set of categories : display_select_cat_wrapper
  • cat_options : instead of using 1 multiselect for true/false items, using 1 multiselect for true, and another one for false. The form provides buttons with arrows to switch categories from one multiselect to another
  • deletion of obsolete function display_categories (working with the old template system)
  • deletion of obsolete functions get_user_plain_structure, create_user_structure, get_user_subcat_ids, update_structure, count_images : useless thanks to global_rank
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions_html.inc.php

    r610 r614  
    212212 */
    213213function get_cat_display_name_cache($uppercats,
    214                                     $separator, 
     214                                    $separator,
    215215                                    $url = 'category.php?cat=',
    216216                                    $replace_space = true)
     
    272272 * HTML code generated uses logical list tags ul and each category is an
    273273 * item li. The paramter given is the category informations as an array,
    274  * used keys are : id, name, dir, nb_images, date_last, subcats (sub-array)
    275  *
    276  * @param array category
     274 * used keys are : id, name, nb_images, date_last
     275 *
     276 * @param array categories
    277277 * @return string
    278278 */
    279 function get_html_menu_category($category)
     279function get_html_menu_category($categories)
    280280{
    281281  global $page, $lang;
    282282
     283  $ref_level = 0;
    283284  $menu = '
     285             <ul class="menu">';
     286 
     287  foreach ($categories as $category)
     288  {
     289    $level = substr_count($category['global_rank'], '.');
     290    if ($level > $ref_level)
     291    {
     292      $menu.= '
     293             <ul class="menu">';
     294    }
     295    else if ($level < $ref_level)
     296    {
     297      $menu.= '
     298             </ul>';
     299    }
     300    $ref_level = $level;
     301   
     302    $menu.= '
    284303
    285304           <li>';
    286305 
    287   $url = add_session_id(PHPWG_ROOT_PATH.'category.php?cat='.$category['id']);
    288 
    289   $class = '';
    290   if (isset($page['cat'])
    291       and is_numeric($page['cat'])
    292       and $category['id'] == $page['cat'])
    293   {
    294     $class = 'menuCategorySelected';
    295   }
    296   else
    297   {
    298     $class = 'menuCategoryNotSelected';
    299   }
    300  
    301   $name = $category['name'];
    302   if (empty($name))
    303   {
    304     $name = str_replace('_', ' ', $category['dir']);
    305   }
    306 
    307   $menu.= '
     306    $url = add_session_id(PHPWG_ROOT_PATH.'category.php?cat='.$category['id']);
     307
     308    $class = '';
     309    if (isset($page['cat'])
     310        and is_numeric($page['cat'])
     311        and $category['id'] == $page['cat'])
     312    {
     313      $class = 'menuCategorySelected';
     314    }
     315    else
     316    {
     317      $class = 'menuCategoryNotSelected';
     318    }
     319
     320    $menu.= '
    308321           <a href="'.$url.'"
    309322              title="'.$lang['hint_category'].'"
    310323              class="'.$class.'">
    311              '.$name.'
     324             '.$category['name'].'
    312325           </a>';
    313326
    314   if ($category['nb_images'] > 0)
    315   {
    316     $menu.= '
     327    if ($category['nb_images'] > 0)
     328    {
     329      $menu.= '
    317330             <span class="menuInfoCat"
    318331                   title="'.$category['nb_images'].'
     
    321334             </span>
    322335             '.get_icon($category['date_last']);
    323   }
    324  
    325   // recursive call
    326   if ($category['expanded'] and count($category['subcats']) > 0)
    327   {
    328     $menu.= '
    329              <ul class="menu">';
    330     foreach ($category['subcats'] as $subcat)
    331     {
    332       $menu.= get_html_menu_category($subcat);
    333     }
    334     $menu.= '
     336    }
     337
     338    $menu.= '</li>';
     339  }
     340 
     341  $menu.= '
    335342             </ul>';
    336   }
    337 
    338   $menu.= '</li>';
    339 
     343 
    340344  return $menu;
    341345}
Note: See TracChangeset for help on using the changeset viewer.