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