Changeset 27266


Ignore:
Timestamp:
Feb 8, 2014, 12:11:14 PM (7 years ago)
Author:
mistic100
Message:

allow to choose the sort order when using limit filter

Location:
extensions/SmartAlbums
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • extensions/SmartAlbums/admin/album.php

    r26442 r27266  
    198198  'limit' => array(
    199199    'name' => l10n('Max. number of photos'),
    200     'options' => array(),
     200    'options' => array(
     201      ''                    => '-- ' . l10n('Default') . ' --',
     202      'file ASC'            => l10n('File name, A → Z'),
     203      'file DESC'           => l10n('File name, Z → A'),
     204      'name ASC'            => l10n('Photo title, A → Z'),
     205      'name DESC'           => l10n('Photo title, Z → A'),
     206      'date_creation DESC'  => l10n('Date created, new → old'),
     207      'date_creation ASC'   => l10n('Date created, old → new'),
     208      'date_available DESC' => l10n('Date posted, new → old'),
     209      'date_available ASC'  => l10n('Date posted, old → new'),
     210      'rating_score DESC'   => l10n('Rating score, high → low'),
     211      'rating_score ASC'    => l10n('Rating score, low → high'),
     212      'hit DESC'            => l10n('Visits, high → low'),
     213      'hit ASC'             => l10n('Visits, low → high'),
     214      'id ASC'              => l10n('Numeric identifier, 1 → 9'),
     215      'id DESC'             => l10n('Numeric identifier, 9 → 1'),
     216      ),
    201217    ),
    202218  );
  • extensions/SmartAlbums/admin/template/album.tpl

    r26741 r27266  
    2828
    2929  $('#removeFilters').click(function() {
    30     $('#filtersList li').each(function() {
    31       $(this).remove();
    32     });
     30    $('#filtersList li:not(.empty)').remove();
     31    $('#filtersList li.empty').show();
     32
     33    $("#addFilter option[value='limit']").removeAttr('disabled');
     34    $("#addFilter option[value='level']").removeAttr('disabled');
    3335
    3436    limit_level=0;
    3537    level_count=0;
     38
    3639    return false;
    3740  });
     
    5356    count++;
    5457
    55     var content = $("#filtersRepo #filter_"+type).html().replace(/iiii/g, count);
    56     $block = $($.parseHTML(content)).appendTo("#filtersList");
     58    $('#filtersList li.empty').hide();
     59
     60    var content = $("#filtersRepo #filter_"+type).html().replace(/iiii/g, count),
     61        $block = $($.parseHTML(content)).appendTo("#filtersList");
    5762
    5863    if (cond) {
     
    97102
    98103  function select_dimensions($block, cond, value) {
    99     console.log($block, cond, value);
    100104    cond = cond || 'width';
     105    var values;
    101106
    102107    $block.find(">.filter-value>span").hide();
     
    113118
    114119  function select_options($block, value) {
    115     values = value.split(',');
    116     for (j in values) {
     120    var values = value.split(',');
     121    for (var j in values) {
    117122      $block.find(".filter-value option[value='"+ values[j] +"']").attr('selected', 'selected');
    118123    }
     
    124129    // remove filter
    125130    $block.find(".removeFilter").click(function() {
    126       type = $(this).next("input").val();
     131      var type = $(this).next("input").val();
     132
    127133      if (type == 'limit') {
    128134        limit_count=1;
     
    242248
    243249{if isset($new_smart)}
    244 function doBlink(obj,start,finish) {
     250function doBlink(obj, start, finish) {
    245251  jQuery(obj).fadeOut(400).fadeIn(400);
    246   if(start!=finish) {
     252
     253  if (start != finish) {
    247254    doBlink(obj,start+1,finish);
    248255  }
     
    271278  <fieldset id="SmartAlbum_options" style="margin-top:1em;{if !isset($filters) AND !isset($new_smart)}display:none;{/if}">
    272279    <legend>{'Filters'|translate}</legend>
    273 
     280   
     281    <div>
     282      <label><input type="radio" name="filters[0][value]" value="and" {if $filter_mode=='and'}checked="checked"{/if}> {'Photos must match all filters'|translate}</label>
     283      <label><input type="radio" name="filters[0][value]" value="or" {if $filter_mode=='or'}checked="checked"{/if}> {'Photos must match at least one filter'|translate}</label>
     284      <input type="hidden" name="filters[0][type]" value="mode">
     285      <input type="hidden" name="filters[0][cond]" value="mode">
     286    </div>
     287
     288    <fieldset>
    274289    <ul id="filtersList">
     290      <li class="empty">{'No filter'|translate}</li>
    275291    {foreach from=$filters item=filter}{strip}
    276292      {if $filter.type == 'tags'}
     
    295311    {/strip}{/foreach}
    296312    </ul>
    297 
    298     <div>
    299       <b>{'Mode'|translate} :</b>
    300       <label><input type="radio" name="filters[0][value]" value="and" {if $filter_mode=='and'}checked="checked"{/if}> AND</label>
    301       <label><input type="radio" name="filters[0][value]" value="or" {if $filter_mode=='or'}checked="checked"{/if}> OR</label>
    302       <input type="hidden" name="filters[0][type]" value="mode">
    303       <input type="hidden" name="filters[0][cond]" value="mode">
    304     </div>
     313    </fieldset>
    305314
    306315    <p class="actionButtons">
     
    325334
    326335  <p class="actionButtons" id="applyFilterBlock">
    327     <input class="submit" type="submit" value="{'Submit'|translate}" name="submitFilters"/>
     336    <input class="submit" type="submit" value="{'Save'|translate}" name="submitFilters"/>
    328337    <input class="submit" type="submit" value="{'Count'|translate}" name="countImages" {if !isset($filters) AND !isset($new_smart)}style="display:none;"{/if}/>
    329338    <span class="count_images_wrapper" {if !isset($filters) AND !isset($new_smart)}style="display:none;"{/if}><span class="count_image">{$IMAGE_COUNT}</span></span>
  • extensions/SmartAlbums/admin/template/filters.inc.tpl

    r26725 r27266  
    155155  <span class="filter-value">
    156156    <input type="text" name="filters[iiii][value]" size="30"/>
    157     <i>{'For "Is (not) in", separate each author by a comma'|translate}</i>
     157    <br><i>{'For "Is (not) in", separate each author by a comma'|translate}</i>
    158158  </span>
    159159</li>
     
    176176
    177177  <span class="filter-value">
    178     <input type="text" name="filters[iiii][value]" size="5"/>
     178    <input type="number" name="filters[iiii][value]" size="5"/>
    179179  </span>
    180180</li>
     
    197197
    198198  <span class="filter-value">
    199     <input type="text" name="filters[iiii][value]" size="5"/>
     199    <input type="number" name="filters[iiii][value]" size="5"/>
    200200  </span>
    201201</li>
     
    231231
    232232  <input type="hidden" name="filters[iiii][cond]" value="limit"/>
    233 
    234   <span class="filter-value">
    235     <input type="text" name="filters[iiii][value]" size="5"/>
    236   </span>
    237 </li>
    238 </div>
     233 
     234  <span class="filter-value" style="width:200px;">
     235    <input type="number" name="filters[iiii][value]" size="5"/>
     236  </span>
     237 
     238  <span class="filter-cond" style="width:auto;">
     239    <b>{'Sort order'|translate}</b>
     240    <select name="filters[iiii][cond]">
     241      {html_options options=$options.limit.options}
     242    </select>
     243    <br><i>{'The sort order is only used in addition to the limit filter, it does not impact the final display order'|translate}</i>
     244  </span>
     245</li>
     246</div>
  • extensions/SmartAlbums/include/functions.inc.php

    r26442 r27266  
    438438      {
    439439        $limit = '0, '.$filter['value'];
     440        if (!empty($filter['cond'])) $order_by = $filter['cond'];
    440441        break;
    441442      }
     
    469470  $MainQuery.= '
    470471  GROUP BY i.id
    471   '.$conf['order_by'].'
     472  '.(isset($order_by) ? "ORDER BY ".$order_by : $conf['order_by']).'
    472473  '.(isset($limit) ? "LIMIT ".$limit : null).'
    473474;';
     
    622623      else
    623624      {
    624         $filter['cond'] = 'limit';
    625625        $limit_is_set = true;
    626626      }
  • extensions/SmartAlbums/language/en_UK/plugin.lang.php

    r26442 r27266  
    6262$lang['Update albums every %s days'] = 'Update albums every %s days';
    6363$lang['Invalid number of days'] = 'Invalid number of days';
    64 $lang['Mode'] = 'Mode';
    6564$lang['Select albums...'] = 'Select albums...';
     65$lang['Photos must match all filters'] = 'Photos must match all filters';
     66$lang['Photos must match at least one filter'] = 'Photos must match at least one filter';
     67$lang['No filter'] = 'No filter';
     68$lang['The sort order is only used in addition to the limit filter, it does not impact the final display order'] = 'The sort order is only used in addition to the limit filter, it does not impact the final display order';
    6669
    6770?>
  • extensions/SmartAlbums/language/fr_FR/plugin.lang.php

    r26442 r27266  
    4343$lang['Limit must be an integer'] = 'La nombre d\'éléments doit être un entier';
    4444$lang['Rating score must be an integer'] = 'Le score doit être un entier';
    45 $lang['Regex is malformed'] = 'Regex malformée';
     45$lang['Regex is malformed'] = 'Regex mal formée';
    4646$lang['You can\'t use more than one limit filter'] = 'Vous ne pouvez choisir qu\'une seule limite de nombre d\'éléments';
    4747$lang['You can\'t use more than one level filter'] = 'Vous ne pouvez choisir qu\'un seul niveau de confidentialité';
     
    6262$lang['Update albums every %s days'] = 'Mettre à jour les albums tous les %s jours';
    6363$lang['Invalid number of days'] = 'Nombre de jour invalide';
    64 $lang['Mode'] = 'Mode';
    6564$lang['Select albums...'] = 'Albums...';
     65$lang['Photos must match all filters'] = 'Les photos doivent respecter tous les filtres';
     66$lang['Photos must match at least one filter'] = 'Les photos doivent respecter au moins un filtre';
     67$lang['No filter'] = 'Aucun filtre';
     68$lang['The sort order is only used in addition to the limit filter, it does not impact the final display order'] = 'L\'ordre de tri est uniquement utilisé pour le nombre max. d\'éléments, il n\'impacte pas l\'ordre d\'affichage';
    6669
    6770?>
  • extensions/SmartAlbums/maintain.inc.php

    r26442 r27266  
    6262  `category_id` smallint(5) unsigned NOT NULL,
    6363  `type` varchar(16) NOT NULL,
    64   `cond` varchar(16) NULL,
     64  `cond` varchar(32) NULL,
    6565  `value` text NULL,
    6666  `updated` DATETIME NOT NULL DEFAULT "1970-01-01 00:00:00"
     
    114114      }
    115115    }
     116   
     117    // limit filter extended in 2.2.1
     118    pwg_query('UPDATE `' . $this->table . '` SET cond = "" WHERE type = "limit" AND cond = "limit";');
     119    pwg_query('ALTER TABLE `' . $this->table . '` CHANGE `cond` `cond` VARCHAR(32) NULL ;');
    116120
    117121    $this->installed = true;
Note: See TracChangeset for help on using the changeset viewer.