aboutsummaryrefslogtreecommitdiffstats
path: root/include/section_init.inc.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2008-09-11 21:40:00 +0000
committerplegall <plg@piwigo.org>2008-09-11 21:40:00 +0000
commitd39db9aaaf43eaedd634a7a5b7d06bcb69d41152 (patch)
tree645010e01f3d84ecbc131c883ca941c50386489b /include/section_init.inc.php
parentfdffe42bdc703a9f2391c77ae0256c33a3eac935 (diff)
feature 169 added: ability to manually sort images inside a category. A
dedicated screen let the administrator sort the images (pur HTML, no JavaScript yet). The "rank" sort order is available only for a category without flat mode. New database column image_category.rank. git-svn-id: http://piwigo.org/svn/trunk@2517 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/section_init.inc.php')
-rw-r--r--include/section_init.inc.php34
1 files changed, 29 insertions, 5 deletions
diff --git a/include/section_init.inc.php b/include/section_init.inc.php
index 053607dfd..97f2f0a42 100644
--- a/include/section_init.inc.php
+++ b/include/section_init.inc.php
@@ -172,16 +172,40 @@ if ( script_basename()=='picture' and 'categories'==$page['section'] and
// By default, it is the same as the $user['nb_image_page']
$page['nb_image_page'] = $user['nb_image_page'];
+// if flat mode is active, we must consider the image set as a standard set
+// and not as a category set because we can't use the #image_category.rank :
+// displayed images are not directly linked to the displayed category
+if ('categories' == $page['section'] and !isset($page['flat']))
+{
+ $conf['order_by'] = $conf['order_by_inside_category'];
+}
+
if (pwg_get_session_var('image_order',0) > 0)
{
+ $image_order_id = pwg_get_session_var('image_order');
+
$orders = get_category_preferred_image_orders();
- $conf['order_by'] = str_replace(
- 'ORDER BY ',
- 'ORDER BY '.$orders[ pwg_get_session_var('image_order',0) ][1].',',
- $conf['order_by']
+ // the current session stored image_order might be not compatible with
+ // current image set, for example if the current image_order is the rank
+ // and that we are displaying images related to a tag.
+ //
+ // In case of incompatibility, the session stored image_order is removed.
+ if ($orders[$image_order_id][2])
+ {
+ $conf['order_by'] = str_replace(
+ 'ORDER BY ',
+ 'ORDER BY '.$orders[$image_order_id][1].',',
+ $conf['order_by']
);
- $page['super_order_by'] = true;
+ $page['super_order_by'] = true;
+
+ }
+ else
+ {
+ pwg_unset_session_var('image_order');
+ $page['super_order_by'] = false;
+ }
}
$forbidden = get_sql_condition_FandF(