Changeset 629


Ignore:
Timestamp:
Dec 2, 2004, 1:45:57 PM (19 years ago)
Author:
gweltas
Message:

Search form update

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/search.php

    r593 r629  
    4040  'L_SEARCH_USERNAME'=>$lang['Find_username'],
    4141  'L_SEARCH'=>$lang['search'],
    42   'L_SEARCH_EXPLAIN'=>$lang['Search_author_explain'],
     42  'L_SEARCH_EXPLAIN'=>$lang['search_explain'],
    4343  'L_SELECT'=>$lang['Select'],
    4444  'L_UPDATE_USERNAME'=>$lang['Look_up_user'],
  • trunk/admin/user_perm.php

    r593 r629  
    8787    'L_SELECT' => $lang['Select'],
    8888    'L_SEARCH' => $lang['Search'],
    89     'L_SEARCH_EXPLAIN' => $lang['Search_author_explain'],
     89    'L_SEARCH_EXPLAIN' => $lang['search_explain'],
    9090    'L_CLOSE_WINDOW' => $lang['Close_window'],
    9191
  • trunk/include/functions_category.inc.php

    r621 r629  
    417417        // construction
    418418        $clauses = $temp_clauses = array();
    419         if (isset($search['fields']['keywords']))
    420                 {
     419        if (isset($search['fields']['allwords']))
     420    {
    421421          $textfields = array('file', 'name', 'comment', 'keywords', 'author');
    422422          foreach ($textfields as $textfield)
    423423          {
    424424            $local_clauses = array();
    425             foreach ($search['fields']['keywords']['words'] as $word)
     425            foreach ($search['fields']['allwords']['words'] as $word)
    426426            {
    427427              array_push($local_clauses, $textfield." LIKE '%".$word."%'");
     
    430430            array_walk($local_clauses,create_function('&$s','$s="(".$s.")";'));
    431431            array_push($temp_clauses,
    432                        implode(' '.$search['fields']['keywords']['mode'].' ',
     432                       implode(' '.$search['fields']['allwords']['mode'].' ',
    433433                               $local_clauses));
    434434          }
    435                   array_push($clauses, implode(' OR ', $temp_clauses));
    436         }
    437                
    438                 if (isset($search['fields']['author']))
    439                 {
     435      array_push($clauses, implode(' OR ', $temp_clauses));
     436        }
     437   
     438    if (isset($search['fields']['author']))
     439    {
    440440           array_push($clauses, "author LIKE '%".$search['fields']['author']['words'][0]."%'");
    441                 }
     441    }
    442442
    443443        $datefields = array('date_available', 'date_creation');
     
    448448          {
    449449            $local_clause = $datefield." ";
    450                         if (isset($search['fields'][$key]['mode']))
    451                         {
    452                           $local_clause .=">";
    453                         }
    454                         $local_clause .="= '";
    455             $local_clause.= str_replace('.', '-',
     450      if (isset($search['fields'][$key]['mode']))
     451      {
     452        $local_clause .=">";
     453      }
     454      $local_clause .="= '";
     455      $local_clause.= str_replace('.', '-',
    456456                                        $search['fields'][$key]['words'][0]);
    457             $local_clause.= "'";
    458             array_push($clauses, $local_clause);
    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         }
     457      $local_clause.= "'";
     458      array_push($clauses, $local_clause);
     459     
     460      if (isset($search['fields'][$key]['mode']))
     461      {
     462        $end_sql_date = str_replace('.', '-',
     463                                        $search['fields'][$key]['mode']);
     464        $local_clause = $datefield." <= '".$end_sql_date."'";
     465        array_push($clauses, $local_clause);
     466      }
     467    }
     468  }
    472469       
    473470        if (isset($search['fields']['cat']))
  • trunk/language/en_UK.iso-8859-1/common.lang.php

    r621 r629  
    142142$lang['search_title'] = 'Search';
    143143$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';
     144$lang['search_keywords'] = 'Search for words';
     145$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';
    146146$lang['search_mode_or'] = 'Search for any terms';
    147147$lang['search_mode_and'] = 'Search for all terms ';
     
    152152$lang['search_explain'] = 'Use * as a wildcard for partial matches';
    153153$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';
     154$lang['search_date_hint'] = 'Select a date and/or an ending date for your query.<br />
     155Leave date empty if you want to make a "before" query.<br />
     156The year must be entered in the last field in the following format : 0000 (i.e. 2004)';
     157$lang['search_date_from'] = 'Date';
     158$lang['search_date_to'] = 'End-Date';
    157159$lang['search_date_type'] = 'Kind of date';
    158160$lang['search_date_available'] = 'Availability';
     
    164166$lang['search_result'] = 'Search results';
    165167
    166 $lang['Search_author_explain'] = 'Use * as a wildcard for partial matches';
    167168$lang['Look_up_user'] = 'Seek user';
    168169$lang['Find_username'] = 'Find a username';
  • trunk/language/fr_FR.iso-8859-1/common.lang.php

    r623 r629  
    144144$lang['search_title'] = 'Rechercher';
    145145$lang['search_options'] = 'Options de recherche';
    146 $lang['search_keywords'] = 'Recherche par mots-clés';
    147 $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';
     146$lang['search_keywords'] = 'Recherche par mots';
     147$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';
    148148$lang['search_mode_or'] = 'Rechercher n\'importe quel de ces termes';
    149149$lang['search_mode_and'] = 'Rechercher tous les termes';
     
    154154$lang['search_explain'] = 'Utilisez * comme un joker pour des recherches partielles';
    155155$lang['search_date'] = 'Rechercher par date';
    156 $lang['search_date_hint'] = 'Sélectionnez une date de début et une période pour vos recherches';
    157 $lang['search_date_from'] = 'A partir du';
    158 $lang['search_duration'] = 'Sur une période de';
     156$lang['search_date_hint'] = 'Sélectionnez une date et une date de fin pour vos recherches.<br />
     157Ne remplissez que la date de fin pour faire une recherche de type "avant".<br />
     158L\'année doit être rentrée dans le dernier champ sous la forme 0000 (par exemple 2004).';
     159$lang['search_date_from'] = 'Date';
     160$lang['search_date_to'] = 'Date de fin';
    159161$lang['search_date_type'] = 'Type de date';
    160162$lang['search_date_available'] = 'Mise à disposition';
     
    167169$lang['invalid_search'] = 'Les mots recherchés doivent comporter plus de 3 caractères et ne doivent pas inclure de caractères de ponctuation';
    168170
    169 $lang['search_field_search'] = 'Rechercher';
    170 $lang['Search_author_explain'] = 'Utilisez * comme un joker pour des recherches partielles';
    171171$lang['Look_up_user'] = 'Rechercher l\'utilisateur';
    172172$lang['Find_username'] = 'Trouver un nom d\'utilisateur';
  • trunk/search.php

    r621 r629  
    3636if (isset($_POST['submit']))
    3737{
    38   if ($_POST['search_keywords'] &&
    39    !preg_match('/^\s*$/', $_POST['search_keywords']))
     38  if ($_POST['search_allwords'] &&
     39   !preg_match('/^\s*$/', $_POST['search_allwords']))
    4040  {
    4141    $local_search = array();
    42         $search_keywords = $_POST['search_keywords'];
     42        $search_keywords = $_POST['search_allwords'];
    4343        $drop_char_match =   array('-', '^', '$', ';', '#', '&', '(', ')', '<', '>',
    4444          '`', '\'', '"', '|', ',', '@', '_', '?', '%', '~', '.', '[', ']', '{', '}',
     
    5252        $words = preg_split('#\s+#', $search_keywords);
    5353    $words = array_unique($words);
    54         $search['fields']['keywords'] = array();
    55         $search['fields']['keywords']['words'] =$words;
    56         $search['fields']['keywords']['mode']= $_POST['mode'];
     54        $search['fields']['allwords'] = array();
     55        $search['fields']['allwords']['words'] =$words;
     56        $search['fields']['allwords']['mode']= $_POST['mode'];
    5757  }
    5858 
     
    8383  // duration
    8484  $search_duration = 0;
    85   if ( !empty($date) && !empty( $_POST['duration_day']) )
    86   {
    87         $search['fields'][$type_date]['mode'] =  $_POST['duration_day'];
     85  if ( !empty($date) && !empty( $_POST['end_year']) )
     86  {
     87        $end_date = $_POST['end_year'].'.'.$_POST['end_month'].'.'.$_POST['end_day'];
     88        $search['fields'][$type_date]['mode'] =  $end_date;
    8889  }
    8990 }
     
    140141$start_month .= '</select>';
    141142
    142 // year list
    143 $start_year = '<select name="start_year">';
    144 $start_year .= '<option value="0"> ---- </option>';
    145 $begin_year = date('Y', time())-10;
    146 for ($i = $begin_year; $i <= date('Y', time()); $i++)
    147 {
    148         $start_year .= '<option value="' . $i . '">' . $i . '</option>';
    149 }
    150 $start_year .= '</select>';
    151 
     143// day list
     144$end_day = '<select name="end_day">';
     145for ($i=0; $i <= 31; $i++)
     146{
     147        $end_day .= '<option value="' . $i . '" >' . ( ($i == 0) ? ' -- ' : str_pad($i, 2, '0', STR_PAD_LEFT) ) . '</option>';
     148}
     149$end_day .= '</select>';
     150
     151// month list
     152$end_month = '<select name="end_month">';
     153$end_month .= '<option value="0"> ------------ </option>';
     154for ($i=1; $i <= 12; $i++)
     155{
     156        $end_month .= '<option value="' . $i . '">' . $lang['month'][$i] . '</option>';
     157}
     158$end_month .= '</select>';
    152159
    153160//
     
    179186  'L_TODAY' => $lang['today'],
    180187  'L_SEARCH_DATE_FROM'=>$lang['search_date_from'],
    181   'L_SEARCH_DURATION'=>$lang['search_duration'],
     188  'L_SEARCH_DATE_TO'=>$lang['search_date_to'],
    182189  'L_DAYS'=>$lang['days'],
    183190  'L_MONTH'=>$lang['w_month'],
     
    192199  'TODAY_MONTH' => date('m', time()),
    193200  'TODAY_YEAR' => date('Y', time()),
    194   'S_CALENDAR_YEAR' => $start_year,
     201  'E_CALENDAR_MONTH' => $end_month,
     202        'E_CALENDAR_DAY' => $end_day,
    195203  'S_CALENDAR_MONTH' => $start_month,
    196204  'S_CALENDAR_DAY' => $start_day,
  • trunk/template/default/search.tpl

    r621 r629  
    1818    <td width="50%" colspan="2"><b>{L_SEARCH_KEYWORDS} : </b><br /><span class="small">{L_SEARCH_KEYWORDS_HINT}</span></td>
    1919    <td colspan="2" valign="top">
    20           <input type="text" style="width: 300px" name="search_keywords" size="30" />
     20          <input type="text" style="width: 300px" name="search_allwords" size="30" />
    2121          <br />
    2222          <input type="radio" name="mode" value="AND" checked="checked" /> {L_SEARCH_ALL_TERMS}<br />
     
    3535        <table><tr><td>
    3636          {L_SEARCH_DATE_FROM} :</td><td>
    37           {S_CALENDAR_DAY}{S_CALENDAR_MONTH}{S_CALENDAR_YEAR}&nbsp;
     37          {S_CALENDAR_DAY}&nbsp;{S_CALENDAR_MONTH}&nbsp;<input name="start_year" type="text" size="4" maxlength="4">&nbsp;
    3838          <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>
    3939          </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}
     40          {L_SEARCH_DATE_TO} :</td><td>
     41          {E_CALENDAR_DAY}&nbsp;{E_CALENDAR_MONTH}&nbsp;<input name="end_year" type="text" size="4" maxlength="4">&nbsp;
     42          <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>
    4243          </td></tr></table>
    4344        </td>
     
    6465    <td width="25%" nowrap="nowrap"><b>{L_SEARCH_DATE_TYPE} : </b></td>
    6566    <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}
     67          <input type="radio" name="date_type" value="date_creation" checked="checked" />{L_SEARCH_CREATION}<br />
     68          <input type="radio" name="date_type" value="date_available" />{L_SEARCH_AVAILABILITY}
    6869        </td>
    6970        <td><b>{L_RESULT_SORT} : </b></td>
Note: See TracChangeset for help on using the changeset viewer.