From bb181b04cf3e4984cb1dfbe95e5521ad917fab76 Mon Sep 17 00:00:00 2001 From: rvelices Date: Wed, 1 Feb 2006 02:46:26 +0000 Subject: 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 --- include/functions_category.inc.php | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'include/functions_category.inc.php') 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 { -- cgit v1.2.3