aboutsummaryrefslogtreecommitdiffstats
path: root/include/ws_functions.inc.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2007-10-12 03:27:34 +0000
committerrvelices <rv-github@modusoptimus.com>2007-10-12 03:27:34 +0000
commit4afa14cc8d3f26f841c92b083355004251d75087 (patch)
tree99606ff8bf43f5c30f50d191f3593a5ca6a43260 /include/ws_functions.inc.php
parent36e0e6e8f1a455367f363048fc1825aebbd67eee (diff)
- fix plugin menu link broken with xamp (realpath behaves differently)
- complete quick search rewriting - now we can quote phrases as in google "New York" is not the same as New York - user comments not searched anymore (faster) - the big full text query does not use joins anymore (faster) - related tags not shown on the index page, but now you can see the matching tags and matching categories git-svn-id: http://piwigo.org/svn/trunk@2135 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/ws_functions.inc.php52
1 files changed, 8 insertions, 44 deletions
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php
index 808f45644..1adc48c39 100644
--- a/include/ws_functions.inc.php
+++ b/include/ws_functions.inc.php
@@ -759,55 +759,19 @@ function ws_images_search($params, &$service)
include_once( PHPWG_ROOT_PATH .'include/functions_search.inc.php' );
include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
- $where_clauses = ws_std_image_sql_filter( $params );
- $order_by = ws_std_image_sql_order($params);
+ $where_clauses = ws_std_image_sql_filter( $params, 'i.' );
+ $order_by = ws_std_image_sql_order($params, 'i.');
- if ( !empty($where_clauses) and !empty($order_by) )
+ if ( !empty($order_by) )
{
+ global $conf;
+ $conf['order_by'] = 'ORDER BY '.$order_by;
$page['super_order_by']=1; // quick_search_result might be faster
}
- $search_result = get_quick_search_results($params['query']);
- global $image_ids; //needed for sorting by rank (usort)
- if ( ( !isset($search_result['as_is'])
- or !empty($where_clauses)
- or !empty($order_by) )
- and !empty($search_result['items']) )
- {
- $where_clauses[] = 'id IN ('
- .wordwrap(implode(', ', $search_result['items']), 80, "\n")
- .')';
- $where_clauses[] = get_sql_condition_FandF(
- array
- (
- 'forbidden_categories' => 'category_id',
- 'visible_categories' => 'category_id',
- 'visible_images' => 'id'
- ),
- '', true
- );
- $query = '
-SELECT DISTINCT id FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id=image_id
- WHERE '.implode('
- AND ', $where_clauses);
- if (!empty($order_by))
- {
- $query .= '
- ORDER BY '.$order_by;
- }
- $image_ids = array_from_query($query, 'id');
- global $ranks;
- $ranks = array_flip( $search_result['items'] );
- usort(
- $image_ids,
- create_function('$i1,$i2', 'global $ranks; return $ranks[$i1]-$ranks[$i2];')
- );
- unset ($ranks);
- }
- else
- {
- $image_ids = $search_result['items'];
- }
+ $search_result = get_quick_search_results($params['query'],
+ implode(',', $where_clauses) );
+ $image_ids = $search_result['items'];
$image_ids = array_slice($image_ids,
$params['page']*$params['per_page'],