Пример #1
0
/**
 * Returns the search results corresponding to a quick/query search.
 * A quick/query search returns many items (search is not strict), but results
 * are sorted by relevance unless $super_order_by is true. Returns:
 *  array (
 *    'items' => array of matching images
 *    'qs'    => array(
 *      'unmatched_terms' => array of terms from the input string that were not matched
 *      'matching_tags' => array of matching tags
 *      'matching_cats' => array of matching categories
 *      'matching_cats_no_images' =>array(99) - matching categories without images
 *      )
 *    )
 *
 * @param string $q
 * @param bool $super_order_by
 * @param string $images_where optional additional restriction on images table
 * @return array
 */
function get_quick_search_results($q, $options)
{
    global $persistent_cache, $conf, $user;
    $cache_key = $persistent_cache->make_key(array(strtolower($q), $conf['order_by'], $user['id'], $user['cache_update_time'], isset($options['permissions']) ? (bool) $options['permissions'] : true, isset($options['images_where']) ? $options['images_where'] : ''));
    if ($persistent_cache->get($cache_key, $res)) {
        return $res;
    }
    $res = get_quick_search_results_no_cache($q, $options);
    if (count($res['items'])) {
        // cache the results only if not empty - otherwise it is useless
        $persistent_cache->set($cache_key, $res, 300);
    }
    return $res;
}
Пример #2
0
    if (isset($_SESSION['bulk_manager_filter']['filesize']['min'])) {
        $where_clause[] = 'filesize >= ' . $_SESSION['bulk_manager_filter']['filesize']['min'] * 1024;
    }
    if (isset($_SESSION['bulk_manager_filter']['filesize']['max'])) {
        $where_clause[] = 'filesize <= ' . $_SESSION['bulk_manager_filter']['filesize']['max'] * 1024;
    }
    $query = '
SELECT id
  FROM ' . IMAGES_TABLE . '
  WHERE ' . implode(' AND ', $where_clause) . '
  ' . $conf['order_by'];
    $filter_sets[] = query2array($query, null, 'id');
}
if (isset($_SESSION['bulk_manager_filter']['search']) && strlen($_SESSION['bulk_manager_filter']['search']['q'])) {
    include_once PHPWG_ROOT_PATH . 'include/functions_search.inc.php';
    $res = get_quick_search_results_no_cache($_SESSION['bulk_manager_filter']['search']['q'], array('permissions' => false));
    if (!empty($res['items']) && !empty($res['qs']['unmatched_terms'])) {
        $template->assign('no_search_results', array_map('htmlspecialchars', $res['qs']['unmatched_terms']));
    }
    $filter_sets[] = $res['items'];
}
$filter_sets = trigger_change('batch_manager_perform_filters', $filter_sets, $_SESSION['bulk_manager_filter']);
$current_set = array_shift($filter_sets);
foreach ($filter_sets as $set) {
    $current_set = array_intersect($current_set, $set);
}
$page['cat_elements_id'] = $current_set;
// +-----------------------------------------------------------------------+
// |                       first element to display                        |
// +-----------------------------------------------------------------------+
// $page['start'] contains the number of the first element in its