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
This commit is contained in:
plegall
2008-09-11 21:40:00 +00:00
parent fdffe42bdc
commit d39db9aaaf
11 changed files with 327 additions and 15 deletions
+10
View File
@@ -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',
+9 -3
View File
@@ -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,
+29 -5
View File
@@ -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(