Changeset 11279


Ignore:
Timestamp:
Jun 9, 2011, 4:32:20 PM (13 years ago)
Author:
mistic100
Message:

feature:2317 move order config to Admin->Config->Options
first try, may has issues with very specials params

Location:
trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/configuration.php

    r10812 r11279  
    101101    'privacy_level',
    102102  );
     103 
     104$order_options = array(
     105    ' ORDER BY date_available DESC, file ASC, id ASC' => 'date_available DESC, file ASC, id ASC',
     106    ' ORDER BY file DESC, date_available DESC' => 'file DESC, date_available DESC',
     107    'custom' => l10n('Custom'),
     108  );
    103109
    104110//------------------------------ verification and registration of modifications
     
    111117    case 'main' :
    112118    {
     119      $order_regex = '#^(( *)(id|file|name|date_available|date_creation|hit|average_rate|comment|author|filesize|width|height|high_filesize|high_width|high_height) (ASC|DESC),{1}){1,}$#';
     120      // process 'order_by_perso' string
     121      if ($_POST['order_by'] == 'custom' AND !empty($_POST['order_by_perso']))
     122      {
     123        $_POST['order_by'] = str_ireplace(
     124          array('order by ', 'asc', 'desc'),
     125          array(null, 'ASC', 'DESC'),
     126          trim($_POST['order_by_perso'])
     127          );
     128       
     129        if (preg_match($order_regex, $_POST['order_by'].','))
     130        {
     131          $_POST['order_by'] = ' ORDER BY '.$_POST['order_by'];
     132        }
     133        else
     134        {
     135          array_push($page['errors'], l10n('Invalid order string').' « '.$_POST['order_by'].' »');
     136        }
     137      }
     138      else if ($_POST['order_by'] == 'custom')
     139      {
     140        array_push($page['errors'], l10n('Invalid order string'));
     141      }
     142      // process 'order_by_inside_category_perso' string
     143      if ($_POST['order_by_inside_category'] == 'as_order_by')
     144      {
     145        $_POST['order_by_inside_category'] = $_POST['order_by'];
     146      }
     147      else if ($_POST['order_by_inside_category'] == 'custom' AND !empty($_POST['order_by_inside_category_perso']))
     148      {
     149        $_POST['order_by_inside_category'] = str_ireplace(
     150          array('order by ', 'asc', 'desc'),
     151          array(null, 'ASC', 'DESC'),
     152          trim($_POST['order_by_inside_category_perso'])
     153          );
     154       
     155        if (preg_match($order_regex, $_POST['order_by_inside_category'].','))
     156        {
     157          $_POST['order_by_inside_category'] = ' ORDER BY '.$_POST['order_by_inside_category'];
     158        }
     159        else
     160        {
     161          array_push($page['errors'], l10n('Invalid order string').' « '.$_POST['order_by_inside_category'].' »');
     162        }
     163      }
     164      else if ($_POST['order_by_inside_category'] == 'custom')
     165      {
     166        array_push($page['errors'], l10n('Invalid order string'));
     167      }
     168     
    113169      if (empty($_POST['gallery_locked']) and $conf['gallery_locked'])
    114170      {
     
    235291  case 'main' :
    236292  {
     293    // process 'order_by' string
     294    if (array_key_exists($conf['order_by'], $order_options))
     295    {
     296      $order_by_selected = $conf['order_by'];
     297      $order_by_perso = null;
     298    }
     299    else
     300    {
     301      $order_by_selected = 'custom';
     302      $order_by_perso = str_replace(' ORDER BY ', null, $conf['order_by']);
     303    }
     304    // process 'order_by_inside_category' string
     305    if ($conf['order_by_inside_category'] == $conf['order_by'])
     306    {
     307      $order_by_inside_category_selected = 'as_order_by';
     308      $order_by_inside_category_perso = null;
     309    }
     310    else if (array_key_exists($conf['order_by_inside_category'], $order_options))
     311    {
     312      $order_by_inside_category_selected = $conf['order_by_inside_category'];
     313      $order_by_inside_category_perso = null;
     314    }
     315    else
     316    {
     317      $order_by_inside_category_selected = 'custom';
     318      $order_by_inside_category_perso = str_replace(' ORDER BY ', null, $conf['order_by_inside_category']);
     319    }
     320     
    237321    $template->assign(
    238322      'main',
     
    246330          ),
    247331        'week_starts_on_options_selected' => $conf['week_starts_on'],
     332        'order_by_options' => $order_options,
     333        'order_by_selected' => $order_by_selected,
     334        'order_by_perso' => $order_by_perso,
     335        'order_by_inside_category_options' =>
     336          array_merge(
     337            array('as_order_by'=>l10n('As default order')),
     338            $order_options
     339            ),
     340        'order_by_inside_category_selected' => $order_by_inside_category_selected,
     341        'order_by_inside_category_perso' => $order_by_inside_category_perso,
    248342        ));
    249343
  • trunk/admin/themes/default/template/configuration.tpl

    r10812 r11279  
    9090
    9191    <li>
    92       <label>
    93         <span class="property">
    94           {'Week starts on'|@translate}
    95           {html_options name="week_starts_on" options=$main.week_starts_on_options selected=$main.week_starts_on_options_selected}
    96         </span>
    97       </label>
    98     </li>
     92      &nbsp;
     93      <span class="property">
     94        {'Week starts on'|@translate}
     95        {html_options name="week_starts_on" options=$main.week_starts_on_options selected=$main.week_starts_on_options_selected}
     96      </span>
     97    </li>
     98   
     99    <li>
     100      &nbsp;
     101      <span class="property">
     102        {'Default photos order'|@translate}
     103        {html_options name="order_by" options=$main.order_by_options selected=$main.order_by_selected}
     104        <input type="text" name="order_by_perso" size="40" value="{$main.order_by_perso}"
     105            {if $main.order_by_selected != 'custom'}style="display:none;"{/if}/>
     106      </span>
     107    </li>
     108    <li>
     109      &nbsp;
     110      <span class="property">
     111        {'Default photos order inside album'|@translate}
     112        {html_options name="order_by_inside_category" options=$main.order_by_inside_category_options selected=$main.order_by_inside_category_selected}
     113        <input type="text" name="order_by_inside_category_perso" size="40" value="{$main.order_by_inside_category_perso}"
     114            {if $main.order_by_inside_category_selected != 'custom'}style="display:none;"{/if}>
     115      </span>
     116    </li>
     117   
     118{footer_script require='jquery'}{literal}
     119jQuery(document).ready(function () {
     120  $('select[name="order_by"]').change(function () {
     121    if ($(this).val() == 'custom') {
     122      $('input[name="order_by_perso"]').show();
     123    } else {
     124      $('input[name="order_by_perso"]').hide();
     125    }
     126  });
     127  $('select[name="order_by_inside_category"]').change(function () {
     128    if ($(this).val() == 'custom') {
     129      $('input[name="order_by_inside_category_perso"]').show();
     130    } else {
     131      $('input[name="order_by_inside_category_perso"]').hide();
     132    }
     133  });
     134});
     135{/literal}{/footer_script}
    99136  </ul>
    100137</fieldset>
  • trunk/install/config.sql

    r11183 r11279  
    5252INSERT INTO piwigo_config (param,value,comment) VALUES ('week_starts_on','monday','Monday may not be the first day of the week');
    5353INSERT INTO piwigo_config (param,value,comment) VALUES ('updates_ignored','a:3:{s:7:"plugins";a:0:{}s:6:"themes";a:0:{}s:9:"languages";a:0:{}}','Extensions ignored for update');
     54INSERT INTO piwigo_config (param,value,comment) VALUES ('order_by',' ORDER BY date_available DESC, file ASC, id ASC','default photo order');
     55INSERT INTO piwigo_config (param,value,comment) VALUES ('order_by_inside_category',' ORDER BY date_available DESC, file ASC, id ASC','default photo order inside category');
    5456INSERT INTO piwigo_config (param,value) VALUES ('upload_form_websize_resize','true');
    5557INSERT INTO piwigo_config (param,value) VALUES ('upload_form_websize_maxwidth','800');
  • trunk/language/en_UK/admin.lang.php

    r11184 r11279  
    151151$lang['Are you sure you want to delete this plugin?'] = "Are you sure you want to delete this plugin?";
    152152$lang['Are you sure you want to install this plugin?'] = "Are you sure you want to install this plugin?";
     153$lang['As default order'] = "As default order";
    153154$lang['Associate to album'] = "Associate to album";
    154155$lang['associate to group'] = "associate to group";
     
    203204$lang['created'] = "created";
    204205$lang['Current name'] = "Current name";
     206$lang['Custom'] = "Custom";
    205207$lang['Database synchronization with files'] = "Database synchronization with files";
    206208$lang['Database'] = "Database";
     
    210212$lang['Deactivate all'] = "Deactivate all";
    211213$lang['Default display'] = "Default display";
     214$lang['Default photos order'] = "Default photos order";
     215$lang['Default photos order inside album'] = "Default photos order inside album";
    212216$lang['Default user cannot be deleted'] = "Default user cannot be deleted";
    213217$lang['Default user does not exist'] = "The default user does not exist";
     
    359363$lang['Installed Themes'] = "Installed Themes";
    360364$lang['Instructions to use Piwigo'] = "Instructions to use Piwigo";
     365$lang['Invalid order string'] = 'Invalid order string';
    361366$lang['Invert'] = 'Invert';
    362367$lang['IP'] = "IP";
  • trunk/language/en_UK/help/configuration.html

    r8711 r11279  
    3434
    3535  <li><strong>Email admins when a new user registers</strong>: administrators will be notified by mail for each registration.</li>
     36 
     37  <li><strong>Default photos order</strong>: You can define a personalized order by selecting &laquo;Personalized&raquo; in the drop-down menu. This field must respect the SQL syntax, example: <i>date_available DESC, file ASC, id ASC</i><br>
     38    Available fields:
     39    <ul style="font-size:0.85em;">
     40      <li><b>date_available</b>: date of the adding to the gallery</li>
     41      <li><b>file</b>: name of the file</li>
     42      <li><b>id</b>: identifier</li>
     43      <li><b>date_creation</b>: date of element creation</li>
     44      <li><b>name</b>: name of the picture</li>
     45      <li><b>hit</b>: number of visits</li>
     46      <li><b>average_rate</b>: average rate on the picture</li>
     47    </ul>
     48    Don't forgot to specify the order for each field with these keywords : <i>ASC</i> and <i>DESC</i>
     49  </li>
    3650
    3751</ul>
  • trunk/language/fr_FR/admin.lang.php

    r11184 r11279  
    843843$lang['If you want to regenerate thumbnails, please go to the <a href="%s">Batch Manager</a>.'] = 'Si vous voulez régénérer des miniatures, merci de vous rendre dans la <a href="%s">Gestion par lot</a>.';
    844844$lang['Graphics Library'] = 'Bibliothèque graphique';
    845 $lang['Show menubar'] = "Afficher le menu";
    846 $lang['No results'] = "Pas de résultat";
    847 $lang['Type in a search term'] = "Entrez un terme de recherche";
    848 $lang['Searching...'] = "Recherche...";
    849 $lang['new'] = "nouveau";
     845$lang['Show menubar'] = 'Afficher le menu';
     846$lang['No results'] = 'Pas de résultat';
     847$lang['Type in a search term'] = 'Entrez un terme de recherche';
     848$lang['Searching...'] = 'Recherche...';
     849$lang['new'] = 'nouveau';
     850$lang['Default photos order'] = "Ordre par défaut des photos";
     851$lang['Default photos order inside album'] = "Ordre par défaut des photos dans un album";
     852$lang['Invalid order string'] = 'Chaîne SQL incorrecte';
     853$lang['As default order'] = "Comme l'ordre par défaut";
     854$lang['Custom'] = "Personnalisé";
    850855?>
  • trunk/language/fr_FR/help/configuration.html

    r9899 r11279  
    3434
    3535  <li><strong>Notifier les administrateurs lors de l'inscription d'un utilisateur</strong>: Les administrateurs recevront un courriel à chaque inscription.</li>
     36 
     37  <li><strong>Ordre par défaut des photos</strong>: Vous pouvez définir un ordre personnalisé et selectionant &laquo;Personnalisé&raquo; dans la liste déroulante. Ce champ doit respecter la syntaxe SQL, exemple: <i>date_available DESC, file ASC, id ASC</i><br>
     38    Liste des champs utilisables :
     39    <ul style="font-size:0.85em;">
     40      <li><b>date_available</b>: date d'ajout à la galerie</li>
     41      <li><b>file</b>: nom du fichier</li>
     42      <li><b>id</b>: identifiant</li>
     43      <li><b>date_creation</b>: date de création</li>
     44      <li><b>name</b>: nom de l'image</li>
     45      <li><b>hit</b>: nombre de visites</li>
     46      <li><b>average_rate</b>: note globale</li>
     47    </ul>
     48    N'oubliez pas pour chaque champ de spécifier l'ordre avec les mots clefs <i>ASC</i> et <i>DESC</i>
     49  </li>
    3650
    3751</ul>
Note: See TracChangeset for help on using the changeset viewer.