aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions_category.inc.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2006-02-01 02:46:26 +0000
committerrvelices <rv-github@modusoptimus.com>2006-02-01 02:46:26 +0000
commitbb181b04cf3e4984cb1dfbe95e5521ad917fab76 (patch)
tree10199843cd8c12ff06ea1f2e0fb6977d6fa1c46f /include/functions_category.inc.php
parentac5fd23412f64b5b8647574a431e3cc13518538e (diff)
feature 280: Allow visitors/users to choose image ordering inside a category
improvement 82: Viewing pictures from remote galleries does not check anymore for the high pictures (existence flag added to create_listing_file and db) correction: link element in picture is in the head instead of body (w3c spec) correction: in profile.php the current template was not selected by default git-svn-id: http://piwigo.org/svn/trunk@1020 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/functions_category.inc.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index c9fee76f0..908f297d6 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -318,6 +318,20 @@ SELECT galleries_url
return $row['galleries_url'];
}
+// returns an array of image orders available for users/visitors
+function get_category_preferred_image_orders()
+{
+ global $lang, $conf;
+ return array(
+ array('Default', '', true),
+ array($lang['best_rated_cat'], 'average_rate DESC', $conf['rate']),
+ array($lang['most_visited_cat'], 'hit DESC', true),
+ array($lang['Creation date'], 'date_creation DESC', true),
+ array($lang['Availability date'], 'date_available DESC', true)
+ );
+}
+
+
// initialize_category initializes ;-) the variables in relation
// with category :
// 1. calculation of the number of pictures in the category
@@ -603,6 +617,29 @@ SELECT COUNT(DISTINCT(id)) AS count
create_navigation_bar( $url, $page['cat_nb_images'], $page['start'],
$user['nb_image_page'], 'back' );
}
+
+ if ($page['cat'] != 'most_visited' and $page['cat'] != 'best_rated')
+ {
+ $available_image_orders = get_category_preferred_image_orders();
+
+ $order_idx=0;
+ if ( isset($_GET['image_order']) )
+ {
+ $order_idx = $_GET['image_order'];
+ setcookie( 'pwg_image_order', $order_idx, 0 );
+ }
+ else if ( isset($_COOKIE['pwg_image_order']) )
+ {
+ $order_idx = $_COOKIE['pwg_image_order'];
+ }
+
+ if ( $order_idx > 0 )
+ {
+ $order = $available_image_orders[$order_idx][1];
+ $conf['order_by'] = str_replace('ORDER BY ', 'ORDER BY '.$order.',',
+ $conf['order_by'] );
+ }
+ }
}
else
{