Changeset 18165 for trunk/include


Ignore:
Timestamp:
Sep 23, 2012, 1:19:26 PM (12 years ago)
Author:
mistic100
Message:

feature 2614: pagination on albums

Location:
trunk/include
Files:
4 edited

Legend:

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

    r12930 r18165  
    2323
    2424/**
    25  * This file is included by the main page to show thumbnails for a category
    26  * that have only subcategories or to show recent categories
     25 * This file is included by the main page to show subcategories of a category
     26 * or to show recent categories or main page categories list
    2727 *
    2828 */
     29
     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);
    2937
    3038// $user['forbidden_categories'] including with USER_CACHE_CATEGORIES_TABLE
     
    3947    count_categories
    4048  FROM '.CATEGORIES_TABLE.' c
    41     INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' ucc ON id = cat_id AND user_id = '.$user['id'];
    42 
    43 if ('recent_cats' == $page['section'])
    44 {
    45   $query.= '
    46   WHERE date_last >= '.pwg_db_get_recent_period_expression($user['recent_period']);
    47 }
    48 else
    49 {
    50   $query.= '
    51   WHERE id_uppercat '.(!isset($page['category']) ? 'is NULL' : '= '.$page['category']['id']);
    52 }
    53 
    54 $query.= '
    55     '.get_sql_condition_FandF(
    56   array(
    57     'visible_categories' => 'id',
    58     ),
    59   'AND'
    60   );
    61 
     49    INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' ucc
     50    ON id = cat_id
     51    AND user_id = '.$user['id'].'
     52  WHERE c.id IN('.implode(',', $selection).')';
     53 
    6254if ('recent_cats' != $page['section'])
    6355{
  • trunk/include/functions.inc.php

    r18164 r18165  
    14301430 * return an array which will be sent to template to display navigation bar
    14311431 */
    1432 function create_navigation_bar($url, $nb_element, $start, $nb_element_page, $clean_url = false)
     1432function create_navigation_bar($url, $nb_element, $start, $nb_element_page, $clean_url = false, $param_name='start')
    14331433{
    14341434  global $conf;
     
    14361436  $navbar = array();
    14371437  $pages_around = $conf['paginate_pages_around'];
    1438   $start_str = $clean_url ? '/start-' : (strpos($url, '?')===false ? '?':'&').'start=';
     1438  $start_str = $clean_url ? '/'.$param_name.'-' : (strpos($url, '?')===false ? '?':'&').$param_name.'=';
    14391439
    14401440  if (!isset($start) or !is_numeric($start) or (is_numeric($start) and $start < 0))
  • trunk/include/functions_url.inc.php

    r15383 r18165  
    459459            and strpos($tokens[$current_token], 'posted-')!==0
    460460            and strpos($tokens[$next_token], 'start-')!==0
     461            and strpos($tokens[$next_token], 'starta-')!==0
    461462            and $tokens[$current_token] != 'flat')
    462463        {
     
    652653      $page['start'] = $matches[1];
    653654    }
     655    elseif (preg_match('/^starta-(\d+)/', $tokens[$i], $matches))
     656    {
     657      $page['starta'] = $matches[1];
     658    }
    654659    $i++;
    655660  }
  • trunk/include/section_init.inc.php

    r13872 r18165  
    4242//   );
    4343
    44 $page['items'] = array();
     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;
    4549
    4650// some ISPs set PATH_INFO to empty string or to SCRIPT_FILENAME while in the
     
    247251    $page['title'] = ''; // will be set later
    248252
     253   
     254  // GET IMAGES LIST
    249255  if
    250256    (
     257      $page['starta'] == 0 and
    251258      (!isset($page['chronology_field'])) and
    252259      (
     
    311318    $page['items'] = array_from_query($query, 'image_id');
    312319  } //otherwise the calendar will requery all subitems
     320 
     321  // GET CATEGORIES LIST
     322  if ( 0==$page['start']
     323    and !isset($page['flat'])
     324    and !isset($page['chronology_field'])
     325    and ('recent_cats'==$page['section'] or 'categories'==$page['section'])
     326    and (!isset($page['category']['count_categories']) or $page['category']['count_categories']>0 )
     327  )
     328  {
     329    $query = '
     330SELECT c.id
     331  FROM '.CATEGORIES_TABLE.' c
     332    INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' ucc
     333    ON id = cat_id
     334    AND user_id = '.$user['id'];
     335
     336    if ('recent_cats' == $page['section'])
     337    {
     338      $query.= '
     339      WHERE date_last >= '.pwg_db_get_recent_period_expression($user['recent_period']);
     340    }
     341    else
     342    {
     343      $query.= '
     344      WHERE id_uppercat '.(!isset($page['category']) ? 'is NULL' : '= '.$page['category']['id']);
     345    }
     346
     347    $query.= '
     348        '.get_sql_condition_FandF(
     349          array('visible_categories' => 'id'),
     350          'AND'
     351          );
     352
     353    $query.= '
     354    ;';
     355
     356    $page['categories'] = array_from_query($query, 'id');
     357  }
    313358}
    314359// special sections
Note: See TracChangeset for help on using the changeset viewer.