Ignore:
Timestamp:
Jun 26, 2013, 12:09:21 AM (11 years ago)
Author:
mistic100
Message:

many corrections & optimizations + remove useless code + clean

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/UserCollections/include/events.inc.php

    r23361 r23551  
    4747function user_collections_page()
    4848{
    49   global $page;
     49  global $page, $template;
    5050
    5151  if (isset($page['section']) and $page['section'] == 'collections')
    5252  {
    5353    include(USER_COLLEC_PATH . '/include/collections.inc.php');
     54  }
     55 
     56  if (!is_a_guest() && count($page['items']))
     57  {
     58    $template->set_filename('uc_tumbnails_cssjs', realpath(USER_COLLEC_PATH . 'template/thumbnails_css_js.tpl'));
     59    $template->parse('uc_tumbnails_cssjs');
    5460  }
    5561}
     
    98104  // get all collections
    99105  $query = '
    100 SELECT id, name, nb_images, active
     106SELECT id, name, nb_images
    101107  FROM '.COLLECTIONS_TABLE.'
    102108  WHERE user_id = '.$user['id'].'
     
    104110;';
    105111  $collections = hash_from_query($query, 'id');
     112 
     113  foreach ($collections as &$col)
     114  {
     115    $col["name"] = trigger_event("render_category_name", $col["name"]);
     116  }
     117  unset($col);
    106118 
    107119  $template->assign(array(
     
    112124  // thumbnails buttons
    113125  $template->set_prefilter('index_thumbnails', 'user_collections_thumbnails_list_button');
    114   $template->set_prefilter('index', 'user_collections_thumbnails_list_cssjs');
    115126 
    116127  return $tpl_thumbnails_var;
     
    133144}
    134145
    135 // add css & js and menu
    136 function user_collections_thumbnails_list_cssjs($content, &$smarty)
    137 {
    138   $content.= file_get_contents(USER_COLLEC_PATH.'template/thumbnails_css_js.tpl');
    139   return $content;
    140 }
    141 
    142146
    143147// +-----------------------------------------------------------------------+
     
    167171  // get all collections
    168172  $query = '
    169 SELECT id, name, nb_images, active
     173SELECT id, name, nb_images
    170174  FROM '.COLLECTIONS_TABLE.'
    171175  WHERE user_id = '.$user['id'].'
     
    173177;';
    174178  $collections = hash_from_query($query, 'id');
     179 
     180  foreach ($collections as &$col)
     181  {
     182    $col["name"] = trigger_event("render_category_name", $col["name"]);
     183  }
     184  unset($col);
    175185 
    176186  $template->assign(array(
     
    214224  {
    215225    $query = '
    216 SELECT *
     226SELECT id, name, nb_images
    217227  FROM '.COLLECTIONS_TABLE.'
    218228  WHERE user_id = '.$user['id'].'
    219   ORDER BY
    220     active DESC,
    221     date_creation DESC
     229  ORDER BY date_creation DESC
    222230;';
    223231    $collections = array_values(hash_from_query($query, 'id'));
     
    226234    for ($i=0; $i<$max && $i<count($collections); $i++)
    227235    {
    228       $collections[$i]['U_EDIT'] = USER_COLLEC_PUBLIC.'edit/'.$collections[$i]['id'];
     236      $collections[$i]['name'] = trigger_event('render_category_name', $collections[$i]['name']);
     237      $collections[$i]['u_edit'] = USER_COLLEC_PUBLIC.'edit/'.$collections[$i]['id'];
    229238      $data['collections'][] = $collections[$i];
    230239    }
     
    239248    $data['U_CREATE'] = add_url_params(USER_COLLEC_PUBLIC, array('action'=>'new','col_id'=>'0','redirect'=>'true'));
    240249   
    241     $template->set_template_dir(USER_COLLEC_PATH . 'template/');
    242250    $block->set_title('<a href="'.USER_COLLEC_PUBLIC.'">'.l10n('Collections').'</a>');
    243     $block->template = 'menublock_user_collec.tpl';
     251    $block->template = realpath(USER_COLLEC_PATH . 'template/menublock.tpl');
    244252    $block->data = $data;
    245253  }
Note: See TracChangeset for help on using the changeset viewer.