aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgweltas <gweltas@piwigo.org>2004-11-25 14:12:33 +0000
committergweltas <gweltas@piwigo.org>2004-11-25 14:12:33 +0000
commit2c109654aac3eda8b98afb8b69b05f921091744d (patch)
tree1176f7f31cd2085adb9751570dd233d9f04e5c2a
parenta8acded5b0302a462211b46dd9dd2bb762d5af9a (diff)
New ergonomic form for search queries.
git-svn-id: http://piwigo.org/svn/trunk@621 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/category_default.inc.php2
-rw-r--r--include/functions_category.inc.php84
-rw-r--r--language/en_UK.iso-8859-1/common.lang.php47
-rw-r--r--language/fr_FR.iso-8859-1/common.lang.php50
-rw-r--r--search.php411
-rw-r--r--template/default/default.css47
-rw-r--r--template/default/search.tpl186
7 files changed, 288 insertions, 539 deletions
diff --git a/include/category_default.inc.php b/include/category_default.inc.php
index 2e89be05b..943bc7b5e 100644
--- a/include/category_default.inc.php
+++ b/include/category_default.inc.php
@@ -46,7 +46,7 @@ SELECT DISTINCT(id),path,file,date_available,category_id
'.$conf['order_by'].'
LIMIT '.$page['start'].','.$page['nb_image_page'].'
;';
-// echo '<pre>'.$query.'</pre>';
+//echo '<pre>'.$query.'</pre>';
$result = pwg_query($query);
// template thumbnail initialization
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index 3561caff8..f92820aa8 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -165,21 +165,9 @@ function count_user_total_images()
$query.= ' WHERE id NOT IN ('.$user['forbidden_categories'].')';
$query.= ';';
-// $query = '
-// SELECT COUNT(DISTINCT(image_id)) as total
-// FROM '.PREFIX_TABLE.'image_category';
-// if (count($user['restrictions']) > 0)
-// {
-// $query.= '
-// WHERE category_id NOT IN ('.$user['forbidden_categories'].')';
-// }
-// $query = '
-// ;';
-
$row = mysql_fetch_array( pwg_query( $query ) );
if ( !isset( $row['total'] ) ) $row['total'] = 0;
-
return $row['total'];
}
@@ -344,7 +332,7 @@ function initialize_category( $calling_page = 'category' )
// By default, it is the same as the $user['nb_image_page']
$page['nb_image_page'] = $user['nb_image_page'];
// $url is used to create the navigation bar
- $url = './category.php?cat='.$page['cat'];
+ $url = PHPWG_ROOT_PATH.'category.php?cat='.$page['cat'];
if ( isset($page['expand']) ) $url.= '&amp;expand='.$page['expand'];
// simple category
if ( is_numeric( $page['cat'] ) )
@@ -427,25 +415,30 @@ function initialize_category( $calling_page = 'category' )
// SQL where clauses are stored in $clauses array during query
// construction
- $clauses = array();
-
- $textfields = array('file', 'name', 'comment', 'keywords', 'author');
- foreach ($textfields as $textfield)
- {
- if (isset($search['fields'][$textfield]))
+ $clauses = $temp_clauses = array();
+ if (isset($search['fields']['keywords']))
+ {
+ $textfields = array('file', 'name', 'comment', 'keywords', 'author');
+ foreach ($textfields as $textfield)
{
$local_clauses = array();
- foreach ($search['fields'][$textfield]['words'] as $word)
+ foreach ($search['fields']['keywords']['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($clauses,
- implode(' '.$search['fields'][$textfield]['mode'].' ',
+ array_push($temp_clauses,
+ implode(' '.$search['fields']['keywords']['mode'].' ',
$local_clauses));
}
+ array_push($clauses, implode(' OR ', $temp_clauses));
}
+
+ 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)
@@ -453,41 +446,30 @@ function initialize_category( $calling_page = 'category' )
$key = $datefield;
if (isset($search['fields'][$key]))
{
- $local_clause = $datefield." = '";
+ $local_clause = $datefield." ";
+ 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);
- }
-
- foreach (array('after','before') as $suffix)
+
+ if (isset($search['fields'][$key]['mode']))
{
- $key = $datefield.'-'.$suffix;
- if (isset($search['fields'][$key]))
- {
- $local_clause = $datefield;
- if ($suffix == 'after')
- {
- $local_clause.= ' >';
- }
- else
- {
- $local_clause.= ' <';
- }
- if (isset($search['fields'][$key]['mode'])
- and $search['fields'][$key]['mode'] == 'inc')
- {
- $local_clause.= '=';
- }
- $local_clause.= " '";
- $local_clause.= str_replace('.', '-',
- $search['fields'][$key]['words'][0]);
- $local_clause.= "'";
- array_push($clauses, $local_clause);
- }
+ $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']['cat']))
{
if ($search['fields']['cat']['mode'] == 'sub_inc')
@@ -529,7 +511,7 @@ SELECT DISTINCT(id) AS id
// adds brackets around where clauses
array_walk($clauses, create_function('&$s', '$s = "(".$s.")";'));
- $page['where'] = 'WHERE '.implode(' '.$search['mode'].' ', $clauses);
+ $page['where'] = 'WHERE '.implode(' AND ', $clauses);
if ( isset( $forbidden ) ) $page['where'].= ' AND '.$forbidden;
$query = '
diff --git a/language/en_UK.iso-8859-1/common.lang.php b/language/en_UK.iso-8859-1/common.lang.php
index 693906548..315be34be 100644
--- a/language/en_UK.iso-8859-1/common.lang.php
+++ b/language/en_UK.iso-8859-1/common.lang.php
@@ -119,6 +119,7 @@ $lang['day'][6] = 'Saturday';
$lang['w_month'] = 'Month';
$lang['w_day'] = 'Day';
$lang['days'] = 'days';
+$lang['today']='Today';
// Customization
$lang['customize_page_title'] = 'Customization';
@@ -139,28 +140,29 @@ $lang['create_cookie'] = 'Create a cookie';
// search
$lang['search_title'] = 'Search';
-$lang['search_wrong_date'] = ' : this date is not valid';
-$lang['search_wrong_date_order'] = 'the period end must be after the period start';
-$lang['search_incoherent_date_search'] = 'when choosing to match all the clauses, you can\'t search "date is" and "date is after" or "date is before"';
-$lang['search_or_clauses'] = 'at least one search clause';
-$lang['search_and_clauses'] = 'all search clauses';
-$lang['search_subcats_included'] = 'include sub-categories';
-$lang['search_date_included'] = 'included';
-$lang['search_date_is'] = 'is';
-$lang['search_date_is_after'] = 'is after';
-$lang['search_date_is_before'] = 'is before';
-$lang['search_file'] = 'file';
-$lang['search_name'] = 'name';
-$lang['search_comment'] = 'comment';
-$lang['search_keywords'] = 'keywords';
-$lang['search_author'] = 'author';
-$lang['search_date_available'] = 'availability date';
-$lang['search_date_creation'] = 'creation date';
-$lang['search_one_clause_at_least'] = 'search at least on one search clause';
-$lang['search_mode_or'] = 'at least one word';
-$lang['search_mode_and'] = 'all the words';
-$lang['search_comments'] = 'separate different words with spaces';
-$lang['invalid_search'] = 'search must be done on 3 caracters or more';
+$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_mode_or'] = 'Search for any terms';
+$lang['search_mode_and'] = 'Search for all terms ';
+$lang['search_author'] = 'Search for Author';
+$lang['search_categories'] = 'Search in Categories';
+$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_type'] = 'Kind of date';
+$lang['search_date_available'] = 'Availability';
+$lang['search_date_creation'] = 'Creation';
+$lang['search_sort'] = 'Sort results by';
+$lang['search_ascending'] = 'Ascending';
+$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';
@@ -195,7 +197,6 @@ $lang['total'] = 'images';
$lang['upload_picture'] = 'Upload a picture';
$lang['generation_time'] = 'Page generated in';
$lang['favorites'] = 'Favorites';
-$lang['search_result'] = 'Search results';
$lang['about_page_title'] = 'About PhpWebGallery';
$lang['about_title'] = 'About...';
$lang['about_message'] = '<div style="text-align:center;font-weigh:bold;">Information about PhpWebGallery</div>
diff --git a/language/fr_FR.iso-8859-1/common.lang.php b/language/fr_FR.iso-8859-1/common.lang.php
index c24aba279..715abe53c 100644
--- a/language/fr_FR.iso-8859-1/common.lang.php
+++ b/language/fr_FR.iso-8859-1/common.lang.php
@@ -117,7 +117,9 @@ $lang['day'][4] = 'Jeudi';
$lang['day'][5] = 'Vendredi';
$lang['day'][6] = 'Samedi';
$lang['w_month']='Mois';
-$lang['w_day']='Jour';
+$lang['w_day']='Jour';;
+$lang['days']='Jours';
+$lang['today']='Aujourd\'hui';
// Customization
@@ -138,30 +140,31 @@ $lang['maxwidth_error'] = 'La largeur maximum des images doit être un entier sup
$lang['maxheight_error'] = 'La hauteur maximum des images doit être un entier supérieur à 50';
// search
-$lang['search_wrong_date'] = ' : date non valide';
-$lang['search_wrong_date_order'] = 'La date de fin doit être postérieure à la date de début';
-$lang['search_incoherent_date_search'] = 'Vous devez choisir une date unique ou une période.';
-$lang['search_or_clauses'] = 'Au moins une condition vérifiée';
-$lang['search_and_clauses'] = 'Toutes les conditions vérifiées';
-$lang['search_subcats_included'] = 'include sub-categories';
-$lang['search_date_included'] = 'included';
-$lang['search_date_is'] = 'est';
-$lang['search_date_is_after'] = 'après';
-$lang['search_date_is_before'] = 'avant';
-$lang['search_file'] = 'file';
-$lang['search_name'] = 'name';
-$lang['search_comment'] = 'comment';
-$lang['search_keywords'] = 'keywords';
-$lang['search_author'] = 'author';
-$lang['search_date_available'] = 'availability date';
-$lang['search_date_creation'] = 'creation date';
-$lang['search_one_clause_at_least'] = 'search at least on one search clause';
+$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_mode_or'] = 'Rechercher n\'importe quel de ces termes';
+$lang['search_mode_and'] = 'Rechercher tous les termes';
+$lang['search_author'] = 'Recherche par auteur';
+$lang['search_categories'] = 'Recherche dans les catégories';
+$lang['search_subcats_included'] = 'Rechercher dans les sous-catégories';
+$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_type'] = 'Type de date';
+$lang['search_date_available'] = 'Mise à disposition';
+$lang['search_date_creation'] = 'Création';
+$lang['search_sort'] = 'Trier par';
+$lang['search_ascending'] = 'Croissant';
+$lang['search_descending'] = 'Décroissant';
+$lang['search_one_clause_at_least'] = 'Recherche vide. Aucun critère n\'a été renseigné.';
$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_mode_or'] = 'au moins un mot';
-$lang['search_mode_and'] = 'tous les mots';
-$lang['search_comments'] = 'séparer les différents mots avec un espace';
-$lang['search_title'] = 'Recherche';
+
$lang['search_field_search'] = 'Rechercher';
$lang['Search_author_explain'] = 'Utilisez * comme un joker pour des recherches partielles';
$lang['Look_up_user'] = 'Rechercher l\'utilisateur';
@@ -190,7 +193,6 @@ $lang['previous_page'] = 'Précédente';
$lang['next_page'] = 'Suivante';
$lang['nb_image_category'] = 'nombre d\'images dans la catégorie';
$lang['recent_image'] = 'Image datant de moins de';
-$lang['days'] = 'jours';
$lang['send_mail'] = 'Contacter l\'adminstrateur';
$lang['title_send_mail'] = '[phpwebgallery] une remarque sur ton site';
$lang['sub-cat'] = 'sous-catégories';
diff --git a/search.php b/search.php
index e38255308..408495ec9 100644
--- a/search.php
+++ b/search.php
@@ -25,178 +25,73 @@
// | USA. |
// +-----------------------------------------------------------------------+
-//------------------------------------------------------------------- functions
-// date_display displays 3 select input fields. The first one is the
-// day of the month, from 0 to 31. The second is the month of the year,
-// from 01 to 12. The last one is the year. The years displayed are the
-// ones given by get_available_years (see function description in
-// ./include/functions.inc.php).
-function display_date($fieldname, $datefield)
-{
- global $template;
-
- // years
- for ($i = 1990; $i < 2006; $i++)
- {
- $selected = '';
- $key = $datefield.':year';
- if (isset($_POST[$key]) and $i == $_POST[$key])
- {
- $selected = ' selected="selected"';
- }
-
- $template->assign_block_vars(
- $fieldname.'year_option',
- array('OPTION'=>$i,
- 'SELECTED'=>$selected
- ));
- }
- // months of year
- for ($i = 1; $i <= 12; $i++)
- {
- $selected = '';
- $key = $datefield.':month';
- if (isset($_POST[$key]) and $i == $_POST[$key])
- {
- $selected = ' selected="selected"';
- }
-
- $template->assign_block_vars(
- $fieldname.'month_option',
- array('OPTION'=>sprintf('%02s', $i),
- 'SELECTED'=>$selected
- ));
- }
- // days of the month
- for ($i = 1; $i <= 31; $i++)
- {
- $selected = '';
- $key = $datefield.':day';
- if (isset($_POST[$key]) and $i == $_POST[$key])
- {
- $selected = ' selected="selected"';
- }
-
- $template->assign_block_vars(
- $fieldname.'day_option',
- array('OPTION'=>sprintf('%02s', $i),
- 'SELECTED'=>$selected
- ));
- }
-}
-
-function display_3dates($fieldname)
-{
- display_date('datefield.', $fieldname);
- display_date('datefield.after_', $fieldname.'-after');
- display_date('datefield.before_', $fieldname.'-before');
-}
//--------------------------------------------------------------------- include
define('PHPWG_ROOT_PATH','./');
include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
//-------------------------------------------------- access authorization check
check_login_authorization();
-//----------------------------------------------------------------- form fields
-$textfields = array('file', 'name', 'comment', 'keywords', 'author');
-$datefields = array('date_available', 'date_creation');
//------------------------------------------------------------------ form check
$errors = array();
$search = array();
-$search['fields'] = array();
if (isset($_POST['submit']))
{
- $search['mode'] = $_POST['mode'];
-
- foreach ($textfields as $textfield)
- {
- if (isset($_POST[$textfield.'-content'])
- and !preg_match('/^\s*$/', $_POST[$textfield.'-content']))
- {
- $local_search = array();
- $words = preg_split('/\s+/', $_POST[$textfield.'-content']);
- foreach ($words as $i => $word)
- {
- if (strlen($word) > 2 and !preg_match('/[,;:\']/', $word))
- {
- array_push($local_search, $word);
- }
- else
- {
- array_push($errors, $lang['invalid_search']);
- }
- }
- $local_search = array_unique($local_search);
- $search['fields'][$textfield] = array();
- $search['fields'][$textfield]['words'] = $local_search;
- if (count($local_search) > 1)
- {
- $search['fields'][$textfield]['mode'] = $_POST[$textfield.'-mode'];
- }
- }
+ if ($_POST['search_keywords'] &&
+ !preg_match('/^\s*$/', $_POST['search_keywords']))
+ {
+ $local_search = array();
+ $search_keywords = $_POST['search_keywords'];
+ $drop_char_match = array('-', '^', '$', ';', '#', '&', '(', ')', '<', '>',
+ '`', '\'', '"', '|', ',', '@', '_', '?', '%', '~', '.', '[', ']', '{', '}',
+ ':', '\\', '/', '=', '\'', '!', '*');
+ $drop_char_replace = array(' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+ '', '', ' ', ' ', ' ', ' ', '', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '
+ , ' ', '' , ' ', ' ', ' ', ' ', ' ');
+ $search_keywords = str_replace($drop_char_match, $drop_char_replace, $search_keywords);
+
+ // 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'];
}
- foreach ($datefields as $datefield)
+
+ if ($_POST['search_author'])
{
- $suffixes = array('','-after','-before');
- foreach ($suffixes as $suffix)
- {
- $field = $datefield.$suffix;
- if (isset($_POST[$field.'-check']))
- {
- $year = $_POST[$field.':year'];
- $month = $_POST[$field.':month'];
- $day = $_POST[$field.':day'];
- $date = $year.'.'.$month.'.'.$day;
- if (!checkdate($month, $day, $year))
- {
- array_push($errors, $date.$lang['search_wrong_date']);
- }
- $search['fields'][$field] = array();
- $search['fields'][$field]['words'] = array($date);
- if ($suffix == '-after' or $suffix == '-before')
- {
- if (isset($_POST[$field.'-included']))
- {
- $search['fields'][$field]['mode'] = 'inc';
- }
- }
- }
- }
- if ($search['mode'] == 'AND')
- {
- // before date must be superior to after date
- if (isset($search['fields'][$datefield.'-before'])
- and isset($search['fields'][$datefield.'-after']))
- {
- $after = $search['fields'][$datefield.'-after']['words'][0];
- $before = $search['fields'][$datefield.'-before']['words'][0];
- if ($after >= $before)
- {
- array_push($errors, $lang['search_wrong_date_order']);
- }
- }
- // having "search is" and ("search is after" or "search is before") is
- // not coherent
- if (isset($search['fields'][$datefield])
- and (isset($search['fields'][$datefield.'-before'])
- or isset($search['fields'][$datefield.'-after'])))
- {
- array_push($errors, $lang['search_incoherent_date_search']);
- }
- }
+ $search['fields']['author'] = array();
+ $search['fields']['author']['words'] = array($_POST['search_author']);
}
- if (isset($_POST['categories-check']))
+
+ if (isset($_POST['cat']))
{
- $field = 'cat';
- $search['fields'][$field] = array();
- $search['fields'][$field]['words'] = $_POST['cat'];
+ $search['fields']['cat'] = array();
+ $search['fields']['cat']['words'] = $_POST['cat'];
if (isset($_POST['subcats-included']))
{
- $search['fields'][$field]['mode'] = 'sub_inc';
+ $search['fields']['cat']['mode'] = 'sub_inc';
}
}
+
+ if (!empty($_POST['start_year']))
+ {
+ $type_date = $_POST['date_type'];
+
+ // start event
+ $date = $_POST['start_year'].'.'.$_POST['start_month'].'.'.$_POST['start_day'];
+ $search['fields'][$type_date]['words'] = array($date);
+
+ // duration
+ $search_duration = 0;
+ if ( !empty($date) && !empty( $_POST['duration_day']) )
+ {
+ $search['fields'][$type_date]['mode'] = $_POST['duration_day'];
+ }
+ }
// search string (for URL) creation
$search_string = '';
$tokens = array();
+ if (!empty($search))
+ {
foreach (array_keys($search['fields']) as $field)
{
$token = $field.':';
@@ -210,10 +105,10 @@ if (isset($_POST['submit']))
$search_string.= implode(';', $tokens);
if (count($tokens) > 1)
{
- $search_string.= '|'.$search['mode'];
+ $search_string.= '|AND';
}
-
- if (count($tokens) == 0)
+ }
+ else
{
array_push($errors, $lang['search_one_clause_at_least']);
}
@@ -225,7 +120,36 @@ if (isset($_POST['submit']) and count($errors) == 0)
$url = add_session_id($url, true);
redirect($url);
}
+
//----------------------------------------------------- template initialization
+// day list
+$start_day = '<select name="start_day">';
+for ($i=0; $i <= 31; $i++)
+{
+ $start_day .= '<option value="' . $i . '" >' . ( ($i == 0) ? ' -- ' : str_pad($i, 2, '0', STR_PAD_LEFT) ) . '</option>';
+}
+$start_day .= '</select>';
+
+// month list
+$start_month = '<select name="start_month">';
+$start_month .= '<option value="0"> ------------ </option>';
+for ($i=1; $i <= 12; $i++)
+{
+ $start_month .= '<option value="' . $i . '">' . $lang['month'][$i] . '</option>';
+}
+$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++)
+{
+ $start_year .= '<option value="' . $i . '">' . $i . '</option>';
+}
+$start_year .= '</select>';
+
+
//
// Start output of page
//
@@ -234,109 +158,47 @@ include(PHPWG_ROOT_PATH.'include/page_header.php');
$template->set_filenames( array('search'=>'search.tpl') );
$template->assign_vars(array(
- 'L_TITLE' => $lang['search_title'],
- 'L_SEARCH_COMMENTS' => $lang['search_comments'],
+ 'L_SEARCH_TITLE' => $lang['search_title'],
+ 'L_SEARCH_OPTIONS' => $lang['search_options'],
'L_RETURN' => $lang['home'],
'L_SUBMIT' => $lang['submit'],
- 'L_SEARCH_OR'=>$lang['search_mode_or'],
- 'L_SEARCH_AND'=>$lang['search_mode_and'],
- 'L_SEARCH_OR_CLAUSES'=>$lang['search_or_clauses'],
- 'L_SEARCH_AND_CLAUSES'=>$lang['search_and_clauses'],
- 'L_SEARCH_CATEGORIES'=>$lang['categories'],
- 'L_SEARCH_SUBCATS_INCLUDED'=>$lang['search_subcats_included'],
- 'L_SEARCH_DATE_INCLUDED'=> $lang['search_date_included'],
- 'L_SEARCH_DATE_IS'=>$lang['search_date_is'],
- 'L_SEARCH_DATE_IS_AFTER'=>$lang['search_date_is_after'],
- 'L_SEARCH_DATE_IS_BEFORE'=>$lang['search_date_is_before'],
+ 'L_RESET' => $lang['reset'],
+ 'L_SEARCH_KEYWORDS'=>$lang['search_keywords'],
+ 'L_SEARCH_KEYWORDS_HINT'=>$lang['search_keywords_hint'],
+ 'L_SEARCH_ANY_TERMS'=>$lang['search_mode_or'],
+ 'L_SEARCH_ALL_TERMS'=>$lang['search_mode_and'],
+ 'L_SEARCH_AUTHOR'=>$lang['search_author'],
+ 'L_SEARCH_AUTHOR_HINT'=>$lang['search_explain'],
+ 'L_SEARCH_CATEGORIES'=>$lang['search_categories'],
+ 'L_SEARCH_CATEGORIES_HINT'=>$lang['search_categories_hint'],
+ 'L_SEARCH_SUBFORUMS'=>$lang['search_subcats_included'],
+ 'L_YES' => $lang['yes'],
+ 'L_NO' => $lang['no'],
+ 'L_SEARCH_DATE' => $lang['search_date'],
+ '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_DAYS'=>$lang['days'],
+ 'L_MONTH'=>$lang['w_month'],
+ 'L_SEARCH_DATE_TYPE'=>$lang['search_date_type'],
+ 'L_SEARCH_CREATION'=>$lang['search_date_creation'],
+ 'L_SEARCH_AVAILABILITY'=>$lang['search_date_available'],
+ 'L_RESULT_SORT'=>$lang['search_sort'],
+ 'L_SORT_ASCENDING'=>$lang['search_ascending'],
+ 'L_SORT_DESCENDING'=>$lang['search_descending'],
- 'F_ACTION' => add_session_id( 'search.php' ),
-
+ 'TODAY_DAY' => date('d', time()),
+ 'TODAY_MONTH' => date('m', time()),
+ 'TODAY_YEAR' => date('Y', time()),
+ 'S_CALENDAR_YEAR' => $start_year,
+ 'S_CALENDAR_MONTH' => $start_month,
+ 'S_CALENDAR_DAY' => $start_day,
+ 'S_SEARCH_ACTION' => add_session_id( 'search.php' ),
'U_HOME' => add_session_id( 'category.php' )
)
);
-//------------------------------------------------------------ text fields form
-foreach ($textfields as $textfield)
-{
- if (isset($_POST[$textfield.'-mode']))
- {
- if ($_POST[$textfield.'-mode'] == 'AND')
- {
- $and_checked = 'checked="checked"';
- $or_checked = '';
- }
- else
- {
- $or_checked = 'checked="checked"';
- $and_checked = '';
- }
- }
- else
- {
- $or_checked = 'checked="checked"';
- $and_checked = '';
- }
-
- $value = '';
- if (isset($_POST[$textfield.'-content']))
- {
- $value = $_POST[$textfield.'-content'];
- }
-
- $template->assign_block_vars(
- 'textfield',
- array('NAME'=>$lang['search_'.$textfield],
- 'L_NAME'=>$textfield,
- 'VALUE'=>$value,
- 'OR_CHECKED'=>$or_checked,
- 'AND_CHECKED'=>$and_checked
- ));
-}
-//------------------------------------------------------------- date field form
-foreach ($datefields as $datefield)
-{
- $checked = '';
- if (isset($_POST[$datefield.'-check']))
- {
- $checked = ' checked="checked"';
- }
-
- $after_checked = '';
- if (isset($_POST[$datefield.'-after-check']))
- {
- $after_checked = ' checked="checked"';
- }
-
- $before_checked = '';
- if (isset($_POST[$datefield.'-before-check']))
- {
- $before_checked = ' checked="checked"';
- }
-
- $after_included_check = '';
- if (isset($_POST[$datefield.'-after-included']))
- {
- $after_included_check = ' checked="checked"';
- }
-
- $before_included_check = '';
- if (isset($_POST[$datefield.'-before-included']))
- {
- $before_included_check = ' checked="checked"';
- }
-
- $template->assign_block_vars(
- 'datefield',
- array('NAME'=>$datefield,
- 'L_NAME'=>$lang['search_'.$datefield],
- 'CHECKED'=>$checked,
- 'AFTER_CHECKED'=>$after_checked,
- 'BEFORE_CHECKED'=>$before_checked,
- 'AFTER_INCLUDED_CHECKED'=>$after_included_check,
- 'BEFORE_INCLUDED_CHECKED'=>$before_included_check
- ));
- display_3dates($datefield);
-}
//------------------------------------------------------------- categories form
$query = '
SELECT name,id,date_last,nb_images,global_rank,uppercats
@@ -348,57 +210,10 @@ SELECT name,id,date_last,nb_images,global_rank,uppercats
}
$query.= '
;';
+
$selecteds = array();
-if (isset($_POST['submit']))
-{
- $selecteds = $_POST['cat'];
-}
display_select_cat_wrapper($query, $selecteds, 'category_option', false);
-$categories_selected = '';
-if (isset($_POST['categories-check']))
-{
- $categories_selected = 'checked="checked"';
-}
-
-$categories_subcats_selected = '';
-if (isset($_POST['subcats-included']))
-{
- $categories_subcats_selected = 'checked="checked"';
-}
-
-$template->assign_vars(
- array(
- 'CATEGORIES_SELECTED'=>$categories_selected,
- 'CATEGORIES_SUBCATS_SELECTED'=>$categories_subcats_selected
- )
- );
-//---------------------------------------------------------------------- OR/AND
-if (isset($_POST['mode']))
-{
- if ($_POST['mode'] == 'AND')
- {
- $and_checked = 'checked="checked"';
- $or_checked = '';
- }
- else
- {
- $or_checked = 'checked="checked"';
- $and_checked = '';
- }
-}
-else
-{
- $or_checked = 'checked="checked"';
- $and_checked = '';
-}
-
-$template->assign_vars(
- array(
- 'OR_CHECKED'=>$or_checked,
- 'AND_CHECKED'=>$and_checked
- )
- );
//-------------------------------------------------------------- errors display
if (sizeof($errors) != 0)
{
diff --git a/template/default/default.css b/template/default/default.css
index abf187d63..d1f0aa84c 100644
--- a/template/default/default.css
+++ b/template/default/default.css
@@ -78,6 +78,10 @@ a.thumbLink:hover { text-decoration:none;}
/* Navigation styles */
+.small{
+ font-size:10px;
+}
+
.titreMenu,.titrePage
{
padding-right: 10px;
@@ -322,10 +326,7 @@ color : #FFF48E;
text-align:center;
font-size:16px;
}
-.menuInfoCat {
- font-family:sans-serif;
- font-size:11px;
-}
+
.totalImages {
text-align:center;
margin-top:5px;
@@ -333,12 +334,6 @@ color : #FFF48E;
font-size:11px;
}
-.infoCat {
- margin-top:10px;
- margin-bottom:10px;
- text-align:left;
-}
-
.copyright {
font-size:10px;
text-align:center;
@@ -424,36 +419,4 @@ div.remoteLocal {
/* for debugging purpose */
pre {
text-align:left;
-}
-
-.confMenu {
- background-color:#444444;
- text-align:center;
-}
-
-.confMenu a {
- padding:2px;
- border:1px solid gray;
- background-color:#505050;
- color:#fff48e;
- color:lightgray;
-}
-
-.confMenu a:hover {
- color:orange;
- text-decoration:none;
-}
-
-.confMenu a.opened {
- background-color:gray;
- color:white;
- text-decoration:none;
-}
-
-.optionTrue {
- color:lightgreen;
-}
-
-.optionFalse {
- color:#ffe1e1;
} \ No newline at end of file
diff --git a/template/default/search.tpl b/template/default/search.tpl
index dfb465528..d79aeb017 100644
--- a/template/default/search.tpl
+++ b/template/default/search.tpl
@@ -1,6 +1,6 @@
-<div class="titrePage">{L_TITLE}</div>
+<div class="titrePage">{L_SEARCH_TITLE}</div>
<br />
-<form method="post" action="{F_ACTION}" style="text-align:center">
+<form method="post" name="post" action="{S_SEARCH_ACTION}">
<!-- BEGIN errors -->
<div class="errors">
<ul>
@@ -10,109 +10,95 @@
</ul>
</div>
<!-- END errors -->
-<table>
- <!-- BEGIN textfield -->
- <tr>
- <td></td>
- <td>{textfield.L_NAME} *</td>
- <td>
- <input type="text" name="{textfield.NAME}-content" value="{textfield.VALUE}" size="40" />
- <input class="radio" type="radio" name="{textfield.NAME}-mode" value="OR" {textfield.OR_CHECKED} /> {L_SEARCH_OR}
- <input class="radio" type="radio" name="{textfield.NAME}-mode" value="AND" {textfield.AND_CHECKED} /> {L_SEARCH_AND}
- </td>
+<table width="100%" align="center" cellpadding="2">
+ <tr class="admin">
+ <th colspan="4">{L_SEARCH_TITLE}</th>
</tr>
- <!-- END textfield -->
- <tr>
- <td colspan="3" style="text-align:center;">* {L_SEARCH_COMMENTS}</td>
+ <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" />
+ <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}
+ </td>
</tr>
- <!-- BEGIN datefield -->
- <tr>
- <td></td>
- <td>{datefield.L_NAME}</td>
- <td>
- <table>
- <tr>
- <td style="text-align:left;"><input type="checkbox" name="{datefield.NAME}-check" value="1" {datefield.CHECKED} /> {L_SEARCH_DATE_IS}</td>
- <td style="text-align:left;">
- <select name="{datefield.NAME}:year">
- <!-- BEGIN year_option -->
- <option{datefield.year_option.SELECTED}>{datefield.year_option.OPTION}</option>
- <!-- END year_option -->
- </select>
- <select name="{datefield.NAME}:month">
- <!-- BEGIN month_option -->
- <option{datefield.month_option.SELECTED}>{datefield.month_option.OPTION}</option>
- <!-- END month_option -->
- </select>
- <select name="{datefield.NAME}:day">
- <!-- BEGIN day_option -->
- <option{datefield.day_option.SELECTED}>{datefield.day_option.OPTION}</option>
- <!-- END day_option -->
- </select>
- </td>
- </tr>
- <tr>
- <td style="text-align:left;"><input type="checkbox" name="{datefield.NAME}-after-check" value="1" {datefield.AFTER_CHECKED} /> {L_SEARCH_DATE_IS_AFTER}</td>
- <td style="text-align:left;">
- <select name="{datefield.NAME}-after:year">
- <!-- BEGIN after_year_option -->
- <option{datefield.after_year_option.SELECTED}>{datefield.after_year_option.OPTION}</option>
- <!-- END after_year_option -->
- </select>
- <select name="{datefield.NAME}-after:month">
- <!-- BEGIN after_month_option -->
- <option{datefield.after_month_option.SELECTED}>{datefield.after_month_option.OPTION}</option>
- <!-- END after_month_option -->
- </select>
- <select name="{datefield.NAME}-after:day">
- <!-- BEGIN after_day_option -->
- <option{datefield.after_day_option.SELECTED}>{datefield.after_day_option.OPTION}</option>
- <!-- END after_day_option -->
- </select>
- <input type="checkbox" name="{datefield.NAME}-after-included" value="1" {datefield.AFTER_INCLUDED_CHECKED} /> {L_SEARCH_DATE_INCLUDED}
- </td>
- </tr>
- <tr>
- <td style="text-align:left;"><input type="checkbox" name="{datefield.NAME}-before-check" value="1" {datefield.BEFORE_CHECKED} /> {L_SEARCH_DATE_IS_BEFORE}</td>
- <td style="text-align:left;">
- <select name="{datefield.NAME}-before:year">
- <!-- BEGIN before_year_option -->
- <option{datefield.before_year_option.SELECTED}>{datefield.before_year_option.OPTION}</option>
- <!-- END before_year_option -->
- </select>
- <select name="{datefield.NAME}-before:month">
- <!-- BEGIN before_month_option -->
- <option{datefield.before_month_option.SELECTED}>{datefield.before_month_option.OPTION}</option>
- <!-- END before_month_option -->
- </select>
- <select name="{datefield.NAME}-before:day">
- <!-- BEGIN before_day_option -->
- <option{datefield.before_day_option.SELECTED}>{datefield.before_day_option.OPTION}</option>
- <!-- END before_day_option -->
- </select>
- <input type="checkbox" name="{datefield.NAME}-before-included" value="1" {datefield.BEFORE_INCLUDED_CHECKED} /> {L_SEARCH_DATE_INCLUDED}
- </td>
- </tr>
- </table>
- </td>
+ <tr>
+ <td colspan="2"><b>{L_SEARCH_AUTHOR} :</b><br /><span class="small">{L_SEARCH_AUTHOR_HINT}</span></td>
+ <td colspan="2" valign="middle">
+ <input type="text" style="width: 300px" name="search_author" size="30" />
+ </td>
</tr>
- <tr>
+ <tr>
+ <td colspan="2"><b>{L_SEARCH_DATE} :</b><br /><span class="small">{L_SEARCH_DATE_HINT}</span></td>
+ <td colspan="2" valign="middle">
+ <table><tr><td>
+ {L_SEARCH_DATE_FROM} :</td><td>
+ {S_CALENDAR_DAY}{S_CALENDAR_MONTH}{S_CALENDAR_YEAR}&nbsp;
+ <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}" />&nbsp;{L_DAYS}
+ </td></tr></table>
+ </td>
</tr>
- <!-- END datefield -->
- <tr>
- <td><input type="checkbox" name="categories-check" value="1" {CATEGORIES_SELECTED} /></td>
- <td>{L_SEARCH_CATEGORIES}</td>
- <td>
- <select style="width:500px" name="cat[]" multiple="multiple" size="10">
- <!-- BEGIN category_option -->
- <option {category_option.SELECTED} value="{category_option.VALUE}">{category_option.OPTION}</option>
- <!-- END category_option -->
+ <tr class="admin">
+ <th colspan="4">{L_SEARCH_OPTIONS}</th>
+ </tr>
+ <tr>
+ <td width="25%" ><b>{L_SEARCH_CATEGORIES} : </b><br /><span class="small">{L_SEARCH_CATEGORIES_HINT}</span></td>
+ <td width="25%" nowrap="nowrap">
+ <select style="width:200px" name="cat[]" multiple="multiple" size="8">
+ <!-- BEGIN category_option -->
+ <option value="{category_option.VALUE}">{category_option.OPTION}</option>
+ <!-- END category_option -->
</select>
- <input type="checkbox" name="subcats-included" value="1" {CATEGORIES_SUBCATS_SELECTED} /> {L_SEARCH_SUBCATS_INCLUDED}
- </td>
+ </td>
+ <td width="25%" nowrap="nowrap"><b>{L_SEARCH_SUBFORUMS} : </b></td>
+ <td width="25%" nowrap="nowrap">
+ <input type="radio" name="subcats-included" value="1" checked="checked" />{L_YES}&nbsp;&nbsp;
+ <input type="radio" name="subcats-included" value="0" />{L_NO}
+ </td>
+ </tr>
+ <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}
+ </td>
+ <td><b>{L_RESULT_SORT} : </b></td>
+ <td nowrap="nowrap">
+ <input type="radio" name="sd" value="AND" />{L_SORT_ASCENDING}<br />
+ <input type="radio" name="sd" value="d" checked="checked" />{L_SORT_DESCENDING}
+ </td>
</tr>
+<!-- <tr>
+ <td width="25%" nowrap="nowrap"><b>{L_SEARCH_WITHIN} : </b></td>
+ <td width="25%" nowrap="nowrap">
+ <input type="radio" name="search_fields" value="all" checked="checked" />{L_SEARCH_ALL}<br />
+ <input type="radio" name="search_fields" value="imgonly" />{L_SEARCH_IMG_ONLY}<br />
+ <input type="radio" name="search_fields" value="commentsonly" />{L_SEARCH_COMMENTS_ONLY}
+ </td>
+ </tr>
+ <tr>
+ <td><b>{L_RESULT_SORT} : </b></td>
+ <td nowrap="nowrap">
+ {S_SELECT_SORT_KEY}<br />
+ <input type="radio" name="sd" value="a" />{L_SORT_ASCENDING}<br />
+ <input type="radio" name="sd" value="d" checked="checked" />{L_SORT_DESCENDING}
+ </td>
+ <td nowrap="nowrap"><b>{L_DISPLAY_RESULTS} : </b></td>
+ <td nowrap="nowrap">
+ <input type="radio" name="show_results" value="images" checked="checked" />{L_IMAGES}&nbsp;&nbsp;
+ <input type="radio" name="show_results" value="comments" /> {L_COMMENTS}
+ </td>
+ </tr>
+ -->
+<tr>
+<td align="center" valign="bottom" colspan="4" height="38">
+<input type="submit" name="submit" value="{L_SUBMIT}" class="bouton" />&nbsp;&nbsp;
+<input type="reset" value="{L_RESET}" class="bouton" />
+</td>
</table>
-<input class="radio" type="radio" name="mode" value="OR" {OR_CHECKED} /> {L_SEARCH_OR_CLAUSES}
-<input class="radio" type="radio" name="mode" value="AND" {AND_CHECKED} /> {L_SEARCH_AND_CLAUSES}<br /><br />
-<input type="submit" name="submit" value="{L_SUBMIT}" class="bouton" /><br /><br />
+</form>
<a href="{U_HOME}" title="{L_RETURN_HINT}">[ {L_RETURN} ]</a>