mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-08-07 09:13:02 +02:00
feature 2614: pagination on albums
git-svn-id: http://piwigo.org/svn/trunk@18165 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
@@ -22,11 +22,19 @@
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
/**
|
||||
* This file is included by the main page to show thumbnails for a category
|
||||
* that have only subcategories or to show recent categories
|
||||
* This file is included by the main page to show subcategories of a category
|
||||
* or to show recent categories or main page categories list
|
||||
*
|
||||
*/
|
||||
|
||||
$selection = array_slice(
|
||||
$page['categories'],
|
||||
$page['starta'],
|
||||
$conf['nb_categories_page']
|
||||
);
|
||||
|
||||
$selection = trigger_event('loc_index_categories_selection', $selection);
|
||||
|
||||
// $user['forbidden_categories'] including with USER_CACHE_CATEGORIES_TABLE
|
||||
$query = '
|
||||
SELECT
|
||||
@@ -38,27 +46,11 @@ SELECT
|
||||
count_images,
|
||||
count_categories
|
||||
FROM '.CATEGORIES_TABLE.' c
|
||||
INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' ucc ON id = cat_id AND user_id = '.$user['id'];
|
||||
|
||||
if ('recent_cats' == $page['section'])
|
||||
{
|
||||
$query.= '
|
||||
WHERE date_last >= '.pwg_db_get_recent_period_expression($user['recent_period']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$query.= '
|
||||
WHERE id_uppercat '.(!isset($page['category']) ? 'is NULL' : '= '.$page['category']['id']);
|
||||
}
|
||||
|
||||
$query.= '
|
||||
'.get_sql_condition_FandF(
|
||||
array(
|
||||
'visible_categories' => 'id',
|
||||
),
|
||||
'AND'
|
||||
);
|
||||
|
||||
INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' ucc
|
||||
ON id = cat_id
|
||||
AND user_id = '.$user['id'].'
|
||||
WHERE c.id IN('.implode(',', $selection).')';
|
||||
|
||||
if ('recent_cats' != $page['section'])
|
||||
{
|
||||
$query.= '
|
||||
|
||||
@@ -1429,13 +1429,13 @@ function verify_ephemeral_key($key, $aditionnal_data_to_hash = '')
|
||||
/**
|
||||
* return an array which will be sent to template to display navigation bar
|
||||
*/
|
||||
function create_navigation_bar($url, $nb_element, $start, $nb_element_page, $clean_url = false)
|
||||
function create_navigation_bar($url, $nb_element, $start, $nb_element_page, $clean_url = false, $param_name='start')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$navbar = array();
|
||||
$pages_around = $conf['paginate_pages_around'];
|
||||
$start_str = $clean_url ? '/start-' : (strpos($url, '?')===false ? '?':'&').'start=';
|
||||
$start_str = $clean_url ? '/'.$param_name.'-' : (strpos($url, '?')===false ? '?':'&').$param_name.'=';
|
||||
|
||||
if (!isset($start) or !is_numeric($start) or (is_numeric($start) and $start < 0))
|
||||
{
|
||||
|
||||
@@ -458,6 +458,7 @@ function parse_section_url( $tokens, &$next_token)
|
||||
and strpos($tokens[$current_token], 'created-')!==0
|
||||
and strpos($tokens[$current_token], 'posted-')!==0
|
||||
and strpos($tokens[$next_token], 'start-')!==0
|
||||
and strpos($tokens[$next_token], 'starta-')!==0
|
||||
and $tokens[$current_token] != 'flat')
|
||||
{
|
||||
if (empty($maybe_permalinks))
|
||||
@@ -651,6 +652,10 @@ function parse_well_known_params_url($tokens, &$i)
|
||||
{
|
||||
$page['start'] = $matches[1];
|
||||
}
|
||||
elseif (preg_match('/^starta-(\d+)/', $tokens[$i], $matches))
|
||||
{
|
||||
$page['starta'] = $matches[1];
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
return $page;
|
||||
|
||||
@@ -41,7 +41,11 @@
|
||||
// 'start' => 24
|
||||
// );
|
||||
|
||||
$page['items'] = array();
|
||||
// exemple of dynamic nb_categories_page (%2 for nice display)
|
||||
// $conf['nb_categories_page'] = 2*round($user['nb_image_page']/4);
|
||||
|
||||
$page['items'] = $page['categories'] = array();
|
||||
$page['start'] = $page['starta'] = 0;
|
||||
|
||||
// some ISPs set PATH_INFO to empty string or to SCRIPT_FILENAME while in the
|
||||
// default apache implementation it is not set
|
||||
@@ -246,8 +250,11 @@ if ('categories' == $page['section'])
|
||||
else
|
||||
$page['title'] = ''; // will be set later
|
||||
|
||||
|
||||
// GET IMAGES LIST
|
||||
if
|
||||
(
|
||||
$page['starta'] == 0 and
|
||||
(!isset($page['chronology_field'])) and
|
||||
(
|
||||
(isset($page['category'])) or
|
||||
@@ -310,6 +317,44 @@ SELECT DISTINCT(image_id)
|
||||
|
||||
$page['items'] = array_from_query($query, 'image_id');
|
||||
} //otherwise the calendar will requery all subitems
|
||||
|
||||
// GET CATEGORIES LIST
|
||||
if ( 0==$page['start']
|
||||
and !isset($page['flat'])
|
||||
and !isset($page['chronology_field'])
|
||||
and ('recent_cats'==$page['section'] or 'categories'==$page['section'])
|
||||
and (!isset($page['category']['count_categories']) or $page['category']['count_categories']>0 )
|
||||
)
|
||||
{
|
||||
$query = '
|
||||
SELECT c.id
|
||||
FROM '.CATEGORIES_TABLE.' c
|
||||
INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' ucc
|
||||
ON id = cat_id
|
||||
AND user_id = '.$user['id'];
|
||||
|
||||
if ('recent_cats' == $page['section'])
|
||||
{
|
||||
$query.= '
|
||||
WHERE date_last >= '.pwg_db_get_recent_period_expression($user['recent_period']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$query.= '
|
||||
WHERE id_uppercat '.(!isset($page['category']) ? 'is NULL' : '= '.$page['category']['id']);
|
||||
}
|
||||
|
||||
$query.= '
|
||||
'.get_sql_condition_FandF(
|
||||
array('visible_categories' => 'id'),
|
||||
'AND'
|
||||
);
|
||||
|
||||
$query.= '
|
||||
;';
|
||||
|
||||
$page['categories'] = array_from_query($query, 'id');
|
||||
}
|
||||
}
|
||||
// special sections
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user