aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--admin/configuration.php36
-rw-r--r--admin/element_set_ranks.php18
-rw-r--r--include/functions_category.inc.php10
-rw-r--r--install/config.sql4
-rw-r--r--install/db/137-database.php62
5 files changed, 92 insertions, 38 deletions
diff --git a/admin/configuration.php b/admin/configuration.php
index 99c0b9666..63bc29f3c 100644
--- a/admin/configuration.php
+++ b/admin/configuration.php
@@ -112,21 +112,21 @@ $display_info_checkboxes = array(
// image order management
$sort_fields = array(
'' => '',
- 'file' => l10n('File name, A → Z'),
+ 'file ASC' => l10n('File name, A → Z'),
'file DESC' => l10n('File name, Z → A'),
- 'name' => l10n('Photo title, A → Z'),
+ 'name ASC' => 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_creation ASC' => l10n('Date created, old → new'),
'date_available DESC' => l10n('Date posted, new → old'),
- 'date_available' => l10n('Date posted, old → new'),
+ 'date_available ASC' => l10n('Date posted, old → new'),
'rating_score DESC' => l10n('Rating score, high → low'),
- 'rating_score' => l10n('Rating score, low → high'),
+ 'rating_score ASC' => l10n('Rating score, low → high'),
'hit DESC' => l10n('Visits, high → low'),
- 'hit' => l10n('Visits, low → high'),
- 'id' => l10n('Numeric identifier, 1 → 9'),
+ 'hit ASC' => l10n('Visits, low → high'),
+ 'id ASC' => l10n('Numeric identifier, 1 → 9'),
'id DESC' => l10n('Numeric identifier, 9 → 1'),
- 'rank' => l10n('Manual sort order'),
+ 'rank ASC' => l10n('Manual sort order'),
);
$comments_order = array(
@@ -162,7 +162,7 @@ if (isset($_POST['submit']))
$order_by = $order_by_inside_category = array_slice($_POST['order_by'], 0, ceil(count($sort_fields)/2));
// there is no rank outside categories
- if ( ($i = array_search('rank', $order_by)) !== false)
+ if ( ($i = array_search('rank ASC', $order_by)) !== false)
{
unset($order_by[$i]);
}
@@ -170,11 +170,11 @@ if (isset($_POST['submit']))
// must define a default order_by if user want to order by rank only
if ( count($order_by) == 0 )
{
- $order_by = array('id');
+ $order_by = array('id ASC');
}
- $_POST['order_by'] = 'ORDER BY '.implode(',', $order_by);
- $_POST['order_by_inside_category'] = 'ORDER BY '.implode(',', $order_by_inside_category);
+ $_POST['order_by'] = 'ORDER BY '.implode(', ', $order_by);
+ $_POST['order_by_inside_category'] = 'ORDER BY '.implode(', ', $order_by_inside_category);
}
}
else
@@ -334,18 +334,10 @@ switch ($page['section'])
}
else
{
+ $out = array();
$order_by = trim($conf['order_by_inside_category']);
$order_by = str_replace('ORDER BY ', null, $order_by);
- $order_by = explode(',', $order_by);
- foreach($order_by as &$order)
- {
- $order = trim($order);
- if (substr_compare($order, ' ASC', -4)==0)
- {
- $order = substr($order, 0, -4);
- }
- }
- unset($order);
+ $order_by = explode(', ', $order_by);
}
$template->assign(
diff --git a/admin/element_set_ranks.php b/admin/element_set_ranks.php
index d9a917136..98f22a8cd 100644
--- a/admin/element_set_ranks.php
+++ b/admin/element_set_ranks.php
@@ -124,7 +124,7 @@ if (isset($_POST['submit']))
}
elseif ($image_order_choice=='rank')
{
- $image_order = 'rank';
+ $image_order = 'rank ASC';
}
$query = '
UPDATE '.CATEGORIES_TABLE.'
@@ -237,21 +237,21 @@ if (pwg_db_num_rows($result) > 0)
// image order management
$sort_fields = array(
'' => '',
- 'file' => l10n('File name, A → Z'),
+ 'file ASC' => l10n('File name, A → Z'),
'file DESC' => l10n('File name, Z → A'),
- 'name' => l10n('Photo title, A → Z'),
+ 'name ASC' => 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_creation ASC' => l10n('Date created, old → new'),
'date_available DESC' => l10n('Date posted, new → old'),
- 'date_available' => l10n('Date posted, old → new'),
+ 'date_available ASC' => l10n('Date posted, old → new'),
'rating_score DESC' => l10n('Rating score, high → low'),
- 'rating_score' => l10n('Rating score, low → high'),
+ 'rating_score ASC' => l10n('Rating score, low → high'),
'hit DESC' => l10n('Visits, high → low'),
- 'hit' => l10n('Visits, low → high'),
- 'id' => l10n('Numeric identifier, 1 → 9'),
+ 'hit ASC' => l10n('Visits, low → high'),
+ 'id ASC' => l10n('Numeric identifier, 1 → 9'),
'id DESC' => l10n('Numeric identifier, 9 → 1'),
- 'rank' => l10n('Manual sort order'),
+ 'rank ASC' => l10n('Manual sort order'),
);
$template->assign('image_order_options', $sort_fields);
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index ec9b9c93a..7cde5e35c 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -221,16 +221,16 @@ function get_category_preferred_image_orders()
return trigger_event('get_category_preferred_image_orders', array(
array(l10n('Default'), '', true),
- array(l10n('Photo title, A → Z'), 'name', true),
+ array(l10n('Photo title, A → Z'), 'name ASC', true),
array(l10n('Photo title, Z → A'), 'name DESC', true),
array(l10n('Date created, new → old'), 'date_creation DESC', true),
- array(l10n('Date created, old → new'), 'date_creation', true),
+ array(l10n('Date created, old → new'), 'date_creation ASC', true),
array(l10n('Date posted, new → old'), 'date_available DESC', true),
- array(l10n('Date posted, old → new'), 'date_available', true),
+ array(l10n('Date posted, old → new'), 'date_available ASC', true),
array(l10n('Rating score, high → low'), 'rating_score DESC', $conf['rate']),
- array(l10n('Rating score, low → high'), 'rating_score', $conf['rate']),
+ array(l10n('Rating score, low → high'), 'rating_score ASC', $conf['rate']),
array(l10n('Visits, high → low'), 'hit DESC', true),
- array(l10n('Visits, low → high'), 'hit', true),
+ array(l10n('Visits, low → high'), 'hit ASC', true),
array(l10n('Permissions'), 'level DESC', is_admin()),
));
}
diff --git a/install/config.sql b/install/config.sql
index ff045fc07..eba9c60ff 100644
--- a/install/config.sql
+++ b/install/config.sql
@@ -56,8 +56,8 @@ INSERT INTO piwigo_config (param,value,comment)
);
INSERT INTO piwigo_config (param,value,comment) VALUES ('week_starts_on','monday','Monday may not be the first day of the week');
INSERT INTO piwigo_config (param,value,comment) VALUES ('updates_ignored','a:3:{s:7:"plugins";a:0:{}s:6:"themes";a:0:{}s:9:"languages";a:0:{}}','Extensions ignored for update');
-INSERT INTO piwigo_config (param,value,comment) VALUES ('order_by','ORDER BY date_available DESC,file,id','default photo order');
-INSERT INTO piwigo_config (param,value,comment) VALUES ('order_by_inside_category','ORDER BY date_available DESC,file,id','default photo order inside category');
+INSERT INTO piwigo_config (param,value,comment) VALUES ('order_by','ORDER BY date_available DESC, file ASC, id ASC','default photo order');
+INSERT INTO piwigo_config (param,value,comment) VALUES ('order_by_inside_category','ORDER BY date_available DESC, file ASC, id ASC','default photo order inside category');
INSERT INTO piwigo_config (param,value) VALUES ('original_resize','false');
INSERT INTO piwigo_config (param,value) VALUES ('original_resize_maxwidth','2016');
INSERT INTO piwigo_config (param,value) VALUES ('original_resize_maxheight','2016');
diff --git a/install/db/137-database.php b/install/db/137-database.php
new file mode 100644
index 000000000..b6299cfd0
--- /dev/null
+++ b/install/db/137-database.php
@@ -0,0 +1,62 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based photo gallery |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify |
+// | it under the terms of the GNU General Public License as published by |
+// | the Free Software Foundation |
+// | |
+// | This program is distributed in the hope that it will be useful, but |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+// | General Public License for more details. |
+// | |
+// | You should have received a copy of the GNU General Public License |
+// | along with this program; if not, write to the Free Software |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA. |
+// +-----------------------------------------------------------------------+
+
+defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
+
+$upgrade_description = 'add ASC keyword to categories image_order field';
+
+
+$query = '
+SELECT id, image_order
+ FROM '.CATEGORIES_TABLE.'
+ WHERE image_order != ""
+;';
+$cats = hash_from_query($query, 'id');
+
+foreach ($cats as $id => &$data)
+{
+ $image_order = explode(',',$data['image_order']);
+ foreach ($image_order as &$order)
+ {
+ if (strpos($order, ' ASC')===false && strpos($order, ' DESC')===false)
+ {
+ $order.= ' ASC';
+ }
+ }
+ unset($order);
+ $data['image_order'] = implode(',',$image_order);
+}
+unset($data);
+
+mass_updates(CATEGORIES_TABLE,
+ array(
+ 'primary' => array('id'),
+ 'update' => array('image_order'),
+ ),
+ $cats
+ );
+
+
+echo "\n".$upgrade_description."\n";
+
+?> \ No newline at end of file