[1015] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 3 | // | Piwigo - a PHP based photo gallery | |
---|
[2297] | 4 | // +-----------------------------------------------------------------------+ |
---|
[19703] | 5 | // | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org | |
---|
[2297] | 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 | // +-----------------------------------------------------------------------+ |
---|
[1015] | 23 | |
---|
| 24 | /** |
---|
| 25 | * returns language value 'included' or 'excluded' depending on boolean |
---|
| 26 | * value. This function is useful only to make duplicate code shorter |
---|
| 27 | * |
---|
| 28 | * @param bool is_included |
---|
| 29 | * @return string |
---|
| 30 | */ |
---|
| 31 | function inc_exc_str($is_included) |
---|
| 32 | { |
---|
[5310] | 33 | return $is_included ? l10n('included') : l10n('excluded'); |
---|
[1015] | 34 | } |
---|
| 35 | |
---|
| 36 | // +-----------------------------------------------------------------------+ |
---|
| 37 | // | initialization | |
---|
| 38 | // +-----------------------------------------------------------------------+ |
---|
| 39 | |
---|
| 40 | define('PHPWG_ROOT_PATH','./'); |
---|
| 41 | include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
---|
[2325] | 42 | check_status(ACCESS_FREE); |
---|
[1113] | 43 | include_once( PHPWG_ROOT_PATH.'include/functions_search.inc.php' ); |
---|
[1015] | 44 | |
---|
| 45 | $page['body_id'] = 'thePopuphelpPage'; |
---|
[2342] | 46 | $title = l10n('Piwigo Help'); |
---|
[7823] | 47 | $page['page_banner'] = ''; |
---|
[2138] | 48 | $page['meta_robots']=array('noindex'=>1, 'nofollow'=>1); |
---|
[1015] | 49 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
---|
| 50 | |
---|
| 51 | $template->set_filenames(array('search_rules' => 'search_rules.tpl')); |
---|
| 52 | |
---|
| 53 | // +-----------------------------------------------------------------------+ |
---|
| 54 | // | Textual rules creation | |
---|
| 55 | // +-----------------------------------------------------------------------+ |
---|
| 56 | |
---|
| 57 | // Rules are stored in database, serialized in an array. This array must be |
---|
| 58 | // transformed into a list of textual rules. |
---|
| 59 | |
---|
| 60 | $search = get_search_array($_GET['search_id']); |
---|
| 61 | |
---|
[1537] | 62 | if (isset($search['q'])) |
---|
| 63 | { |
---|
[2223] | 64 | $template->append( 'search_words', $search['q'] ); |
---|
[1537] | 65 | } |
---|
| 66 | else |
---|
| 67 | { |
---|
[2223] | 68 | $template->assign( |
---|
[1537] | 69 | array( |
---|
| 70 | 'INTRODUCTION' |
---|
| 71 | => 'OR' == $search['mode'] |
---|
| 72 | ? l10n('At least one listed rule must be satisfied.') |
---|
| 73 | : l10n('Each listed rule must be satisfied.'), |
---|
| 74 | ) |
---|
| 75 | ); |
---|
| 76 | } |
---|
[1015] | 77 | |
---|
| 78 | if (isset($search['fields']['allwords'])) |
---|
| 79 | { |
---|
[25005] | 80 | $template->append( |
---|
| 81 | 'search_words', |
---|
| 82 | l10n( |
---|
| 83 | 'searched words : %s', |
---|
[1015] | 84 | join(', ', $search['fields']['allwords']['words']) |
---|
| 85 | ) |
---|
[2223] | 86 | ); |
---|
[1015] | 87 | } |
---|
| 88 | |
---|
[1119] | 89 | if (isset($search['fields']['tags'])) |
---|
| 90 | { |
---|
[2223] | 91 | $template->assign('SEARCH_TAGS_MODE', $search['fields']['tags']['mode']); |
---|
| 92 | |
---|
[1119] | 93 | $query = ' |
---|
| 94 | SELECT name |
---|
| 95 | FROM '.TAGS_TABLE.' |
---|
| 96 | WHERE id IN ('.implode(',', $search['fields']['tags']['words']).') |
---|
| 97 | ;'; |
---|
[2223] | 98 | $template->assign( |
---|
| 99 | 'search_tags', |
---|
| 100 | array_from_query($query, 'name') |
---|
| 101 | ); |
---|
[1119] | 102 | } |
---|
| 103 | |
---|
[1015] | 104 | if (isset($search['fields']['author'])) |
---|
| 105 | { |
---|
[2223] | 106 | $template->append( |
---|
[25005] | 107 | 'search_words', |
---|
| 108 | l10n( |
---|
| 109 | 'author(s) : %s', |
---|
| 110 | join(', ', $search['fields']['author']['words']) |
---|
[1015] | 111 | ) |
---|
[2223] | 112 | ); |
---|
[1015] | 113 | } |
---|
| 114 | |
---|
| 115 | if (isset($search['fields']['cat'])) |
---|
| 116 | { |
---|
| 117 | if ($search['fields']['cat']['sub_inc']) |
---|
| 118 | { |
---|
| 119 | // searching all the categories id of sub-categories |
---|
| 120 | $cat_ids = get_subcat_ids($search['fields']['cat']['words']); |
---|
| 121 | } |
---|
| 122 | else |
---|
| 123 | { |
---|
| 124 | $cat_ids = $search['fields']['cat']['words']; |
---|
| 125 | } |
---|
| 126 | |
---|
| 127 | $query = ' |
---|
| 128 | SELECT id, uppercats, global_rank |
---|
| 129 | FROM '.CATEGORIES_TABLE.' |
---|
| 130 | WHERE id IN ('. |
---|
| 131 | implode(',', $cat_ids). |
---|
| 132 | ') |
---|
| 133 | ;'; |
---|
| 134 | $result = pwg_query($query); |
---|
| 135 | |
---|
| 136 | $categories = array(); |
---|
| 137 | if (!empty($result)) |
---|
| 138 | { |
---|
[4325] | 139 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[1015] | 140 | { |
---|
[25018] | 141 | $categories[] = $row; |
---|
[1015] | 142 | } |
---|
| 143 | } |
---|
| 144 | usort($categories, 'global_rank_compare'); |
---|
| 145 | |
---|
| 146 | foreach ($categories as $category) |
---|
| 147 | { |
---|
[2223] | 148 | $template->append( |
---|
| 149 | 'search_categories', |
---|
| 150 | get_cat_display_name_cache( |
---|
[1015] | 151 | $category['uppercats'], |
---|
[1092] | 152 | null, // no url on category names |
---|
[1015] | 153 | false // no blank replacement |
---|
| 154 | ) |
---|
| 155 | ); |
---|
| 156 | } |
---|
| 157 | } |
---|
| 158 | |
---|
| 159 | foreach (array('date_available', 'date_creation') as $datefield) |
---|
| 160 | { |
---|
| 161 | if ('date_available' == $datefield) |
---|
| 162 | { |
---|
| 163 | $lang_items = array( |
---|
[5311] | 164 | 'date' => l10n('posted on %s'), |
---|
| 165 | 'period' => l10n('posted between %s (%s) and %s (%s)'), |
---|
| 166 | 'after' => l10n('posted after %s (%s)'), |
---|
| 167 | 'before' => l10n('posted before %s (%s)'), |
---|
[1015] | 168 | ); |
---|
| 169 | } |
---|
| 170 | elseif ('date_creation' == $datefield) |
---|
| 171 | { |
---|
| 172 | $lang_items = array( |
---|
[5310] | 173 | 'date' => l10n('created on %s'), |
---|
| 174 | 'period' => l10n('created between %s (%s) and %s (%s)'), |
---|
| 175 | 'after' => l10n('created after %s (%s)'), |
---|
| 176 | 'before' => l10n('created before %s (%s)'), |
---|
[1015] | 177 | ); |
---|
| 178 | } |
---|
| 179 | |
---|
| 180 | $keys = array( |
---|
| 181 | 'date' => $datefield, |
---|
| 182 | 'after' => $datefield.'-after', |
---|
| 183 | 'before' => $datefield.'-before', |
---|
| 184 | ); |
---|
| 185 | |
---|
| 186 | if (isset($search['fields'][ $keys['date'] ])) |
---|
| 187 | { |
---|
[2223] | 188 | $template->assign( |
---|
| 189 | strtoupper($datefield), |
---|
| 190 | sprintf( |
---|
[5310] | 191 | $lang_items['date'], |
---|
[1015] | 192 | format_date($search['fields'][ $keys['date'] ]) |
---|
[2223] | 193 | ) |
---|
[1015] | 194 | ); |
---|
| 195 | } |
---|
| 196 | elseif (isset($search['fields'][ $keys['before'] ]) |
---|
| 197 | and isset($search['fields'][ $keys['after'] ])) |
---|
| 198 | { |
---|
[2223] | 199 | $template->assign( |
---|
| 200 | strtoupper($datefield), |
---|
| 201 | sprintf( |
---|
[5310] | 202 | $lang_items['period'], |
---|
[1071] | 203 | |
---|
[1015] | 204 | format_date($search['fields'][ $keys['after'] ]['date']), |
---|
| 205 | inc_exc_str($search['fields'][ $keys['after'] ]['inc']), |
---|
| 206 | |
---|
| 207 | format_date($search['fields'][ $keys['before'] ]['date']), |
---|
| 208 | inc_exc_str($search['fields'][ $keys['before'] ]['inc']) |
---|
[2223] | 209 | ) |
---|
[1015] | 210 | ); |
---|
| 211 | } |
---|
| 212 | elseif (isset($search['fields'][ $keys['before'] ])) |
---|
| 213 | { |
---|
[2223] | 214 | $template->assign( |
---|
| 215 | strtoupper($datefield), |
---|
| 216 | sprintf( |
---|
[5310] | 217 | $lang_items['before'], |
---|
[1071] | 218 | |
---|
[1015] | 219 | format_date($search['fields'][ $keys['before'] ]['date']), |
---|
| 220 | inc_exc_str($search['fields'][ $keys['before'] ]['inc']) |
---|
[2223] | 221 | ) |
---|
[1015] | 222 | ); |
---|
| 223 | } |
---|
| 224 | elseif (isset($search['fields'][ $keys['after'] ])) |
---|
| 225 | { |
---|
[2223] | 226 | $template->assign( |
---|
| 227 | strtoupper($datefield), |
---|
| 228 | sprintf( |
---|
[5310] | 229 | $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 | // | html code display | |
---|
| 240 | // +-----------------------------------------------------------------------+ |
---|
| 241 | |
---|
[2223] | 242 | $template->pparse('search_rules'); |
---|
[1015] | 243 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
| 244 | ?> |
---|