[2] | 1 | <?php |
---|
[354] | 2 | // +-----------------------------------------------------------------------+ |
---|
[2297] | 3 | // | Piwigo - a PHP based picture gallery | |
---|
| 4 | // +-----------------------------------------------------------------------+ |
---|
[5196] | 5 | // | Copyright(C) 2008-2010 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 | // +-----------------------------------------------------------------------+ |
---|
[420] | 23 | |
---|
[364] | 24 | define('PHPWG_ROOT_PATH','./'); |
---|
[613] | 25 | include_once(PHPWG_ROOT_PATH.'include/common.inc.php'); |
---|
[1082] | 26 | include(PHPWG_ROOT_PATH.'include/section_init.inc.php'); |
---|
[1612] | 27 | include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php'); |
---|
[1052] | 28 | |
---|
[1082] | 29 | // Check Access and exit when user status is not ok |
---|
[1072] | 30 | check_status(ACCESS_GUEST); |
---|
| 31 | |
---|
[1082] | 32 | // access authorization check |
---|
| 33 | if (isset($page['category'])) |
---|
[1036] | 34 | { |
---|
[1861] | 35 | check_restrictions($page['category']['id']); |
---|
[1036] | 36 | } |
---|
[1082] | 37 | |
---|
[2327] | 38 | $page['rank_of'] = array_flip($page['items']); |
---|
| 39 | |
---|
[1036] | 40 | // if this image_id doesn't correspond to this category, an error message is |
---|
| 41 | // displayed, and execution is stopped |
---|
[2327] | 42 | if ( !isset($page['rank_of'][$page['image_id']]) ) |
---|
[934] | 43 | { |
---|
[2430] | 44 | $query = ' |
---|
[2446] | 45 | SELECT id, file, level |
---|
[2430] | 46 | FROM '.IMAGES_TABLE.' |
---|
| 47 | WHERE '; |
---|
| 48 | if ($page['image_id']>0) |
---|
| 49 | { |
---|
| 50 | $query .= 'id = '.$page['image_id']; |
---|
| 51 | } |
---|
| 52 | else |
---|
| 53 | {// url given by file name |
---|
| 54 | assert( !empty($page['image_file']) ); |
---|
[2512] | 55 | $query .= 'file LIKE "' . |
---|
| 56 | str_replace(array('_','%'), array('/_','/%'), $page['image_file'] ). |
---|
| 57 | '.%" ESCAPE "/" LIMIT 1'; |
---|
[2430] | 58 | } |
---|
[4325] | 59 | if ( ! ( $row = pwg_db_fetch_assoc(pwg_query($query)) ) ) |
---|
[2430] | 60 | {// element does not exist |
---|
| 61 | page_not_found( 'The requested image does not exist', |
---|
| 62 | duplicate_index_url() |
---|
| 63 | ); |
---|
| 64 | } |
---|
| 65 | if ($row['level']>$user['level']) |
---|
| 66 | { |
---|
| 67 | access_denied(); |
---|
| 68 | } |
---|
[5127] | 69 | |
---|
| 70 | $page['image_id'] = $row['id']; |
---|
| 71 | $page['image_file'] = $row['file']; |
---|
[2430] | 72 | if ( !isset($page['rank_of'][$page['image_id']]) ) |
---|
| 73 | {// the image can still be non accessible (filter/cat perm) and/or not in the set |
---|
| 74 | global $filter; |
---|
[2446] | 75 | if ( !empty($filter['visible_images']) and |
---|
[2430] | 76 | !in_array($page['image_id'], explode(',',$filter['visible_images']) ) ) |
---|
| 77 | { |
---|
| 78 | page_not_found( 'The requested image is filtered', |
---|
| 79 | duplicate_index_url() |
---|
| 80 | ); |
---|
| 81 | } |
---|
| 82 | if ('categories'==$page['section'] and !isset($page['category']) ) |
---|
| 83 | {// flat view - all items |
---|
| 84 | access_denied(); |
---|
| 85 | } |
---|
| 86 | else |
---|
| 87 | {// try to see if we can access it differently |
---|
| 88 | $query = ' |
---|
| 89 | SELECT id |
---|
| 90 | FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id=image_id |
---|
| 91 | WHERE id='.$page['image_id'] |
---|
| 92 | . get_sql_condition_FandF( |
---|
| 93 | array('forbidden_categories' => 'category_id'), |
---|
| 94 | " AND" |
---|
| 95 | ).' |
---|
| 96 | LIMIT 1'; |
---|
[4325] | 97 | if ( pwg_db_num_rows( pwg_query($query) ) == 0 ) |
---|
[2430] | 98 | { |
---|
| 99 | access_denied(); |
---|
| 100 | } |
---|
| 101 | else |
---|
| 102 | { |
---|
| 103 | if ('best_rated'==$page['section']) |
---|
| 104 | { |
---|
| 105 | $page['rank_of'][$page['image_id']] = count($page['items']); |
---|
| 106 | array_push($page['items'], $page['image_id'] ); |
---|
| 107 | } |
---|
| 108 | else |
---|
| 109 | { |
---|
| 110 | $url = make_picture_url( |
---|
| 111 | array( |
---|
| 112 | 'image_id' => $page['image_id'], |
---|
| 113 | 'image_file' => $page['image_file'], |
---|
| 114 | 'section' => 'categories', |
---|
| 115 | 'flat' => true, |
---|
| 116 | ) |
---|
| 117 | ); |
---|
| 118 | set_status_header( 'recent_pics'==$page['section'] ? 301 : 302); |
---|
| 119 | redirect_http( $url ); |
---|
| 120 | } |
---|
| 121 | } |
---|
| 122 | } |
---|
| 123 | } |
---|
[934] | 124 | } |
---|
| 125 | |
---|
[2407] | 126 | // There is cookie, so we must handle it at the beginning |
---|
| 127 | if ( isset($_GET['metadata']) ) |
---|
| 128 | { |
---|
| 129 | if ( pwg_get_session_var('show_metadata') == null ) |
---|
| 130 | { |
---|
[2572] | 131 | pwg_set_session_var('show_metadata', 1 ); |
---|
[2407] | 132 | } else { |
---|
| 133 | pwg_unset_session_var('show_metadata'); |
---|
| 134 | } |
---|
| 135 | } |
---|
| 136 | |
---|
[1590] | 137 | // add default event handler for rendering element content |
---|
[1787] | 138 | add_event_handler( |
---|
| 139 | 'render_element_content', |
---|
| 140 | 'default_picture_content', |
---|
| 141 | EVENT_HANDLER_PRIORITY_NEUTRAL, |
---|
| 142 | 2 |
---|
| 143 | ); |
---|
[2079] | 144 | // add default event handler for rendering element description |
---|
| 145 | add_event_handler('render_element_description', 'nl2br'); |
---|
| 146 | |
---|
[1590] | 147 | trigger_action('loc_begin_picture'); |
---|
| 148 | |
---|
| 149 | // this is the default handler that generates the display for the element |
---|
| 150 | function default_picture_content($content, $element_info) |
---|
| 151 | { |
---|
| 152 | if ( !empty($content) ) |
---|
| 153 | {// someone hooked us - so we skip; |
---|
| 154 | return $content; |
---|
| 155 | } |
---|
| 156 | if (!isset($element_info['image_url'])) |
---|
| 157 | { // nothing to do |
---|
| 158 | return $content; |
---|
| 159 | } |
---|
[1793] | 160 | |
---|
[1882] | 161 | global $user, $page, $template; |
---|
[1793] | 162 | |
---|
[1882] | 163 | $template->set_filenames( |
---|
[1787] | 164 | array('default_content'=>'picture_content.tpl') |
---|
| 165 | ); |
---|
[1590] | 166 | |
---|
[2218] | 167 | if ( !$page['slideshow'] and isset($element_info['high_url']) ) |
---|
[1590] | 168 | { |
---|
| 169 | $uuid = uniqid(rand()); |
---|
[2227] | 170 | $template->assign( |
---|
[1590] | 171 | 'high', |
---|
| 172 | array( |
---|
| 173 | 'U_HIGH' => $element_info['high_url'], |
---|
| 174 | 'UUID' => $uuid, |
---|
| 175 | ) |
---|
| 176 | ); |
---|
| 177 | } |
---|
[2227] | 178 | $template->assign( array( |
---|
[1590] | 179 | 'SRC_IMG' => $element_info['image_url'], |
---|
| 180 | 'ALT_IMG' => $element_info['file'], |
---|
[1596] | 181 | 'WIDTH_IMG' => @$element_info['scaled_width'], |
---|
| 182 | 'HEIGHT_IMG' => @$element_info['scaled_height'], |
---|
[1590] | 183 | ) |
---|
| 184 | ); |
---|
[1882] | 185 | return $template->parse( 'default_content', true); |
---|
[1590] | 186 | } |
---|
| 187 | |
---|
[1082] | 188 | // +-----------------------------------------------------------------------+ |
---|
| 189 | // | initialization | |
---|
| 190 | // +-----------------------------------------------------------------------+ |
---|
| 191 | |
---|
[1036] | 192 | // caching first_rank, last_rank, current_rank in the displayed |
---|
| 193 | // section. This should also help in readability. |
---|
| 194 | $page['first_rank'] = 0; |
---|
| 195 | $page['last_rank'] = count($page['items']) - 1; |
---|
[1082] | 196 | $page['current_rank'] = $page['rank_of'][ $page['image_id'] ]; |
---|
[1036] | 197 | |
---|
| 198 | // caching current item : readability purpose |
---|
[1082] | 199 | $page['current_item'] = $page['image_id']; |
---|
[1036] | 200 | |
---|
| 201 | if ($page['current_rank'] != $page['first_rank']) |
---|
[2] | 202 | { |
---|
[1086] | 203 | // caching first & previous item : readability purpose |
---|
[1036] | 204 | $page['previous_item'] = $page['items'][ $page['current_rank'] - 1 ]; |
---|
[1086] | 205 | $page['first_item'] = $page['items'][ $page['first_rank'] ]; |
---|
[2] | 206 | } |
---|
[1036] | 207 | |
---|
| 208 | if ($page['current_rank'] != $page['last_rank']) |
---|
| 209 | { |
---|
[1086] | 210 | // caching next & last item : readability purpose |
---|
[1036] | 211 | $page['next_item'] = $page['items'][ $page['current_rank'] + 1 ]; |
---|
[1086] | 212 | $page['last_item'] = $page['items'][ $page['last_rank'] ]; |
---|
[1036] | 213 | } |
---|
| 214 | |
---|
[1503] | 215 | $url_up = duplicate_index_url( |
---|
[1082] | 216 | array( |
---|
| 217 | 'start' => |
---|
| 218 | floor($page['current_rank'] / $user['nb_image_page']) |
---|
| 219 | * $user['nb_image_page'] |
---|
| 220 | ), |
---|
| 221 | array( |
---|
| 222 | 'start', |
---|
| 223 | ) |
---|
| 224 | ); |
---|
[1014] | 225 | |
---|
[1503] | 226 | $url_self = duplicate_picture_url(); |
---|
[811] | 227 | |
---|
[1082] | 228 | // +-----------------------------------------------------------------------+ |
---|
| 229 | // | actions | |
---|
| 230 | // +-----------------------------------------------------------------------+ |
---|
[858] | 231 | |
---|
[1082] | 232 | /** |
---|
| 233 | * Actions are favorite adding, user comment deletion, setting the picture |
---|
| 234 | * as representative of the current category... |
---|
| 235 | * |
---|
| 236 | * Actions finish by a redirection |
---|
| 237 | */ |
---|
[858] | 238 | |
---|
[1590] | 239 | if (isset($_GET['action'])) |
---|
[858] | 240 | { |
---|
[1082] | 241 | switch ($_GET['action']) |
---|
[1041] | 242 | { |
---|
[1082] | 243 | case 'add_to_favorites' : |
---|
[1041] | 244 | { |
---|
[1082] | 245 | $query = ' |
---|
| 246 | INSERT INTO '.FAVORITES_TABLE.' |
---|
| 247 | (image_id,user_id) |
---|
| 248 | VALUES |
---|
| 249 | ('.$page['image_id'].','.$user['id'].') |
---|
| 250 | ;'; |
---|
| 251 | pwg_query($query); |
---|
| 252 | |
---|
| 253 | redirect($url_self); |
---|
[1086] | 254 | |
---|
[1082] | 255 | break; |
---|
[1041] | 256 | } |
---|
[1082] | 257 | case 'remove_from_favorites' : |
---|
| 258 | { |
---|
| 259 | $query = ' |
---|
| 260 | DELETE FROM '.FAVORITES_TABLE.' |
---|
| 261 | WHERE user_id = '.$user['id'].' |
---|
| 262 | AND image_id = '.$page['image_id'].' |
---|
| 263 | ;'; |
---|
| 264 | pwg_query($query); |
---|
[1041] | 265 | |
---|
[1082] | 266 | if ('favorites' == $page['section']) |
---|
| 267 | { |
---|
| 268 | redirect($url_up); |
---|
| 269 | } |
---|
| 270 | else |
---|
| 271 | { |
---|
| 272 | redirect($url_self); |
---|
| 273 | } |
---|
[1086] | 274 | |
---|
[1082] | 275 | break; |
---|
| 276 | } |
---|
| 277 | case 'set_as_representative' : |
---|
[1041] | 278 | { |
---|
[1590] | 279 | if (is_admin() and !is_adviser() and isset($page['category'])) |
---|
[1082] | 280 | { |
---|
[1041] | 281 | $query = ' |
---|
[1082] | 282 | UPDATE '.CATEGORIES_TABLE.' |
---|
| 283 | SET representative_picture_id = '.$page['image_id'].' |
---|
[1861] | 284 | WHERE id = '.$page['category']['id'].' |
---|
[1082] | 285 | ;'; |
---|
| 286 | pwg_query($query); |
---|
| 287 | } |
---|
[1086] | 288 | |
---|
[1082] | 289 | redirect($url_self); |
---|
[1086] | 290 | |
---|
[1082] | 291 | break; |
---|
| 292 | } |
---|
| 293 | case 'toggle_metadata' : |
---|
| 294 | { |
---|
| 295 | break; |
---|
| 296 | } |
---|
| 297 | case 'add_to_caddie' : |
---|
| 298 | { |
---|
[1106] | 299 | fill_caddie(array($page['image_id'])); |
---|
[1082] | 300 | redirect($url_self); |
---|
| 301 | break; |
---|
| 302 | } |
---|
| 303 | case 'rate' : |
---|
| 304 | { |
---|
[1107] | 305 | include_once(PHPWG_ROOT_PATH.'include/functions_rate.inc.php'); |
---|
[1787] | 306 | rate_picture( |
---|
| 307 | $page['image_id'], |
---|
| 308 | isset($_POST['rate']) ? $_POST['rate'] : $_GET['rate'] |
---|
| 309 | ); |
---|
[1082] | 310 | redirect($url_self); |
---|
| 311 | } |
---|
[3445] | 312 | case 'edit_comment' : |
---|
| 313 | { |
---|
[5195] | 314 | check_pwg_token(); |
---|
| 315 | |
---|
[5127] | 316 | include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php'); |
---|
[5195] | 317 | |
---|
| 318 | check_input_parameter('comment_to_edit', $_GET, false, PATTERN_ID); |
---|
| 319 | |
---|
| 320 | $author_id = get_comment_author_id($_GET['comment_to_edit']); |
---|
| 321 | |
---|
| 322 | if (can_manage_comment('edit', $author_id)) |
---|
[3445] | 323 | { |
---|
[5127] | 324 | if (!empty($_POST['content'])) |
---|
| 325 | { |
---|
[5195] | 326 | update_user_comment( |
---|
| 327 | array( |
---|
| 328 | 'comment_id' => $_GET['comment_to_edit'], |
---|
| 329 | 'image_id' => $page['image_id'], |
---|
| 330 | 'content' => $_POST['content'] |
---|
| 331 | ), |
---|
| 332 | $_POST['key'] |
---|
| 333 | ); |
---|
| 334 | |
---|
[5127] | 335 | redirect($url_self); |
---|
[5195] | 336 | } |
---|
| 337 | else |
---|
| 338 | { |
---|
[5127] | 339 | $edit_comment = $_GET['comment_to_edit']; |
---|
| 340 | break; |
---|
| 341 | } |
---|
[3445] | 342 | } |
---|
| 343 | } |
---|
[1082] | 344 | case 'delete_comment' : |
---|
| 345 | { |
---|
[5195] | 346 | check_pwg_token(); |
---|
| 347 | |
---|
[5127] | 348 | include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php'); |
---|
[5195] | 349 | |
---|
| 350 | check_input_parameter('comment_to_delete', $_GET, false, PATTERN_ID); |
---|
| 351 | |
---|
| 352 | $author_id = get_comment_author_id($_GET['comment_to_delete']); |
---|
| 353 | |
---|
| 354 | if (can_manage_comment('delete', $author_id)) |
---|
[1082] | 355 | { |
---|
[5127] | 356 | delete_user_comment($_GET['comment_to_delete']); |
---|
[1082] | 357 | } |
---|
[5195] | 358 | |
---|
[1082] | 359 | redirect($url_self); |
---|
| 360 | } |
---|
[3409] | 361 | case 'validate_comment' : |
---|
| 362 | { |
---|
[5195] | 363 | check_pwg_token(); |
---|
| 364 | |
---|
[5127] | 365 | include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php'); |
---|
[5195] | 366 | |
---|
| 367 | check_input_parameter('comment_to_validate', $_GET, false, PATTERN_ID); |
---|
| 368 | |
---|
[5653] | 369 | $author_id = get_comment_author_id($_GET['comment_to_validate']); |
---|
[5195] | 370 | |
---|
| 371 | if (can_manage_comment('validate', $author_id)) |
---|
[3409] | 372 | { |
---|
[5195] | 373 | validate_user_comment($_GET['comment_to_validate']); |
---|
[3409] | 374 | } |
---|
[5195] | 375 | |
---|
[3409] | 376 | redirect($url_self); |
---|
| 377 | } |
---|
| 378 | |
---|
[1082] | 379 | } |
---|
[1041] | 380 | } |
---|
| 381 | |
---|
[1082] | 382 | // incrementation of the number of hits, we do this only if no action |
---|
[2155] | 383 | if (trigger_event('allow_increment_element_hit_count', !isset($_POST['content']) ) ) |
---|
[2048] | 384 | { |
---|
| 385 | $query = ' |
---|
[1082] | 386 | UPDATE |
---|
| 387 | '.IMAGES_TABLE.' |
---|
| 388 | SET hit = hit+1 |
---|
| 389 | WHERE id = '.$page['image_id'].' |
---|
| 390 | ;'; |
---|
[2048] | 391 | pwg_query($query); |
---|
| 392 | } |
---|
[745] | 393 | //---------------------------------------------------------- related categories |
---|
| 394 | $query = ' |
---|
| 395 | SELECT category_id,uppercats,commentable,global_rank |
---|
| 396 | FROM '.IMAGE_CATEGORY_TABLE.' |
---|
| 397 | INNER JOIN '.CATEGORIES_TABLE.' ON category_id = id |
---|
[1082] | 398 | WHERE image_id = '.$page['image_id'].' |
---|
[1677] | 399 | '.get_sql_condition_FandF |
---|
| 400 | ( |
---|
| 401 | array |
---|
| 402 | ( |
---|
| 403 | 'forbidden_categories' => 'category_id', |
---|
| 404 | 'visible_categories' => 'category_id' |
---|
| 405 | ), |
---|
| 406 | 'AND' |
---|
| 407 | ).' |
---|
[745] | 408 | ;'; |
---|
| 409 | $result = pwg_query($query); |
---|
| 410 | $related_categories = array(); |
---|
[4325] | 411 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[745] | 412 | { |
---|
| 413 | array_push($related_categories, $row); |
---|
| 414 | } |
---|
| 415 | usort($related_categories, 'global_rank_compare'); |
---|
[1086] | 416 | //-------------------------first, prev, current, next & last picture management |
---|
[402] | 417 | $picture = array(); |
---|
[368] | 418 | |
---|
[1082] | 419 | $ids = array($page['image_id']); |
---|
[1036] | 420 | if (isset($page['previous_item'])) |
---|
[465] | 421 | { |
---|
[1036] | 422 | array_push($ids, $page['previous_item']); |
---|
[1086] | 423 | array_push($ids, $page['first_item']); |
---|
[465] | 424 | } |
---|
[1036] | 425 | if (isset($page['next_item'])) |
---|
[465] | 426 | { |
---|
[1036] | 427 | array_push($ids, $page['next_item']); |
---|
[1086] | 428 | array_push($ids, $page['last_item']); |
---|
[465] | 429 | } |
---|
[368] | 430 | |
---|
[454] | 431 | $query = ' |
---|
[1036] | 432 | SELECT * |
---|
| 433 | FROM '.IMAGES_TABLE.' |
---|
| 434 | WHERE id IN ('.implode(',', $ids).') |
---|
| 435 | ;'; |
---|
[368] | 436 | |
---|
[1036] | 437 | $result = pwg_query($query); |
---|
[368] | 438 | |
---|
[4325] | 439 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[345] | 440 | { |
---|
[1036] | 441 | if (isset($page['previous_item']) and $row['id'] == $page['previous_item']) |
---|
[465] | 442 | { |
---|
[1086] | 443 | $i = 'previous'; |
---|
[465] | 444 | } |
---|
[1036] | 445 | else if (isset($page['next_item']) and $row['id'] == $page['next_item']) |
---|
[465] | 446 | { |
---|
[1036] | 447 | $i = 'next'; |
---|
[465] | 448 | } |
---|
[1086] | 449 | else if (isset($page['first_item']) and $row['id'] == $page['first_item']) |
---|
| 450 | { |
---|
| 451 | $i = 'first'; |
---|
| 452 | } |
---|
| 453 | else if (isset($page['last_item']) and $row['id'] == $page['last_item']) |
---|
| 454 | { |
---|
| 455 | $i = 'last'; |
---|
| 456 | } |
---|
[1036] | 457 | else |
---|
| 458 | { |
---|
| 459 | $i = 'current'; |
---|
| 460 | } |
---|
[1059] | 461 | |
---|
[1596] | 462 | $picture[$i] = $row; |
---|
[465] | 463 | |
---|
| 464 | $picture[$i]['is_picture'] = false; |
---|
| 465 | if (in_array(get_extension($row['file']), $conf['picture_ext'])) |
---|
| 466 | { |
---|
| 467 | $picture[$i]['is_picture'] = true; |
---|
| 468 | } |
---|
[1059] | 469 | |
---|
[1612] | 470 | // ------ build element_path and element_url |
---|
| 471 | $picture[$i]['element_path'] = get_element_path($picture[$i]); |
---|
| 472 | $picture[$i]['element_url'] = get_element_url($picture[$i]); |
---|
[402] | 473 | |
---|
[1612] | 474 | // ------ build image_path and image_url |
---|
| 475 | if ($i=='current' or $i=='next') |
---|
[465] | 476 | { |
---|
[1612] | 477 | $picture[$i]['image_path'] = get_image_path( $picture[$i] ); |
---|
| 478 | $picture[$i]['image_url'] = get_image_url( $picture[$i] ); |
---|
[465] | 479 | } |
---|
[1590] | 480 | |
---|
[1612] | 481 | if ($i=='current') |
---|
[465] | 482 | { |
---|
[1612] | 483 | if ( $picture[$i]['is_picture'] ) |
---|
[536] | 484 | { |
---|
[1612] | 485 | if ( $user['enabled_high']=='true' ) |
---|
[536] | 486 | { |
---|
[1612] | 487 | $hi_url=get_high_url($picture[$i]); |
---|
| 488 | if ( !empty($hi_url) ) |
---|
[1090] | 489 | { |
---|
[1612] | 490 | $picture[$i]['high_url'] = $hi_url; |
---|
| 491 | $picture[$i]['download_url'] = get_download_url('h',$picture[$i]); |
---|
[1090] | 492 | } |
---|
[536] | 493 | } |
---|
| 494 | } |
---|
[1590] | 495 | else |
---|
[1612] | 496 | { // not a pic - need download link |
---|
| 497 | $picture[$i]['download_url'] = get_download_url('e',$picture[$i]); |
---|
[1590] | 498 | } |
---|
| 499 | } |
---|
| 500 | |
---|
[1596] | 501 | $picture[$i]['thumbnail'] = get_thumbnail_url($row); |
---|
[1059] | 502 | |
---|
[402] | 503 | if ( !empty( $row['name'] ) ) |
---|
[345] | 504 | { |
---|
[465] | 505 | $picture[$i]['name'] = $row['name']; |
---|
[345] | 506 | } |
---|
| 507 | else |
---|
| 508 | { |
---|
[1612] | 509 | $file_wo_ext = get_filename_wo_extension($row['file']); |
---|
[465] | 510 | $picture[$i]['name'] = str_replace('_', ' ', $file_wo_ext); |
---|
[345] | 511 | } |
---|
| 512 | |
---|
[1503] | 513 | $picture[$i]['url'] = duplicate_picture_url( |
---|
[1082] | 514 | array( |
---|
| 515 | 'image_id' => $row['id'], |
---|
[1090] | 516 | 'image_file' => $row['file'], |
---|
[1082] | 517 | ), |
---|
| 518 | array( |
---|
| 519 | 'start', |
---|
| 520 | ) |
---|
| 521 | ); |
---|
[1086] | 522 | |
---|
| 523 | if ('previous'==$i and $page['previous_item']==$page['first_item']) |
---|
| 524 | { |
---|
| 525 | $picture['first'] = $picture[$i]; |
---|
| 526 | } |
---|
| 527 | if ('next'==$i and $page['next_item']==$page['last_item']) |
---|
| 528 | { |
---|
| 529 | $picture['last'] = $picture[$i]; |
---|
| 530 | } |
---|
[345] | 531 | } |
---|
[368] | 532 | |
---|
[1590] | 533 | // calculation of width and height for the current picture |
---|
| 534 | if (empty($picture['current']['width'])) |
---|
| 535 | { |
---|
| 536 | $taille_image = @getimagesize($picture['current']['image_path']); |
---|
| 537 | if ($taille_image!==false) |
---|
| 538 | { |
---|
| 539 | $picture['current']['width'] = $taille_image[0]; |
---|
| 540 | $picture['current']['height']= $taille_image[1]; |
---|
| 541 | } |
---|
| 542 | } |
---|
| 543 | |
---|
| 544 | if (!empty($picture['current']['width'])) |
---|
| 545 | { |
---|
[1787] | 546 | list( |
---|
| 547 | $picture['current']['scaled_width'], |
---|
| 548 | $picture['current']['scaled_height'] |
---|
| 549 | ) = get_picture_size( |
---|
[1590] | 550 | $picture['current']['width'], |
---|
| 551 | $picture['current']['height'], |
---|
| 552 | @$user['maxwidth'], |
---|
| 553 | @$user['maxheight'] |
---|
| 554 | ); |
---|
| 555 | } |
---|
| 556 | |
---|
[2218] | 557 | $slideshow_params = array(); |
---|
| 558 | $slideshow_url_params = array(); |
---|
[858] | 559 | |
---|
[2218] | 560 | if (isset($_GET['slideshow'])) |
---|
[2] | 561 | { |
---|
[1793] | 562 | $page['slideshow'] = true; |
---|
[2218] | 563 | $page['meta_robots'] = array('noindex'=>1, 'nofollow'=>1); |
---|
| 564 | |
---|
| 565 | $slideshow_params = decode_slideshow_params($_GET['slideshow']); |
---|
| 566 | $slideshow_url_params['slideshow'] = encode_slideshow_params($slideshow_params); |
---|
| 567 | |
---|
| 568 | if ($slideshow_params['play']) |
---|
| 569 | { |
---|
| 570 | $id_pict_redirect = ''; |
---|
| 571 | if (isset($page['next_item'])) |
---|
[2169] | 572 | { |
---|
[2218] | 573 | $id_pict_redirect = 'next'; |
---|
[2169] | 574 | } |
---|
[2218] | 575 | else |
---|
| 576 | { |
---|
| 577 | if ($slideshow_params['repeat'] and isset($page['first_item'])) |
---|
| 578 | { |
---|
| 579 | $id_pict_redirect = 'first'; |
---|
| 580 | } |
---|
| 581 | } |
---|
| 582 | |
---|
| 583 | if (!empty($id_pict_redirect)) |
---|
| 584 | { |
---|
[2521] | 585 | // $refresh, $url_link and $title are required for creating |
---|
[2218] | 586 | // an automated refresh page in header.tpl |
---|
| 587 | $refresh = $slideshow_params['period']; |
---|
| 588 | $url_link = add_url_params( |
---|
| 589 | $picture[$id_pict_redirect]['url'], |
---|
| 590 | $slideshow_url_params |
---|
| 591 | ); |
---|
| 592 | } |
---|
[1793] | 593 | } |
---|
[2218] | 594 | } |
---|
| 595 | else |
---|
| 596 | { |
---|
| 597 | $page['slideshow'] = false; |
---|
| 598 | } |
---|
[2549] | 599 | if ($page['slideshow'] and $conf['light_slideshow']) |
---|
| 600 | { |
---|
| 601 | $template->set_filenames( array('slideshow' => 'slideshow.tpl')); |
---|
| 602 | } |
---|
| 603 | else |
---|
| 604 | { |
---|
| 605 | $template->set_filenames( array('picture' => 'picture.tpl')); |
---|
| 606 | } |
---|
[2218] | 607 | |
---|
[1793] | 608 | $title = $picture['current']['name']; |
---|
[1820] | 609 | $title_nb = ($page['current_rank'] + 1).'/'.count($page['items']); |
---|
[2] | 610 | |
---|
[531] | 611 | // metadata |
---|
[1503] | 612 | $url_metadata = duplicate_picture_url(); |
---|
[2407] | 613 | $url_metadata = add_url_params( $url_metadata, array('metadata'=>null) ); |
---|
[1590] | 614 | |
---|
[2407] | 615 | |
---|
[1590] | 616 | // do we have a plugin that can show metadata for something else than images? |
---|
[1787] | 617 | $metadata_showable = trigger_event( |
---|
| 618 | 'get_element_metadata_available', |
---|
| 619 | ( |
---|
| 620 | ($conf['show_exif'] or $conf['show_iptc']) |
---|
| 621 | and isset($picture['current']['image_path']) |
---|
[1590] | 622 | ), |
---|
[1787] | 623 | $picture['current']['path'] |
---|
| 624 | ); |
---|
| 625 | |
---|
[2407] | 626 | if ( $metadata_showable and pwg_get_session_var('show_metadata') ) |
---|
[531] | 627 | { |
---|
[2407] | 628 | $page['meta_robots']=array('noindex'=>1, 'nofollow'=>1); |
---|
[531] | 629 | } |
---|
[1590] | 630 | |
---|
[2407] | 631 | |
---|
[1590] | 632 | $page['body_id'] = 'thePicturePage'; |
---|
| 633 | |
---|
[1882] | 634 | // allow plugins to change what we computed before passing data to template |
---|
| 635 | $picture = trigger_event('picture_pictures_data', $picture); |
---|
[1787] | 636 | |
---|
[1882] | 637 | |
---|
[1787] | 638 | if (isset($picture['next']['image_url']) |
---|
[2204] | 639 | and $picture['next']['is_picture'] ) |
---|
[531] | 640 | { |
---|
[2227] | 641 | $template->assign('U_PREFETCH', $picture['next']['image_url'] ); |
---|
[531] | 642 | } |
---|
| 643 | |
---|
[1036] | 644 | //------------------------------------------------------- navigation management |
---|
[2227] | 645 | foreach (array('first','previous','next','last', 'current') as $which_image) |
---|
[1020] | 646 | { |
---|
[1086] | 647 | if (isset($picture[$which_image])) |
---|
| 648 | { |
---|
[2227] | 649 | $template->assign( |
---|
[1086] | 650 | $which_image, |
---|
[2413] | 651 | array_merge( |
---|
| 652 | $picture[$which_image], |
---|
| 653 | array( |
---|
| 654 | 'TITLE' => $picture[$which_image]['name'], |
---|
| 655 | 'THUMB_SRC' => $picture[$which_image]['thumbnail'], |
---|
| 656 | // Params slideshow was transmit to navigation buttons |
---|
| 657 | 'U_IMG' => |
---|
| 658 | add_url_params( |
---|
| 659 | $picture[$which_image]['url'], $slideshow_url_params), |
---|
| 660 | ) |
---|
[1086] | 661 | ) |
---|
| 662 | ); |
---|
[5304] | 663 | if ($conf['picture_download_icon'] and !empty($picture['current']['download_url'])) |
---|
| 664 | { |
---|
| 665 | $template->append($which_image, array('U_DOWNLOAD' => $picture['current']['download_url']), true); |
---|
| 666 | } |
---|
[1086] | 667 | } |
---|
[1020] | 668 | } |
---|
| 669 | |
---|
[2218] | 670 | |
---|
| 671 | if ($page['slideshow']) |
---|
| 672 | { |
---|
[2227] | 673 | $tpl_slideshow = array(); |
---|
| 674 | |
---|
[2218] | 675 | //slideshow end |
---|
[2227] | 676 | $template->assign( |
---|
[2218] | 677 | array( |
---|
[2227] | 678 | 'U_SLIDESHOW_STOP' => $picture['current']['url'], |
---|
[2218] | 679 | ) |
---|
| 680 | ); |
---|
| 681 | |
---|
| 682 | foreach (array('repeat', 'play') as $p) |
---|
| 683 | { |
---|
[2227] | 684 | $var_name = |
---|
| 685 | 'U_' |
---|
| 686 | .($slideshow_params[$p] ? 'STOP_' : 'START_') |
---|
| 687 | .strtoupper($p); |
---|
| 688 | |
---|
| 689 | $tpl_slideshow[$var_name] = |
---|
[2218] | 690 | add_url_params( |
---|
| 691 | $picture['current']['url'], |
---|
| 692 | array('slideshow' => |
---|
| 693 | encode_slideshow_params( |
---|
[2227] | 694 | array_merge($slideshow_params, |
---|
[2218] | 695 | array($p => ! $slideshow_params[$p])) |
---|
| 696 | ) |
---|
| 697 | ) |
---|
[2227] | 698 | ); |
---|
[2218] | 699 | } |
---|
| 700 | |
---|
| 701 | foreach (array('dec', 'inc') as $op) |
---|
| 702 | { |
---|
| 703 | $new_period = $slideshow_params['period'] + ((($op == 'dec') ? -1 : 1) * $conf['slideshow_period_step']); |
---|
| 704 | $new_slideshow_params = |
---|
| 705 | correct_slideshow_params( |
---|
[2227] | 706 | array_merge($slideshow_params, |
---|
[2218] | 707 | array('period' => $new_period))); |
---|
| 708 | |
---|
| 709 | if ($new_slideshow_params['period'] === $new_period) |
---|
| 710 | { |
---|
[2227] | 711 | $var_name = 'U_'.strtoupper($op).'_PERIOD'; |
---|
| 712 | $tpl_slideshow[$var_name] = |
---|
[2218] | 713 | add_url_params( |
---|
| 714 | $picture['current']['url'], |
---|
| 715 | array('slideshow' => encode_slideshow_params($new_slideshow_params) |
---|
| 716 | ) |
---|
| 717 | ); |
---|
| 718 | } |
---|
| 719 | } |
---|
[2227] | 720 | $template->assign('slideshow', $tpl_slideshow ); |
---|
[2218] | 721 | } |
---|
[5293] | 722 | elseif ($conf['picture_slideshow_icon']) |
---|
[2218] | 723 | { |
---|
[2227] | 724 | $template->assign( |
---|
[2218] | 725 | array( |
---|
[2227] | 726 | 'U_SLIDESHOW_START' => |
---|
[2218] | 727 | add_url_params( |
---|
| 728 | $picture['current']['url'], |
---|
| 729 | array( 'slideshow'=>'')) |
---|
| 730 | ) |
---|
| 731 | ); |
---|
| 732 | } |
---|
| 733 | |
---|
[2227] | 734 | $template->assign( |
---|
[1082] | 735 | array( |
---|
[1128] | 736 | 'SECTION_TITLE' => $page['title'], |
---|
[1082] | 737 | 'PHOTO' => $title_nb, |
---|
[2227] | 738 | 'SHOW_PICTURE_NAME_ON_TITLE' => $conf['show_picture_name_on_title'], |
---|
[2759] | 739 | 'IS_HOME' => ('categories'==$page['section'] and !isset($page['category']) ), |
---|
[368] | 740 | |
---|
[1082] | 741 | 'LEVEL_SEPARATOR' => $conf['level_separator'], |
---|
[2309] | 742 | |
---|
[2227] | 743 | 'U_UP' => $url_up, |
---|
[5293] | 744 | 'DISPLAY_NAV_BUTTONS' => $conf['picture_navigation_icons'], |
---|
| 745 | 'DISPLAY_NAV_THUMB' => $conf['picture_navigation_thumb'] |
---|
[1082] | 746 | ) |
---|
| 747 | ); |
---|
[803] | 748 | |
---|
[5293] | 749 | if ($conf['picture_metadata_icon']) |
---|
| 750 | { |
---|
| 751 | $template->assign('U_METADATA', $url_metadata); |
---|
| 752 | } |
---|
[803] | 753 | |
---|
[5293] | 754 | |
---|
[536] | 755 | //------------------------------------------------------- upper menu management |
---|
[1082] | 756 | |
---|
[2227] | 757 | // admin links |
---|
[1070] | 758 | if (is_admin()) |
---|
[858] | 759 | { |
---|
[2227] | 760 | if (isset($page['category'])) |
---|
| 761 | { |
---|
| 762 | $template->assign( |
---|
| 763 | array( |
---|
| 764 | 'U_SET_AS_REPRESENTATIVE' => add_url_params($url_self, |
---|
| 765 | array('action'=>'set_as_representative') |
---|
| 766 | ) |
---|
| 767 | ) |
---|
| 768 | ); |
---|
| 769 | } |
---|
[2309] | 770 | |
---|
[3167] | 771 | $url_admin = |
---|
| 772 | get_root_url().'admin.php?page=picture_modify' |
---|
| 773 | .'&cat_id='.(isset($page['category']) ? $page['category']['id'] : '') |
---|
| 774 | .'&image_id='.$page['image_id']; |
---|
| 775 | |
---|
[2227] | 776 | $template->assign( |
---|
[858] | 777 | array( |
---|
[2227] | 778 | 'U_CADDIE' => add_url_params($url_self, |
---|
[1094] | 779 | array('action'=>'add_to_caddie') |
---|
[2227] | 780 | ), |
---|
| 781 | 'U_ADMIN' => $url_admin, |
---|
[1082] | 782 | ) |
---|
[858] | 783 | ); |
---|
[3167] | 784 | |
---|
[6025] | 785 | $template->assign('available_permission_levels', get_privacy_level_options()); |
---|
[858] | 786 | } |
---|
| 787 | |
---|
[1082] | 788 | // favorite manipulation |
---|
[5305] | 789 | if (!is_a_guest() and $conf['picture_favorite_icon']) |
---|
[531] | 790 | { |
---|
| 791 | // verify if the picture is already in the favorite of the user |
---|
[1082] | 792 | $query = ' |
---|
| 793 | SELECT COUNT(*) AS nb_fav |
---|
| 794 | FROM '.FAVORITES_TABLE.' |
---|
| 795 | WHERE image_id = '.$page['image_id'].' |
---|
| 796 | AND user_id = '.$user['id'].' |
---|
| 797 | ;'; |
---|
| 798 | $result = pwg_query($query); |
---|
[4325] | 799 | $row = pwg_db_fetch_assoc($result); |
---|
[1086] | 800 | |
---|
[1082] | 801 | if ($row['nb_fav'] == 0) |
---|
[2] | 802 | { |
---|
[2227] | 803 | $template->assign( |
---|
[531] | 804 | 'favorite', |
---|
| 805 | array( |
---|
[1825] | 806 | 'FAVORITE_IMG' => |
---|
| 807 | get_root_url().get_themeconf('icon_dir').'/favorite.png', |
---|
[5021] | 808 | 'FAVORITE_HINT' => l10n('add this image to your favorites'), |
---|
[1094] | 809 | 'U_FAVORITE' => add_url_params( |
---|
[1825] | 810 | $url_self, |
---|
| 811 | array('action'=>'add_to_favorites') |
---|
| 812 | ), |
---|
[1082] | 813 | ) |
---|
| 814 | ); |
---|
[2] | 815 | } |
---|
[531] | 816 | else |
---|
| 817 | { |
---|
[2227] | 818 | $template->assign( |
---|
[531] | 819 | 'favorite', |
---|
| 820 | array( |
---|
[1825] | 821 | 'FAVORITE_IMG' => |
---|
| 822 | get_root_url().get_themeconf('icon_dir').'/del_favorite.png', |
---|
[5021] | 823 | 'FAVORITE_HINT' => l10n('delete this image from your favorites'), |
---|
[1094] | 824 | 'U_FAVORITE' => add_url_params( |
---|
[1825] | 825 | $url_self, |
---|
| 826 | array('action'=>'remove_from_favorites') |
---|
| 827 | ), |
---|
[1082] | 828 | ) |
---|
| 829 | ); |
---|
[531] | 830 | } |
---|
[2] | 831 | } |
---|
[368] | 832 | |
---|
[2] | 833 | //--------------------------------------------------------- picture information |
---|
[393] | 834 | // legend |
---|
[465] | 835 | if (isset($picture['current']['comment']) |
---|
| 836 | and !empty($picture['current']['comment'])) |
---|
[393] | 837 | { |
---|
[2227] | 838 | $template->assign( |
---|
| 839 | 'COMMENT_IMG', |
---|
[2079] | 840 | trigger_event('render_element_description', |
---|
| 841 | $picture['current']['comment']) |
---|
[2227] | 842 | ); |
---|
[393] | 843 | } |
---|
| 844 | |
---|
[847] | 845 | $infos = array(); |
---|
| 846 | |
---|
| 847 | // author |
---|
| 848 | if (!empty($picture['current']['author'])) |
---|
[51] | 849 | { |
---|
[847] | 850 | $infos['INFO_AUTHOR'] = |
---|
[1825] | 851 | // FIXME because of search engine partial rewrite, giving the author |
---|
| 852 | // name threw GET is not supported anymore. This feature should come |
---|
| 853 | // back later, with a better design |
---|
[1008] | 854 | // '<a href="'. |
---|
| 855 | // PHPWG_ROOT_PATH.'category.php?cat=search'. |
---|
| 856 | // '&search=author:'.$picture['current']['author'] |
---|
| 857 | // .'">'.$picture['current']['author'].'</a>'; |
---|
| 858 | $picture['current']['author']; |
---|
[51] | 859 | } |
---|
[774] | 860 | |
---|
[847] | 861 | // creation date |
---|
| 862 | if (!empty($picture['current']['date_creation'])) |
---|
[635] | 863 | { |
---|
[1051] | 864 | $val = format_date($picture['current']['date_creation']); |
---|
[1503] | 865 | $url = make_index_url( |
---|
[1825] | 866 | array( |
---|
| 867 | 'chronology_field'=>'created', |
---|
| 868 | 'chronology_style'=>'monthly', |
---|
| 869 | 'chronology_view'=>'list', |
---|
| 870 | 'chronology_date' => explode('-', $picture['current']['date_creation']) |
---|
| 871 | ) |
---|
| 872 | ); |
---|
| 873 | $infos['INFO_CREATION_DATE'] = |
---|
| 874 | '<a href="'.$url.'" rel="nofollow">'.$val.'</a>'; |
---|
[847] | 875 | } |
---|
| 876 | |
---|
| 877 | // date of availability |
---|
[3122] | 878 | $val = format_date($picture['current']['date_available']); |
---|
[1503] | 879 | $url = make_index_url( |
---|
[1825] | 880 | array( |
---|
| 881 | 'chronology_field'=>'posted', |
---|
| 882 | 'chronology_style'=>'monthly', |
---|
| 883 | 'chronology_view'=>'list', |
---|
| 884 | 'chronology_date' => explode( |
---|
| 885 | '-', |
---|
| 886 | substr($picture['current']['date_available'], 0, 10) |
---|
[1090] | 887 | ) |
---|
[1825] | 888 | ) |
---|
| 889 | ); |
---|
[1135] | 890 | $infos['INFO_POSTED_DATE'] = '<a href="'.$url.'" rel="nofollow">'.$val.'</a>'; |
---|
[847] | 891 | |
---|
| 892 | // size in pixels |
---|
[1590] | 893 | if ($picture['current']['is_picture'] and isset($picture['current']['width']) ) |
---|
[847] | 894 | { |
---|
[1590] | 895 | if ($picture['current']['scaled_width'] !== $picture['current']['width'] ) |
---|
[568] | 896 | { |
---|
[847] | 897 | $infos['INFO_DIMENSIONS'] = |
---|
[1590] | 898 | '<a href="'.$picture['current']['image_url'].'" title="'. |
---|
[847] | 899 | l10n('Original dimensions').'">'. |
---|
[1590] | 900 | $picture['current']['width'].'*'.$picture['current']['height'].'</a>'; |
---|
[568] | 901 | } |
---|
[635] | 902 | else |
---|
| 903 | { |
---|
[1590] | 904 | $infos['INFO_DIMENSIONS'] = |
---|
| 905 | $picture['current']['width'].'*'.$picture['current']['height']; |
---|
[635] | 906 | } |
---|
[568] | 907 | } |
---|
[774] | 908 | |
---|
[847] | 909 | // filesize |
---|
| 910 | if (!empty($picture['current']['filesize'])) |
---|
| 911 | { |
---|
| 912 | $infos['INFO_FILESIZE'] = |
---|
| 913 | sprintf(l10n('%d Kb'), $picture['current']['filesize']); |
---|
| 914 | } |
---|
| 915 | |
---|
| 916 | // number of visits |
---|
| 917 | $infos['INFO_VISITS'] = $picture['current']['hit']; |
---|
| 918 | |
---|
| 919 | // file |
---|
| 920 | $infos['INFO_FILE'] = $picture['current']['file']; |
---|
| 921 | |
---|
[2227] | 922 | $template->assign($infos); |
---|
[5304] | 923 | $template->assign('display_info', unserialize($conf['picture_informations'])); |
---|
[2227] | 924 | |
---|
| 925 | // related tags |
---|
[1827] | 926 | $tags = get_common_tags( array($page['image_id']), -1); |
---|
| 927 | if ( count($tags) ) |
---|
[847] | 928 | { |
---|
[2227] | 929 | foreach ($tags as $tag) |
---|
[1119] | 930 | { |
---|
[2227] | 931 | $template->append( |
---|
| 932 | 'related_tags', |
---|
[2413] | 933 | array_merge( $tag, |
---|
| 934 | array( |
---|
| 935 | 'URL' => make_index_url( |
---|
[2227] | 936 | array( |
---|
| 937 | 'tags' => array($tag) |
---|
| 938 | ) |
---|
| 939 | ), |
---|
[2413] | 940 | 'U_TAG_IMAGE' => duplicate_picture_url( |
---|
[2227] | 941 | array( |
---|
| 942 | 'section' => 'tags', |
---|
| 943 | 'tags' => array($tag) |
---|
| 944 | ) |
---|
| 945 | ) |
---|
[1119] | 946 | ) |
---|
[2413] | 947 | ) |
---|
[2227] | 948 | ); |
---|
[1119] | 949 | } |
---|
[847] | 950 | } |
---|
| 951 | |
---|
| 952 | // related categories |
---|
[2309] | 953 | if ( count($related_categories)==1 and |
---|
| 954 | isset($page['category']) and |
---|
| 955 | $related_categories[0]['category_id']==$page['category']['id'] ) |
---|
| 956 | { // no need to go to db, we have all the info |
---|
[2227] | 957 | $template->append( |
---|
[2309] | 958 | 'related_categories', |
---|
| 959 | get_cat_display_name( $page['category']['upper_names'] ) |
---|
[847] | 960 | ); |
---|
| 961 | } |
---|
[2309] | 962 | else |
---|
| 963 | { // use only 1 sql query to get names for all related categories |
---|
| 964 | $ids = array(); |
---|
| 965 | foreach ($related_categories as $category) |
---|
| 966 | {// add all uppercats to $ids |
---|
| 967 | $ids = array_merge($ids, explode(',', $category['uppercats']) ); |
---|
| 968 | } |
---|
| 969 | $ids = array_unique($ids); |
---|
| 970 | $query = ' |
---|
| 971 | SELECT id, name, permalink |
---|
| 972 | FROM '.CATEGORIES_TABLE.' |
---|
| 973 | WHERE id IN ('.implode(',',$ids).')'; |
---|
| 974 | $cat_map = hash_from_query($query, 'id'); |
---|
| 975 | foreach ($related_categories as $category) |
---|
| 976 | { |
---|
| 977 | $cats = array(); |
---|
| 978 | foreach ( explode(',', $category['uppercats']) as $id ) |
---|
| 979 | { |
---|
| 980 | $cats[] = $cat_map[$id]; |
---|
| 981 | } |
---|
| 982 | $template->append('related_categories', get_cat_display_name($cats) ); |
---|
| 983 | } |
---|
| 984 | } |
---|
[847] | 985 | |
---|
[1882] | 986 | // maybe someone wants a special display (call it before page_header so that |
---|
| 987 | // they can add stylesheets) |
---|
| 988 | $element_content = trigger_event( |
---|
| 989 | 'render_element_content', |
---|
| 990 | '', |
---|
| 991 | $picture['current'] |
---|
| 992 | ); |
---|
[2227] | 993 | $template->assign( 'ELEMENT_CONTENT', $element_content ); |
---|
[1882] | 994 | |
---|
[1082] | 995 | // +-----------------------------------------------------------------------+ |
---|
| 996 | // | sub pages | |
---|
| 997 | // +-----------------------------------------------------------------------+ |
---|
[847] | 998 | |
---|
[1082] | 999 | include(PHPWG_ROOT_PATH.'include/picture_rate.inc.php'); |
---|
| 1000 | include(PHPWG_ROOT_PATH.'include/picture_comment.inc.php'); |
---|
[2407] | 1001 | if ($metadata_showable and pwg_get_session_var('show_metadata') <> null ) |
---|
[1107] | 1002 | { |
---|
| 1003 | include(PHPWG_ROOT_PATH.'include/picture_metadata.inc.php'); |
---|
| 1004 | } |
---|
[345] | 1005 | |
---|
[1627] | 1006 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
---|
[1793] | 1007 | trigger_action('loc_end_picture'); |
---|
[2549] | 1008 | if ($page['slideshow'] and $conf['light_slideshow']) |
---|
| 1009 | { |
---|
| 1010 | $template->pparse('slideshow'); |
---|
| 1011 | } |
---|
| 1012 | else |
---|
| 1013 | { |
---|
| 1014 | $template->pparse('picture'); |
---|
| 1015 | } |
---|
[2327] | 1016 | //------------------------------------------------------------ log informations |
---|
| 1017 | pwg_log($picture['current']['id'], 'picture'); |
---|
[369] | 1018 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
[362] | 1019 | ?> |
---|