Changeset 18462


Ignore:
Timestamp:
Oct 4, 2012, 5:03:55 PM (12 years ago)
Author:
mistic100
Message:

feature:2614 pagination on albums
return to old fashioned way (one query in category_cats), restoring recent_cats feature and "menubar optimization", rename "starta" into "startcat"

Location:
trunk
Files:
4 edited

Legend:

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

    r18165 r18462  
    2828 */
    2929
    30 $selection = array_slice(
    31   $page['categories'],
    32   $page['starta'],
    33   $conf['nb_categories_page']
    34   );
    35 
    36 $selection = trigger_event('loc_index_categories_selection', $selection);
    3730
    3831// $user['forbidden_categories'] including with USER_CACHE_CATEGORIES_TABLE
     
    4942    INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' ucc
    5043    ON id = cat_id
    51     AND user_id = '.$user['id'].'
    52   WHERE c.id IN('.implode(',', $selection).')';
     44    AND user_id = '.$user['id'];
     45 
     46if ('recent_cats' == $page['section'])
     47{
     48  $query.= '
     49  WHERE date_last >= '.pwg_db_get_recent_period_expression($user['recent_period']);
     50}
     51else
     52{
     53  $query.= '
     54  WHERE id_uppercat '.(!isset($page['category']) ? 'is NULL' : '= '.$page['category']['id']);
     55}
     56
     57$query.= '
     58      '.get_sql_condition_FandF(
     59        array('visible_categories' => 'id'),
     60        'AND'
     61        );
    5362 
    5463if ('recent_cats' != $page['section'])
     
    6170;';
    6271
    63 $result = pwg_query($query);
     72$categories_sql = hash_from_query($query, 'id');
     73
     74$page['total_categories'] = count($categories_sql);
     75
     76$categories_sql = array_slice(
     77  array_values($categories_sql),
     78  $page['startcat'],
     79  $conf['nb_categories_page']
     80  );
     81
     82$categories_sql = trigger_event('loc_index_categories_selection', $categories_sql);
     83
    6484$categories = array();
    6585$category_ids = array();
     
    6787$user_representative_updates_for = array();
    6888
    69 while ($row = pwg_db_fetch_assoc($result))
     89foreach ($categories_sql as $row)
    7090{
    7191  $row['is_child_date_last'] = @$row['max_date_last']>@$row['date_last'];
     
    375395
    376396  $template->assign_var_from_handle('CATEGORIES', 'index_category_thumbnails');
    377 }
     397 
     398  // navigation bar
     399  $page['cats_navigation_bar'] = array();
     400  if ($page['total_categories'] > $conf['nb_categories_page'])
     401  {
     402    $page['cats_navigation_bar'] = create_navigation_bar(
     403      duplicate_index_url(array(), array('startcat')),
     404      $page['total_categories'],
     405      $page['startcat'],
     406      $conf['nb_categories_page'],
     407      true, 'startcat'
     408      );
     409  }
     410
     411  $template->assign('cats_navbar', $page['cats_navigation_bar'] );
     412}
     413
    378414pwg_debug('end include/category_cats.inc.php');
    379415?>
  • trunk/include/functions_url.inc.php

    r18165 r18462  
    459459            and strpos($tokens[$current_token], 'posted-')!==0
    460460            and strpos($tokens[$next_token], 'start-')!==0
    461             and strpos($tokens[$next_token], 'starta-')!==0
     461            and strpos($tokens[$next_token], 'startcat-')!==0
    462462            and $tokens[$current_token] != 'flat')
    463463        {
     
    653653      $page['start'] = $matches[1];
    654654    }
    655     elseif (preg_match('/^starta-(\d+)/', $tokens[$i], $matches))
    656     {
    657       $page['starta'] = $matches[1];
     655    elseif (preg_match('/^startcat-(\d+)/', $tokens[$i], $matches))
     656    {
     657      $page['startcat'] = $matches[1];
    658658    }
    659659    $i++;
  • trunk/include/section_init.inc.php

    r18392 r18462  
    4242//   );
    4343
    44 // exemple of dynamic nb_categories_page (%2 for nice display)
    45 // $conf['nb_categories_page'] = 2*round($user['nb_image_page']/4);
    46 
    47 $page['items'] = $page['categories'] = array();
    48 $page['start'] = $page['starta'] = 0;
     44
     45$page['items'] = array();
     46$page['start'] = $page['startcat'] = 0;
    4947
    5048// some ISPs set PATH_INFO to empty string or to SCRIPT_FILENAME while in the
     
    255253  if
    256254    (
    257       $page['starta'] == 0 and
     255      $page['startcat'] == 0 and
    258256      (!isset($page['chronology_field'])) and
    259257      (
     
    318316    $page['items'] = array_from_query($query, 'image_id');
    319317  } //otherwise the calendar will requery all subitems
    320  
    321   // GET CATEGORIES LIST
    322   if ( script_basename()=='index'
    323     and 0==$page['start']
    324     and !isset($page['flat'])
    325     and !isset($page['chronology_field'])
    326     and ('recent_cats'==$page['section'] or 'categories'==$page['section'])
    327     and (!isset($page['category']['count_categories']) or $page['category']['count_categories']>0 )
    328   )
    329   {
    330     $query = '
    331 SELECT c.id
    332   FROM '.CATEGORIES_TABLE.' c
    333     INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' ucc
    334     ON id = cat_id
    335     AND user_id = '.$user['id'];
    336 
    337     if ('recent_cats' == $page['section'])
    338     {
    339       $query.= '
    340       WHERE date_last >= '.pwg_db_get_recent_period_expression($user['recent_period']);
    341     }
    342     else
    343     {
    344       $query.= '
    345       WHERE id_uppercat '.(!isset($page['category']) ? 'is NULL' : '= '.$page['category']['id']);
    346     }
    347 
    348     $query.= '
    349         '.get_sql_condition_FandF(
    350           array('visible_categories' => 'id'),
    351           'AND'
    352           );
    353 
    354     $query.= '
    355     ;';
    356 
    357     $page['categories'] = array_from_query($query, 'id');
    358   }
    359318}
    360319// special sections
  • trunk/index.php

    r18165 r18462  
    8484}
    8585
    86 $page['cats_navigation_bar'] = array();
    87 if (count($page['categories']) > $conf['nb_categories_page'])
    88 {
    89   $page['cats_navigation_bar'] = create_navigation_bar(
    90     duplicate_index_url(array(), array('starta')),
    91     count($page['categories']),
    92     $page['starta'],
    93     $conf['nb_categories_page'],
    94     true, 'starta'
    95     );
    96 }
    97 
    98 $template->assign( 'thumb_navbar', $page['navigation_bar'] );
    99 $template->assign( 'cats_navbar', $page['cats_navigation_bar'] );
     86$template->assign('thumb_navbar', $page['navigation_bar'] );
    10087
    10188// caddie filling :-)
     
    299286
    300287//------------------------------------------------------ main part : thumbnails
    301 if ( !empty($page['categories']) )
     288if ( 0==$page['start']
     289  and !isset($page['flat'])
     290  and !isset($page['chronology_field'])
     291  and ('recent_cats'==$page['section'] or 'categories'==$page['section'])
     292  and (!isset($page['category']['count_categories']) or $page['category']['count_categories']>0 )
     293)
    302294{
    303295  include(PHPWG_ROOT_PATH.'include/category_cats.inc.php');
    304296}
     297
    305298if ( !empty($page['items']) )
    306299{
Note: See TracChangeset for help on using the changeset viewer.