diff options
Diffstat (limited to '')
-rw-r--r-- | admin/configuration.php | 94 | ||||
-rw-r--r-- | admin/themes/default/template/configuration.tpl | 49 |
2 files changed, 137 insertions, 6 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> + + <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> + + <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> + + <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} |