diff --git a/admin/configuration.php b/admin/configuration.php
index c615d64f1..8a7094864 100644
--- a/admin/configuration.php
+++ b/admin/configuration.php
@@ -222,6 +222,11 @@ if (isset($_POST['submit']))
}
case 'display' :
{
+ if (!preg_match($int_pattern, $_POST['nb_categories_page'])
+ or $_POST['nb_categories_page'] < 4)
+ {
+ array_push($page['errors'], l10n('The number of albums a page must be above 4.'));
+ }
foreach( $display_checkboxes as $checkbox)
{
$_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true';
@@ -422,7 +427,8 @@ switch ($page['section'])
$template->append(
'display',
array(
- 'picture_informations' => unserialize($conf['picture_informations'])
+ 'picture_informations' => unserialize($conf['picture_informations']),
+ 'NB_CATEGORIES_PAGE' => $conf['nb_categories_page'],
),
true
);
diff --git a/admin/themes/default/template/configuration.tpl b/admin/themes/default/template/configuration.tpl
index 388e26d0d..a2520b0c3 100644
--- a/admin/themes/default/template/configuration.tpl
+++ b/admin/themes/default/template/configuration.tpl
@@ -645,6 +645,13 @@ jQuery(document).ready(function() {
{'slideshow'|@translate|@ucfirst|@string_format:$pwg->l10n('Activate icon "%s"')}
+
+
+
+
diff --git a/include/category_cats.inc.php b/include/category_cats.inc.php
index c8b728e5a..b09f4eaec 100644
--- a/include/category_cats.inc.php
+++ b/include/category_cats.inc.php
@@ -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.= '
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 0be5ec9ef..031ee652a 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -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))
{
diff --git a/include/functions_url.inc.php b/include/functions_url.inc.php
index 8d9dba93e..7a3853e25 100644
--- a/include/functions_url.inc.php
+++ b/include/functions_url.inc.php
@@ -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;
diff --git a/include/section_init.inc.php b/include/section_init.inc.php
index 2bfb1e9b5..25712a0bb 100644
--- a/include/section_init.inc.php
+++ b/include/section_init.inc.php
@@ -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
diff --git a/index.php b/index.php
index 02cd6369f..12797cc0b 100644
--- a/index.php
+++ b/index.php
@@ -29,10 +29,6 @@ include(PHPWG_ROOT_PATH.'include/section_init.inc.php');
// Check Access and exit when user status is not ok
check_status(ACCESS_GUEST);
-if (!isset($page['start']))
-{
- $page['start'] = 0;
-}
// access authorization check
if (isset($page['category']))
@@ -74,6 +70,7 @@ if (isset($_GET['display']))
}
//-------------------------------------------------------------- initialization
+// navigation bar
$page['navigation_bar'] = array();
if (count($page['items']) > $page['nb_image_page'])
{
@@ -82,10 +79,25 @@ if (count($page['items']) > $page['nb_image_page'])
count($page['items']),
$page['start'],
$page['nb_image_page'],
- true
+ true, 'start'
);
}
+$page['cats_navigation_bar'] = array();
+if (count($page['categories']) > $conf['nb_categories_page'])
+{
+ $page['cats_navigation_bar'] = create_navigation_bar(
+ duplicate_index_url(array(), array('starta')),
+ count($page['categories']),
+ $page['starta'],
+ $conf['nb_categories_page'],
+ true, 'starta'
+ );
+}
+
+$template->assign( 'thumb_navbar', $page['navigation_bar'] );
+$template->assign( 'cats_navbar', $page['cats_navigation_bar'] );
+
// caddie filling :-)
if (isset($_GET['caddie']))
{
@@ -242,8 +254,6 @@ if ( $page['section']=='search' and $page['start']==0 and
}
}
-// navigation bar
-$template->assign( 'navbar', $page['navigation_bar'] );
if ( $conf['index_sort_order_input']
and count($page['items']) > 0
@@ -288,12 +298,7 @@ if ( isset($page['category']['count_categories']) and $page['category']['count_c
}
//------------------------------------------------------ main part : thumbnails
-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 )
- )
+if ( !empty($page['categories']) )
{
include(PHPWG_ROOT_PATH.'include/category_cats.inc.php');
}
diff --git a/install/config.sql b/install/config.sql
index b68af137a..e1c1128eb 100644
--- a/install/config.sql
+++ b/install/config.sql
@@ -21,6 +21,7 @@ INSERT INTO piwigo_config (param,value,comment) VALUES ('history_admin','false',
INSERT INTO piwigo_config (param,value,comment) VALUES ('history_guest','true','keep a history of guest visits on your website');
INSERT INTO piwigo_config (param,value,comment) VALUES ('allow_user_registration','true','allow visitors to register?');
INSERT INTO piwigo_config (param,value,comment) VALUES ('allow_user_customization','true','allow users to customize their gallery?');
+INSERT INTO piwigo_config (param,value,comment) VALUES ('nb_categories_page','12');
INSERT INTO piwigo_config (param,value,comment) VALUES ('nbm_send_html_mail','true','Send mail on HTML format for notification by mail');
INSERT INTO piwigo_config (param,value,comment) VALUES ('nbm_send_mail_as','','Send mail as param value for notification by mail');
INSERT INTO piwigo_config (param,value,comment) VALUES ('nbm_send_detailed_content','true','Send detailed content for notification by mail');
diff --git a/install/db/131-database.php b/install/db/131-database.php
new file mode 100644
index 000000000..0af7771e9
--- /dev/null
+++ b/install/db/131-database.php
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/language/en_UK/admin.lang.php b/language/en_UK/admin.lang.php
index 15ce554a1..7055d3e01 100644
--- a/language/en_UK/admin.lang.php
+++ b/language/en_UK/admin.lang.php
@@ -538,6 +538,7 @@ $lang['nothing'] = "nothing";
$lang['Notification'] = "Notification";
$lang['Notify administrators when a comment is'] = 'Notify administrators when a comment is';
$lang['Number of comments per page'] = "Number of comments per page";
+$lang['Number of albums per page'] = 'Number of albums per page';
$lang['Number of downloads'] = "Number of downloads";
$lang['number of miniaturized photos'] = "number of thumbnails created";
$lang['Number of rates'] = "Number of rates";
diff --git a/language/fr_FR/admin.lang.php b/language/fr_FR/admin.lang.php
index ca2f7c21b..ff50d076f 100644
--- a/language/fr_FR/admin.lang.php
+++ b/language/fr_FR/admin.lang.php
@@ -936,4 +936,5 @@ $lang['Landscape'] = 'Paysage';
$lang['Panorama'] = 'Panorama';
$lang['Manage photos'] = 'Gérer les photos';
$lang['View in gallery'] = 'Voir dans la galerie';
+$lang['Number of albums per page'] = 'Nombre d\'albums par page';
?>
\ No newline at end of file
diff --git a/themes/default/template/index.tpl b/themes/default/template/index.tpl
index 14045342a..410d08481 100644
--- a/themes/default/template/index.tpl
+++ b/themes/default/template/index.tpl
@@ -163,13 +163,20 @@ jQuery("#derivativeSwitchBox").on("mouseleave", function() {
{/if}
{if !empty($CATEGORIES)}{$CATEGORIES}{/if}
+{if !empty($cats_navbar)}
+ {assign var=navbar value=$cats_navbar}
+ {include file='navigation_bar.tpl'|@get_extent:'navbar'}
+{/if}
+
{if !empty($THUMBNAILS)}
{/if}
-
-{if !empty($navbar)}{include file='navigation_bar.tpl'|@get_extent:'navbar'}{/if}
+{if !empty($thumb_navbar)}
+ {assign var=navbar value=$thumb_navbar}
+ {include file='navigation_bar.tpl'|@get_extent:'navbar'}
+{/if}
{if !empty($PLUGIN_INDEX_CONTENT_END)}{$PLUGIN_INDEX_CONTENT_END}{/if}
{* *}