Changeset 18165 for trunk


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

feature 2614: pagination on albums

Location:
trunk
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/configuration.php

    r18164 r18165  
    223223    case 'display' :
    224224    {
     225      if (!preg_match($int_pattern, $_POST['nb_categories_page'])
     226            or $_POST['nb_categories_page'] < 4)
     227      {
     228        array_push($page['errors'], l10n('The number of albums a page must be above 4.'));
     229      }
    225230      foreach( $display_checkboxes as $checkbox)
    226231      {
     
    423428        'display',
    424429        array(
    425           'picture_informations' => unserialize($conf['picture_informations'])
     430          'picture_informations' => unserialize($conf['picture_informations']),
     431          'NB_CATEGORIES_PAGE' => $conf['nb_categories_page'],
    426432          ),
    427433        true
  • trunk/admin/themes/default/template/configuration.tpl

    r18164 r18165  
    646646      </label>
    647647    </li>
     648   
     649    <li>
     650      <label>
     651        {'Number of albums per page'|@translate}
     652        <input type="text" size="3" maxlength="4" name="nb_categories_page" id="nb_categories_page" value="{$display.NB_CATEGORIES_PAGE}">
     653      </label>
     654    </li>
    648655  </ul>
    649656</fieldset>
  • 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 ? '?':'&amp;').'start=';
     1438  $start_str = $clean_url ? '/'.$param_name.'-' : (strpos($url, '?')===false ? '?':'&amp;').$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
  • trunk/index.php

    r16987 r18165  
    3030check_status(ACCESS_GUEST);
    3131
    32 if (!isset($page['start']))
    33 {
    34   $page['start'] = 0;
    35 }
    3632
    3733// access authorization check
     
    7571//-------------------------------------------------------------- initialization
    7672
     73// navigation bar
    7774$page['navigation_bar'] = array();
    7875if (count($page['items']) > $page['nb_image_page'])
     
    8380    $page['start'],
    8481    $page['nb_image_page'],
    85     true
    86     );
    87 }
     82    true, 'start'
     83    );
     84}
     85
     86$page['cats_navigation_bar'] = array();
     87if (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'] );
    88100
    89101// caddie filling :-)
     
    243255}
    244256
    245 // navigation bar
    246 $template->assign( 'navbar', $page['navigation_bar'] );
    247257
    248258if ( $conf['index_sort_order_input']
     
    289299
    290300//------------------------------------------------------ main part : thumbnails
    291 if ( 0==$page['start']
    292     and !isset($page['flat'])
    293     and !isset($page['chronology_field'])
    294     and ('recent_cats'==$page['section'] or 'categories'==$page['section'])
    295     and (!isset($page['category']['count_categories']) or $page['category']['count_categories']>0 )
    296   )
     301if ( !empty($page['categories']) )
    297302{
    298303  include(PHPWG_ROOT_PATH.'include/category_cats.inc.php');
  • trunk/install/config.sql

    r18164 r18165  
    2222INSERT INTO piwigo_config (param,value,comment) VALUES ('allow_user_registration','true','allow visitors to register?');
    2323INSERT INTO piwigo_config (param,value,comment) VALUES ('allow_user_customization','true','allow users to customize their gallery?');
     24INSERT INTO piwigo_config (param,value,comment) VALUES ('nb_categories_page','12');
    2425INSERT INTO piwigo_config (param,value,comment) VALUES ('nbm_send_html_mail','true','Send mail on HTML format for notification by mail');
    2526INSERT INTO piwigo_config (param,value,comment) VALUES ('nbm_send_mail_as','','Send mail as param value for notification by mail');
  • trunk/language/en_UK/admin.lang.php

    r18080 r18165  
    539539$lang['Notify administrators when a comment is'] = 'Notify administrators when a comment is';
    540540$lang['Number of comments per page'] = "Number of comments per page";
     541$lang['Number of albums per page'] = 'Number of albums per page';
    541542$lang['Number of downloads'] = "Number of downloads";
    542543$lang['number of miniaturized photos'] = "number of thumbnails created";
  • trunk/language/fr_FR/admin.lang.php

    r18080 r18165  
    937937$lang['Manage photos'] = 'Gérer les photos';
    938938$lang['View in gallery'] = 'Voir dans la galerie';
     939$lang['Number of albums per page'] = 'Nombre d\'albums par page';
    939940?>
  • trunk/themes/default/template/index.tpl

    r14180 r18165  
    164164
    165165{if !empty($CATEGORIES)}{$CATEGORIES}{/if}
     166{if !empty($cats_navbar)}
     167  {assign var=navbar value=$cats_navbar}
     168  {include file='navigation_bar.tpl'|@get_extent:'navbar'}
     169{/if}
     170
    166171{if !empty($THUMBNAILS)}
    167172<ul class="thumbnails" id="thumbnails">
     
    169174</ul>
    170175{/if}
    171 
    172 {if !empty($navbar)}{include file='navigation_bar.tpl'|@get_extent:'navbar'}{/if}
     176{if !empty($thumb_navbar)}
     177  {assign var=navbar value=$thumb_navbar}
     178  {include file='navigation_bar.tpl'|@get_extent:'navbar'}
     179{/if}
    173180
    174181{if !empty($PLUGIN_INDEX_CONTENT_END)}{$PLUGIN_INDEX_CONTENT_END}{/if}
Note: See TracChangeset for help on using the changeset viewer.