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/configuration.php

    r13068 r13087  
    107107// image order management
    108108$sort_fields = array(
    109   '' => '',
    110   'rank' => l10n('Rank'),
    111   'file' => l10n('File name'),
    112   'name' => l10n('Photo name'),
    113   'date_creation' => l10n('Creation date'),
    114   'date_available' => l10n('Post date'),
    115   'rating_score' => l10n('Rating score'),
    116   'hit' => l10n('Most visited'),
    117   'id' => 'Id',
     109  ''                    => '',
     110  'file ASC'            => l10n('file name, A → Z'),
     111  'file DESC'           => l10n('file name, Z → A'),
     112  'name ASC'            => l10n('photo title, A → Z'),
     113  'name DESC'           => l10n('photo title, Z → A'),
     114  'date_creation DESC'  => l10n('date created, new → old'),
     115  'date_creation ASC'   => l10n('date created, old → new'),
     116  'date_available DESC' => l10n('date posted, new → old'),
     117  'date_available ASC'  => l10n('date posted, old → new'),
     118  'rating_score DESC'   => l10n('rating score, high → low'),
     119  'rating_score ASC'    => l10n('rating score, low → high'),
     120  'hit DESC'            => l10n('visits, high → low'),
     121  'hit ASC'             => l10n('visits, low → high'),
     122  'id ASC'              => l10n('numeric identifier, 1 → 9'),
     123  'id DESC'             => l10n('numeric identifier, 9 → 1'),
     124  'rank ASC'            => l10n('manual sort order'),
    118125  );
    119 
    120 $sort_directions = array(
    121   'ASC' => l10n('ascending'),
    122   'DESC' => l10n('descending'),
    123   );
     126 
    124127
    125128//------------------------------ verification and registration of modifications
     
    134137      if ( !isset($conf['order_by_custom']) and !isset($conf['order_by_inside_category_custom']) )
    135138      {
    136         if ( !empty($_POST['order_by_field']) )
    137         {
    138           $order_by = array();
    139           $order_by_inside_category = array();
     139        if ( !empty($_POST['order_by']) )
     140        {         
     141          // limit to the number of available parameters
     142          $order_by = $order_by_inside_category = array_slice($_POST['order_by'], 0, ceil(count($sort_fields)/2));
    140143         
    141           for ($i=0; $i<count($_POST['order_by_field']); $i++)
    142           {
    143             if ( $i >= (count($sort_fields)-1) ) break; // limit to the number of available parameters
    144             if ( empty($_POST['order_by_field'][$i]) )
    145             {
    146               array_push($page['errors'], l10n('No field selected'));
    147               break;
    148             }
    149             else
    150             {
    151               // there is no rank outside categories
    152               if ($_POST['order_by_field'][$i] != 'rank')
    153               {
    154                 $order_by[] = $_POST['order_by_field'][$i].' '.$_POST['order_by_direction'][$i];
    155               }
    156               $order_by_inside_category[] = $_POST['order_by_field'][$i].' '.$_POST['order_by_direction'][$i];
    157             }
    158           }
     144          // there is no rank outside categories
     145          unset($order_by[ array_search('rank ASC', $order_by) ]);
     146         
    159147          // must define a default order_by if user want to order by rank only
    160148          if ( count($order_by) == 0 )
     
    165153          $_POST['order_by'] = 'ORDER BY '.implode(', ', $order_by);
    166154          $_POST['order_by_inside_category'] = 'ORDER BY '.implode(', ', $order_by_inside_category);
    167           unset($_POST['order_by_field']);
     155        }
     156        else
     157        {
     158          array_push($page['errors'], l10n('No field selected'));
    168159        }
    169160      }
     
    324315    if ( isset($conf['order_by_custom']) or isset($conf['order_by_inside_category_custom']) )
    325316    {
    326       $order_by = array(array(
    327         'FIELD' => '',   
    328         'DIRECTION' => 'ASC',
    329         ));
    330        
     317      $order_by = array('');
    331318      $template->assign('ORDER_BY_IS_CUSTOM', true);
    332319    }
     
    337324      $order_by = str_replace('ORDER BY ', null, $order_by);
    338325      $order_by = explode(', ', $order_by);
    339       foreach ($order_by as $field)
    340       {
    341         $field= explode(' ', $field);
    342         $out[] = array(
    343           'FIELD' => $field[0],   
    344           'DIRECTION' => $field[1],   
    345         );
    346       }
    347       $order_by = $out;
    348326    }
    349327 
     
    359337        'week_starts_on_options_selected' => $conf['week_starts_on'],
    360338        'order_by' => $order_by,
    361         'order_field_options' => $sort_fields,
    362         'order_direction_options' => $sort_directions,
     339        'order_by_options' => $sort_fields,
    363340        )
    364341      );
Note: See TracChangeset for help on using the changeset viewer.