feature 3093: search form, ability to select the list of properties on which

the search terms applies.

feature 3094: minor redesign on search form.


git-svn-id: http://piwigo.org/svn/trunk@28709 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
plegall
2014-06-17 11:11:44 +00:00
parent 583af81d3d
commit 6f8caf22ba
6 changed files with 73 additions and 32 deletions
+7 -1
View File
@@ -85,7 +85,13 @@ function get_sql_search_clause($search)
if (isset($search['fields']['allwords'])) if (isset($search['fields']['allwords']))
{ {
$fields = array('file', 'name', 'comment', 'author'); $fields = array('file', 'name', 'comment');
if (isset($search['fields']['allwords']['fields']) and count($search['fields']['allwords']['fields']) > 0)
{
$fields = array_intersect($fields, $search['fields']['allwords']['fields']);
}
// in the OR mode, request bust be : // in the OR mode, request bust be :
// ((field1 LIKE '%word1%' OR field2 LIKE '%word1%') // ((field1 LIKE '%word1%' OR field2 LIKE '%word1%')
// OR (field1 LIKE '%word2%' OR field2 LIKE '%word2%')) // OR (field1 LIKE '%word2%' OR field2 LIKE '%word2%'))
+3
View File
@@ -419,4 +419,7 @@ $lang['Password confirmation is missing. Please confirm the chosen password.'] =
$lang['%d photos per page'] = '%d photos per page'; $lang['%d photos per page'] = '%d photos per page';
$lang['Theme'] = 'Theme'; $lang['Theme'] = 'Theme';
$lang['No results for'] = 'No results for'; $lang['No results for'] = 'No results for';
$lang['Apply on properties'] = 'Apply on properties';
$lang['Photo title'] = 'Photo title';
$lang['Photo description'] = 'Photo description';
?> ?>
+4 -1
View File
@@ -418,4 +418,7 @@ $lang['Password is missing. Please enter the password.'] = "Le mot de passe manq
$lang['Password confirmation is missing. Please confirm the chosen password.'] = "La confirmation du mot de passe manque. Veuillez confirmer le mot de passe choisi."; $lang['Password confirmation is missing. Please confirm the chosen password.'] = "La confirmation du mot de passe manque. Veuillez confirmer le mot de passe choisi.";
$lang['%d photos per page'] = '%d photos par page'; $lang['%d photos per page'] = '%d photos par page';
$lang['Theme'] = 'Thème'; $lang['Theme'] = 'Thème';
$lang['No results for'] = 'Aucun résultat pour'; $lang['No results for'] = 'Aucun résultat pour';
$lang['Apply on properties'] = 'Appliquer sur les propriétés';
$lang['Photo title'] = 'Titre de la photo';
$lang['Photo description'] = 'Description de la photo';
+3
View File
@@ -48,6 +48,8 @@ if (isset($_POST['submit']))
and !preg_match('/^\s*$/', $_POST['search_allwords'])) and !preg_match('/^\s*$/', $_POST['search_allwords']))
{ {
check_input_parameter('mode', $_POST, false, '/^(OR|AND)$/'); check_input_parameter('mode', $_POST, false, '/^(OR|AND)$/');
$fields = array_intersect($_POST['fields'], array('name', 'comment', 'file'));
$drop_char_match = array( $drop_char_match = array(
'-','^','$',';','#','&','(',')','<','>','`','\'','"','|',',','@','_', '-','^','$',';','#','&','(',')','<','>','`','\'','"','|',',','@','_',
@@ -69,6 +71,7 @@ if (isset($_POST['submit']))
) )
), ),
'mode' => $_POST['mode'], 'mode' => $_POST['mode'],
'fields' => $fields,
); );
} }
+27 -27
View File
@@ -31,39 +31,46 @@ jQuery(document).ready(function() {
<form class="filter" method="post" name="search" action="{$F_SEARCH_ACTION}"> <form class="filter" method="post" name="search" action="{$F_SEARCH_ACTION}">
<fieldset> <fieldset>
<legend>{'Filter'|@translate}</legend> <legend>{'Search for words'|@translate}</legend>
<label>{'Search for words'|@translate} <p>
<input type="text" name="search_allwords" size="35"> <input type="text" name="search_allwords">
</label> <br>
<ul> <label><input type="radio" name="mode" value="AND" checked="checked">{'Search for all terms'|@translate}</label>
<li><label> <label><input type="radio" name="mode" value="OR">{'Search for any term'|@translate}</label>
<input type="radio" name="mode" value="AND" checked="checked">{'Search for all terms'|@translate} </p>
</label></li>
<li><label> <p>
<input type="radio" name="mode" value="OR">{'Search for any term'|@translate} <strong>{'Apply on properties'|translate}</strong><br>
</label></li> <label><input type="checkbox" name="fields[]" value="name" checked="checked">{'Photo title'|translate}</label>
</ul> <label><input type="checkbox" name="fields[]" value="comment" checked="checked">{'Photo description'|translate}</label>
<label>{'Search for Author'|@translate} <label><input type="checkbox" name="fields[]" value="file" checked="checked">{'File name'|translate}</label>
</p>
</fieldset>
<fieldset>
<legend>{'Search for Author'|@translate}</legend>
<p>
<select id="authors" placeholder="{'Type in a search term'|translate}" name="authors[]" multiple style="width:500px;"> <select id="authors" placeholder="{'Type in a search term'|translate}" name="authors[]" multiple style="width:500px;">
{foreach from=$AUTHORS item=author} {foreach from=$AUTHORS item=author}
<option value="{$author.author|strip_tags:false|escape:html}">{$author.author|strip_tags:false} ({$author.counter|translate_dec:'%d photo':'%d photos'})</option> <option value="{$author.author|strip_tags:false|escape:html}">{$author.author|strip_tags:false} ({$author.counter|translate_dec:'%d photo':'%d photos'})</option>
{/foreach} {/foreach}
</select> </select>
</label> </p>
</fieldset> </fieldset>
{if isset($TAGS)} {if isset($TAGS)}
<fieldset> <fieldset>
<legend>{'Search tags'|@translate}</legend> <legend>{'Search tags'|@translate}</legend>
<p>
<select id="tags" placeholder="{'Type in a search term'|translate}" name="tags[]" multiple style="width:500px;"> <select id="tags" placeholder="{'Type in a search term'|translate}" name="tags[]" multiple style="width:500px;">
{foreach from=$TAGS item=tag} {foreach from=$TAGS item=tag}
<option value="{$tag.id}">{$tag.name} ({$tag.counter|translate_dec:'%d photo':'%d photos'})</option> <option value="{$tag.id}">{$tag.name} ({$tag.counter|translate_dec:'%d photo':'%d photos'})</option>
{/foreach} {/foreach}
</select> </select>
<label><span><input type="radio" name="tag_mode" value="AND" checked="checked"> {'All tags'|@translate}</span></label> <label><span><input type="radio" name="tag_mode" value="AND" checked="checked"> {'All tags'|@translate}</span></label>
<label><span><input type="radio" name="tag_mode" value="OR"> {'Any tag'|@translate}</span></label> <label><span><input type="radio" name="tag_mode" value="OR"> {'Any tag'|@translate}</span></label>
</p>
</fieldset> </fieldset>
{/if} {/if}
@@ -120,20 +127,13 @@ jQuery(document).ready(function() {
<fieldset> <fieldset>
<legend>{'Search in albums'|@translate}</legend> <legend>{'Search in albums'|@translate}</legend>
<label>{'Albums'|@translate} <p>
<select class="categoryList" name="cat[]" multiple="multiple" size="15"> <select class="categoryList" name="cat[]" multiple="multiple" size="15">
{html_options options=$category_options selected=$category_options_selected} {html_options options=$category_options selected=$category_options_selected}
</select> </select>
</label> <br>
<ul> <label><input type="checkbox" name="subcats-included" value="1" checked="checked">{'Search in sub-albums'|@translate}</label>
<li><label>{'Search in sub-albums'|@translate}</label></li> </p>
<li><label>
<input type="radio" name="subcats-included" value="1" checked="checked">{'Yes'|@translate}
</label></li>
<li><label>
<input type="radio" name="subcats-included" value="0">{'No'|@translate}
</label></li>
</ul>
</fieldset> </fieldset>
<p> <p>
<input class="submit" type="submit" name="submit" value="{'Submit'|@translate}"> <input class="submit" type="submit" name="submit" value="{'Submit'|@translate}">
+29 -3
View File
@@ -509,8 +509,7 @@ FIELDSET {
margin: 1em; margin: 1em;
} }
.filter UL, .filter UL {
.filter LABEL {
display: block; display: block;
float: left; float: left;
margin-right: 1em; margin-right: 1em;
@@ -522,15 +521,42 @@ FIELDSET {
margin-bottom: 0.5em; margin-bottom: 0.5em;
} }
.filter FIELDSET {
padding-bottom:0;
}
.filter LI LABEL { .filter LI LABEL {
display: inline; display: inline;
float: none; float: none;
} }
.filter P {
text-align:left;
margin:0 0 15px 0;
line-height:20px;
}
.filter input[name="search_allwords"] {
width:500px;
}
.filter P input[type="checkbox"], .filter P input[type="radio"] {
vertical-align:middle;
margin-top:-4px;
}
.filter input[type="submit"] {
margin-left:1em;
}
.filter P LABEL {
margin-right:1em;
}
/*IE6 needs override because of > selector*/ /*IE6 needs override because of > selector*/
.filter LABEL>INPUT, .filter LABEL>INPUT,
.filter LABEL>SELECT { .filter LABEL>SELECT {
display: block; /* display: block; */
margin: 0.5em 0; margin: 0.5em 0;
} }