From 3c76f29e4fc1bb2d5e5f1d0cb1eeefebf13d6635 Mon Sep 17 00:00:00 2001 From: mistic100 Date: Fri, 10 Feb 2012 21:41:08 +0000 Subject: feature 2568: redesigned order_by fields in Admin->Config->Options git-svn-id: http://piwigo.org/svn/trunk@13087 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/element_set_ranks.php | 76 +++++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 47 deletions(-) (limited to 'admin/element_set_ranks.php') diff --git a/admin/element_set_ranks.php b/admin/element_set_ranks.php index cfdceaacd..e66e84f74 100644 --- a/admin/element_set_ranks.php +++ b/admin/element_set_ranks.php @@ -104,28 +104,21 @@ if (isset($_POST['submit'])) ); } - $image_order = null; if (!empty($_POST['image_order_choice']) && in_array($_POST['image_order_choice'], $image_order_choices)) { $image_order_choice = $_POST['image_order_choice']; } + $image_order = null; if ($image_order_choice=='user_define') { - for ($i=1; $i<=3; $i++) + for ($i=0; $i<3; $i++) { - if ( !empty($_POST['order_field_'.$i]) ) + if (!empty($_POST['image_order'][$i])) { - if (! empty($image_order) ) - { - $image_order .= ','; - } - $image_order .= $_POST['order_field_'.$i]; - if ($_POST['order_direction_'.$i]=='DESC') - { - $image_order .= ' DESC'; - } + if (!empty($image_order)) $image_order.= ','; + $image_order.= $_POST['image_order'][$i]; } } } @@ -134,7 +127,8 @@ if (isset($_POST['submit'])) $image_order = 'rank'; } $query = ' -UPDATE '.CATEGORIES_TABLE.' SET image_order=\''.$image_order.'\' +UPDATE '.CATEGORIES_TABLE.' + SET image_order=\''.$image_order.'\' WHERE id='.$page['category_id']; pwg_query($query); @@ -272,50 +266,38 @@ if (pwg_db_num_rows($result) > 0) } // image order management $sort_fields = array( - '' => '', - 'date_creation' => l10n('Creation date'), - 'date_available' => l10n('Post date'), - 'rating_score' => l10n('Rating score'), - 'hit' => l10n('Most visited'), - 'file' => l10n('File name'), - 'name' => l10n('Photo name'), - 'id' => 'Id', - 'rank' => l10n('Rank'), + '' => '', + 'file' => l10n('file name, A → Z'), + 'file DESC' => l10n('file name, Z → A'), + 'name' => l10n('photo title, A → Z'), + 'name DESC' => l10n('photo title, Z → A'), + 'date_creation DESC' => l10n('date created, new → old'), + 'date_creation' => l10n('date created, old → new'), + 'date_available DESC' => l10n('date posted, new → old'), + 'date_available' => l10n('date posted, old → new'), + 'rating_score DESC' => l10n('rating score, high → low'), + 'rating_score' => l10n('rating score, low → high'), + 'hit DESC' => l10n('visits, high → low'), + 'hit' => l10n('visits, low → high'), + 'id' => l10n('numeric identifier, 1 → 9'), + 'id DESC' => l10n('numeric identifier, 9 → 1'), + 'rank' => l10n('manual sort order'), ); -$sort_directions = array( - 'ASC' => l10n('ascending'), - 'DESC' => l10n('descending'), - ); +$template->assign('image_order_options', $sort_fields); -$template->assign('image_order_field_options', $sort_fields); -$template->assign('image_order_direction_options', $sort_directions); - -$matches = array(); -if ( !empty( $category['image_order'] ) ) -{ - preg_match_all('/([a-z_]+) *(?:(asc|desc)(?:ending)?)? *(?:, *|$)/i', - $category['image_order'], $matches); -} +$image_order = explode(',', $category['image_order']); for ($i=0; $i<3; $i++) // 3 fields { - $tpl_image_order_select = array( - 'ID' => $i+1, - 'FIELD' => array(''), - 'DIRECTION' => array('ASC'), - ); - - if ( isset($matches[1][$i]) ) + if ( isset($image_order[$i]) ) { - $tpl_image_order_select['FIELD'] = array($matches[1][$i]); + $template->append('image_order', $image_order[$i]); } - - if (isset($matches[2][$i]) and strcasecmp($matches[2][$i],'DESC')==0) + else { - $tpl_image_order_select['DIRECTION'] = array('DESC'); + $template->append('image_order', ''); } - $template->append( 'image_orders', $tpl_image_order_select); } $template->assign('image_order_choice', $image_order_choice); -- cgit v1.2.3