Index: /trunk/admin/configuration.php
===================================================================
--- /trunk/admin/configuration.php	(revision 13086)
+++ /trunk/admin/configuration.php	(revision 13087)
@@ -107,19 +107,22 @@
 // image order management
 $sort_fields = array(
-  '' => '',
-  'rank' => l10n('Rank'),
-  'file' => l10n('File name'),
-  'name' => l10n('Photo name'),
-  'date_creation' => l10n('Creation date'),
-  'date_available' => l10n('Post date'),
-  'rating_score' => l10n('Rating score'),
-  'hit' => l10n('Most visited'),
-  'id' => 'Id',
+  ''                    => '',
+  'file ASC'            => l10n('file name, A &rarr; Z'),
+  'file DESC'           => l10n('file name, Z &rarr; A'),
+  'name ASC'            => l10n('photo title, A &rarr; Z'),
+  'name DESC'           => l10n('photo title, Z &rarr; A'),
+  'date_creation DESC'  => l10n('date created, new &rarr; old'),
+  'date_creation ASC'   => l10n('date created, old &rarr; new'),
+  'date_available DESC' => l10n('date posted, new &rarr; old'),
+  'date_available ASC'  => l10n('date posted, old &rarr; new'),
+  'rating_score DESC'   => l10n('rating score, high &rarr; low'),
+  'rating_score ASC'    => l10n('rating score, low &rarr; high'),
+  'hit DESC'            => l10n('visits, high &rarr; low'),
+  'hit ASC'             => l10n('visits, low &rarr; high'),
+  'id ASC'              => l10n('numeric identifier, 1 &rarr; 9'),
+  'id DESC'             => l10n('numeric identifier, 9 &rarr; 1'),
+  'rank ASC'            => l10n('manual sort order'),
   );
-
-$sort_directions = array(
-  'ASC' => l10n('ascending'),
-  'DESC' => l10n('descending'),
-  );
+  
 
 //------------------------------ verification and registration of modifications
@@ -134,27 +137,12 @@
       if ( !isset($conf['order_by_custom']) and !isset($conf['order_by_inside_category_custom']) )
       {
-        if ( !empty($_POST['order_by_field']) )
-        {
-          $order_by = array();
-          $order_by_inside_category = array();
+        if ( !empty($_POST['order_by']) )
+        {         
+          // limit to the number of available parameters
+          $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
-              if ($_POST['order_by_field'][$i] != 'rank')
-              {
-                $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];
-            }
-          }
+          // there is no rank outside categories
+          unset($order_by[ array_search('rank ASC', $order_by) ]);
+          
           // must define a default order_by if user want to order by rank only
           if ( count($order_by) == 0 )
@@ -165,5 +153,8 @@
           $_POST['order_by'] = 'ORDER BY '.implode(', ', $order_by);
           $_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'));
         }
       }
@@ -324,9 +315,5 @@
     if ( isset($conf['order_by_custom']) or isset($conf['order_by_inside_category_custom']) )
     {
-      $order_by = array(array(
-        'FIELD' => '',    
-        'DIRECTION' => 'ASC', 
-        ));
-        
+      $order_by = array('');
       $template->assign('ORDER_BY_IS_CUSTOM', true);
     }
@@ -337,13 +324,4 @@
       $order_by = str_replace('ORDER BY ', null, $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;
     }
   
@@ -359,6 +337,5 @@
         'week_starts_on_options_selected' => $conf['week_starts_on'],
         'order_by' => $order_by,
-        'order_field_options' => $sort_fields,
-        'order_direction_options' => $sort_directions,
+        'order_by_options' => $sort_fields,
         )
       );
Index: /trunk/admin/element_set_ranks.php
===================================================================
--- /trunk/admin/element_set_ranks.php	(revision 13086)
+++ /trunk/admin/element_set_ranks.php	(revision 13087)
@@ -105,5 +105,4 @@
   }
 
-  $image_order = null;
   if (!empty($_POST['image_order_choice'])
       && in_array($_POST['image_order_choice'], $image_order_choices))
@@ -112,19 +111,13 @@
   }
 
+  $image_order = null;
   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) )
-        {
-          $image_order .= ',';
-        }
-        $image_order .= $_POST['order_field_'.$i];
-        if ($_POST['order_direction_'.$i]=='DESC')
-        {
-          $image_order .= ' DESC';
-        }
+        if (!empty($image_order)) $image_order.= ',';
+        $image_order.= $_POST['image_order'][$i];
       }
     }
@@ -135,5 +128,6 @@
   }
   $query = '
-UPDATE '.CATEGORIES_TABLE.' SET image_order=\''.$image_order.'\'
+UPDATE '.CATEGORIES_TABLE.' 
+  SET image_order=\''.$image_order.'\'
   WHERE id='.$page['category_id'];
   pwg_query($query);
@@ -273,48 +267,36 @@
 // image order management
 $sort_fields = array(
-  '' => '',
-  'date_creation' => l10n('Creation date'),
-  'date_available' => l10n('Post date'),
-  'rating_score' => l10n('Rating score'),
-  'hit' => l10n('Most visited'),
-  'file' => l10n('File name'),
-  'name' => l10n('Photo name'),
-  'id' => 'Id',
-  'rank' => l10n('Rank'),
+  ''                    => '',
+  'file'                => l10n('file name, A &rarr; Z'),
+  'file DESC'           => l10n('file name, Z &rarr; A'),
+  'name'                => l10n('photo title, A &rarr; Z'),
+  'name DESC'           => l10n('photo title, Z &rarr; A'),
+  'date_creation DESC'  => l10n('date created, new &rarr; old'),
+  'date_creation'       => l10n('date created, old &rarr; new'),
+  'date_available DESC' => l10n('date posted, new &rarr; old'),
+  'date_available'      => l10n('date posted, old &rarr; new'),
+  'rating_score DESC'   => l10n('rating score, high &rarr; low'),
+  'rating_score'        => l10n('rating score, low &rarr; high'),
+  'hit DESC'            => l10n('visits, high &rarr; low'),
+  'hit'                 => l10n('visits, low &rarr; high'),
+  'id'                  => l10n('numeric identifier, 1 &rarr; 9'),
+  'id DESC'             => l10n('numeric identifier, 9 &rarr; 1'),
+  'rank'                => l10n('manual sort order'),
   );
 
-$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);
-}
+$template->assign('image_order_options', $sort_fields);
+
+$image_order = explode(',', $category['image_order']);
 
 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);
+  if ( isset($image_order[$i]) )
+  {
+    $template->append('image_order', $image_order[$i]);
+  }
+  else
+  {
+    $template->append('image_order', '');
+  }
 }
 
Index: /trunk/admin/themes/default/template/configuration.tpl
===================================================================
--- /trunk/admin/themes/default/template/configuration.tpl	(revision 13086)
+++ /trunk/admin/themes/default/template/configuration.tpl	(revision 13087)
@@ -109,10 +109,7 @@
         {foreach from=$main.order_by item=order}
         <span class="filter {if $ORDER_BY_IS_CUSTOM}transparent{/if}">          
-          <select name="order_by_field[]" {if $ORDER_BY_IS_CUSTOM}disabled{/if}>
-            {html_options options=$main.order_field_options selected=$order.FIELD }
+          <select name="order_by[]" {if $ORDER_BY_IS_CUSTOM}disabled{/if}>
+            {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>  
           <a class="removeFilter">{'delete'|@translate}</a>
         </span>
@@ -129,5 +126,5 @@
 {footer_script require='jquery'}
 // 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}
@@ -150,8 +147,6 @@
 jQuery(document).ready(function () {
   $('.addFilter').click(function() {
-    rel = $(this).attr('rel');
     $(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_direction[]"]').val('ASC');
+    $(this).prev('span.filter').children('select[name="order_by[]"]').val('');
     
     fields++;
Index: /trunk/admin/themes/default/template/element_set_ranks.tpl
===================================================================
--- /trunk/admin/themes/default/template/element_set_ranks.tpl	(revision 13086)
+++ /trunk/admin/themes/default/template/element_set_ranks.tpl	(revision 13087)
@@ -79,12 +79,9 @@
       <label for="image_order_user_define">{'automatic order'|@translate}</label>
       <div id="image_order_user_define_options">
-      {foreach from=$image_orders item=order}
+      {foreach from=$image_order item=order}
       <p class="field">
-        <select name="order_field_{$order.ID}">
-          {html_options options=$image_order_field_options selected=$order.FIELD }
+        <select name="image_order[]">
+          {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>      
       </p>
       {/foreach}
