mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-27 19:59:56 +03:00
Search form update
git-svn-id: http://piwigo.org/svn/trunk@629 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
93c3c7d6e3
commit
19be28e415
7 changed files with 75 additions and 68 deletions
|
@ -39,7 +39,7 @@ $template->assign_vars(array(
|
|||
|
||||
'L_SEARCH_USERNAME'=>$lang['Find_username'],
|
||||
'L_SEARCH'=>$lang['search'],
|
||||
'L_SEARCH_EXPLAIN'=>$lang['Search_author_explain'],
|
||||
'L_SEARCH_EXPLAIN'=>$lang['search_explain'],
|
||||
'L_SELECT'=>$lang['Select'],
|
||||
'L_UPDATE_USERNAME'=>$lang['Look_up_user'],
|
||||
'L_CLOSE_WINDOW'=>$lang['Close'],
|
||||
|
|
|
@ -86,7 +86,7 @@ function username_search($search_match)
|
|||
'L_UPDATE_USERNAME' => $lang['Select_username'],
|
||||
'L_SELECT' => $lang['Select'],
|
||||
'L_SEARCH' => $lang['Search'],
|
||||
'L_SEARCH_EXPLAIN' => $lang['Search_author_explain'],
|
||||
'L_SEARCH_EXPLAIN' => $lang['search_explain'],
|
||||
'L_CLOSE_WINDOW' => $lang['Close_window'],
|
||||
|
||||
'S_USERNAME_OPTIONS' => $username_list,
|
||||
|
|
|
@ -416,29 +416,29 @@ function initialize_category( $calling_page = 'category' )
|
|||
// SQL where clauses are stored in $clauses array during query
|
||||
// construction
|
||||
$clauses = $temp_clauses = array();
|
||||
if (isset($search['fields']['keywords']))
|
||||
{
|
||||
if (isset($search['fields']['allwords']))
|
||||
{
|
||||
$textfields = array('file', 'name', 'comment', 'keywords', 'author');
|
||||
foreach ($textfields as $textfield)
|
||||
{
|
||||
$local_clauses = array();
|
||||
foreach ($search['fields']['keywords']['words'] as $word)
|
||||
foreach ($search['fields']['allwords']['words'] as $word)
|
||||
{
|
||||
array_push($local_clauses, $textfield." LIKE '%".$word."%'");
|
||||
}
|
||||
// adds brackets around where clauses
|
||||
array_walk($local_clauses,create_function('&$s','$s="(".$s.")";'));
|
||||
array_push($temp_clauses,
|
||||
implode(' '.$search['fields']['keywords']['mode'].' ',
|
||||
implode(' '.$search['fields']['allwords']['mode'].' ',
|
||||
$local_clauses));
|
||||
}
|
||||
array_push($clauses, implode(' OR ', $temp_clauses));
|
||||
array_push($clauses, implode(' OR ', $temp_clauses));
|
||||
}
|
||||
|
||||
if (isset($search['fields']['author']))
|
||||
{
|
||||
if (isset($search['fields']['author']))
|
||||
{
|
||||
array_push($clauses, "author LIKE '%".$search['fields']['author']['words'][0]."%'");
|
||||
}
|
||||
}
|
||||
|
||||
$datefields = array('date_available', 'date_creation');
|
||||
foreach ($datefields as $datefield)
|
||||
|
@ -447,28 +447,25 @@ function initialize_category( $calling_page = 'category' )
|
|||
if (isset($search['fields'][$key]))
|
||||
{
|
||||
$local_clause = $datefield." ";
|
||||
if (isset($search['fields'][$key]['mode']))
|
||||
{
|
||||
$local_clause .=">";
|
||||
}
|
||||
$local_clause .="= '";
|
||||
$local_clause.= str_replace('.', '-',
|
||||
if (isset($search['fields'][$key]['mode']))
|
||||
{
|
||||
$local_clause .=">";
|
||||
}
|
||||
$local_clause .="= '";
|
||||
$local_clause.= str_replace('.', '-',
|
||||
$search['fields'][$key]['words'][0]);
|
||||
$local_clause.= "'";
|
||||
array_push($clauses, $local_clause);
|
||||
$local_clause.= "'";
|
||||
array_push($clauses, $local_clause);
|
||||
|
||||
if (isset($search['fields'][$key]['mode']))
|
||||
{
|
||||
$search_tokens = explode('.', $search['fields'][$key]['words'][0]);
|
||||
$start_time = mktime(0, 0, 0, $search_tokens[1], $search_tokens[2],$search_tokens[0]);
|
||||
$search_duration = intval($search['fields'][$key]['mode']) * 86400;
|
||||
$end_time = $start_time + $search_duration;
|
||||
$end_sql_date = date('Y-m-d',$end_time);
|
||||
$local_clause = $datefield." <= '".$end_sql_date."'";
|
||||
array_push($clauses, $local_clause);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($search['fields'][$key]['mode']))
|
||||
{
|
||||
$end_sql_date = str_replace('.', '-',
|
||||
$search['fields'][$key]['mode']);
|
||||
$local_clause = $datefield." <= '".$end_sql_date."'";
|
||||
array_push($clauses, $local_clause);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($search['fields']['cat']))
|
||||
{
|
||||
|
|
|
@ -141,8 +141,8 @@ $lang['create_cookie'] = 'Create a cookie';
|
|||
// search
|
||||
$lang['search_title'] = 'Search';
|
||||
$lang['search_options'] = 'Search Options';
|
||||
$lang['search_keywords'] = 'Search for Keywords';
|
||||
$lang['search_keywords_hint'] = 'Use + for words which must be found, - for words which must not be found and | for words which may or may not be found. Use * as a wildcard for partial matches';
|
||||
$lang['search_keywords'] = 'Search for words';
|
||||
$lang['search_keywords_hint'] = 'Search for entered words in all the attributes related to the pictures displayed in the gallery. Use * as a wildcard for partial matches';
|
||||
$lang['search_mode_or'] = 'Search for any terms';
|
||||
$lang['search_mode_and'] = 'Search for all terms ';
|
||||
$lang['search_author'] = 'Search for Author';
|
||||
|
@ -151,9 +151,11 @@ $lang['search_subcats_included'] = 'Search in subcategroies';
|
|||
$lang['search_categories_hint'] = 'Select the category or categories you wish to search in. For speed all subcategories can be searched by selecting the parent and setting enable search subcategories below.';
|
||||
$lang['search_explain'] = 'Use * as a wildcard for partial matches';
|
||||
$lang['search_date'] = 'Search by Date';
|
||||
$lang['search_date_hint'] = 'Select a date and a duration for your query. The date is inclusive.';
|
||||
$lang['search_date_from'] = 'From';
|
||||
$lang['search_duration'] = 'During';
|
||||
$lang['search_date_hint'] = 'Select a date and/or an ending date for your query.<br />
|
||||
Leave date empty if you want to make a "before" query.<br />
|
||||
The year must be entered in the last field in the following format : 0000 (i.e. 2004)';
|
||||
$lang['search_date_from'] = 'Date';
|
||||
$lang['search_date_to'] = 'End-Date';
|
||||
$lang['search_date_type'] = 'Kind of date';
|
||||
$lang['search_date_available'] = 'Availability';
|
||||
$lang['search_date_creation'] = 'Creation';
|
||||
|
@ -163,7 +165,6 @@ $lang['search_descending'] = 'Descending';
|
|||
$lang['search_one_clause_at_least'] = 'Empty query. No criteria has been entered.';
|
||||
$lang['search_result'] = 'Search results';
|
||||
|
||||
$lang['Search_author_explain'] = 'Use * as a wildcard for partial matches';
|
||||
$lang['Look_up_user'] = 'Seek user';
|
||||
$lang['Find_username'] = 'Find a username';
|
||||
$lang['No_match'] = 'No match';
|
||||
|
|
|
@ -143,8 +143,8 @@ $lang['maxheight_error'] = 'La hauteur maximum des images doit
|
|||
// search
|
||||
$lang['search_title'] = 'Rechercher';
|
||||
$lang['search_options'] = 'Options de recherche';
|
||||
$lang['search_keywords'] = 'Recherche par mots-clés';
|
||||
$lang['search_keywords_hint'] = 'Vous pouvez utiliser <u>AND</u> pour déterminer les mots qui doivent être présents dans les résultats, <u>OR</u> pour déterminer les mots qui peuvent être présents dans les résultats et <u>NOT</u> pour déterminer les mots qui ne devraient pas être présents dans les résultats. Utilisez * comme un joker pour des recherches partielles';
|
||||
$lang['search_keywords'] = 'Recherche par mots';
|
||||
$lang['search_keywords_hint'] = 'Effectuez une recherche sur tous les champs des images présentes dans la galerie. Utilisez * comme un joker pour des recherches partielles';
|
||||
$lang['search_mode_or'] = 'Rechercher n\'importe quel de ces termes';
|
||||
$lang['search_mode_and'] = 'Rechercher tous les termes';
|
||||
$lang['search_author'] = 'Recherche par auteur';
|
||||
|
@ -153,9 +153,11 @@ $lang['search_subcats_included'] = 'Rechercher dans les sous-cat
|
|||
$lang['search_categories_hint'] = 'Sélectionnez le ou les catégorie(s) pour lesquelles vous souhaitez faire votre rechercher.';
|
||||
$lang['search_explain'] = 'Utilisez * comme un joker pour des recherches partielles';
|
||||
$lang['search_date'] = 'Rechercher par date';
|
||||
$lang['search_date_hint'] = 'Sélectionnez une date de début et une période pour vos recherches';
|
||||
$lang['search_date_from'] = 'A partir du';
|
||||
$lang['search_duration'] = 'Sur une période de';
|
||||
$lang['search_date_hint'] = 'Sélectionnez une date et une date de fin pour vos recherches.<br />
|
||||
Ne remplissez que la date de fin pour faire une recherche de type "avant".<br />
|
||||
L\'année doit être rentrée dans le dernier champ sous la forme 0000 (par exemple 2004).';
|
||||
$lang['search_date_from'] = 'Date';
|
||||
$lang['search_date_to'] = 'Date de fin';
|
||||
$lang['search_date_type'] = 'Type de date';
|
||||
$lang['search_date_available'] = 'Mise à disposition';
|
||||
$lang['search_date_creation'] = 'Création';
|
||||
|
@ -166,8 +168,6 @@ $lang['search_one_clause_at_least'] = 'Recherche vide. Aucun crit
|
|||
$lang['search_result'] = 'Résultats de la recherche';
|
||||
$lang['invalid_search'] = 'Les mots recherchés doivent comporter plus de 3 caractères et ne doivent pas inclure de caractères de ponctuation';
|
||||
|
||||
$lang['search_field_search'] = 'Rechercher';
|
||||
$lang['Search_author_explain'] = 'Utilisez * comme un joker pour des recherches partielles';
|
||||
$lang['Look_up_user'] = 'Rechercher l\'utilisateur';
|
||||
$lang['Find_username'] = 'Trouver un nom d\'utilisateur';
|
||||
$lang['No_match'] = 'Aucun enregistrement trouvé.';
|
||||
|
|
42
search.php
42
search.php
|
@ -35,11 +35,11 @@ $errors = array();
|
|||
$search = array();
|
||||
if (isset($_POST['submit']))
|
||||
{
|
||||
if ($_POST['search_keywords'] &&
|
||||
!preg_match('/^\s*$/', $_POST['search_keywords']))
|
||||
if ($_POST['search_allwords'] &&
|
||||
!preg_match('/^\s*$/', $_POST['search_allwords']))
|
||||
{
|
||||
$local_search = array();
|
||||
$search_keywords = $_POST['search_keywords'];
|
||||
$search_keywords = $_POST['search_allwords'];
|
||||
$drop_char_match = array('-', '^', '$', ';', '#', '&', '(', ')', '<', '>',
|
||||
'`', '\'', '"', '|', ',', '@', '_', '?', '%', '~', '.', '[', ']', '{', '}',
|
||||
':', '\\', '/', '=', '\'', '!', '*');
|
||||
|
@ -51,9 +51,9 @@ if (isset($_POST['submit']))
|
|||
// Split words
|
||||
$words = preg_split('#\s+#', $search_keywords);
|
||||
$words = array_unique($words);
|
||||
$search['fields']['keywords'] = array();
|
||||
$search['fields']['keywords']['words'] =$words;
|
||||
$search['fields']['keywords']['mode']= $_POST['mode'];
|
||||
$search['fields']['allwords'] = array();
|
||||
$search['fields']['allwords']['words'] =$words;
|
||||
$search['fields']['allwords']['mode']= $_POST['mode'];
|
||||
}
|
||||
|
||||
if ($_POST['search_author'])
|
||||
|
@ -82,9 +82,10 @@ if (isset($_POST['submit']))
|
|||
|
||||
// duration
|
||||
$search_duration = 0;
|
||||
if ( !empty($date) && !empty( $_POST['duration_day']) )
|
||||
if ( !empty($date) && !empty( $_POST['end_year']) )
|
||||
{
|
||||
$search['fields'][$type_date]['mode'] = $_POST['duration_day'];
|
||||
$end_date = $_POST['end_year'].'.'.$_POST['end_month'].'.'.$_POST['end_day'];
|
||||
$search['fields'][$type_date]['mode'] = $end_date;
|
||||
}
|
||||
}
|
||||
// search string (for URL) creation
|
||||
|
@ -139,16 +140,22 @@ for ($i=1; $i <= 12; $i++)
|
|||
}
|
||||
$start_month .= '</select>';
|
||||
|
||||
// year list
|
||||
$start_year = '<select name="start_year">';
|
||||
$start_year .= '<option value="0"> ---- </option>';
|
||||
$begin_year = date('Y', time())-10;
|
||||
for ($i = $begin_year; $i <= date('Y', time()); $i++)
|
||||
// day list
|
||||
$end_day = '<select name="end_day">';
|
||||
for ($i=0; $i <= 31; $i++)
|
||||
{
|
||||
$start_year .= '<option value="' . $i . '">' . $i . '</option>';
|
||||
$end_day .= '<option value="' . $i . '" >' . ( ($i == 0) ? ' -- ' : str_pad($i, 2, '0', STR_PAD_LEFT) ) . '</option>';
|
||||
}
|
||||
$start_year .= '</select>';
|
||||
$end_day .= '</select>';
|
||||
|
||||
// month list
|
||||
$end_month = '<select name="end_month">';
|
||||
$end_month .= '<option value="0"> ------------ </option>';
|
||||
for ($i=1; $i <= 12; $i++)
|
||||
{
|
||||
$end_month .= '<option value="' . $i . '">' . $lang['month'][$i] . '</option>';
|
||||
}
|
||||
$end_month .= '</select>';
|
||||
|
||||
//
|
||||
// Start output of page
|
||||
|
@ -178,7 +185,7 @@ $template->assign_vars(array(
|
|||
'L_SEARCH_DATE_HINT' => $lang['search_date_hint'],
|
||||
'L_TODAY' => $lang['today'],
|
||||
'L_SEARCH_DATE_FROM'=>$lang['search_date_from'],
|
||||
'L_SEARCH_DURATION'=>$lang['search_duration'],
|
||||
'L_SEARCH_DATE_TO'=>$lang['search_date_to'],
|
||||
'L_DAYS'=>$lang['days'],
|
||||
'L_MONTH'=>$lang['w_month'],
|
||||
'L_SEARCH_DATE_TYPE'=>$lang['search_date_type'],
|
||||
|
@ -191,7 +198,8 @@ $template->assign_vars(array(
|
|||
'TODAY_DAY' => date('d', time()),
|
||||
'TODAY_MONTH' => date('m', time()),
|
||||
'TODAY_YEAR' => date('Y', time()),
|
||||
'S_CALENDAR_YEAR' => $start_year,
|
||||
'E_CALENDAR_MONTH' => $end_month,
|
||||
'E_CALENDAR_DAY' => $end_day,
|
||||
'S_CALENDAR_MONTH' => $start_month,
|
||||
'S_CALENDAR_DAY' => $start_day,
|
||||
'S_SEARCH_ACTION' => add_session_id( 'search.php' ),
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<tr>
|
||||
<td width="50%" colspan="2"><b>{L_SEARCH_KEYWORDS} : </b><br /><span class="small">{L_SEARCH_KEYWORDS_HINT}</span></td>
|
||||
<td colspan="2" valign="top">
|
||||
<input type="text" style="width: 300px" name="search_keywords" size="30" />
|
||||
<input type="text" style="width: 300px" name="search_allwords" size="30" />
|
||||
<br />
|
||||
<input type="radio" name="mode" value="AND" checked="checked" /> {L_SEARCH_ALL_TERMS}<br />
|
||||
<input type="radio" name="mode" value="OR" /> {L_SEARCH_ANY_TERMS}
|
||||
|
@ -34,11 +34,12 @@
|
|||
<td colspan="2" valign="middle">
|
||||
<table><tr><td>
|
||||
{L_SEARCH_DATE_FROM} :</td><td>
|
||||
{S_CALENDAR_DAY}{S_CALENDAR_MONTH}{S_CALENDAR_YEAR}
|
||||
{S_CALENDAR_DAY} {S_CALENDAR_MONTH} <input name="start_year" type="text" size="4" maxlength="4">
|
||||
<a href="#" name="#" onClick="document.post.start_day.value={TODAY_DAY};document.post.start_month.value={TODAY_MONTH};document.post.start_year.value={TODAY_YEAR};" />{L_TODAY}</a>
|
||||
</tr><tr><td>
|
||||
{L_SEARCH_DURATION} : </td><td>
|
||||
<input name="duration_day" type="post" maxlength="5" size="3" value="{DURATION_DAY}" /> {L_DAYS}
|
||||
{L_SEARCH_DATE_TO} :</td><td>
|
||||
{E_CALENDAR_DAY} {E_CALENDAR_MONTH} <input name="end_year" type="text" size="4" maxlength="4">
|
||||
<a href="#" name="#" onClick="document.post.end_day.value={TODAY_DAY};document.post.end_month.value={TODAY_MONTH};document.post.end_year.value={TODAY_YEAR};" />{L_TODAY}</a>
|
||||
</td></tr></table>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -63,8 +64,8 @@
|
|||
<tr>
|
||||
<td width="25%" nowrap="nowrap"><b>{L_SEARCH_DATE_TYPE} : </b></td>
|
||||
<td width="25%" nowrap="nowrap">
|
||||
<input type="radio" name="date_type" value="date_creation" />{L_SEARCH_CREATION}<br />
|
||||
<input type="radio" name="date_type" value="date_available" checked="checked" />{L_SEARCH_AVAILABILITY}
|
||||
<input type="radio" name="date_type" value="date_creation" checked="checked" />{L_SEARCH_CREATION}<br />
|
||||
<input type="radio" name="date_type" value="date_available" />{L_SEARCH_AVAILABILITY}
|
||||
</td>
|
||||
<td><b>{L_RESULT_SORT} : </b></td>
|
||||
<td nowrap="nowrap">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue