aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--admin/configuration.php94
-rw-r--r--admin/themes/default/template/configuration.tpl49
-rw-r--r--install/config.sql2
-rw-r--r--install/db/106-database.php48
-rw-r--r--language/en_UK/admin.lang.php5
-rw-r--r--language/en_UK/help/configuration.html14
-rw-r--r--language/fr_FR/admin.lang.php15
-rw-r--r--language/fr_FR/help/configuration.html14
8 files changed, 230 insertions, 11 deletions
diff --git a/admin/configuration.php b/admin/configuration.php
index ea8c6b773..c03e4223b 100644
--- a/admin/configuration.php
+++ b/admin/configuration.php
@@ -100,6 +100,12 @@ $display_info_checkboxes = array(
'average_rate',
'privacy_level',
);
+
+$order_options = array(
+ ' ORDER BY date_available DESC, file ASC, id ASC' => 'date_available DESC, file ASC, id ASC',
+ ' ORDER BY file DESC, date_available DESC' => 'file DESC, date_available DESC',
+ 'custom' => l10n('Custom'),
+ );
//------------------------------ verification and registration of modifications
if (isset($_POST['submit']))
@@ -110,6 +116,56 @@ if (isset($_POST['submit']))
{
case 'main' :
{
+ $order_regex = '#^(( *)(id|file|name|date_available|date_creation|hit|average_rate|comment|author|filesize|width|height|high_filesize|high_width|high_height) (ASC|DESC),{1}){1,}$#';
+ // process 'order_by_perso' string
+ if ($_POST['order_by'] == 'custom' AND !empty($_POST['order_by_perso']))
+ {
+ $_POST['order_by'] = str_ireplace(
+ array('order by ', 'asc', 'desc'),
+ array(null, 'ASC', 'DESC'),
+ trim($_POST['order_by_perso'])
+ );
+
+ if (preg_match($order_regex, $_POST['order_by'].','))
+ {
+ $_POST['order_by'] = ' ORDER BY '.$_POST['order_by'];
+ }
+ else
+ {
+ array_push($page['errors'], l10n('Invalid order string').' « '.$_POST['order_by'].' »');
+ }
+ }
+ else if ($_POST['order_by'] == 'custom')
+ {
+ array_push($page['errors'], l10n('Invalid order string'));
+ }
+ // process 'order_by_inside_category_perso' string
+ if ($_POST['order_by_inside_category'] == 'as_order_by')
+ {
+ $_POST['order_by_inside_category'] = $_POST['order_by'];
+ }
+ else if ($_POST['order_by_inside_category'] == 'custom' AND !empty($_POST['order_by_inside_category_perso']))
+ {
+ $_POST['order_by_inside_category'] = str_ireplace(
+ array('order by ', 'asc', 'desc'),
+ array(null, 'ASC', 'DESC'),
+ trim($_POST['order_by_inside_category_perso'])
+ );
+
+ if (preg_match($order_regex, $_POST['order_by_inside_category'].','))
+ {
+ $_POST['order_by_inside_category'] = ' ORDER BY '.$_POST['order_by_inside_category'];
+ }
+ else
+ {
+ array_push($page['errors'], l10n('Invalid order string').' « '.$_POST['order_by_inside_category'].' »');
+ }
+ }
+ else if ($_POST['order_by_inside_category'] == 'custom')
+ {
+ array_push($page['errors'], l10n('Invalid order string'));
+ }
+
if (empty($_POST['gallery_locked']) and $conf['gallery_locked'])
{
$tpl_var = & $template->get_template_vars('header_msgs');
@@ -234,6 +290,34 @@ switch ($page['section'])
{
case 'main' :
{
+ // process 'order_by' string
+ if (array_key_exists($conf['order_by'], $order_options))
+ {
+ $order_by_selected = $conf['order_by'];
+ $order_by_perso = null;
+ }
+ else
+ {
+ $order_by_selected = 'custom';
+ $order_by_perso = str_replace(' ORDER BY ', null, $conf['order_by']);
+ }
+ // process 'order_by_inside_category' string
+ if ($conf['order_by_inside_category'] == $conf['order_by'])
+ {
+ $order_by_inside_category_selected = 'as_order_by';
+ $order_by_inside_category_perso = null;
+ }
+ else if (array_key_exists($conf['order_by_inside_category'], $order_options))
+ {
+ $order_by_inside_category_selected = $conf['order_by_inside_category'];
+ $order_by_inside_category_perso = null;
+ }
+ else
+ {
+ $order_by_inside_category_selected = 'custom';
+ $order_by_inside_category_perso = str_replace(' ORDER BY ', null, $conf['order_by_inside_category']);
+ }
+
$template->assign(
'main',
array(
@@ -245,6 +329,16 @@ switch ($page['section'])
'monday' => $lang['day'][1],
),
'week_starts_on_options_selected' => $conf['week_starts_on'],
+ 'order_by_options' => $order_options,
+ 'order_by_selected' => $order_by_selected,
+ 'order_by_perso' => $order_by_perso,
+ 'order_by_inside_category_options' =>
+ array_merge(
+ array('as_order_by'=>l10n('As default order')),
+ $order_options
+ ),
+ 'order_by_inside_category_selected' => $order_by_inside_category_selected,
+ 'order_by_inside_category_perso' => $order_by_inside_category_perso,
));
foreach ($main_checkboxes as $checkbox)
diff --git a/admin/themes/default/template/configuration.tpl b/admin/themes/default/template/configuration.tpl
index aeeba5ab3..f9d3cd576 100644
--- a/admin/themes/default/template/configuration.tpl
+++ b/admin/themes/default/template/configuration.tpl
@@ -89,13 +89,50 @@
</li>
<li>
- <label>
- <span class="property">
- {'Week starts on'|@translate}
- {html_options name="week_starts_on" options=$main.week_starts_on_options selected=$main.week_starts_on_options_selected}
- </span>
- </label>
+ &nbsp;
+ <span class="property">
+ {'Week starts on'|@translate}
+ {html_options name="week_starts_on" options=$main.week_starts_on_options selected=$main.week_starts_on_options_selected}
+ </span>
+ </li>
+
+ <li>
+ &nbsp;
+ <span class="property">
+ {'Default photos order'|@translate}
+ {html_options name="order_by" options=$main.order_by_options selected=$main.order_by_selected}
+ <input type="text" name="order_by_perso" size="40" value="{$main.order_by_perso}"
+ {if $main.order_by_selected != 'custom'}style="display:none;"{/if}/>
+ </span>
</li>
+ <li>
+ &nbsp;
+ <span class="property">
+ {'Default photos order inside album'|@translate}
+ {html_options name="order_by_inside_category" options=$main.order_by_inside_category_options selected=$main.order_by_inside_category_selected}
+ <input type="text" name="order_by_inside_category_perso" size="40" value="{$main.order_by_inside_category_perso}"
+ {if $main.order_by_inside_category_selected != 'custom'}style="display:none;"{/if}>
+ </span>
+ </li>
+
+{footer_script require='jquery'}{literal}
+jQuery(document).ready(function () {
+ $('select[name="order_by"]').change(function () {
+ if ($(this).val() == 'custom') {
+ $('input[name="order_by_perso"]').show();
+ } else {
+ $('input[name="order_by_perso"]').hide();
+ }
+ });
+ $('select[name="order_by_inside_category"]').change(function () {
+ if ($(this).val() == 'custom') {
+ $('input[name="order_by_inside_category_perso"]').show();
+ } else {
+ $('input[name="order_by_inside_category_perso"]').hide();
+ }
+ });
+});
+{/literal}{/footer_script}
</ul>
</fieldset>
{/if}
diff --git a/install/config.sql b/install/config.sql
index 0fe30084e..22805cd8e 100644
--- a/install/config.sql
+++ b/install/config.sql
@@ -51,6 +51,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 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 ('upload_form_websize_resize','true');
INSERT INTO piwigo_config (param,value) VALUES ('upload_form_websize_maxwidth','800');
INSERT INTO piwigo_config (param,value) VALUES ('upload_form_websize_maxheight','600');
diff --git a/install/db/106-database.php b/install/db/106-database.php
new file mode 100644
index 000000000..187754ebe
--- /dev/null
+++ b/install/db/106-database.php
@@ -0,0 +1,48 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based photo gallery |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2011 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. |
+// +-----------------------------------------------------------------------+
+
+if (!defined('PHPWG_ROOT_PATH'))
+{
+ die('Hacking attempt!');
+}
+
+$upgrade_description = 'add order parameters to bdd';
+
+$query = '
+INSERT INTO '.PREFIX_TABLE.'config(param,value,comment)
+ VALUES (\'order_by\', \''.$conf['order_by'].'\', \'default photos order\')
+;';
+pwg_query($query);
+
+$query = '
+INSERT INTO '.PREFIX_TABLE.'config(param,value,comment)
+ VALUES (\'order_by_inside_category\', \''.$conf['order_by_inside_category'].'\', \'default photos order inside category\')
+;';
+pwg_query($query);
+
+echo
+"\n"
+. $upgrade_description
+."\n"
+;
+?> \ No newline at end of file
diff --git a/language/en_UK/admin.lang.php b/language/en_UK/admin.lang.php
index 4457cdecb..1a06d530b 100644
--- a/language/en_UK/admin.lang.php
+++ b/language/en_UK/admin.lang.php
@@ -150,6 +150,7 @@ $lang['Apply to sub-albums'] = "Apply to sub-albums";
$lang['Are you sure to install this upgrade? You must verify if this version does not need uninstallation.'] = "Are you sure you want to install this upgrade? You must verify if this version does not need prior uninstallation.";
$lang['Are you sure you want to delete this plugin?'] = "Are you sure you want to delete this plugin?";
$lang['Are you sure you want to install this plugin?'] = "Are you sure you want to install this plugin?";
+$lang['As default order'] = "As default order";
$lang['Associate to album'] = "Associate to album";
$lang['associate to group'] = "associate to group";
$lang['Associated'] = "Associated";
@@ -202,6 +203,7 @@ $lang['Create the "%s" directory at the root of your Piwigo installation'] = 'Cr
$lang['Create this site'] = "Create this site";
$lang['created'] = "created";
$lang['Current name'] = "Current name";
+$lang['Custom'] = "Custom";
$lang['Database synchronization with files'] = "Database synchronization with files";
$lang['Database'] = "Database";
$lang['Date'] = "Date";
@@ -209,6 +211,8 @@ $lang['Day'] = "Day";
$lang['Deactivate'] = "Deactivate";
$lang['Deactivate all'] = "Deactivate all";
$lang['Default display'] = "Default display";
+$lang['Default photos order'] = "Default photos order";
+$lang['Default photos order inside album'] = "Default photos order inside album";
$lang['Default user cannot be deleted'] = "Default user cannot be deleted";
$lang['Default user does not exist'] = "The default user does not exist";
$lang['default values'] = "default values";
@@ -358,6 +362,7 @@ $lang['Install'] = "Install";
$lang['Installed Languages'] = 'Installed Languages';
$lang['Installed Themes'] = "Installed Themes";
$lang['Instructions to use Piwigo'] = "Instructions to use Piwigo";
+$lang['Invalid order string'] = 'Invalid order string';
$lang['Invert'] = 'Invert';
$lang['IP'] = "IP";
$lang['JPEG files or ZIP archives with JPEG files inside please.'] = 'JPEG files or ZIP archives with JPEG files inside please.';
diff --git a/language/en_UK/help/configuration.html b/language/en_UK/help/configuration.html
index 7fb8d537d..a2a913627 100644
--- a/language/en_UK/help/configuration.html
+++ b/language/en_UK/help/configuration.html
@@ -33,6 +33,20 @@ page.</li>
<li><strong>Mail address is mandatory for all users</strong>: mail address will be checked on registration or profile update, except if the action is done by an administrator.</li>
<li><strong>Email admins when a new user registers</strong>: administrators will be notified by mail for each registration.</li>
+
+ <li><strong>Default photos order</strong>: You can define a personalized order by selecting &laquo;Personalized&raquo; in the drop-down menu. This field must respect the SQL syntax, example: <i>date_available DESC, file ASC, id ASC</i><br>
+ Available fields:
+ <ul style="font-size:0.85em;">
+ <li><b>date_available</b>: date of the adding to the gallery</li>
+ <li><b>file</b>: name of the file</li>
+ <li><b>id</b>: identifier</li>
+ <li><b>date_creation</b>: date of element creation</li>
+ <li><b>name</b>: name of the picture</li>
+ <li><b>hit</b>: number of visits</li>
+ <li><b>average_rate</b>: average rate on the picture</li>
+ </ul>
+ Don't forgot to specify the order for each field with these keywords : <i>ASC</i> and <i>DESC</i>
+ </li>
</ul>
diff --git a/language/fr_FR/admin.lang.php b/language/fr_FR/admin.lang.php
index edc122917..b551498ca 100644
--- a/language/fr_FR/admin.lang.php
+++ b/language/fr_FR/admin.lang.php
@@ -842,9 +842,14 @@ $lang['Height'] = 'Hauteur';
$lang['Follow Orientation'] = "Respecter l'orientation";
$lang['If you want to regenerate thumbnails, please go to the <a href="%s">Batch Manager</a>.'] = 'Si vous voulez régénérer des miniatures, merci de vous rendre dans la <a href="%s">Gestion par lot</a>.';
$lang['Graphics Library'] = 'Bibliothèque graphique';
-$lang['Show menubar'] = "Afficher le menu";
-$lang['No results'] = "Pas de résultat";
-$lang['Type in a search term'] = "Entrez un terme de recherche";
-$lang['Searching...'] = "Recherche...";
-$lang['new'] = "nouveau";
+$lang['Show menubar'] = 'Afficher le menu';
+$lang['No results'] = 'Pas de résultat';
+$lang['Type in a search term'] = 'Entrez un terme de recherche';
+$lang['Searching...'] = 'Recherche...';
+$lang['new'] = 'nouveau';
+$lang['Default photos order'] = "Ordre par défaut des photos";
+$lang['Default photos order inside album'] = "Ordre par défaut des photos dans un album";
+$lang['Invalid order string'] = 'Chaîne SQL incorrecte';
+$lang['As default order'] = "Comme l'ordre par défaut";
+$lang['Custom'] = "Personnalisé";
?> \ No newline at end of file
diff --git a/language/fr_FR/help/configuration.html b/language/fr_FR/help/configuration.html
index 45c29066a..e5c7a8eb3 100644
--- a/language/fr_FR/help/configuration.html
+++ b/language/fr_FR/help/configuration.html
@@ -33,6 +33,20 @@ galerie.</li>
<li><strong>L'adresse mail est obligatoire pour tous les utilisateurs</strong>: L'adresse mail sera vérifié lors des inscriptions ou de la mise à jour des profils sauf si l'action est effectuée dans la partie administration.</li>
<li><strong>Notifier les administrateurs lors de l'inscription d'un utilisateur</strong>: Les administrateurs recevront un courriel à chaque inscription.</li>
+
+ <li><strong>Ordre par défaut des photos</strong>: Vous pouvez définir un ordre personnalisé et selectionant &laquo;Personnalisé&raquo; dans la liste déroulante. Ce champ doit respecter la syntaxe SQL, exemple: <i>date_available DESC, file ASC, id ASC</i><br>
+ Liste des champs utilisables :
+ <ul style="font-size:0.85em;">
+ <li><b>date_available</b>: date d'ajout à la galerie</li>
+ <li><b>file</b>: nom du fichier</li>
+ <li><b>id</b>: identifiant</li>
+ <li><b>date_creation</b>: date de création</li>
+ <li><b>name</b>: nom de l'image</li>
+ <li><b>hit</b>: nombre de visites</li>
+ <li><b>average_rate</b>: note globale</li>
+ </ul>
+ N'oubliez pas pour chaque champ de spécifier l'ordre avec les mots clefs <i>ASC</i> et <i>DESC</i>
+ </li>
</ul>