Changeset 28087


Ignore:
Timestamp:
Apr 5, 2014, 9:24:27 PM (10 years ago)
Author:
rvelices
Message:

bug 3069: add quick search as filter in batch manager

Location:
trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/batch_manager.php

    r26461 r28087  
    8686    {
    8787      $_SESSION['bulk_manager_filter']['level'] = $_POST['filter_level'];
    88      
     88
    8989      if (isset($_POST['filter_level_include_lower']))
    9090      {
     
    9393    }
    9494  }
    95  
     95
    9696  if (isset($_POST['filter_dimension_use']))
    9797  {
     
    111111    }
    112112  }
     113
     114  if (isset($_POST['filter_search_use']))
     115  {
     116    $_SESSION['bulk_manager_filter']['search']['q'] = $_POST['q'];
     117  }
    113118}
    114119// filters from url
    115 else if (isset($_GET['filter']))
     120elseif (isset($_GET['filter']))
    116121{
    117122  if (!is_array($_GET['filter']))
     
    119124    $_GET['filter'] = explode(',', $_GET['filter']);
    120125  }
    121  
     126
    122127  $_SESSION['bulk_manager_filter'] = array();
    123  
     128
    124129  foreach ($_GET['filter'] as $filter)
    125130  {
    126131    list($type, $value) = explode('-', $filter);
    127    
     132
    128133    switch ($type)
    129134    {
     
    131136      $_SESSION['bulk_manager_filter']['prefilter'] = $value;
    132137      break;
    133    
     138
    134139    case 'album':
    135140      if (is_numeric($value))
     
    138143      }
    139144      break;
    140      
     145
    141146    case 'tag':
    142147      if (is_numeric($value))
     
    146151      }
    147152      break;
    148      
     153
    149154    case 'level':
    150155      if (is_numeric($value) && in_array($value, $conf['available_permission_levels']))
     
    179184;';
    180185    $filter_sets[] = array_from_query($query, 'element_id');
    181    
     186
    182187    break;
    183188
     
    189194;';
    190195    $filter_sets[] = array_from_query($query, 'image_id');
    191    
     196
    192197    break;
    193198
     
    207212      $filter_sets[] = array_from_query($query, 'id');
    208213    }
    209    
     214
    210215    break;
    211216
     
    235240
    236241    $filter_sets[] = array_diff($all_elements, $linked_to_virtual);
    237    
     242
    238243    break;
    239244
     
    247252;';
    248253    $filter_sets[] = array_from_query($query, 'id');
    249    
     254
    250255    break;
    251256
     
    259264;';
    260265    $filter_sets[] = array_from_query($query, 'id');
    261    
     266
    262267    break;
    263268
     
    281286;';
    282287    $filter_sets[] = array_from_query($query, 'id');
    283    
     288
    284289    break;
    285290
     
    291296
    292297    $filter_sets[] = array_from_query($query, 'id');
    293    
     298
    294299    break;
    295300  }
     
    326331    $operator = '<=';
    327332  }
    328  
     333
    329334  $query = '
    330335SELECT id
     
    375380    $where_clause[] = 'width/height < '.($_SESSION['bulk_manager_filter']['dimension']['max_ratio']+0.01);
    376381  }
    377  
     382
    378383  $query = '
    379384SELECT id
     
    383388
    384389  $filter_sets[] = array_from_query($query, 'id');
     390}
     391
     392if (isset($_SESSION['bulk_manager_filter']['search']))
     393{
     394  include_once( PHPWG_ROOT_PATH .'include/functions_search.inc.php' );
     395  $res = get_quick_search_results($_SESSION['bulk_manager_filter']['search']['q'], array('permissions'=>false));
     396  $filter_sets[] = $res['items'];
    385397}
    386398
  • trunk/admin/batch_manager_global.php

    r26461 r28087  
    8787
    8888  $action = $_POST['selectAction'];
    89  
     89
    9090  if ('remove_from_caddie' == $action)
    9191  {
     
    148148      l10n('Information data registered in database')
    149149      );
    150    
     150
    151151    // let's refresh the page because we the current set might be modified
    152152    if ('no_album' == $page['prefilter'])
     
    172172      l10n('Information data registered in database')
    173173      );
    174    
     174
    175175    // let's refresh the page because we the current set might be modified
    176176    if ('no_album' == $page['prefilter'])
     
    225225        l10n('Information data registered in database')
    226226        );
    227      
     227
    228228      // let's refresh the page because the current set might be modified
    229229      redirect($redirect_url);
     
    238238      $_POST['author'] = null;
    239239    }
    240    
     240
    241241    $datas = array();
    242242    foreach ($collection as $image_id)
     
    262262      $_POST['title'] = null;
    263263    }
    264    
     264
    265265    $datas = array();
    266266    foreach ($collection as $image_id)
     
    278278      );
    279279  }
    280  
     280
    281281  // date_creation
    282282  if ('date_creation' == $action)
     
    309309      );
    310310  }
    311  
     311
    312312  // privacy_level
    313313  if ('level' == $action)
     
    336336    }
    337337  }
    338  
     338
    339339  // add_to_caddie
    340340  if ('add_to_caddie' == $action)
     
    342342    fill_caddie($collection);
    343343  }
    344  
     344
    345345  // delete
    346346  if ('delete' == $action)
     
    665665SELECT id,path,representative_ext,file,filesize,level,name,width,height,rotation
    666666  FROM '.IMAGES_TABLE;
    667  
     667
    668668  if ($is_category)
    669669  {
    670670    $category_info = get_cat_info($_SESSION['bulk_manager_filter']['category']);
    671    
     671
    672672    $conf['order_by'] = $conf['order_by_inside_category'];
    673673    if (!empty($category_info['image_order']))
  • trunk/admin/themes/default/template/batch_manager_global.tpl

    r26179 r28087  
    666666        <input type="hidden" name="filter_dimension_max_ratio" value="{$dimensions.selected.max_ratio}">
    667667      </li>
     668
     669                        <li id="filter_search"{if !isset($filter.search)} style="display:none"{/if}>
     670                                <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
     671                                <input type="checkbox" name="filter_search_use" class="useFilterCheckbox"{if isset($filter.search)} checked="checked"{/if}>
     672                                {'Search'|@translate}
     673                                <input name="q" size=40 value="{$filter.search.q|stripslashes|htmlspecialchars}">
     674                                {combine_script id='core.scripts' load='async' path='themes/default/js/scripts.js'}
     675                                <a href="admin/popuphelp.php?page=quick_search"onclick="popuphelp(this.href);return false;" title="{'Help'|@translate}"><span class="icon-help-circled"></span></a>
     676                        </li>
    668677    </ul>
    669678
     
    677686        <option value="filter_level" {if isset($filter.level)}disabled="disabled"{/if}>{'Privacy level'|@translate}</option>
    678687        <option value="filter_dimension" {if isset($filter.dimension)}disabled="disabled"{/if}>{'Dimensions'|@translate}</option>
     688                                <option value="filter_search"{if isset($filter.search)} disabled="disabled"{/if}>{'Search'|@translate}</option>
    679689      </select>
    680690      <a id="removeFilters" href="">{'Remove all filters'|@translate}</a>
  • trunk/include/functions_search.inc.php

    r28080 r28087  
    11941194 * @return array
    11951195 */
    1196 function get_quick_search_results($q, $super_order_by, $images_where='')
     1196function get_quick_search_results($q, $options)
    11971197{
    11981198  global $conf;
     
    12551255  }
    12561256
     1257  $permissions = !isset($options['permissions']) ? true : $options['permissions'];
     1258
    12571259  $where_clauses = array();
    12581260  $where_clauses[]='i.id IN ('. implode(',', $ids) . ')';
    1259   if (!empty($images_where))
     1261  if (!empty($options['images_where'))
    12601262  {
    12611263    $where_clauses[]='('.$images_where.')';
    12621264  }
    1263   $where_clauses[] = get_sql_condition_FandF(
    1264       array
    1265         (
    1266           'forbidden_categories' => 'category_id',
    1267           'visible_categories' => 'category_id',
    1268           'visible_images' => 'i.id'
    1269         ),
    1270       null,true
    1271     );
     1265  if ($permissions)
     1266  {
     1267    $where_clauses[] = get_sql_condition_FandF(
     1268        array
     1269          (
     1270            'forbidden_categories' => 'category_id',
     1271            'visible_categories' => 'category_id',
     1272            'visible_images' => 'i.id'
     1273          ),
     1274        null,true
     1275      );
     1276  }
    12721277
    12731278  $query = '
    1274 SELECT DISTINCT(id)
    1275   FROM '.IMAGES_TABLE.' i
    1276     INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
     1279SELECT DISTINCT(id) FROM '.IMAGES_TABLE.' i';
     1280  if ($permissions)
     1281  {
     1282    $query .= '
     1283    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id';
     1284  }
     1285  $query .= '
    12771286  WHERE '.implode("\n AND ", $where_clauses)."\n".
    12781287  $conf['order_by'];
     
    13061315  else
    13071316  {
    1308     return get_quick_search_results($search['q'], $super_order_by, $images_where);
     1317    return get_quick_search_results($search['q'], array('super_order_by'=>$super_order_by, 'images_where'=>$images_where) );
    13091318  }
    13101319}
  • trunk/include/ws_functions/pwg.images.php

    r26461 r28087  
    295295 *    @option string key
    296296 */
    297 function ws_images_addComment($params, &$service)
     297function ws_images_addComment($params, $service)
    298298{
    299299  $query = '
     
    355355 *    @option int comments_per_page
    356356 */
    357 function ws_images_getInfo($params, &$service)
     357function ws_images_getInfo($params, $service)
    358358{
    359359  global $user, $conf;
     
    580580 *    @option float rate
    581581 */
    582 function ws_images_rate($params, &$service)
     582function ws_images_rate($params, $service)
    583583{
    584584  $query = '
     
    621621 *    @option string order (optional)
    622622 */
    623 function ws_images_search($params, &$service)
     623function ws_images_search($params, $service)
    624624{
    625625  include_once(PHPWG_ROOT_PATH .'include/functions_search.inc.php');
     
    639639  $search_result = get_quick_search_results(
    640640    $params['query'],
    641     $super_order_by,
    642     implode(' AND ', $where_clauses)
     641    array(
     642      'super_order_by' => $super_order_by,
     643      'images_where' => implode(' AND ', $where_clauses)
     644    )
    643645    );
    644646
     
    705707 *    @option int level
    706708 */
    707 function ws_images_setPrivacyLevel($params, &$service)
     709function ws_images_setPrivacyLevel($params, $service)
    708710{
    709711  global $conf;
     
    738740 *    @option int rank
    739741 */
    740 function ws_images_setRank($params, &$service)
     742function ws_images_setRank($params, $service)
    741743{
    742744  // does the image really exist?
     
    821823 *    @option int position
    822824 */
    823 function ws_images_add_chunk($params, &$service)
     825function ws_images_add_chunk($params, $service)
    824826{
    825827  global $conf;
     
    878880 *    @option string sum
    879881 */
    880 function ws_images_addFile($params, &$service)
     882function ws_images_addFile($params, $service)
    881883{
    882884  ws_logfile(__FUNCTION__.', input :  '.var_export($params, true));
     
    971973 *    @option int image_id (optional)
    972974 */
    973 function ws_images_add($params, &$service)
     975function ws_images_add($params, $service)
    974976{
    975977  global $conf, $user;
     
    11341136 *    @option int image_id (optional)
    11351137 */
    1136 function ws_images_addSimple($params, &$service)
     1138function ws_images_addSimple($params, $service)
    11371139{
    11381140  global $conf;
     
    12481250 *    @option string filename_list (optional)
    12491251 */
    1250 function ws_images_exist($params, &$service)
     1252function ws_images_exist($params, $service)
    12511253{
    12521254  ws_logfile(__FUNCTION__.' '.var_export($params, true));
     
    13211323 *    @option string file_sum
    13221324 */
    1323 function ws_images_checkFiles($params, &$service)
     1325function ws_images_checkFiles($params, $service)
    13241326{
    13251327  ws_logfile(__FUNCTION__.', input :  '.var_export($params, true));
     
    13931395 *    @option string multiple_value_mode
    13941396 */
    1395 function ws_images_setInfo($params, &$service)
     1397function ws_images_setInfo($params, $service)
    13961398{
    13971399  include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
     
    15291531 *    @option string pwg_token
    15301532 */
    1531 function ws_images_delete($params, &$service)
     1533function ws_images_delete($params, $service)
    15321534{
    15331535  if (get_pwg_token() != $params['pwg_token'])
     
    15661568 * @param mixed[] $params
    15671569 */
    1568 function ws_images_checkUpload($params, &$service)
     1570function ws_images_checkUpload($params, $service)
    15691571{
    15701572  include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
Note: See TracChangeset for help on using the changeset viewer.