mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-05-01 05:40:02 +03:00
feature 2568: redesigned order_by fields in Admin->Config->Options
git-svn-id: http://piwigo.org/svn/trunk@13087 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
b82ddfb655
commit
3c76f29e4f
4 changed files with 66 additions and 115 deletions
|
@ -107,20 +107,23 @@ $display_info_checkboxes = array(
|
||||||
// image order management
|
// image order management
|
||||||
$sort_fields = array(
|
$sort_fields = array(
|
||||||
'' => '',
|
'' => '',
|
||||||
'rank' => l10n('Rank'),
|
'file ASC' => l10n('file name, A → Z'),
|
||||||
'file' => l10n('File name'),
|
'file DESC' => l10n('file name, Z → A'),
|
||||||
'name' => l10n('Photo name'),
|
'name ASC' => l10n('photo title, A → Z'),
|
||||||
'date_creation' => l10n('Creation date'),
|
'name DESC' => l10n('photo title, Z → A'),
|
||||||
'date_available' => l10n('Post date'),
|
'date_creation DESC' => l10n('date created, new → old'),
|
||||||
'rating_score' => l10n('Rating score'),
|
'date_creation ASC' => l10n('date created, old → new'),
|
||||||
'hit' => l10n('Most visited'),
|
'date_available DESC' => l10n('date posted, new → old'),
|
||||||
'id' => 'Id',
|
'date_available ASC' => l10n('date posted, old → new'),
|
||||||
|
'rating_score DESC' => l10n('rating score, high → low'),
|
||||||
|
'rating_score ASC' => l10n('rating score, low → high'),
|
||||||
|
'hit DESC' => l10n('visits, high → low'),
|
||||||
|
'hit ASC' => l10n('visits, low → high'),
|
||||||
|
'id ASC' => l10n('numeric identifier, 1 → 9'),
|
||||||
|
'id DESC' => l10n('numeric identifier, 9 → 1'),
|
||||||
|
'rank ASC' => l10n('manual sort order'),
|
||||||
);
|
);
|
||||||
|
|
||||||
$sort_directions = array(
|
|
||||||
'ASC' => l10n('ascending'),
|
|
||||||
'DESC' => l10n('descending'),
|
|
||||||
);
|
|
||||||
|
|
||||||
//------------------------------ verification and registration of modifications
|
//------------------------------ verification and registration of modifications
|
||||||
if (isset($_POST['submit']))
|
if (isset($_POST['submit']))
|
||||||
|
@ -133,29 +136,14 @@ if (isset($_POST['submit']))
|
||||||
{
|
{
|
||||||
if ( !isset($conf['order_by_custom']) and !isset($conf['order_by_inside_category_custom']) )
|
if ( !isset($conf['order_by_custom']) and !isset($conf['order_by_inside_category_custom']) )
|
||||||
{
|
{
|
||||||
if ( !empty($_POST['order_by_field']) )
|
if ( !empty($_POST['order_by']) )
|
||||||
{
|
{
|
||||||
$order_by = array();
|
// limit to the number of available parameters
|
||||||
$order_by_inside_category = array();
|
$order_by = $order_by_inside_category = array_slice($_POST['order_by'], 0, ceil(count($sort_fields)/2));
|
||||||
|
|
||||||
for ($i=0; $i<count($_POST['order_by_field']); $i++)
|
|
||||||
{
|
|
||||||
if ( $i >= (count($sort_fields)-1) ) break; // limit to the number of available parameters
|
|
||||||
if ( empty($_POST['order_by_field'][$i]) )
|
|
||||||
{
|
|
||||||
array_push($page['errors'], l10n('No field selected'));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// there is no rank outside categories
|
// there is no rank outside categories
|
||||||
if ($_POST['order_by_field'][$i] != 'rank')
|
unset($order_by[ array_search('rank ASC', $order_by) ]);
|
||||||
{
|
|
||||||
$order_by[] = $_POST['order_by_field'][$i].' '.$_POST['order_by_direction'][$i];
|
|
||||||
}
|
|
||||||
$order_by_inside_category[] = $_POST['order_by_field'][$i].' '.$_POST['order_by_direction'][$i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// must define a default order_by if user want to order by rank only
|
// must define a default order_by if user want to order by rank only
|
||||||
if ( count($order_by) == 0 )
|
if ( count($order_by) == 0 )
|
||||||
{
|
{
|
||||||
|
@ -164,7 +152,10 @@ if (isset($_POST['submit']))
|
||||||
|
|
||||||
$_POST['order_by'] = 'ORDER BY '.implode(', ', $order_by);
|
$_POST['order_by'] = 'ORDER BY '.implode(', ', $order_by);
|
||||||
$_POST['order_by_inside_category'] = 'ORDER BY '.implode(', ', $order_by_inside_category);
|
$_POST['order_by_inside_category'] = 'ORDER BY '.implode(', ', $order_by_inside_category);
|
||||||
unset($_POST['order_by_field']);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
array_push($page['errors'], l10n('No field selected'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,11 +314,7 @@ switch ($page['section'])
|
||||||
|
|
||||||
if ( isset($conf['order_by_custom']) or isset($conf['order_by_inside_category_custom']) )
|
if ( isset($conf['order_by_custom']) or isset($conf['order_by_inside_category_custom']) )
|
||||||
{
|
{
|
||||||
$order_by = array(array(
|
$order_by = array('');
|
||||||
'FIELD' => '',
|
|
||||||
'DIRECTION' => 'ASC',
|
|
||||||
));
|
|
||||||
|
|
||||||
$template->assign('ORDER_BY_IS_CUSTOM', true);
|
$template->assign('ORDER_BY_IS_CUSTOM', true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -336,15 +323,6 @@ switch ($page['section'])
|
||||||
$order_by = trim($conf['order_by_inside_category']);
|
$order_by = trim($conf['order_by_inside_category']);
|
||||||
$order_by = str_replace('ORDER BY ', null, $order_by);
|
$order_by = str_replace('ORDER BY ', null, $order_by);
|
||||||
$order_by = explode(', ', $order_by);
|
$order_by = explode(', ', $order_by);
|
||||||
foreach ($order_by as $field)
|
|
||||||
{
|
|
||||||
$field= explode(' ', $field);
|
|
||||||
$out[] = array(
|
|
||||||
'FIELD' => $field[0],
|
|
||||||
'DIRECTION' => $field[1],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$order_by = $out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$template->assign(
|
$template->assign(
|
||||||
|
@ -358,8 +336,7 @@ switch ($page['section'])
|
||||||
),
|
),
|
||||||
'week_starts_on_options_selected' => $conf['week_starts_on'],
|
'week_starts_on_options_selected' => $conf['week_starts_on'],
|
||||||
'order_by' => $order_by,
|
'order_by' => $order_by,
|
||||||
'order_field_options' => $sort_fields,
|
'order_by_options' => $sort_fields,
|
||||||
'order_direction_options' => $sort_directions,
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -104,28 +104,21 @@ if (isset($_POST['submit']))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$image_order = null;
|
|
||||||
if (!empty($_POST['image_order_choice'])
|
if (!empty($_POST['image_order_choice'])
|
||||||
&& in_array($_POST['image_order_choice'], $image_order_choices))
|
&& in_array($_POST['image_order_choice'], $image_order_choices))
|
||||||
{
|
{
|
||||||
$image_order_choice = $_POST['image_order_choice'];
|
$image_order_choice = $_POST['image_order_choice'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$image_order = null;
|
||||||
if ($image_order_choice=='user_define')
|
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) )
|
if (!empty($image_order)) $image_order.= ',';
|
||||||
{
|
$image_order.= $_POST['image_order'][$i];
|
||||||
$image_order .= ',';
|
|
||||||
}
|
|
||||||
$image_order .= $_POST['order_field_'.$i];
|
|
||||||
if ($_POST['order_direction_'.$i]=='DESC')
|
|
||||||
{
|
|
||||||
$image_order .= ' DESC';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,7 +127,8 @@ if (isset($_POST['submit']))
|
||||||
$image_order = 'rank';
|
$image_order = 'rank';
|
||||||
}
|
}
|
||||||
$query = '
|
$query = '
|
||||||
UPDATE '.CATEGORIES_TABLE.' SET image_order=\''.$image_order.'\'
|
UPDATE '.CATEGORIES_TABLE.'
|
||||||
|
SET image_order=\''.$image_order.'\'
|
||||||
WHERE id='.$page['category_id'];
|
WHERE id='.$page['category_id'];
|
||||||
pwg_query($query);
|
pwg_query($query);
|
||||||
|
|
||||||
|
@ -273,49 +267,37 @@ if (pwg_db_num_rows($result) > 0)
|
||||||
// image order management
|
// image order management
|
||||||
$sort_fields = array(
|
$sort_fields = array(
|
||||||
'' => '',
|
'' => '',
|
||||||
'date_creation' => l10n('Creation date'),
|
'file' => l10n('file name, A → Z'),
|
||||||
'date_available' => l10n('Post date'),
|
'file DESC' => l10n('file name, Z → A'),
|
||||||
'rating_score' => l10n('Rating score'),
|
'name' => l10n('photo title, A → Z'),
|
||||||
'hit' => l10n('Most visited'),
|
'name DESC' => l10n('photo title, Z → A'),
|
||||||
'file' => l10n('File name'),
|
'date_creation DESC' => l10n('date created, new → old'),
|
||||||
'name' => l10n('Photo name'),
|
'date_creation' => l10n('date created, old → new'),
|
||||||
'id' => 'Id',
|
'date_available DESC' => l10n('date posted, new → old'),
|
||||||
'rank' => l10n('Rank'),
|
'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(
|
$template->assign('image_order_options', $sort_fields);
|
||||||
'ASC' => l10n('ascending'),
|
|
||||||
'DESC' => l10n('descending'),
|
|
||||||
);
|
|
||||||
|
|
||||||
$template->assign('image_order_field_options', $sort_fields);
|
$image_order = explode(',', $category['image_order']);
|
||||||
$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);
|
|
||||||
}
|
|
||||||
|
|
||||||
for ($i=0; $i<3; $i++) // 3 fields
|
for ($i=0; $i<3; $i++) // 3 fields
|
||||||
{
|
{
|
||||||
$tpl_image_order_select = array(
|
if ( isset($image_order[$i]) )
|
||||||
'ID' => $i+1,
|
|
||||||
'FIELD' => array(''),
|
|
||||||
'DIRECTION' => array('ASC'),
|
|
||||||
);
|
|
||||||
|
|
||||||
if ( isset($matches[1][$i]) )
|
|
||||||
{
|
{
|
||||||
$tpl_image_order_select['FIELD'] = array($matches[1][$i]);
|
$template->append('image_order', $image_order[$i]);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (isset($matches[2][$i]) and strcasecmp($matches[2][$i],'DESC')==0)
|
|
||||||
{
|
{
|
||||||
$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);
|
$template->assign('image_order_choice', $image_order_choice);
|
||||||
|
|
|
@ -108,11 +108,8 @@ jQuery(document).ready(function(){
|
||||||
|
|
||||||
{foreach from=$main.order_by item=order}
|
{foreach from=$main.order_by item=order}
|
||||||
<span class="filter {if $ORDER_BY_IS_CUSTOM}transparent{/if}">
|
<span class="filter {if $ORDER_BY_IS_CUSTOM}transparent{/if}">
|
||||||
<select name="order_by_field[]" {if $ORDER_BY_IS_CUSTOM}disabled{/if}>
|
<select name="order_by[]" {if $ORDER_BY_IS_CUSTOM}disabled{/if}>
|
||||||
{html_options options=$main.order_field_options selected=$order.FIELD }
|
{html_options options=$main.order_by_options selected=$order}
|
||||||
</select>
|
|
||||||
<select name="order_by_direction[]" {if $ORDER_BY_IS_CUSTOM}disabled{/if}>
|
|
||||||
{html_options options=$main.order_direction_options selected=$order.DIRECTION }
|
|
||||||
</select>
|
</select>
|
||||||
<a class="removeFilter">{'delete'|@translate}</a>
|
<a class="removeFilter">{'delete'|@translate}</a>
|
||||||
</span>
|
</span>
|
||||||
|
@ -128,7 +125,7 @@ jQuery(document).ready(function(){
|
||||||
{if !$ORDER_BY_IS_CUSTOM}
|
{if !$ORDER_BY_IS_CUSTOM}
|
||||||
{footer_script require='jquery'}
|
{footer_script require='jquery'}
|
||||||
// counters for displaying of addFilter link
|
// counters for displaying of addFilter link
|
||||||
fields = {$main.order_by|@count}; max_fields = {$main.order_field_options|@count}; max_fields--;
|
fields = {$main.order_by|@count}; max_fields = Math.ceil({$main.order_by_options|@count}/2);
|
||||||
|
|
||||||
{literal}
|
{literal}
|
||||||
function updateAddFilterLink() {
|
function updateAddFilterLink() {
|
||||||
|
@ -149,10 +146,8 @@ function updateRemoveFilterTrigger() {
|
||||||
|
|
||||||
jQuery(document).ready(function () {
|
jQuery(document).ready(function () {
|
||||||
$('.addFilter').click(function() {
|
$('.addFilter').click(function() {
|
||||||
rel = $(this).attr('rel');
|
|
||||||
$(this).prev('span.filter').clone().insertBefore($(this));
|
$(this).prev('span.filter').clone().insertBefore($(this));
|
||||||
$(this).prev('span.filter').children('select[name="order_by_field[]"]').val('');
|
$(this).prev('span.filter').children('select[name="order_by[]"]').val('');
|
||||||
$(this).prev('span.filter').children('select[name="order_by_direction[]"]').val('ASC');
|
|
||||||
|
|
||||||
fields++;
|
fields++;
|
||||||
updateAddFilterLink();
|
updateAddFilterLink();
|
||||||
|
|
|
@ -78,13 +78,10 @@ jQuery('.clipwrapper').tipTip({
|
||||||
<input type="radio" name="image_order_choice" id="image_order_user_define" value="user_define"{if $image_order_choice=='user_define'} checked="checked"{/if}>
|
<input type="radio" name="image_order_choice" id="image_order_user_define" value="user_define"{if $image_order_choice=='user_define'} checked="checked"{/if}>
|
||||||
<label for="image_order_user_define">{'automatic order'|@translate}</label>
|
<label for="image_order_user_define">{'automatic order'|@translate}</label>
|
||||||
<div id="image_order_user_define_options">
|
<div id="image_order_user_define_options">
|
||||||
{foreach from=$image_orders item=order}
|
{foreach from=$image_order item=order}
|
||||||
<p class="field">
|
<p class="field">
|
||||||
<select name="order_field_{$order.ID}">
|
<select name="image_order[]">
|
||||||
{html_options options=$image_order_field_options selected=$order.FIELD }
|
{html_options options=$image_order_options selected=$order}
|
||||||
</select>
|
|
||||||
<select name="order_direction_{$order.ID}">
|
|
||||||
{html_options options=$image_order_direction_options selected=$order.DIRECTION }
|
|
||||||
</select>
|
</select>
|
||||||
</p>
|
</p>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue