[1015] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[2297] | 3 | // | Piwigo - a PHP based picture gallery | |
---|
| 4 | // +-----------------------------------------------------------------------+ |
---|
| 5 | // | Copyright(C) 2008 Piwigo Team http://piwigo.org | |
---|
| 6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
| 7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
| 8 | // +-----------------------------------------------------------------------+ |
---|
| 9 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 10 | // | it under the terms of the GNU General Public License as published by | |
---|
| 11 | // | the Free Software Foundation | |
---|
| 12 | // | | |
---|
| 13 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 16 | // | General Public License for more details. | |
---|
| 17 | // | | |
---|
| 18 | // | You should have received a copy of the GNU General Public License | |
---|
| 19 | // | along with this program; if not, write to the Free Software | |
---|
| 20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 21 | // | USA. | |
---|
| 22 | // +-----------------------------------------------------------------------+ |
---|
| 23 | // +-----------------------------------------------------------------------+ |
---|
[1015] | 24 | // | PhpWebGallery - a PHP based picture gallery | |
---|
| 25 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
[2223] | 26 | // | Copyright (C) 2003-2008 PhpWebGallery Team - http://phpwebgallery.net | |
---|
[1015] | 27 | // +-----------------------------------------------------------------------+ |
---|
[1113] | 28 | // | file : $Id: search_rules.php 2297 2008-04-04 22:57:23Z plg $ |
---|
| 29 | // | last update : $Date: 2008-04-04 22:57:23 +0000 (Fri, 04 Apr 2008) $ |
---|
| 30 | // | last modifier : $Author: plg $ |
---|
| 31 | // | revision : $Revision: 2297 $ |
---|
[1015] | 32 | // +-----------------------------------------------------------------------+ |
---|
| 33 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 34 | // | it under the terms of the GNU General Public License as published by | |
---|
| 35 | // | the Free Software Foundation | |
---|
| 36 | // | | |
---|
| 37 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 38 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 39 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 40 | // | General Public License for more details. | |
---|
| 41 | // | | |
---|
| 42 | // | You should have received a copy of the GNU General Public License | |
---|
| 43 | // | along with this program; if not, write to the Free Software | |
---|
| 44 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 45 | // | USA. | |
---|
| 46 | // +-----------------------------------------------------------------------+ |
---|
| 47 | |
---|
| 48 | /** |
---|
| 49 | * returns language value 'included' or 'excluded' depending on boolean |
---|
| 50 | * value. This function is useful only to make duplicate code shorter |
---|
| 51 | * |
---|
| 52 | * @param bool is_included |
---|
| 53 | * @return string |
---|
| 54 | */ |
---|
| 55 | function inc_exc_str($is_included) |
---|
| 56 | { |
---|
| 57 | return $is_included ? l10n('included') : l10n('excluded'); |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | // +-----------------------------------------------------------------------+ |
---|
| 61 | // | initialization | |
---|
| 62 | // +-----------------------------------------------------------------------+ |
---|
| 63 | |
---|
| 64 | define('PHPWG_ROOT_PATH','./'); |
---|
| 65 | include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
---|
[1851] | 66 | check_status(ACCESS_NONE); |
---|
[1113] | 67 | include_once( PHPWG_ROOT_PATH.'include/functions_search.inc.php' ); |
---|
[1015] | 68 | |
---|
| 69 | $page['body_id'] = 'thePopuphelpPage'; |
---|
[1071] | 70 | $title = l10n('PhpWebGallery Help'); |
---|
| 71 | $page['page_banner'] = '<h1>'.$title.'</h1>'; |
---|
[2138] | 72 | $page['meta_robots']=array('noindex'=>1, 'nofollow'=>1); |
---|
[1015] | 73 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
---|
| 74 | |
---|
| 75 | $template->set_filenames(array('search_rules' => 'search_rules.tpl')); |
---|
| 76 | |
---|
| 77 | // +-----------------------------------------------------------------------+ |
---|
| 78 | // | Textual rules creation | |
---|
| 79 | // +-----------------------------------------------------------------------+ |
---|
| 80 | |
---|
| 81 | // Rules are stored in database, serialized in an array. This array must be |
---|
| 82 | // transformed into a list of textual rules. |
---|
| 83 | |
---|
| 84 | $search = get_search_array($_GET['search_id']); |
---|
| 85 | |
---|
[1537] | 86 | if (isset($search['q'])) |
---|
| 87 | { |
---|
[2223] | 88 | $template->append( 'search_words', $search['q'] ); |
---|
[1537] | 89 | } |
---|
| 90 | else |
---|
| 91 | { |
---|
[2223] | 92 | $template->assign( |
---|
[1537] | 93 | array( |
---|
| 94 | 'INTRODUCTION' |
---|
| 95 | => 'OR' == $search['mode'] |
---|
| 96 | ? l10n('At least one listed rule must be satisfied.') |
---|
| 97 | : l10n('Each listed rule must be satisfied.'), |
---|
| 98 | ) |
---|
| 99 | ); |
---|
| 100 | } |
---|
[1015] | 101 | |
---|
| 102 | if (isset($search['fields']['allwords'])) |
---|
| 103 | { |
---|
[2223] | 104 | $template->append( 'search_words', |
---|
| 105 | sprintf( |
---|
[1015] | 106 | l10n('searched words : %s'), |
---|
| 107 | join(', ', $search['fields']['allwords']['words']) |
---|
| 108 | ) |
---|
[2223] | 109 | ); |
---|
[1015] | 110 | } |
---|
| 111 | |
---|
[1119] | 112 | if (isset($search['fields']['tags'])) |
---|
| 113 | { |
---|
[2223] | 114 | $template->assign('SEARCH_TAGS_MODE', $search['fields']['tags']['mode']); |
---|
| 115 | |
---|
[1119] | 116 | $query = ' |
---|
| 117 | SELECT name |
---|
| 118 | FROM '.TAGS_TABLE.' |
---|
| 119 | WHERE id IN ('.implode(',', $search['fields']['tags']['words']).') |
---|
| 120 | ;'; |
---|
[2223] | 121 | $template->assign( |
---|
| 122 | 'search_tags', |
---|
| 123 | array_from_query($query, 'name') |
---|
| 124 | ); |
---|
[1119] | 125 | } |
---|
| 126 | |
---|
[1015] | 127 | if (isset($search['fields']['author'])) |
---|
| 128 | { |
---|
[2223] | 129 | $template->append( |
---|
| 130 | 'search_words', |
---|
| 131 | sprintf( |
---|
[1015] | 132 | l10n('author(s) : %s'), |
---|
| 133 | join(', ', $search['fields']['author']['words']) |
---|
| 134 | ) |
---|
[2223] | 135 | ); |
---|
[1015] | 136 | } |
---|
| 137 | |
---|
| 138 | if (isset($search['fields']['cat'])) |
---|
| 139 | { |
---|
| 140 | if ($search['fields']['cat']['sub_inc']) |
---|
| 141 | { |
---|
| 142 | // searching all the categories id of sub-categories |
---|
| 143 | $cat_ids = get_subcat_ids($search['fields']['cat']['words']); |
---|
| 144 | } |
---|
| 145 | else |
---|
| 146 | { |
---|
| 147 | $cat_ids = $search['fields']['cat']['words']; |
---|
| 148 | } |
---|
| 149 | |
---|
| 150 | $query = ' |
---|
| 151 | SELECT id, uppercats, global_rank |
---|
| 152 | FROM '.CATEGORIES_TABLE.' |
---|
| 153 | WHERE id IN ('. |
---|
| 154 | implode(',', $cat_ids). |
---|
| 155 | ') |
---|
| 156 | ;'; |
---|
| 157 | $result = pwg_query($query); |
---|
| 158 | |
---|
| 159 | $categories = array(); |
---|
| 160 | if (!empty($result)) |
---|
| 161 | { |
---|
| 162 | while ($row = mysql_fetch_array($result)) |
---|
| 163 | { |
---|
| 164 | array_push($categories, $row); |
---|
| 165 | } |
---|
| 166 | } |
---|
| 167 | usort($categories, 'global_rank_compare'); |
---|
| 168 | |
---|
| 169 | foreach ($categories as $category) |
---|
| 170 | { |
---|
[2223] | 171 | $template->append( |
---|
| 172 | 'search_categories', |
---|
| 173 | get_cat_display_name_cache( |
---|
[1015] | 174 | $category['uppercats'], |
---|
[1092] | 175 | null, // no url on category names |
---|
[1015] | 176 | false // no blank replacement |
---|
| 177 | ) |
---|
| 178 | ); |
---|
| 179 | } |
---|
| 180 | } |
---|
| 181 | |
---|
| 182 | foreach (array('date_available', 'date_creation') as $datefield) |
---|
| 183 | { |
---|
| 184 | if ('date_available' == $datefield) |
---|
| 185 | { |
---|
| 186 | $lang_items = array( |
---|
| 187 | 'date' => 'became available on %s', |
---|
| 188 | 'period' => 'became available between %s (%s) and %s (%s)', |
---|
| 189 | 'after' => 'became available after %s (%s)', |
---|
| 190 | 'before' => 'became available before %s (%s)', |
---|
| 191 | ); |
---|
| 192 | } |
---|
| 193 | elseif ('date_creation' == $datefield) |
---|
| 194 | { |
---|
| 195 | $lang_items = array( |
---|
| 196 | 'date' => 'created on %s', |
---|
| 197 | 'period' => 'created between %s (%s) and %s (%s)', |
---|
| 198 | 'after' => 'created after %s (%s)', |
---|
| 199 | 'before' => 'created before %s (%s)', |
---|
| 200 | ); |
---|
| 201 | } |
---|
| 202 | |
---|
| 203 | $keys = array( |
---|
| 204 | 'date' => $datefield, |
---|
| 205 | 'after' => $datefield.'-after', |
---|
| 206 | 'before' => $datefield.'-before', |
---|
| 207 | ); |
---|
| 208 | |
---|
| 209 | if (isset($search['fields'][ $keys['date'] ])) |
---|
| 210 | { |
---|
[2223] | 211 | $template->assign( |
---|
| 212 | strtoupper($datefield), |
---|
| 213 | sprintf( |
---|
[1015] | 214 | l10n($lang_items['date']), |
---|
| 215 | format_date($search['fields'][ $keys['date'] ]) |
---|
[2223] | 216 | ) |
---|
[1015] | 217 | ); |
---|
| 218 | } |
---|
| 219 | elseif (isset($search['fields'][ $keys['before'] ]) |
---|
| 220 | and isset($search['fields'][ $keys['after'] ])) |
---|
| 221 | { |
---|
[2223] | 222 | $template->assign( |
---|
| 223 | strtoupper($datefield), |
---|
| 224 | sprintf( |
---|
[1015] | 225 | l10n($lang_items['period']), |
---|
[1071] | 226 | |
---|
[1015] | 227 | format_date($search['fields'][ $keys['after'] ]['date']), |
---|
| 228 | inc_exc_str($search['fields'][ $keys['after'] ]['inc']), |
---|
| 229 | |
---|
| 230 | format_date($search['fields'][ $keys['before'] ]['date']), |
---|
| 231 | inc_exc_str($search['fields'][ $keys['before'] ]['inc']) |
---|
[2223] | 232 | ) |
---|
[1015] | 233 | ); |
---|
| 234 | } |
---|
| 235 | elseif (isset($search['fields'][ $keys['before'] ])) |
---|
| 236 | { |
---|
[2223] | 237 | $template->assign( |
---|
| 238 | strtoupper($datefield), |
---|
| 239 | sprintf( |
---|
[1015] | 240 | l10n($lang_items['before']), |
---|
[1071] | 241 | |
---|
[1015] | 242 | format_date($search['fields'][ $keys['before'] ]['date']), |
---|
| 243 | inc_exc_str($search['fields'][ $keys['before'] ]['inc']) |
---|
[2223] | 244 | ) |
---|
[1015] | 245 | ); |
---|
| 246 | } |
---|
| 247 | elseif (isset($search['fields'][ $keys['after'] ])) |
---|
| 248 | { |
---|
[2223] | 249 | $template->assign( |
---|
| 250 | strtoupper($datefield), |
---|
| 251 | sprintf( |
---|
[1015] | 252 | l10n($lang_items['after']), |
---|
[1071] | 253 | |
---|
[1015] | 254 | format_date($search['fields'][ $keys['after'] ]['date']), |
---|
| 255 | inc_exc_str($search['fields'][ $keys['after'] ]['inc']) |
---|
| 256 | ) |
---|
| 257 | ); |
---|
| 258 | } |
---|
| 259 | } |
---|
| 260 | |
---|
| 261 | // +-----------------------------------------------------------------------+ |
---|
| 262 | // | html code display | |
---|
| 263 | // +-----------------------------------------------------------------------+ |
---|
| 264 | |
---|
[2223] | 265 | $template->pparse('search_rules'); |
---|
[1015] | 266 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
| 267 | ?> |
---|