From f56fc4f36dd9ec183710b2e64a45865713c0f9d6 Mon Sep 17 00:00:00 2001 From: mistic100 Date: Thu, 9 Jun 2011 14:32:20 +0000 Subject: feature:2317 move order config to Admin->Config->Options first try, may has issues with very specials params git-svn-id: http://piwigo.org/svn/trunk@11279 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/configuration.php | 94 +++++++++++++++++++++++++ admin/themes/default/template/configuration.tpl | 49 +++++++++++-- install/config.sql | 2 + install/db/106-database.php | 48 +++++++++++++ language/en_UK/admin.lang.php | 5 ++ language/en_UK/help/configuration.html | 14 ++++ language/fr_FR/admin.lang.php | 15 ++-- language/fr_FR/help/configuration.html | 14 ++++ 8 files changed, 230 insertions(+), 11 deletions(-) create mode 100644 install/db/106-database.php 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 @@
  • - +   + + {'Week starts on'|@translate} + {html_options name="week_starts_on" options=$main.week_starts_on_options selected=$main.week_starts_on_options_selected} + +
  • + +
  • +   + + {'Default photos order'|@translate} + {html_options name="order_by" options=$main.order_by_options selected=$main.order_by_selected} + +
  • +
  • +   + + {'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} + + +
  • + +{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} {/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 @@ + \ 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.
  • Mail address is mandatory for all users: mail address will be checked on registration or profile update, except if the action is done by an administrator.
  • Email admins when a new user registers: administrators will be notified by mail for each registration.
  • + +
  • Default photos order: You can define a personalized order by selecting «Personalized» in the drop-down menu. This field must respect the SQL syntax, example: date_available DESC, file ASC, id ASC
    + Available fields: + + Don't forgot to specify the order for each field with these keywords : ASC and DESC +
  • 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 Batch Manager.'] = 'Si vous voulez régénérer des miniatures, merci de vous rendre dans la Gestion par lot.'; $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.
  • L'adresse mail est obligatoire pour tous les utilisateurs: 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.
  • Notifier les administrateurs lors de l'inscription d'un utilisateur: Les administrateurs recevront un courriel à chaque inscription.
  • + +
  • Ordre par défaut des photos: Vous pouvez définir un ordre personnalisé et selectionant «Personnalisé» dans la liste déroulante. Ce champ doit respecter la syntaxe SQL, exemple: date_available DESC, file ASC, id ASC
    + Liste des champs utilisables : + + N'oubliez pas pour chaque champ de spécifier l'ordre avec les mots clefs ASC et DESC +
  • -- cgit v1.2.3