Show
Ignore:
Timestamp:
03/11/08 03:04:27 (5 years ago)
Author:
rvelices
Message:

- remove $confsubcatify (it was my reqquest to Pierrick when plugins were not available; now it can be done through plugin)
- optimization when show_nb_comments true (1 sql query per page instead of 1 query per element)
- some cleanup & more standard trigger names

Files:
1 modified

Legend:

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

    r2234 r2274  
    216216  } 
    217217 
     218  $template->set_filename('index_category_thumbnails', 'mainpage_categories.tpl'); 
     219 
    218220  trigger_action('loc_begin_index_category_thumbnails', $categories); 
    219   if ($conf['subcatify']) 
    220   { 
    221     $template->set_filename('mainpage_categories', 'mainpage_categories.tpl'); 
    222  
    223     foreach ($categories as $category) 
    224     { 
    225       if ($page['section']=='recent_cats') 
    226       { 
    227         $name = get_cat_display_name_cache($category['uppercats'], null, false); 
    228       } 
    229       else 
    230       { 
    231         $name = $category['name']; 
    232       } 
    233  
    234       $icon_ts = get_icon($category['max_date_last'], $category['is_child_date_last']); 
    235  
    236       $tpl_var = 
     221 
     222  foreach ($categories as $category) 
     223  { 
     224    if ($page['section']=='recent_cats') 
     225    { 
     226      $name = get_cat_display_name_cache($category['uppercats'], null, false); 
     227    } 
     228    else 
     229    { 
     230      $name = $category['name']; 
     231    } 
     232 
     233    $icon_ts = get_icon($category['max_date_last'], $category['is_child_date_last']); 
     234 
     235    $tpl_var = 
    237236        array( 
    238237          'ID'    => $category['id'], 
     
    260259                'subcatify_category_description')), 
    261260          'NAME'  => $name, 
    262           ); 
    263  
    264       if ($conf['display_fromto']) 
     261        ); 
     262 
     263    if ($conf['display_fromto']) 
     264    { 
     265      if (isset($dates_of_category[ $category['id'] ])) 
    265266      { 
    266         if (isset($dates_of_category[ $category['id'] ])) 
     267        $from = $dates_of_category[ $category['id'] ]['from']; 
     268        $to   = $dates_of_category[ $category['id'] ]['to']; 
     269 
     270        if (!empty($from)) 
    267271        { 
    268           $from = $dates_of_category[ $category['id'] ]['from']; 
    269           $to   = $dates_of_category[ $category['id'] ]['to']; 
    270  
    271           if (!empty($from)) 
     272          $info = ''; 
     273 
     274          if ($from == $to) 
    272275          { 
    273             $info = ''; 
    274  
    275             if ($from == $to) 
    276             { 
    277               $info = format_date($from); 
    278             } 
    279             else 
    280             { 
    281               $info = sprintf( 
    282                 l10n('from %s to %s'), 
    283                 format_date($from), 
    284                 format_date($to) 
    285                 ); 
    286             } 
    287             $tpl_var['INFO_DATES'] = $info; 
     276            $info = format_date($from); 
    288277          } 
     278          else 
     279          { 
     280            $info = sprintf( 
     281              l10n('from %s to %s'), 
     282              format_date($from), 
     283              format_date($to) 
     284              ); 
     285          } 
     286          $tpl_var['INFO_DATES'] = $info; 
    289287        } 
    290       }//fromto 
    291  
    292       $template->append( 'category_thumbnails', $tpl_var); 
    293  
    294  
    295       //plugins need to add/modify sth in this loop ? 
    296       trigger_action('loc_index_category_thumbnail', 
    297         $category, 'categories.category' ); 
    298     } 
    299  
    300     $template->assign_var_from_handle('CATEGORIES', 'mainpage_categories'); 
    301   } 
    302   else 
    303   { 
    304     $template->set_filename( 'thumbnails', 'thumbnails.tpl'); 
    305  
    306     if ($page['section']=='recent_cats') 
    307     { 
    308       $old_level_separator = $conf['level_separator']; 
    309       $conf['level_separator'] = '<br />'; 
    310     } 
    311  
    312     foreach ($categories as $category) 
    313     { 
    314       $tpl_var = 
    315         array( 
    316           'IMAGE'       => $thumbnail_src_of[ $category['representative_picture_id'] ], 
    317           'IMAGE_ALT'   => $category['name'], 
    318           'IMAGE_TITLE' => get_display_images_count 
    319                                   ( 
    320                                     $category['nb_images'], 
    321                                     $category['count_images'], 
    322                                     $category['count_categories'], 
    323                                     true, 
    324                                     ' / ' 
    325                                   ), 
    326  
    327           'U_IMG_LINK'  => make_index_url( 
    328             array( 
    329               'category' => $category 
    330               ) 
    331             ), 
    332           'CLASS'       => 'thumbCat', 
    333           ); 
    334       if ($page['section']=='recent_cats') 
    335       { 
    336         $name = get_cat_display_name_cache($category['uppercats'], null, false); 
    337288      } 
    338       else 
    339       { 
    340         $name = $category['name']; 
    341         $tpl_var['IMAGE_TS'] = get_icon($category['max_date_last'], $category['is_child_date_last']); 
    342       } 
    343       $tpl_var['CATEGORY_NAME']=$name; 
    344  
    345       $template->append('thumbnails', $tpl_var); 
    346  
    347       //plugins need to add/modify sth in this loop ? 
    348       trigger_action('loc_index_category_thumbnail', 
    349         $category, 'thumbnails' ); 
    350  
    351     } 
    352  
    353     if ( isset($old_level_separator) ) 
    354     { 
    355       $conf['level_separator']=$old_level_separator; 
    356     } 
    357  
    358     $template->assign_var_from_handle('CATEGORIES', 'thumbnails'); 
    359   } 
     289    }//fromto 
     290 
     291    //plugins need to add/modify sth in this loop ? 
     292    $tpl_var = trigger_event('loc_index_category_thumbnail', 
     293                  $tpl_var, $category ); 
     294 
     295    $template->append( 'category_thumbnails', $tpl_var); 
     296  } 
     297 
    360298  trigger_action('loc_end_index_category_thumbnails', $categories); 
     299  $template->assign_var_from_handle('CATEGORIES', 'index_category_thumbnails'); 
    361300} 
    362301?>