Ignore:
Timestamp:
Feb 10, 2012, 10:41:08 PM (12 years ago)
Author:
mistic100
Message:

feature 2568: redesigned order_by fields in Admin->Config->Options

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/element_set_ranks.php

    r13013 r13087  
    105105  }
    106106
    107   $image_order = null;
    108107  if (!empty($_POST['image_order_choice'])
    109108      && in_array($_POST['image_order_choice'], $image_order_choices))
     
    112111  }
    113112
     113  $image_order = null;
    114114  if ($image_order_choice=='user_define')
    115115  {
    116     for ($i=1; $i<=3; $i++)
     116    for ($i=0; $i<3; $i++)
    117117    {
    118       if ( !empty($_POST['order_field_'.$i]) )
     118      if (!empty($_POST['image_order'][$i]))
    119119      {
    120         if (! empty($image_order) )
    121         {
    122           $image_order .= ',';
    123         }
    124         $image_order .= $_POST['order_field_'.$i];
    125         if ($_POST['order_direction_'.$i]=='DESC')
    126         {
    127           $image_order .= ' DESC';
    128         }
     120        if (!empty($image_order)) $image_order.= ',';
     121        $image_order.= $_POST['image_order'][$i];
    129122      }
    130123    }
     
    135128  }
    136129  $query = '
    137 UPDATE '.CATEGORIES_TABLE.' SET image_order=\''.$image_order.'\'
     130UPDATE '.CATEGORIES_TABLE.'
     131  SET image_order=\''.$image_order.'\'
    138132  WHERE id='.$page['category_id'];
    139133  pwg_query($query);
     
    273267// image order management
    274268$sort_fields = array(
    275   '' => '',
    276   'date_creation' => l10n('Creation date'),
    277   'date_available' => l10n('Post date'),
    278   'rating_score' => l10n('Rating score'),
    279   'hit' => l10n('Most visited'),
    280   'file' => l10n('File name'),
    281   'name' => l10n('Photo name'),
    282   'id' => 'Id',
    283   'rank' => l10n('Rank'),
     269  ''                    => '',
     270  'file'                => l10n('file name, A &rarr; Z'),
     271  'file DESC'           => l10n('file name, Z &rarr; A'),
     272  'name'                => l10n('photo title, A &rarr; Z'),
     273  'name DESC'           => l10n('photo title, Z &rarr; A'),
     274  'date_creation DESC'  => l10n('date created, new &rarr; old'),
     275  'date_creation'       => l10n('date created, old &rarr; new'),
     276  'date_available DESC' => l10n('date posted, new &rarr; old'),
     277  'date_available'      => l10n('date posted, old &rarr; new'),
     278  'rating_score DESC'   => l10n('rating score, high &rarr; low'),
     279  'rating_score'        => l10n('rating score, low &rarr; high'),
     280  'hit DESC'            => l10n('visits, high &rarr; low'),
     281  'hit'                 => l10n('visits, low &rarr; high'),
     282  'id'                  => l10n('numeric identifier, 1 &rarr; 9'),
     283  'id DESC'             => l10n('numeric identifier, 9 &rarr; 1'),
     284  'rank'                => l10n('manual sort order'),
    284285  );
    285286
    286 $sort_directions = array(
    287   'ASC' => l10n('ascending'),
    288   'DESC' => l10n('descending'),
    289   );
    290 
    291 $template->assign('image_order_field_options', $sort_fields);
    292 $template->assign('image_order_direction_options', $sort_directions);
    293 
    294 $matches = array();
    295 if ( !empty( $category['image_order'] ) )
    296 {
    297   preg_match_all('/([a-z_]+) *(?:(asc|desc)(?:ending)?)? *(?:, *|$)/i',
    298     $category['image_order'], $matches);
    299 }
     287$template->assign('image_order_options', $sort_fields);
     288
     289$image_order = explode(',', $category['image_order']);
    300290
    301291for ($i=0; $i<3; $i++) // 3 fields
    302292{
    303   $tpl_image_order_select = array(
    304       'ID' => $i+1,
    305       'FIELD' => array(''),
    306       'DIRECTION' => array('ASC'),
    307     );
    308 
    309   if ( isset($matches[1][$i]) )
    310   {
    311     $tpl_image_order_select['FIELD'] = array($matches[1][$i]);
    312   }
    313 
    314   if (isset($matches[2][$i]) and strcasecmp($matches[2][$i],'DESC')==0)
    315   {
    316     $tpl_image_order_select['DIRECTION'] = array('DESC');
    317   }
    318   $template->append( 'image_orders', $tpl_image_order_select);
     293  if ( isset($image_order[$i]) )
     294  {
     295    $template->append('image_order', $image_order[$i]);
     296  }
     297  else
     298  {
     299    $template->append('image_order', '');
     300  }
    319301}
    320302
Note: See TracChangeset for help on using the changeset viewer.