aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
Diffstat (limited to 'admin')
-rw-r--r--admin/element_set_ranks.php100
-rw-r--r--admin/themes/default/default-layout.css4
-rw-r--r--admin/themes/default/template/element_set_ranks.tpl30
3 files changed, 130 insertions, 4 deletions
diff --git a/admin/element_set_ranks.php b/admin/element_set_ranks.php
index e6134f9f5..27d9012f4 100644
--- a/admin/element_set_ranks.php
+++ b/admin/element_set_ranks.php
@@ -84,6 +84,9 @@ function save_images_order($category_id, $images)
// | global mode form submission |
// +-----------------------------------------------------------------------+
+$image_order_choices = array('default', 'rank', 'user_define');
+$image_order_choice = 'default';
+
if (isset($_POST['submit']))
{
asort($_POST['rank_of_image'], SORT_NUMERIC);
@@ -97,6 +100,40 @@ if (isset($_POST['submit']))
$page['infos'],
l10n('Images manual order was saved')
);
+
+ $image_order = null;
+ if (!empty($_POST['image_order_choice'])
+ && in_array($_POST['image_order_choice'], $image_order_choices))
+ {
+ $image_order_choice = $_POST['image_order_choice'];
+ }
+
+ if ($image_order_choice=='user_define')
+ {
+ for ($i=1; $i<=3; $i++)
+ {
+ if ( !empty($_POST['order_field_'.$i]) )
+ {
+ if (! empty($image_order) )
+ {
+ $image_order .= ',';
+ }
+ $image_order .= $_POST['order_field_'.$i];
+ if ($_POST['order_direction_'.$i]=='DESC')
+ {
+ $image_order .= ' DESC';
+ }
+ }
+ }
+ }
+ elseif ($image_order_choice=='rank')
+ {
+ $image_order = 'rank';
+ }
+ $query = '
+UPDATE '.CATEGORIES_TABLE.' SET image_order=\''.$image_order.'\'
+ WHERE id='.$page['category_id'];
+ pwg_query($query);
}
// +-----------------------------------------------------------------------+
@@ -108,15 +145,22 @@ $template->set_filenames(
$base_url = get_root_url().'admin.php';
-// $form_action = $base_url.'?page=element_set_global';
-
$query = '
-SELECT uppercats
+SELECT *
FROM '.CATEGORIES_TABLE.'
WHERE id = '.$page['category_id'].'
;';
$category = pwg_db_fetch_assoc(pwg_query($query));
+if ($category['image_order']=='rank')
+{
+ $image_order_choice = 'rank';
+}
+elseif ($category['image_order']!='')
+{
+ $image_order_choice = 'user_define';
+}
+
// Navigation path
$navigation = get_cat_display_name_cache(
$category['uppercats'],
@@ -174,6 +218,56 @@ while ($row = pwg_db_fetch_assoc($result))
$current_rank++;
}
+// image order management
+$sort_fields = array(
+ '' => '',
+ 'date_creation' => l10n('Creation date'),
+ 'date_available' => l10n('Post date'),
+ 'average_rate' => l10n('Average rate'),
+ 'hit' => l10n('Most visited'),
+ 'file' => l10n('File name'),
+ 'id' => 'Id',
+ 'rank' => l10n('Rank'),
+ );
+
+$sort_directions = array(
+ 'ASC' => l10n('ascending'),
+ 'DESC' => l10n('descending'),
+ );
+
+$template->assign('image_order_field_options', $sort_fields);
+$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
+{
+ $tpl_image_order_select = array(
+ 'ID' => $i+1,
+ 'FIELD' => array(''),
+ 'DIRECTION' => array('ASC'),
+ );
+
+ if ( isset($matches[1][$i]) )
+ {
+ $tpl_image_order_select['FIELD'] = array($matches[1][$i]);
+ }
+
+ if (isset($matches[2][$i]) and strcasecmp($matches[2][$i],'DESC')==0)
+ {
+ $tpl_image_order_select['DIRECTION'] = array('DESC');
+ }
+ $template->append( 'image_orders', $tpl_image_order_select);
+}
+
+$template->assign('image_order_choice', $image_order_choice);
+
+
// +-----------------------------------------------------------------------+
// | sending html code |
// +-----------------------------------------------------------------------+
diff --git a/admin/themes/default/default-layout.css b/admin/themes/default/default-layout.css
index 35de67694..3950825a3 100644
--- a/admin/themes/default/default-layout.css
+++ b/admin/themes/default/default-layout.css
@@ -293,6 +293,10 @@ FORM P {
margin-bottom: 2em;
}
+form p.field {
+ text-align: left;
+}
+
FORM FIELDSET P {
margin-top: 1em;
margin-bottom: 0;
diff --git a/admin/themes/default/template/element_set_ranks.tpl b/admin/themes/default/template/element_set_ranks.tpl
index b45ca5d19..804d053ff 100644
--- a/admin/themes/default/template/element_set_ranks.tpl
+++ b/admin/themes/default/template/element_set_ranks.tpl
@@ -1,7 +1,7 @@
{known_script id="jquery" src=$ROOT_URL|@cat:"themes/default/js/jquery.packed.js"}
{known_script id="jquery.ui" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.core.packed.js" }
{known_script id="jquery.ui.sortable" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.sortable.packed.js" }
-
+{html_head}
{literal}
<script type="text/javascript">
$(function() {
@@ -15,12 +15,14 @@
$(this).find("input[name^=rank_of_image]")
.each(function() { $(this).attr('value', (i+1)*10)});
});
+ $('#image_order_rank').attr('checked', true);
}
});
});
</script>
{/literal}
+{/html_head}
<h2>{'Manage image ranks'|@translate}</h2>
@@ -46,9 +48,35 @@
</ul>
{/if}
</fieldset>
+
+ <fieldset>
+ <legend>{'Sort order'|@translate}</legend>
+ <p class="field">
+ <input type="radio" name="image_order_choice" id="image_order_default" value="default"{if $image_order_choice=='default'} checked="checked"{/if}>
+ <label for="image_order_default">{'Use the default image sort order (defined in the configuration file)'|@translate}</label>
+ </p>
+ <p class="field">
+ <input type="radio" name="image_order_choice" id="image_order_rank" value="rank"{if $image_order_choice=='rank'} checked="checked"{/if}>
+ <label for="image_order_rank">{'By rank'|@translate}</label>
+ </p>
+ <p class="field">
+ <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">{'Manual order'|@translate}</label>
+ {foreach from=$image_orders item=order}
+ <p class="field">
+ <select name="order_field_{$order.ID}">
+ {html_options options=$image_order_field_options selected=$order.FIELD }
+ </select>
+ <select name="order_direction_{$order.ID}">
+ {html_options options=$image_order_direction_options selected=$order.DIRECTION }
+ </select>
+ </p>
+ {/foreach}
+ </fieldset>
<p><input class="submit" type="submit" value="{'Submit'|@translate}" name="submit" {$TAG_INPUT_ENABLED}></p>
</form>
+
{else}
<div class="infos"><p>{'No element in this category'|@translate}</p></div>
{/if}