From 2fa746ff100edb9cfa4f7803cab2bfa8ca14ab7b Mon Sep 17 00:00:00 2001 From: rvelices Date: Sun, 6 Apr 2014 06:33:46 +0000 Subject: bug 3056: quick search - added events for plugins; completed help file git-svn-id: http://piwigo.org/svn/trunk@28092 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions_search.inc.php | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/functions_search.inc.php b/include/functions_search.inc.php index 85cfeee78..e9d04d09f 100644 --- a/include/functions_search.inc.php +++ b/include/functions_search.inc.php @@ -867,18 +867,17 @@ function qsearch_get_images(QExpression $expr, QResults $qsr) case 'photo': $clauses[] = $file_like; - if ($inflector!=null && strlen($term)>2 + $variants = array(); + if (strlen($term)>2 && ($expr->stoken_modifiers[$i] & (QST_QUOTED|QST_WILDCARD))==0 - && strcspn($term, '\'0123456789') == strlen($term) - ) + && strcspn($term, '\'0123456789') == strlen($term) ) { - $variants = array_unique( array_diff( $inflector->get_variants($term), array($term) ) ); + if ($inflector!=null) + $variants = array_unique( array_diff( $inflector->get_variants($term), array($term) ) ); + $variants = trigger_event('qsearch_get_variants', $variants, $token, $expr); + $variants = array_unique( array_diff( $variants, array($term) ) ); $qsr->variants[$term] = $variants; } - else - { - $variants = array(); - } if (strlen($term)>3) // default minimum full text index { @@ -930,7 +929,10 @@ function qsearch_get_images(QExpression $expr, QResults $qsr) case 'posted': $clauses[] = $token->scope->get_sql('date_available', $token); break; - + default: + // allow plugins to have their own scope with columns added in db by themselves + $clauses = trigger_event('qsearch_get_images_sql_scopes', $clauses, $token, $expr); + break; } if (!empty($clauses)) { @@ -1216,7 +1218,7 @@ function get_quick_search_results($q, $options) $scopes[] = new QNumericRangeScope('hits', array('hit', 'visit', 'visits')); $scopes[] = new QNumericRangeScope('score', array('rating'), true); - $createdDateAliases = array('taken'); + $createdDateAliases = array('taken', 'shot'); $postedDateAliases = array('added'); if ($conf['calendar_datefield'] == 'date_creation') $createdDateAliases[] = 'date'; @@ -1225,13 +1227,22 @@ function get_quick_search_results($q, $options) $scopes[] = new QDateRangeScope('created', $createdDateAliases, true); $scopes[] = new QDateRangeScope('posted', $postedDateAliases); + // allow plugins to add their own scopes + $scopes = trigger_event('qsearch_get_scopes', $scopes); $expression = new QExpression($q, $scopes); + trigger_action('qsearch_expression_parsed', $expression); //var_export($expression); + if (count($expression->stokens)==0) + { + return $search_results; + } $qsr = new QResults; qsearch_get_tags($expression, $qsr); qsearch_get_images($expression, $qsr); -//var_export($qsr->all_tags); + + // allow plugins to evaluate their own scopes + trigger_action('qsearch_before_eval', $expression, $qsr); $ids = qsearch_eval($expression, $qsr, $tmp, $search_results['qs']['unmatched_terms']); -- cgit v1.2.3