Changeset 17677


Ignore:
Timestamp:
08/31/12 12:58:56 (7 years ago)
Author:
mistic100
Message:

add album filter

Location:
extensions/SmartAlbums
Files:
7 edited

Legend:

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

    r16938 r17677  
    162162      ), 
    163163    ), 
     164  'album' => array( 
     165    'name' => l10n('Album'), 
     166    'options' => array( 
     167      'all'   => l10n('All these albums'), 
     168      'one'   => l10n('One of these albums'), 
     169      'none'  => l10n('None of these albums'), 
     170      'only'  => l10n('Only these albums'), 
     171      ), 
     172    ), 
    164173  'author' => array( 
    165174    'name' => l10n('Author'), 
     
    220229;'; 
    221230    $filter['value'] = get_taglist($query);  
     231  } 
     232  else if ($filter['type'] == 'album') 
     233  { 
     234    $filter['value'] = explode(',', $filter['value']);  
    222235  } 
    223236   
     
    237250  FROM '.TAGS_TABLE.' 
    238251;'; 
    239 $all_tags = get_taglist($query); 
     252$template->assign('all_tags', get_taglist($query)); 
     253 
     254/* all albums */ 
     255$query = ' 
     256SELECT  
     257    id,  
     258    name,  
     259    uppercats,  
     260    global_rank 
     261  FROM '.CATEGORIES_TABLE.' 
     262;'; 
     263display_select_cat_wrapper($query, array(), 'all_albums'); 
    240264 
    241265/* get image number */ 
     
    254278} 
    255279 
     280 
     281/* template vars */ 
    256282if (isset($_GET['new_smart'])) 
    257283{ 
     
    261287$template->assign(array( 
    262288  'COUNT_SCRIPT_URL' => SMART_PATH.'include/count_images.php', 
    263   'all_tags' => $all_tags, 
    264289  'level_options' => get_privacy_level_options(), 
    265290  'F_ACTION' => $self_url, 
  • extensions/SmartAlbums/admin/template/album.tpl

    r16924 r17677  
    11{combine_css path=$SMART_PATH|@cat:"admin/template/style.css"} 
     2 
    23{include file='include/datepicker.inc.tpl'} 
    34{combine_script id='jquery.tokeninput' load='async' require='jquery' path='themes/default/js/plugins/jquery.tokeninput.js'} 
    45 
    5 {footer_script require='jquery.tokeninput'} 
     6{combine_css path="themes/default/js/plugins/chosen.css"} 
     7{combine_script id='jquery.chosen' load='footer' path='themes/default/js/plugins/chosen.jquery.min.js'} 
     8 
     9{footer_script require='jquery.tokeninput,jquery.chosen'} 
    610var lang = new Array(); 
    711var options = new Array(); 
     
    1317{/foreach} 
    1418 
     19lang['Select albums...'] = '{'Select albums...'|@translate}'; 
    1520lang['For "Is (not) in", separate each author by a comma'] = '{'For "Is (not) in", separate each author by a comma'|@translate|escape:javascript}'; 
    1621lang['remove this filter'] = '{'remove this filter'|@translate|escape:javascript}'; 
    1722{capture assign="option_content"}{html_options options=$level_options selected=0}{/capture} 
    1823options['level_options'] = "{$option_content|escape:javascript}"; 
     24{capture assign="option_content"}{html_options options=$all_albums selected=0}{/capture} 
     25options['album_options'] = "{$option_content|escape:javascript}"; 
    1926 
    2027{literal} 
     
    5865    ' <span class="filter-value">'; 
    5966   
    60   if (type == 'tags') 
     67  if (type == 'tags') { 
    6168    content+= ' <select name="filters['+ i +'][value]" class="tagSelect"></select>'; 
    62   else if (type == 'level') 
     69  } 
     70  else if (type == 'album') { 
     71    content+= ' <select name="filters['+ i +'][value][]" class="albumSelect" multiple="multiple" data-placeholder="'+ lang['Select albums...'] +'">'+ options['album_options'] +'</select>'; 
     72  } 
     73  else if (type == 'level') { 
    6374    content+= ' <select name="filters['+ i +'][value]">'+ options['level_options'] +'</select>'; 
    64   else 
     75  } 
     76  else { 
    6577    content+= ' <input type="text" name="filters['+ i +'][value]" size="30"/>'; 
    66    
    67   if (type == 'author') 
     78  } 
     79   
     80  if (type == 'author') { 
    6881    content+= ' <i>'+ lang['For "Is (not) in", separate each author by a comma'] +'</i>'; 
     82  } 
    6983     
    7084  content+= '</span>'; 
     
    100114    } 
    101115  ); 
     116   
     117  jQuery(".albumSelect").chosen(); 
    102118} 
    103119 
     
    160176            {/foreach} 
    161177            </select> 
     178          {elseif $filter.TYPE == 'album'} 
     179            <select name="filters[{$i}][value][]" class="albumSelect" multiple="multiple" data-placeholder="{'Select albums...'|@translate}"> 
     180              {html_options options=$all_albums selected=$filter.VALUE} 
     181            </select> 
    162182          {elseif $filter.TYPE == 'level'} 
    163183            <select name="filters[{$i}][value]"> 
     
    185205          <option value="date">{'Date'|@translate}</option> 
    186206          <option value="name">{'Photo name'|@translate}</option> 
     207          <option value="album">{'Album'|@translate}</option> 
    187208          <option value="author">{'Author'|@translate}</option> 
    188209          <option value="hit">{'Hits'|@translate}</option> 
  • extensions/SmartAlbums/admin/template/style.css

    r16104 r17677  
    6060  border-radius:4px; 
    6161} 
     62 
     63.albumSelect { 
     64  width:600px; 
     65} 
     66  .chzn-container { 
     67    font-size:12px !important; 
     68  } 
     69  .chzn-choices li { 
     70    margin-bottom:1px !important; 
     71    padding: 3px 20px 3px 5px !important; 
     72    border-bottom-style:solid !important; 
     73  } 
     74  .search-field { 
     75    border-width:0px !important; 
     76  } 
     77  .chzn-choices .search-field input { 
     78    padding-bottom:1px !important; 
     79  } 
  • extensions/SmartAlbums/include/count_images.php

    r16104 r17677  
    1111if (!is_admin()) die('Hacking attempt!'); 
    1212 
    13 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 
    14 include_once(SMART_PATH.'include/functions.inc.php'); 
    15  
    16 load_language('plugin.lang', SMART_PATH); 
    17 $conf['SmartAlbums'] = unserialize($conf['SmartAlbums']); 
    1813 
    1914if (isset($_POST['filters'])) 
  • extensions/SmartAlbums/include/functions.inc.php

    r17013 r17677  
    254254      } 
    255255       
     256      // album 
     257      case 'album': 
     258      { 
     259        switch ($filter['cond']) 
     260        { 
     261          // search images existing in all albums 
     262          case 'all': 
     263          { 
     264            $albums_arr = explode(',', $filter['value']); 
     265            foreach($albums_arr as $value) 
     266            { 
     267              $sub_query = ' 
     268      SELECT image_id  
     269        FROM '.IMAGE_CATEGORY_TABLE.' 
     270        WHERE category_id = '.$value.' 
     271      '; 
     272              $where[] = 'i.id IN ('.$sub_query.')'; 
     273            } 
     274             
     275            break; 
     276          } 
     277          // search images existing in one of these albums 
     278          case 'one': 
     279          { 
     280            $sub_query = ' 
     281      SELECT image_id 
     282        FROM '.IMAGE_CATEGORY_TABLE.' 
     283        WHERE category_id IN('.$filter['value'].') 
     284      '; 
     285            $where[] = 'i.id IN ('.$sub_query.')'; 
     286             
     287            break; 
     288          } 
     289          // exclude images existing in one of these albums 
     290          case 'none': 
     291          { 
     292            $sub_query = ' 
     293      SELECT image_id 
     294        FROM '.IMAGE_CATEGORY_TABLE.' 
     295        WHERE category_id IN('.$filter['value'].') 
     296      '; 
     297            $where[] = 'i.id NOT IN ('.$sub_query.')'; 
     298             
     299            break; 
     300          } 
     301          // exclude images existing on other albums, and search images existing in all albums 
     302          case 'only': 
     303          { 
     304            $sub_query = ' 
     305      SELECT image_id 
     306        FROM '.IMAGE_CATEGORY_TABLE.' 
     307        WHERE category_id NOT IN('.$filter['value'].') 
     308      '; 
     309            $where[] = 'i.id NOT IN ('.$sub_query.')'; 
     310             
     311            $albums_arr = explode(',', $filter['value']); 
     312            foreach($albums_arr as $value) 
     313            { 
     314              $sub_query = ' 
     315      SELECT image_id  
     316        FROM '.IMAGE_CATEGORY_TABLE.' 
     317        WHERE category_id = '.$value.' 
     318      '; 
     319              $where[] = 'i.id IN ('.$sub_query.')'; 
     320            } 
     321             
     322            break; 
     323          } 
     324        } 
     325         
     326        break; 
     327      } 
     328       
    256329      // author 
    257330      case 'author': 
     
    398471      $error = true; 
    399472      array_push($page['errors'], l10n('Name is empty')); 
     473    } 
     474  } 
     475  # album 
     476  else if ($filter['type'] == 'album') 
     477  { 
     478    if (@$filter['value'] == null) 
     479    { 
     480      $error = true; 
     481      array_push($page['errors'], l10n('No album selected')); 
     482    } 
     483    else 
     484    { 
     485      $filter['value'] = implode(',', $filter['value']); 
    400486    } 
    401487  } 
  • extensions/SmartAlbums/language/en_UK/plugin.lang.php

    r16939 r17677  
    88$lang['None of these tags'] = 'None of these tags'; 
    99$lang['Only these tags'] = 'Only these tags'; 
     10$lang['All these albums'] = 'All these albums'; 
     11$lang['One of these albums'] = 'One of these albums'; 
     12$lang['None of these albums'] = 'None of these albums'; 
     13$lang['Only these albums'] = 'Only these albums'; 
    1014$lang['Added on'] = 'Added on'; 
    1115$lang['Added before'] = 'Added before'; 
     
    3337$lang['All SmartAlbums'] = 'All SmartAlbums'; 
    3438$lang['No tag selected'] = 'No tag selected'; 
     39$lang['No album selected'] = 'No album selected'; 
    3540$lang['Date string is malformed'] = 'Date string is malformed'; 
    3641$lang['Name is empty'] = 'Name is empty'; 
  • extensions/SmartAlbums/language/fr_FR/plugin.lang.php

    r16939 r17677  
    88$lang['None of these tags'] = 'Aucun des tags'; 
    99$lang['Only these tags'] = 'Seulement les tags'; 
     10$lang['All these albums'] = 'Tous les albums'; 
     11$lang['One of these albums'] = 'Un des albums'; 
     12$lang['None of these albums'] = 'Aucun des albums'; 
     13$lang['Only these albums'] = 'Seulement les albums'; 
    1014$lang['Added on'] = 'Ajouté le'; 
    1115$lang['Added before'] = 'Ajouté avant le'; 
     
    3337$lang['All SmartAlbums'] = 'Tous les  SmartAlbums'; 
    3438$lang['No tag selected'] = 'Aucun tag sélectionné'; 
     39$lang['No album selected'] = 'Aucun album sélectionné'; 
    3540$lang['Date string is malformed'] = 'Date incorrecte'; 
    3641$lang['Name is empty'] = 'Le nom est vide'; 
Note: See TracChangeset for help on using the changeset viewer.