Skip to content

Commit

Permalink
bug 3056: quick search - added events for plugins; completed help file
Browse files Browse the repository at this point in the history
git-svn-id: http://piwigo.org/svn/trunk@28092 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
rvelices committed Apr 6, 2014
1 parent 35fd7da commit 2fa746f
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 23 deletions.
33 changes: 22 additions & 11 deletions include/functions_search.inc.php
Expand Up @@ -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
{
Expand Down Expand Up @@ -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))
{
Expand Down Expand Up @@ -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';
Expand All @@ -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']);

Expand Down
41 changes: 29 additions & 12 deletions language/en_UK/help/quick_search.html
Expand Up @@ -34,7 +34,7 @@ <h2>Search</h2>
<td>either term<br>
<q>OR search</q><br>
</td>
<td>Add a OR between words.<br>
<td>Add an OR between words.<br>
<q>john OR bill</q></td>
</tr>

Expand Down Expand Up @@ -63,29 +63,34 @@ <h2>Search</h2>
<table style="border-collapse:collapse;text-align:left">

<tr>
<td><q>tag:</q>
<td><q>tag:</q><br>
<q>tags:</q>
</td>
<td>Searches only in tag names without looking at photo titles or descriptions.<br>
<q>tag:john</q>, <q>tag:(john OR bill)</q></td>
</tr>

<tr>
<td><q>photo:</q>
<td><q>photo:</q><br>
<q>photos:</q>
</td>
<td></td>
<td>Searches only for photos with the given words in title or description.<br>
<q>photo:John</q></td>
</tr>

<tr>
<td><q>file:</q>
</td>
<td>Searches by file name.</td>
<td>Searches by file name.<br>
<q>file:DSC_</q></td>
</tr>

<tr>
<td><q>created:</q><br>
<q>taken:</q>
<q>shot:</q>
</td>
<td>Searches photos by taken date<br>
<td>Searches photos by taken date.<br>
<q>taken:2003</q> photos taken in 2003<br>
<q>taken:20035</q>,<q>taken:2003-5</q>,<q>taken:2003-05</q> photos from may 2003<br>
<q>taken:2003..2008</q> photos from 2003 to 2008<br>
Expand All @@ -96,34 +101,46 @@ <h2>Search</h2>
<tr>
<td><q>posted:</q>
</td>
<td></td>
<td>Searches photos by posted date.</td>
</tr>

<tr>
<td><q>width:</q><br>
<q>height:</q>
</td>
<td></td>
<td>Searches photos with a given width or height.</td>
</tr>
<tr>
<td><q>size:</q>
</td>
<td></td>
<td>Searches photos by size in pixels<br>
<q>size:5m</q> returns photos of 5 megapixels<br>
<q>size:>12m</q> returns photos of 12 megapixels or more<br></td>
</tr>
<tr>
<td><q>ratio:</q>
</td>
<td></td>
<td>Searches photos by width/height ratio.<br>
<q>ratio:3/4 OR ratio:4/3</q> finds photos from compact cameras in portrait or landscape modes
<q>ratio:>16/9</q> finds panoramas
</td>
</tr>
<tr>
<td><q>hits:</q>
</td>
<td></td>
</tr>
<tr>
<td><q>score:</q>
<td><q>score:</q><br>
<q>rating:</q>
</td>
<td></td>
<td>Hint: <q>score:*</q> will give you all photos with at least one vote. <q>score:</q> will give you photos without votes.</td>
</tr>
<tr>
<td><q>filesize:</q>
</td>
<td>Searches photos by file size<br>
<q>filesize:1m..10m</q> finds files between 1MB and 10MB.</td>
</tr>

</table>

0 comments on commit 2fa746f

Please sign in to comment.