aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/config_default.inc.php10
-rw-r--r--include/functions_category.inc.php12
-rw-r--r--include/section_init.inc.php34
3 files changed, 48 insertions, 8 deletions
diff --git a/include/config_default.inc.php b/include/config_default.inc.php
index 838cc20b0..9956ba164 100644
--- a/include/config_default.inc.php
+++ b/include/config_default.inc.php
@@ -63,6 +63,16 @@
// the date_available
$conf['order_by'] = ' ORDER BY date_available DESC, file ASC, id ASC';
+// order_by_inside_category : inside a category, images can also be ordered
+// by rank. A manually defined rank on each image for the category.
+//
+// In addition to fields of #images table, you can use the
+// #image_category.rank column
+//
+// $conf['order_by_inside_category'] = ' ORDER BY rank';
+// will sort images by the manually defined rank of images in this category.
+$conf['order_by_inside_category'] = $conf['order_by'];
+
// file_ext : file extensions (case sensitive) authorized
$conf['file_ext'] = array('jpg','JPG','jpeg','JPEG',
'png','PNG','gif','GIF','mpg','zip',
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index 0bca0897a..92e9cf229 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -257,15 +257,21 @@ SELECT galleries_url
// returns an array of image orders available for users/visitors
function get_category_preferred_image_orders()
{
- global $conf;
+ global $conf, $page;
+
return array(
array(l10n('default_sort'), '', true),
array(l10n('Average rate'), 'average_rate DESC', $conf['rate']),
array(l10n('most_visited_cat'), 'hit DESC', true),
array(l10n('Creation date'), 'date_creation DESC', true),
array(l10n('Post date'), 'date_available DESC', true),
- array(l10n('File name'), 'file ASC', true)
- );
+ array(l10n('File name'), 'file ASC', true),
+ array(
+ l10n('Rank'),
+ 'rank ASC',
+ ('categories' == $page['section'] and !isset($page['flat']))
+ )
+ );
}
function display_select_categories($categories,
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(