From 8b4857c7730a8c55396ac254c50a4ff1e0d8016b Mon Sep 17 00:00:00 2001 From: rvelices Date: Sat, 31 May 2014 18:50:30 +0000 Subject: quick search - small fixes & improvements available number of comments per user do not use visible_categories (only forbidden) git-svn-id: http://piwigo.org/svn/trunk@28579 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions.inc.php | 11 +++++------ include/functions_search.inc.php | 24 ++++++++++++++---------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/include/functions.inc.php b/include/functions.inc.php index bdd430171..ecc799a55 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -1176,16 +1176,16 @@ function conf_update_param($param, $value, $updateGlobal=false, $parser=null) { $dbValue = $value; } - + $query = ' INSERT INTO '.CONFIG_TABLE.' (param, value) VALUES(\''.$param.'\', \''.$dbValue.'\') ON DUPLICATE KEY UPDATE value = \''.$dbValue.'\' ;'; - + pwg_query($query); - + if ($updateGlobal) { global $conf; @@ -1368,7 +1368,7 @@ function get_filter_page_value($value_name) { return $conf['filter_pages'][$page_name][$value_name]; } - else if (isset($conf['filter_pages']['default'][$value_name])) + elseif (isset($conf['filter_pages']['default'][$value_name])) { return $conf['filter_pages']['default'][$value_name]; } @@ -1994,8 +1994,7 @@ function get_nb_available_comments() array ( 'forbidden_categories' => 'category_id', - 'visible_categories' => 'category_id', - 'visible_images' => 'ic.image_id' + 'forbidden_images' => 'ic.image_id' ), '', true ); diff --git a/include/functions_search.inc.php b/include/functions_search.inc.php index 6280c4d9d..1b3e521ea 100644 --- a/include/functions_search.inc.php +++ b/include/functions_search.inc.php @@ -606,7 +606,7 @@ class QMultiToken $crt_token .= $ch; break; } - if (strlen($crt_token) && preg_match('/[0-9]/', substr($crt_token,-1)) + if (strlen($crt_token) && preg_match('/[0-9]/', substr($crt_token,-1)) && $qi+1?@[\]^`{|}~','/').']+/', $variant, PREG_SPLIT_NO_EMPTY) + $max = max( array_map( 'mb_strlen', + preg_split('/['.preg_quote('-\'!"#$%&()*+,./:;<=>?@[\]^`{|}~','/').']+/', $variant) ) ); if ($max<4) $use_ft = false; @@ -966,7 +966,7 @@ WHERE ('. implode("\n OR ",$clauses) .')'; // check adjacent short words for ($i=0; $istokens)-1; $i++) { - if ( (strlen($expr->stokens[$i])<=3 || strlen($expr->stokens[$i+1])<=3) + if ( (strlen($expr->stokens[$i]->term)<=3 || strlen($expr->stokens[$i+1]->term)<=3) && (($expr->stoken_modifiers[$i] & (QST_QUOTED|QST_WILDCARD)) == 0) && (($expr->stoken_modifiers[$i+1] & (QST_BREAK|QST_QUOTED|QST_WILDCARD)) == 0) ) { @@ -995,11 +995,16 @@ SELECT image_id FROM '.IMAGE_TAG_TABLE.' if ($expr->stoken_modifiers[$i]&QST_NOT) $not_ids = array_merge($not_ids, $tag_ids); else - $positive_ids = array_merge($positive_ids, $tag_ids); + { + if (strlen($token->term)>2 || count($expr->stokens)==1 || isset($token->scope) || ($token->modifier&(QST_WILDCARD|QST_QUOTED)) ) + {// add tag ids to list only if the word is not too short (such as de / la /les ...) + $positive_ids = array_merge($positive_ids, $tag_ids); + } + } } elseif (isset($token->scope) && 'tag' == $token->scope->id && strlen($token->term)==0) { - if ($tokens[$i]->modifier & QST_WILDCARD) + if ($token->modifier & QST_WILDCARD) {// eg. 'tag:*' returns all tagged images $qsr->tag_iids[$i] = query2array('SELECT DISTINCT image_id FROM '.IMAGE_TAG_TABLE, null, 'image_id'); } @@ -1095,7 +1100,7 @@ function get_quick_search_results($q, $options) $cache_key = $persistent_cache->make_key( array( strtolower($q), $conf['order_by'], - $user['id'],$user['cache_update_time'], + $user['id'],$user['cache_update_time'], isset($options['permissions']) ? (boolean)$options['permissions'] : true, isset($options['images_where']) ? $options['images_where'] : '', ) ); @@ -1221,8 +1226,7 @@ function get_quick_search_results_no_cache($q, $options) array ( 'forbidden_categories' => 'category_id', - 'visible_categories' => 'category_id', - 'visible_images' => 'i.id' + 'forbidden_images' => 'i.id' ), null,true ); -- cgit v1.2.3