Changeset 621 for trunk


Ignore:
Timestamp:
Nov 25, 2004, 3:12:33 PM (20 years ago)
Author:
gweltas
Message:

New ergonomic form for search queries.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/category_default.inc.php

    r606 r621  
    4747  LIMIT '.$page['start'].','.$page['nb_image_page'].'
    4848;';
    49 // echo '<pre>'.$query.'</pre>';
     49//echo '<pre>'.$query.'</pre>';
    5050$result = pwg_query($query);
    5151
  • trunk/include/functions_category.inc.php

    r617 r621  
    166166  $query.= ';';
    167167 
    168 //   $query = '
    169 // SELECT COUNT(DISTINCT(image_id)) as total
    170 //   FROM '.PREFIX_TABLE.'image_category';
    171 //   if (count($user['restrictions']) > 0)
    172 //   {
    173 //     $query.= '
    174 //   WHERE category_id NOT IN ('.$user['forbidden_categories'].')';
    175 //   }
    176 //   $query = '
    177 // ;';
    178  
    179168  $row = mysql_fetch_array( pwg_query( $query ) );
    180169
    181170  if ( !isset( $row['total'] ) ) $row['total'] = 0;
    182 
    183171  return $row['total'];
    184172}
     
    345333    $page['nb_image_page'] = $user['nb_image_page'];
    346334    // $url is used to create the navigation bar
    347     $url = './category.php?cat='.$page['cat'];
     335    $url = PHPWG_ROOT_PATH.'category.php?cat='.$page['cat'];
    348336    if ( isset($page['expand']) ) $url.= '&amp;expand='.$page['expand'];
    349337    // simple category
     
    428416        // SQL where clauses are stored in $clauses array during query
    429417        // construction
    430         $clauses = array();
    431        
    432         $textfields = array('file', 'name', 'comment', 'keywords', 'author');
    433         foreach ($textfields as $textfield)
    434         {
    435           if (isset($search['fields'][$textfield]))
     418        $clauses = $temp_clauses = array();
     419        if (isset($search['fields']['keywords']))
     420                {
     421          $textfields = array('file', 'name', 'comment', 'keywords', 'author');
     422          foreach ($textfields as $textfield)
    436423          {
    437424            $local_clauses = array();
    438             foreach ($search['fields'][$textfield]['words'] as $word)
     425            foreach ($search['fields']['keywords']['words'] as $word)
    439426            {
    440427              array_push($local_clauses, $textfield." LIKE '%".$word."%'");
     
    442429            // adds brackets around where clauses
    443430            array_walk($local_clauses,create_function('&$s','$s="(".$s.")";'));
    444             array_push($clauses,
    445                        implode(' '.$search['fields'][$textfield]['mode'].' ',
     431            array_push($temp_clauses,
     432                       implode(' '.$search['fields']['keywords']['mode'].' ',
    446433                               $local_clauses));
    447434          }
    448         }
     435                  array_push($clauses, implode(' OR ', $temp_clauses));
     436        }
     437               
     438                if (isset($search['fields']['author']))
     439                {
     440           array_push($clauses, "author LIKE '%".$search['fields']['author']['words'][0]."%'");
     441                }
    449442
    450443        $datefields = array('date_available', 'date_creation');
     
    454447          if (isset($search['fields'][$key]))
    455448          {
    456             $local_clause = $datefield." = '";
     449            $local_clause = $datefield." ";
     450                        if (isset($search['fields'][$key]['mode']))
     451                        {
     452                          $local_clause .=">";
     453                        }
     454                        $local_clause .="= '";
    457455            $local_clause.= str_replace('.', '-',
    458456                                        $search['fields'][$key]['words'][0]);
    459457            $local_clause.= "'";
    460458            array_push($clauses, $local_clause);
    461           }
    462 
    463           foreach (array('after','before') as $suffix)
    464           {
    465             $key = $datefield.'-'.$suffix;
    466             if (isset($search['fields'][$key]))
    467             {
    468               $local_clause = $datefield;
    469               if ($suffix == 'after')
    470               {
    471                 $local_clause.= ' >';
    472               }
    473               else
    474               {
    475                 $local_clause.= ' <';
    476               }
    477               if (isset($search['fields'][$key]['mode'])
    478                   and $search['fields'][$key]['mode'] == 'inc')
    479               {
    480                 $local_clause.= '=';
    481               }
    482               $local_clause.= " '";
    483               $local_clause.= str_replace('.', '-',
    484                                           $search['fields'][$key]['words'][0]);
    485               $local_clause.= "'";
    486               array_push($clauses, $local_clause);
    487             }
    488           }
    489         }
    490 
     459                       
     460                        if (isset($search['fields'][$key]['mode']))
     461          {
     462                    $search_tokens = explode('.', $search['fields'][$key]['words'][0]);
     463                    $start_time = mktime(0, 0, 0, $search_tokens[1], $search_tokens[2],$search_tokens[0]);
     464                        $search_duration = intval($search['fields'][$key]['mode']) * 86400;
     465                        $end_time = $start_time + $search_duration;
     466                        $end_sql_date = date('Y-m-d',$end_time);
     467                    $local_clause = $datefield." <= '".$end_sql_date."'";
     468            array_push($clauses, $local_clause);
     469          }
     470                  }
     471        }
     472       
    491473        if (isset($search['fields']['cat']))
    492474        {
     
    530512        // adds brackets around where clauses
    531513        array_walk($clauses, create_function('&$s', '$s = "(".$s.")";'));
    532         $page['where'] = 'WHERE '.implode(' '.$search['mode'].' ', $clauses);
     514        $page['where'] = 'WHERE '.implode(' AND ', $clauses);
    533515        if ( isset( $forbidden ) ) $page['where'].= ' AND '.$forbidden;
    534516
  • trunk/language/en_UK.iso-8859-1/common.lang.php

    r607 r621  
    120120$lang['w_day'] = 'Day';
    121121$lang['days'] = 'days';
     122$lang['today']='Today';
    122123
    123124// Customization
     
    140141// search
    141142$lang['search_title'] = 'Search';
    142 $lang['search_wrong_date'] = ' : this date is not valid';
    143 $lang['search_wrong_date_order'] = 'the period end must be after the period start';
    144 $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"';
    145 $lang['search_or_clauses'] = 'at least one search clause';
    146 $lang['search_and_clauses'] = 'all search clauses';
    147 $lang['search_subcats_included'] = 'include sub-categories';
    148 $lang['search_date_included'] = 'included';
    149 $lang['search_date_is'] = 'is';
    150 $lang['search_date_is_after'] = 'is after';
    151 $lang['search_date_is_before'] = 'is before';
    152 $lang['search_file'] = 'file';
    153 $lang['search_name'] = 'name';
    154 $lang['search_comment'] = 'comment';
    155 $lang['search_keywords'] = 'keywords';
    156 $lang['search_author'] = 'author';
    157 $lang['search_date_available'] = 'availability date';
    158 $lang['search_date_creation'] = 'creation date';
    159 $lang['search_one_clause_at_least'] = 'search at least on one search clause';
    160 $lang['search_mode_or'] = 'at least one word';
    161 $lang['search_mode_and'] = 'all the words';
    162 $lang['search_comments'] = 'separate different words with spaces';
    163 $lang['invalid_search'] = 'search must be done on 3 caracters or more';
     143$lang['search_options'] = 'Search Options';
     144$lang['search_keywords'] = 'Search for Keywords';
     145$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';
     146$lang['search_mode_or'] = 'Search for any terms';
     147$lang['search_mode_and'] = 'Search for all terms ';
     148$lang['search_author'] = 'Search for Author';
     149$lang['search_categories'] = 'Search in Categories';
     150$lang['search_subcats_included'] = 'Search in subcategroies';
     151$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.';
     152$lang['search_explain'] = 'Use * as a wildcard for partial matches';
     153$lang['search_date'] = 'Search by Date';
     154$lang['search_date_hint'] = 'Select a date and a duration for your query. The date is inclusive.';
     155$lang['search_date_from'] = 'From';
     156$lang['search_duration'] = 'During';
     157$lang['search_date_type'] = 'Kind of date';
     158$lang['search_date_available'] = 'Availability';
     159$lang['search_date_creation'] = 'Creation';
     160$lang['search_sort'] = 'Sort results by';
     161$lang['search_ascending'] = 'Ascending';
     162$lang['search_descending'] = 'Descending';
     163$lang['search_one_clause_at_least'] = 'Empty query. No criteria has been entered.';
     164$lang['search_result'] = 'Search results';
     165
    164166$lang['Search_author_explain'] = 'Use * as a wildcard for partial matches';
    165167$lang['Look_up_user'] = 'Seek user';
     
    196198$lang['generation_time'] = 'Page generated in';
    197199$lang['favorites'] = 'Favorites';
    198 $lang['search_result'] = 'Search results';
    199200$lang['about_page_title'] = 'About PhpWebGallery';
    200201$lang['about_title'] = 'About...';
  • trunk/language/fr_FR.iso-8859-1/common.lang.php

    r607 r621  
    118118$lang['day'][6] = 'Samedi';
    119119$lang['w_month']='Mois';
    120 $lang['w_day']='Jour';
     120$lang['w_day']='Jour';;
     121$lang['days']='Jours';
     122$lang['today']='Aujourd\'hui';
    121123
    122124
     
    139141
    140142// search
    141 $lang['search_wrong_date'] = ' : date non valide';
    142 $lang['search_wrong_date_order'] = 'La date de fin doit être postérieure à la date de début';
    143 $lang['search_incoherent_date_search'] = 'Vous devez choisir une date unique ou une période.';
    144 $lang['search_or_clauses'] = 'Au moins une condition vérifiée';
    145 $lang['search_and_clauses'] = 'Toutes les conditions vérifiées';
    146 $lang['search_subcats_included'] = 'include sub-categories';
    147 $lang['search_date_included'] = 'included';
    148 $lang['search_date_is'] = 'est';
    149 $lang['search_date_is_after'] = 'après';
    150 $lang['search_date_is_before'] = 'avant';
    151 $lang['search_file'] = 'file';
    152 $lang['search_name'] = 'name';
    153 $lang['search_comment'] = 'comment';
    154 $lang['search_keywords'] = 'keywords';
    155 $lang['search_author'] = 'author';
    156 $lang['search_date_available'] = 'availability date';
    157 $lang['search_date_creation'] = 'creation date';
    158 $lang['search_one_clause_at_least'] = 'search at least on one search clause';
     143$lang['search_title'] = 'Rechercher';
     144$lang['search_options'] = 'Options de recherche';
     145$lang['search_keywords'] = 'Recherche par mots-clés';
     146$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';
     147$lang['search_mode_or'] = 'Rechercher n\'importe quel de ces termes';
     148$lang['search_mode_and'] = 'Rechercher tous les termes';
     149$lang['search_author'] = 'Recherche par auteur';
     150$lang['search_categories'] = 'Recherche dans les catégories';
     151$lang['search_subcats_included'] = 'Rechercher dans les sous-catégories';
     152$lang['search_categories_hint'] = 'Sélectionnez le ou les catégorie(s) pour lesquelles vous souhaitez faire votre rechercher.';
     153$lang['search_explain'] = 'Utilisez * comme un joker pour des recherches partielles';
     154$lang['search_date'] = 'Rechercher par date';
     155$lang['search_date_hint'] = 'Sélectionnez une date de début et une période pour vos recherches';
     156$lang['search_date_from'] = 'A partir du';
     157$lang['search_duration'] = 'Sur une période de';
     158$lang['search_date_type'] = 'Type de date';
     159$lang['search_date_available'] = 'Mise à disposition';
     160$lang['search_date_creation'] = 'Création';
     161$lang['search_sort'] = 'Trier par';
     162$lang['search_ascending'] = 'Croissant';
     163$lang['search_descending'] = 'Décroissant';
     164$lang['search_one_clause_at_least'] = 'Recherche vide. Aucun critère n\'a été renseigné.';
    159165$lang['search_result'] = 'Résultats de la recherche';
    160166$lang['invalid_search'] = 'Les mots recherchés doivent comporter plus de 3 caractères et ne doivent pas inclure de caractères de ponctuation';
    161 $lang['search_mode_or'] = 'au moins un mot';
    162 $lang['search_mode_and'] = 'tous les mots';
    163 $lang['search_comments'] = 'séparer les différents mots avec un espace';
    164 $lang['search_title'] = 'Recherche';
     167
    165168$lang['search_field_search'] = 'Rechercher';
    166169$lang['Search_author_explain'] = 'Utilisez * comme un joker pour des recherches partielles';
     
    191194$lang['nb_image_category'] = 'nombre d\'images dans la catégorie';
    192195$lang['recent_image'] = 'Image datant de moins de';
    193 $lang['days'] = 'jours';
    194196$lang['send_mail'] = 'Contacter l\'adminstrateur';
    195197$lang['title_send_mail'] = '[phpwebgallery] une remarque sur ton site';
  • trunk/search.php

    r614 r621  
    2626// +-----------------------------------------------------------------------+
    2727
    28 //------------------------------------------------------------------- functions
    29 // date_display displays 3 select input fields. The first one is the
    30 // day of the month, from 0 to 31. The second is the month of the year,
    31 // from 01 to 12. The last one is the year. The years displayed are the
    32 // ones given by get_available_years (see function description in
    33 // ./include/functions.inc.php).
    34 function display_date($fieldname, $datefield)
    35 {
    36   global $template;
    37 
    38   // years
    39   for ($i = 1990; $i < 2006; $i++)
    40   {
    41     $selected = '';
    42     $key = $datefield.':year';
    43     if (isset($_POST[$key]) and $i == $_POST[$key])
    44     {
    45       $selected = ' selected="selected"';
    46     }
    47    
    48     $template->assign_block_vars(
    49       $fieldname.'year_option',
    50       array('OPTION'=>$i,
    51             'SELECTED'=>$selected
    52         ));
    53   }
    54   // months of year
    55   for ($i = 1; $i <= 12; $i++)
    56   {
    57     $selected = '';
    58     $key = $datefield.':month';
    59     if (isset($_POST[$key]) and $i == $_POST[$key])
    60     {
    61       $selected = ' selected="selected"';
    62     }
    63 
    64     $template->assign_block_vars(
    65       $fieldname.'month_option',
    66       array('OPTION'=>sprintf('%02s', $i),
    67             'SELECTED'=>$selected
    68         ));
    69   }
    70   // days of the month
    71   for ($i = 1; $i <= 31; $i++)
    72   {
    73     $selected = '';
    74     $key = $datefield.':day';
    75     if (isset($_POST[$key]) and $i == $_POST[$key])
    76     {
    77       $selected = ' selected="selected"';
    78     }
    79 
    80     $template->assign_block_vars(
    81       $fieldname.'day_option',
    82       array('OPTION'=>sprintf('%02s', $i),
    83             'SELECTED'=>$selected
    84         ));
    85   }
    86 }
    87 
    88 function display_3dates($fieldname)
    89 {
    90   display_date('datefield.', $fieldname);
    91   display_date('datefield.after_', $fieldname.'-after');
    92   display_date('datefield.before_', $fieldname.'-before');
    93 }
    9428//--------------------------------------------------------------------- include
    9529define('PHPWG_ROOT_PATH','./');
     
    9731//-------------------------------------------------- access authorization check
    9832check_login_authorization();
    99 //----------------------------------------------------------------- form fields
    100 $textfields = array('file', 'name', 'comment', 'keywords', 'author');
    101 $datefields = array('date_available', 'date_creation');
    10233//------------------------------------------------------------------ form check
    10334$errors = array();
    10435$search = array();
    105 $search['fields'] = array();
    10636if (isset($_POST['submit']))
    10737{
    108   $search['mode'] = $_POST['mode'];
    109 
    110   foreach ($textfields as $textfield)
    111   {
    112     if (isset($_POST[$textfield.'-content'])
    113         and !preg_match('/^\s*$/', $_POST[$textfield.'-content']))
    114     {
    115       $local_search = array();
    116       $words = preg_split('/\s+/', $_POST[$textfield.'-content']);
    117       foreach ($words as $i => $word)
    118       {
    119         if (strlen($word) > 2 and !preg_match('/[,;:\']/', $word))
    120         {
    121           array_push($local_search, $word);
    122         }
    123         else
    124         {
    125           array_push($errors, $lang['invalid_search']);
    126         }
    127       }
    128       $local_search = array_unique($local_search);
    129       $search['fields'][$textfield] = array();
    130       $search['fields'][$textfield]['words'] = $local_search;
    131       if (count($local_search) > 1)
    132       {
    133         $search['fields'][$textfield]['mode'] = $_POST[$textfield.'-mode'];
    134       }
    135     }
    136   }
    137   foreach ($datefields as $datefield)
    138   {
    139     $suffixes = array('','-after','-before');
    140     foreach ($suffixes as $suffix)
    141     {
    142       $field = $datefield.$suffix;
    143       if (isset($_POST[$field.'-check']))
    144       {
    145         $year = $_POST[$field.':year'];
    146         $month = $_POST[$field.':month'];
    147         $day = $_POST[$field.':day'];
    148         $date = $year.'.'.$month.'.'.$day;
    149         if (!checkdate($month, $day, $year))
    150         {
    151           array_push($errors, $date.$lang['search_wrong_date']);
    152         }
    153         $search['fields'][$field] = array();
    154         $search['fields'][$field]['words'] = array($date);
    155         if ($suffix == '-after' or $suffix == '-before')
    156         {
    157           if (isset($_POST[$field.'-included']))
    158           {
    159             $search['fields'][$field]['mode'] = 'inc';
    160           }
    161         }
    162       }
    163     }
    164     if ($search['mode'] == 'AND')
    165     {
    166       // before date must be superior to after date
    167       if (isset($search['fields'][$datefield.'-before'])
    168           and isset($search['fields'][$datefield.'-after']))
    169       {
    170         $after = $search['fields'][$datefield.'-after']['words'][0];
    171         $before = $search['fields'][$datefield.'-before']['words'][0];
    172         if ($after >= $before)
    173         {
    174           array_push($errors, $lang['search_wrong_date_order']);
    175         }
    176       }
    177       // having "search is" and ("search is after" or "search is before") is
    178       // not coherent
    179       if (isset($search['fields'][$datefield])
    180           and (isset($search['fields'][$datefield.'-before'])
    181                or isset($search['fields'][$datefield.'-after'])))
    182       {
    183         array_push($errors, $lang['search_incoherent_date_search']);
    184       }
    185     }
    186   }
    187   if (isset($_POST['categories-check']))
    188   {
    189     $field = 'cat';
    190     $search['fields'][$field] = array();
    191     $search['fields'][$field]['words'] = $_POST['cat'];
     38  if ($_POST['search_keywords'] &&
     39   !preg_match('/^\s*$/', $_POST['search_keywords']))
     40  {
     41    $local_search = array();
     42        $search_keywords = $_POST['search_keywords'];
     43        $drop_char_match =   array('-', '^', '$', ';', '#', '&', '(', ')', '<', '>',
     44          '`', '\'', '"', '|', ',', '@', '_', '?', '%', '~', '.', '[', ']', '{', '}',
     45          ':', '\\', '/', '=', '\'', '!', '*');
     46        $drop_char_replace = array(' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
     47          '',  '',   ' ', ' ', ' ', ' ', '',  ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '
     48          , ' ', '' ,  ' ', ' ', ' ',  ' ', ' ');
     49        $search_keywords = str_replace($drop_char_match, $drop_char_replace, $search_keywords);
     50       
     51        // Split words
     52        $words = preg_split('#\s+#', $search_keywords);
     53    $words = array_unique($words);
     54        $search['fields']['keywords'] = array();
     55        $search['fields']['keywords']['words'] =$words;
     56        $search['fields']['keywords']['mode']= $_POST['mode'];
     57  }
     58 
     59  if ($_POST['search_author'])
     60  {
     61    $search['fields']['author'] = array();
     62    $search['fields']['author']['words'] = array($_POST['search_author']);
     63  }
     64 
     65  if (isset($_POST['cat']))
     66  {
     67    $search['fields']['cat'] = array();
     68    $search['fields']['cat']['words'] = $_POST['cat'];
    19269    if (isset($_POST['subcats-included']))
    19370    {
    194       $search['fields'][$field]['mode'] = 'sub_inc';
     71      $search['fields']['cat']['mode'] = 'sub_inc';
    19572    }
    19673  }
     74 
     75  if (!empty($_POST['start_year']))
     76 {
     77  $type_date = $_POST['date_type'];
     78
     79  // start event
     80  $date = $_POST['start_year'].'.'.$_POST['start_month'].'.'.$_POST['start_day'];
     81  $search['fields'][$type_date]['words'] = array($date);
     82 
     83  // duration
     84  $search_duration = 0;
     85  if ( !empty($date) && !empty( $_POST['duration_day']) )
     86  {
     87        $search['fields'][$type_date]['mode'] =  $_POST['duration_day'];
     88  }
     89 }
    19790  // search string (for URL) creation
    19891  $search_string = '';
    19992  $tokens = array();
     93  if (!empty($search))
     94  {
    20095  foreach (array_keys($search['fields']) as $field)
    20196  {
     
    211106  if (count($tokens) > 1)
    212107  {
    213     $search_string.= '|'.$search['mode'];
    214   }
    215  
    216   if (count($tokens) == 0)
     108    $search_string.= '|AND';
     109  }
     110  }
     111  else
    217112  {
    218113    array_push($errors, $lang['search_one_clause_at_least']);
     
    226121  redirect($url);
    227122}
     123
    228124//----------------------------------------------------- template initialization
     125// day list
     126$start_day = '<select name="start_day">';
     127for ($i=0; $i <= 31; $i++)
     128{
     129        $start_day .= '<option value="' . $i . '" >' . ( ($i == 0) ? ' -- ' : str_pad($i, 2, '0', STR_PAD_LEFT) ) . '</option>';
     130}
     131$start_day .= '</select>';
     132
     133// month list
     134$start_month = '<select name="start_month">';
     135$start_month .= '<option value="0"> ------------ </option>';
     136for ($i=1; $i <= 12; $i++)
     137{
     138        $start_month .= '<option value="' . $i . '">' . $lang['month'][$i] . '</option>';
     139}
     140$start_month .= '</select>';
     141
     142// year list
     143$start_year = '<select name="start_year">';
     144$start_year .= '<option value="0"> ---- </option>';
     145$begin_year = date('Y', time())-10;
     146for ($i = $begin_year; $i <= date('Y', time()); $i++)
     147{
     148        $start_year .= '<option value="' . $i . '">' . $i . '</option>';
     149}
     150$start_year .= '</select>';
     151
     152
    229153//
    230154// Start output of page
     
    235159$template->set_filenames( array('search'=>'search.tpl') );
    236160$template->assign_vars(array(
    237   'L_TITLE' => $lang['search_title'],
    238   'L_SEARCH_COMMENTS' => $lang['search_comments'],
     161  'L_SEARCH_TITLE' => $lang['search_title'],
     162  'L_SEARCH_OPTIONS' => $lang['search_options'],
    239163  'L_RETURN' => $lang['home'],
    240164  'L_SUBMIT' => $lang['submit'],
    241   'L_SEARCH_OR'=>$lang['search_mode_or'],
    242   'L_SEARCH_AND'=>$lang['search_mode_and'],
    243   'L_SEARCH_OR_CLAUSES'=>$lang['search_or_clauses'],
    244   'L_SEARCH_AND_CLAUSES'=>$lang['search_and_clauses'],
    245   'L_SEARCH_CATEGORIES'=>$lang['categories'],
    246   'L_SEARCH_SUBCATS_INCLUDED'=>$lang['search_subcats_included'],
    247   'L_SEARCH_DATE_INCLUDED'=> $lang['search_date_included'],
    248   'L_SEARCH_DATE_IS'=>$lang['search_date_is'],
    249   'L_SEARCH_DATE_IS_AFTER'=>$lang['search_date_is_after'],
    250   'L_SEARCH_DATE_IS_BEFORE'=>$lang['search_date_is_before'],
    251  
    252   'F_ACTION' => add_session_id( 'search.php' ),
    253    
     165  'L_RESET' => $lang['reset'],
     166  'L_SEARCH_KEYWORDS'=>$lang['search_keywords'],
     167  'L_SEARCH_KEYWORDS_HINT'=>$lang['search_keywords_hint'],
     168  'L_SEARCH_ANY_TERMS'=>$lang['search_mode_or'],
     169  'L_SEARCH_ALL_TERMS'=>$lang['search_mode_and'],
     170  'L_SEARCH_AUTHOR'=>$lang['search_author'],
     171  'L_SEARCH_AUTHOR_HINT'=>$lang['search_explain'],
     172  'L_SEARCH_CATEGORIES'=>$lang['search_categories'],
     173  'L_SEARCH_CATEGORIES_HINT'=>$lang['search_categories_hint'],
     174  'L_SEARCH_SUBFORUMS'=>$lang['search_subcats_included'],
     175  'L_YES' => $lang['yes'],
     176  'L_NO' => $lang['no'],
     177  'L_SEARCH_DATE' => $lang['search_date'],
     178  'L_SEARCH_DATE_HINT' => $lang['search_date_hint'],
     179  'L_TODAY' => $lang['today'],
     180  'L_SEARCH_DATE_FROM'=>$lang['search_date_from'],
     181  'L_SEARCH_DURATION'=>$lang['search_duration'],
     182  'L_DAYS'=>$lang['days'],
     183  'L_MONTH'=>$lang['w_month'],
     184  'L_SEARCH_DATE_TYPE'=>$lang['search_date_type'],
     185  'L_SEARCH_CREATION'=>$lang['search_date_creation'],
     186  'L_SEARCH_AVAILABILITY'=>$lang['search_date_available'],
     187  'L_RESULT_SORT'=>$lang['search_sort'],
     188  'L_SORT_ASCENDING'=>$lang['search_ascending'],
     189  'L_SORT_DESCENDING'=>$lang['search_descending'],
     190 
     191  'TODAY_DAY' => date('d', time()),
     192  'TODAY_MONTH' => date('m', time()),
     193  'TODAY_YEAR' => date('Y', time()),
     194  'S_CALENDAR_YEAR' => $start_year,
     195  'S_CALENDAR_MONTH' => $start_month,
     196  'S_CALENDAR_DAY' => $start_day,
     197  'S_SEARCH_ACTION' => add_session_id( 'search.php' ),   
    254198  'U_HOME' => add_session_id( 'category.php' )
    255199  )
    256200);
    257201
    258 //------------------------------------------------------------ text fields form
    259 foreach ($textfields as $textfield)
    260 {
    261   if (isset($_POST[$textfield.'-mode']))
    262   {
    263     if ($_POST[$textfield.'-mode'] == 'AND')
    264     {
    265       $and_checked = 'checked="checked"';
    266       $or_checked  = '';
    267     }
    268     else
    269     {
    270       $or_checked  = 'checked="checked"';
    271       $and_checked = '';
    272     }
    273   }
    274   else
    275   {
    276     $or_checked  = 'checked="checked"';
    277     $and_checked = '';
    278   }
    279 
    280   $value = '';
    281   if (isset($_POST[$textfield.'-content']))
    282   {
    283     $value = $_POST[$textfield.'-content'];
    284   }
    285  
    286   $template->assign_block_vars(
    287     'textfield',
    288     array('NAME'=>$lang['search_'.$textfield],
    289           'L_NAME'=>$textfield,
    290           'VALUE'=>$value,
    291           'OR_CHECKED'=>$or_checked,
    292           'AND_CHECKED'=>$and_checked
    293           ));
    294 }
    295 //------------------------------------------------------------- date field form
    296 foreach ($datefields as $datefield)
    297 {
    298   $checked = '';
    299   if (isset($_POST[$datefield.'-check']))
    300   {
    301     $checked = ' checked="checked"';
    302   }
    303 
    304   $after_checked = '';
    305   if (isset($_POST[$datefield.'-after-check']))
    306   {
    307     $after_checked = ' checked="checked"';
    308   }
    309 
    310   $before_checked = '';
    311   if (isset($_POST[$datefield.'-before-check']))
    312   {
    313     $before_checked = ' checked="checked"';
    314   }
    315 
    316   $after_included_check = '';
    317   if (isset($_POST[$datefield.'-after-included']))
    318   {
    319     $after_included_check = ' checked="checked"';
    320   }
    321 
    322   $before_included_check = '';
    323   if (isset($_POST[$datefield.'-before-included']))
    324   {
    325     $before_included_check = ' checked="checked"';
    326   }
    327  
    328   $template->assign_block_vars(
    329     'datefield',
    330     array('NAME'=>$datefield,
    331           'L_NAME'=>$lang['search_'.$datefield],
    332           'CHECKED'=>$checked,
    333           'AFTER_CHECKED'=>$after_checked,
    334           'BEFORE_CHECKED'=>$before_checked,
    335           'AFTER_INCLUDED_CHECKED'=>$after_included_check,
    336           'BEFORE_INCLUDED_CHECKED'=>$before_included_check
    337           ));
    338   display_3dates($datefield);
    339 }
    340202//------------------------------------------------------------- categories form
    341203$query = '
     
    349211$query.= '
    350212;';
     213
    351214$selecteds = array();
    352 if (isset($_POST['submit']))
    353 {
    354   $selecteds = $_POST['cat'];
    355 }
    356215display_select_cat_wrapper($query, $selecteds, 'category_option', false);
    357216
    358 $categories_selected = '';
    359 if (isset($_POST['categories-check']))
    360 {
    361   $categories_selected = 'checked="checked"';
    362 }
    363 
    364 $categories_subcats_selected = '';
    365 if (isset($_POST['subcats-included']))
    366 {
    367   $categories_subcats_selected = 'checked="checked"';
    368 }
    369 
    370 $template->assign_vars(
    371   array(
    372     'CATEGORIES_SELECTED'=>$categories_selected,
    373     'CATEGORIES_SUBCATS_SELECTED'=>$categories_subcats_selected
    374     )
    375   );
    376 //---------------------------------------------------------------------- OR/AND
    377 if (isset($_POST['mode']))
    378 {
    379   if ($_POST['mode'] == 'AND')
    380   {
    381     $and_checked = 'checked="checked"';
    382     $or_checked  = '';
    383   }
    384   else
    385   {
    386     $or_checked  = 'checked="checked"';
    387     $and_checked = '';
    388   }
    389 }
    390 else
    391 {
    392   $or_checked  = 'checked="checked"';
    393   $and_checked = '';
    394 }
    395 
    396 $template->assign_vars(
    397   array(
    398     'OR_CHECKED'=>$or_checked,
    399     'AND_CHECKED'=>$and_checked
    400     )
    401   );
    402217//-------------------------------------------------------------- errors display
    403218if (sizeof($errors) != 0)
  • trunk/template/default/default.css

    r602 r621  
    7878
    7979/* Navigation styles */
     80
     81.small{
     82  font-size:10px;
     83}
    8084
    8185.titreMenu,.titrePage
     
    323327  font-size:16px;
    324328}
    325 .menuInfoCat {
    326   font-family:sans-serif;
    327   font-size:11px;
    328 }
     329
    329330.totalImages {
    330331  text-align:center;
     
    332333  font-family:sans-serif;
    333334  font-size:11px;
    334 }
    335 
    336 .infoCat {
    337   margin-top:10px;
    338   margin-bottom:10px;
    339   text-align:left;
    340335}
    341336
     
    426421  text-align:left;
    427422}
    428 
    429 .confMenu {
    430   background-color:#444444;
    431   text-align:center;
    432 }
    433 
    434 .confMenu a {
    435   padding:2px;
    436   border:1px solid gray;
    437   background-color:#505050;
    438   color:#fff48e;
    439   color:lightgray;
    440 }
    441 
    442 .confMenu a:hover {
    443   color:orange;
    444   text-decoration:none;
    445 }
    446 
    447 .confMenu a.opened {
    448   background-color:gray;
    449   color:white;
    450   text-decoration:none;
    451 }
    452 
    453 .optionTrue {
    454   color:lightgreen;
    455 }
    456 
    457 .optionFalse {
    458   color:#ffe1e1;
    459 }
  • trunk/template/default/search.tpl

    r607 r621  
    1 <div class="titrePage">{L_TITLE}</div>
     1<div class="titrePage">{L_SEARCH_TITLE}</div>
    22<br />
    3 <form method="post" action="{F_ACTION}" style="text-align:center">
     3<form method="post" name="post" action="{S_SEARCH_ACTION}">
    44<!-- BEGIN errors -->
    55<div class="errors">
     
    1111</div>
    1212<!-- END errors -->
    13 <table>
    14   <!-- BEGIN textfield -->
    15   <tr>
    16     <td></td>
    17     <td>{textfield.L_NAME} *</td>
    18     <td>
    19       <input type="text" name="{textfield.NAME}-content" value="{textfield.VALUE}" size="40" />
    20       <input class="radio" type="radio" name="{textfield.NAME}-mode" value="OR" {textfield.OR_CHECKED} /> {L_SEARCH_OR}
    21       <input class="radio" type="radio" name="{textfield.NAME}-mode" value="AND" {textfield.AND_CHECKED} /> {L_SEARCH_AND}
    22     </td>
     13<table width="100%" align="center" cellpadding="2">
     14  <tr class="admin">
     15    <th colspan="4">{L_SEARCH_TITLE}</th>
    2316  </tr>
    24   <!-- END textfield -->
    25   <tr>
    26    <td colspan="3" style="text-align:center;">* {L_SEARCH_COMMENTS}</td>
     17  <tr>
     18    <td width="50%" colspan="2"><b>{L_SEARCH_KEYWORDS} : </b><br /><span class="small">{L_SEARCH_KEYWORDS_HINT}</span></td>
     19    <td colspan="2" valign="top">
     20          <input type="text" style="width: 300px" name="search_keywords" size="30" />
     21          <br />
     22          <input type="radio" name="mode" value="AND" checked="checked" /> {L_SEARCH_ALL_TERMS}<br />
     23          <input type="radio" name="mode" value="OR" /> {L_SEARCH_ANY_TERMS}
     24        </td>
    2725  </tr>
    28   <!-- BEGIN datefield -->
    29   <tr>
    30     <td></td>
    31     <td>{datefield.L_NAME}</td>
    32     <td>
    33       <table>
    34         <tr>
    35           <td style="text-align:left;"><input type="checkbox" name="{datefield.NAME}-check" value="1" {datefield.CHECKED} /> {L_SEARCH_DATE_IS}</td>
    36           <td style="text-align:left;">
    37             <select name="{datefield.NAME}:year">
    38               <!-- BEGIN year_option -->
    39               <option{datefield.year_option.SELECTED}>{datefield.year_option.OPTION}</option>
    40               <!-- END year_option -->
    41             </select>
    42             <select name="{datefield.NAME}:month">
    43               <!-- BEGIN month_option -->
    44               <option{datefield.month_option.SELECTED}>{datefield.month_option.OPTION}</option>
    45               <!-- END month_option -->
    46             </select>
    47             <select name="{datefield.NAME}:day">
    48               <!-- BEGIN day_option -->
    49               <option{datefield.day_option.SELECTED}>{datefield.day_option.OPTION}</option>
    50               <!-- END day_option -->
    51             </select>
    52           </td>
    53         </tr>
    54         <tr>
    55           <td style="text-align:left;"><input type="checkbox" name="{datefield.NAME}-after-check" value="1" {datefield.AFTER_CHECKED} /> {L_SEARCH_DATE_IS_AFTER}</td>
    56           <td style="text-align:left;">
    57             <select name="{datefield.NAME}-after:year">
    58               <!-- BEGIN after_year_option -->
    59               <option{datefield.after_year_option.SELECTED}>{datefield.after_year_option.OPTION}</option>
    60               <!-- END after_year_option -->
    61             </select>
    62             <select name="{datefield.NAME}-after:month">
    63               <!-- BEGIN after_month_option -->
    64               <option{datefield.after_month_option.SELECTED}>{datefield.after_month_option.OPTION}</option>
    65               <!-- END after_month_option -->
    66             </select>
    67             <select name="{datefield.NAME}-after:day">
    68               <!-- BEGIN after_day_option -->
    69               <option{datefield.after_day_option.SELECTED}>{datefield.after_day_option.OPTION}</option>
    70               <!-- END after_day_option -->
    71             </select>
    72             <input type="checkbox" name="{datefield.NAME}-after-included" value="1" {datefield.AFTER_INCLUDED_CHECKED} /> {L_SEARCH_DATE_INCLUDED}
    73           </td>
    74         </tr>
    75         <tr>
    76           <td style="text-align:left;"><input type="checkbox" name="{datefield.NAME}-before-check" value="1" {datefield.BEFORE_CHECKED} /> {L_SEARCH_DATE_IS_BEFORE}</td>
    77           <td style="text-align:left;">
    78             <select name="{datefield.NAME}-before:year">
    79               <!-- BEGIN before_year_option -->
    80               <option{datefield.before_year_option.SELECTED}>{datefield.before_year_option.OPTION}</option>
    81               <!-- END before_year_option -->
    82             </select>
    83             <select name="{datefield.NAME}-before:month">
    84               <!-- BEGIN before_month_option -->
    85               <option{datefield.before_month_option.SELECTED}>{datefield.before_month_option.OPTION}</option>
    86               <!-- END before_month_option -->
    87             </select>
    88             <select name="{datefield.NAME}-before:day">
    89               <!-- BEGIN before_day_option -->
    90               <option{datefield.before_day_option.SELECTED}>{datefield.before_day_option.OPTION}</option>
    91               <!-- END before_day_option -->
    92             </select>
    93             <input type="checkbox" name="{datefield.NAME}-before-included" value="1" {datefield.BEFORE_INCLUDED_CHECKED} /> {L_SEARCH_DATE_INCLUDED}
    94           </td>
    95         </tr>
    96       </table>
    97     </td>
     26  <tr>
     27    <td colspan="2"><b>{L_SEARCH_AUTHOR} :</b><br /><span class="small">{L_SEARCH_AUTHOR_HINT}</span></td>
     28    <td colspan="2" valign="middle">
     29          <input type="text" style="width: 300px" name="search_author" size="30" />
     30        </td>
     31  </tr>
     32  <tr>
     33    <td colspan="2"><b>{L_SEARCH_DATE} :</b><br /><span class="small">{L_SEARCH_DATE_HINT}</span></td>
     34    <td colspan="2" valign="middle">
     35        <table><tr><td>
     36          {L_SEARCH_DATE_FROM} :</td><td>
     37          {S_CALENDAR_DAY}{S_CALENDAR_MONTH}{S_CALENDAR_YEAR}&nbsp;
     38          <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>
     39          </tr><tr><td>
     40          {L_SEARCH_DURATION} : </td><td>
     41          <input name="duration_day" type="post" maxlength="5" size="3" value="{DURATION_DAY}" />&nbsp;{L_DAYS}
     42          </td></tr></table>
     43        </td>
     44  </tr>
     45  <tr class="admin">
     46    <th colspan="4">{L_SEARCH_OPTIONS}</th>
     47  </tr>
     48  <tr>
     49    <td width="25%" ><b>{L_SEARCH_CATEGORIES} : </b><br /><span class="small">{L_SEARCH_CATEGORIES_HINT}</span></td>
     50    <td width="25%" nowrap="nowrap">
     51          <select style="width:200px" name="cat[]" multiple="multiple" size="8">
     52      <!-- BEGIN category_option -->
     53        <option value="{category_option.VALUE}">{category_option.OPTION}</option>
     54      <!-- END category_option -->
     55      </select>
     56        </td>
     57    <td width="25%" nowrap="nowrap"><b>{L_SEARCH_SUBFORUMS} : </b></td>
     58    <td width="25%" nowrap="nowrap">
     59          <input type="radio" name="subcats-included" value="1" checked="checked" />{L_YES}&nbsp;&nbsp;
     60          <input type="radio" name="subcats-included" value="0" />{L_NO}
     61        </td>
     62   </tr>
     63   <tr>
     64    <td width="25%" nowrap="nowrap"><b>{L_SEARCH_DATE_TYPE} : </b></td>
     65    <td width="25%" nowrap="nowrap">
     66          <input type="radio" name="date_type" value="date_creation" />{L_SEARCH_CREATION}<br />
     67          <input type="radio" name="date_type" value="date_available" checked="checked" />{L_SEARCH_AVAILABILITY}
     68        </td>
     69        <td><b>{L_RESULT_SORT} : </b></td>
     70    <td nowrap="nowrap">
     71          <input type="radio" name="sd" value="AND" />{L_SORT_ASCENDING}<br />
     72          <input type="radio" name="sd" value="d" checked="checked" />{L_SORT_DESCENDING}
     73        </td>
     74  </tr>
     75<!--  <tr>
     76    <td width="25%" nowrap="nowrap"><b>{L_SEARCH_WITHIN} : </b></td>
     77    <td width="25%" nowrap="nowrap">
     78          <input type="radio" name="search_fields" value="all" checked="checked" />{L_SEARCH_ALL}<br />
     79          <input type="radio" name="search_fields" value="imgonly" />{L_SEARCH_IMG_ONLY}<br />
     80          <input type="radio" name="search_fields" value="commentsonly" />{L_SEARCH_COMMENTS_ONLY}
     81        </td>
    9882  </tr>
    9983  <tr>
    100   </tr>
    101   <!-- END datefield -->
    102   <tr>
    103     <td><input type="checkbox" name="categories-check" value="1" {CATEGORIES_SELECTED} /></td>
    104     <td>{L_SEARCH_CATEGORIES}</td>
    105     <td>
    106       <select style="width:500px" name="cat[]" multiple="multiple" size="10">
    107         <!-- BEGIN category_option -->
    108         <option {category_option.SELECTED} value="{category_option.VALUE}">{category_option.OPTION}</option>
    109         <!-- END category_option -->
    110       </select>
    111       <input type="checkbox" name="subcats-included" value="1" {CATEGORIES_SUBCATS_SELECTED} /> {L_SEARCH_SUBCATS_INCLUDED}
    112     </td>
    113   </tr>
     84    <td><b>{L_RESULT_SORT} : </b></td>
     85    <td nowrap="nowrap">
     86          {S_SELECT_SORT_KEY}<br />
     87          <input type="radio" name="sd" value="a" />{L_SORT_ASCENDING}<br />
     88          <input type="radio" name="sd" value="d" checked="checked" />{L_SORT_DESCENDING}
     89        </td>
     90    <td nowrap="nowrap"><b>{L_DISPLAY_RESULTS} : </b></td>
     91    <td nowrap="nowrap">
     92          <input type="radio" name="show_results" value="images" checked="checked" />{L_IMAGES}&nbsp;&nbsp;
     93          <input type="radio" name="show_results" value="comments" /> {L_COMMENTS}
     94        </td>
     95  </tr> 
     96  -->
     97<tr>
     98<td align="center" valign="bottom" colspan="4" height="38">
     99<input type="submit" name="submit" value="{L_SUBMIT}" class="bouton" />&nbsp;&nbsp;
     100<input type="reset" value="{L_RESET}" class="bouton" />
     101</td>
    114102</table>
    115 <input class="radio" type="radio" name="mode" value="OR" {OR_CHECKED} /> {L_SEARCH_OR_CLAUSES}
    116 <input class="radio" type="radio" name="mode" value="AND" {AND_CHECKED} /> {L_SEARCH_AND_CLAUSES}<br /><br />
    117 <input type="submit" name="submit" value="{L_SUBMIT}" class="bouton" /><br /><br />
     103</form>
    118104<a href="{U_HOME}" title="{L_RETURN_HINT}">[ {L_RETURN} ]</a>
Note: See TracChangeset for help on using the changeset viewer.