[2] | 1 | <?php |
---|
[354] | 2 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 3 | // | Piwigo - a PHP based photo gallery | |
---|
[2297] | 4 | // +-----------------------------------------------------------------------+ |
---|
[12920] | 5 | // | Copyright(C) 2008-2012 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 | |
---|
[12798] | 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']) ); |
---|
[6654] | 55 | $query .= 'file LIKE \'' . |
---|
[2512] | 56 | str_replace(array('_','%'), array('/_','/%'), $page['image_file'] ). |
---|
[6654] | 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 | { |
---|
[15299] | 152 | global $conf; |
---|
| 153 | |
---|
[1590] | 154 | if ( !empty($content) ) |
---|
| 155 | {// someone hooked us - so we skip; |
---|
| 156 | return $content; |
---|
| 157 | } |
---|
[12796] | 158 | |
---|
| 159 | if (isset($_COOKIE['picture_deriv'])) |
---|
| 160 | { |
---|
[12958] | 161 | if ( array_key_exists($_COOKIE['picture_deriv'], ImageStdParams::get_defined_type_map()) ) |
---|
| 162 | { |
---|
| 163 | pwg_set_session_var('picture_deriv', $_COOKIE['picture_deriv']); |
---|
| 164 | } |
---|
| 165 | setcookie('picture_deriv', false, 0, cookie_path() ); |
---|
[1590] | 166 | } |
---|
[15299] | 167 | $deriv_type = pwg_get_session_var('picture_deriv', $conf['derivative_default_size']); |
---|
[12796] | 168 | $selected_derivative = $element_info['derivatives'][$deriv_type]; |
---|
[1793] | 169 | |
---|
[12855] | 170 | $unique_derivatives = array(); |
---|
| 171 | $show_original = isset($element_info['element_url']); |
---|
[12796] | 172 | $added = array(); |
---|
| 173 | foreach($element_info['derivatives'] as $type => $derivative) |
---|
| 174 | { |
---|
[13074] | 175 | if ($type==IMG_SQUARE || $type==IMG_THUMB) |
---|
| 176 | continue; |
---|
[13736] | 177 | if (!array_key_exists($type, ImageStdParams::get_defined_type_map())) |
---|
| 178 | continue; |
---|
[12796] | 179 | $url = $derivative->get_url(); |
---|
| 180 | if (isset($added[$url])) |
---|
| 181 | continue; |
---|
| 182 | $added[$url] = 1; |
---|
[12855] | 183 | $show_original &= !($derivative->same_as_source()); |
---|
| 184 | $unique_derivatives[$type]= $derivative; |
---|
[12796] | 185 | } |
---|
| 186 | |
---|
[12855] | 187 | global $page, $template; |
---|
[12920] | 188 | |
---|
[12855] | 189 | if ($show_original) |
---|
| 190 | { |
---|
| 191 | $template->assign( 'U_ORIGINAL', $element_info['element_url'] ); |
---|
| 192 | } |
---|
| 193 | |
---|
[12796] | 194 | $template->append('current', array( |
---|
| 195 | 'selected_derivative' => $selected_derivative, |
---|
[12855] | 196 | 'unique_derivatives' => $unique_derivatives, |
---|
[12796] | 197 | ), true); |
---|
[1793] | 198 | |
---|
[12796] | 199 | |
---|
[1882] | 200 | $template->set_filenames( |
---|
[1787] | 201 | array('default_content'=>'picture_content.tpl') |
---|
| 202 | ); |
---|
[1590] | 203 | |
---|
[2227] | 204 | $template->assign( array( |
---|
[1590] | 205 | 'ALT_IMG' => $element_info['file'], |
---|
[12958] | 206 | 'COOKIE_PATH' => cookie_path(), |
---|
[1590] | 207 | ) |
---|
| 208 | ); |
---|
[1882] | 209 | return $template->parse( 'default_content', true); |
---|
[1590] | 210 | } |
---|
| 211 | |
---|
[1082] | 212 | // +-----------------------------------------------------------------------+ |
---|
| 213 | // | initialization | |
---|
| 214 | // +-----------------------------------------------------------------------+ |
---|
| 215 | |
---|
[1036] | 216 | // caching first_rank, last_rank, current_rank in the displayed |
---|
| 217 | // section. This should also help in readability. |
---|
| 218 | $page['first_rank'] = 0; |
---|
| 219 | $page['last_rank'] = count($page['items']) - 1; |
---|
[1082] | 220 | $page['current_rank'] = $page['rank_of'][ $page['image_id'] ]; |
---|
[1036] | 221 | |
---|
| 222 | // caching current item : readability purpose |
---|
[1082] | 223 | $page['current_item'] = $page['image_id']; |
---|
[1036] | 224 | |
---|
| 225 | if ($page['current_rank'] != $page['first_rank']) |
---|
[2] | 226 | { |
---|
[1086] | 227 | // caching first & previous item : readability purpose |
---|
[1036] | 228 | $page['previous_item'] = $page['items'][ $page['current_rank'] - 1 ]; |
---|
[1086] | 229 | $page['first_item'] = $page['items'][ $page['first_rank'] ]; |
---|
[2] | 230 | } |
---|
[1036] | 231 | |
---|
| 232 | if ($page['current_rank'] != $page['last_rank']) |
---|
| 233 | { |
---|
[1086] | 234 | // caching next & last item : readability purpose |
---|
[1036] | 235 | $page['next_item'] = $page['items'][ $page['current_rank'] + 1 ]; |
---|
[1086] | 236 | $page['last_item'] = $page['items'][ $page['last_rank'] ]; |
---|
[1036] | 237 | } |
---|
| 238 | |
---|
[1503] | 239 | $url_up = duplicate_index_url( |
---|
[1082] | 240 | array( |
---|
| 241 | 'start' => |
---|
[8634] | 242 | floor($page['current_rank'] / $page['nb_image_page']) |
---|
| 243 | * $page['nb_image_page'] |
---|
[1082] | 244 | ), |
---|
| 245 | array( |
---|
| 246 | 'start', |
---|
| 247 | ) |
---|
| 248 | ); |
---|
[1014] | 249 | |
---|
[1503] | 250 | $url_self = duplicate_picture_url(); |
---|
[811] | 251 | |
---|
[1082] | 252 | // +-----------------------------------------------------------------------+ |
---|
| 253 | // | actions | |
---|
| 254 | // +-----------------------------------------------------------------------+ |
---|
[858] | 255 | |
---|
[1082] | 256 | /** |
---|
| 257 | * Actions are favorite adding, user comment deletion, setting the picture |
---|
| 258 | * as representative of the current category... |
---|
| 259 | * |
---|
| 260 | * Actions finish by a redirection |
---|
| 261 | */ |
---|
[858] | 262 | |
---|
[1590] | 263 | if (isset($_GET['action'])) |
---|
[858] | 264 | { |
---|
[1082] | 265 | switch ($_GET['action']) |
---|
[1041] | 266 | { |
---|
[1082] | 267 | case 'add_to_favorites' : |
---|
[1041] | 268 | { |
---|
[1082] | 269 | $query = ' |
---|
| 270 | INSERT INTO '.FAVORITES_TABLE.' |
---|
| 271 | (image_id,user_id) |
---|
| 272 | VALUES |
---|
| 273 | ('.$page['image_id'].','.$user['id'].') |
---|
| 274 | ;'; |
---|
| 275 | pwg_query($query); |
---|
| 276 | |
---|
| 277 | redirect($url_self); |
---|
[1086] | 278 | |
---|
[1082] | 279 | break; |
---|
[1041] | 280 | } |
---|
[1082] | 281 | case 'remove_from_favorites' : |
---|
| 282 | { |
---|
| 283 | $query = ' |
---|
| 284 | DELETE FROM '.FAVORITES_TABLE.' |
---|
| 285 | WHERE user_id = '.$user['id'].' |
---|
| 286 | AND image_id = '.$page['image_id'].' |
---|
| 287 | ;'; |
---|
| 288 | pwg_query($query); |
---|
[1041] | 289 | |
---|
[1082] | 290 | if ('favorites' == $page['section']) |
---|
| 291 | { |
---|
| 292 | redirect($url_up); |
---|
| 293 | } |
---|
| 294 | else |
---|
| 295 | { |
---|
| 296 | redirect($url_self); |
---|
| 297 | } |
---|
[1086] | 298 | |
---|
[1082] | 299 | break; |
---|
| 300 | } |
---|
| 301 | case 'set_as_representative' : |
---|
[1041] | 302 | { |
---|
[8126] | 303 | if (is_admin() and isset($page['category'])) |
---|
[1082] | 304 | { |
---|
[1041] | 305 | $query = ' |
---|
[1082] | 306 | UPDATE '.CATEGORIES_TABLE.' |
---|
| 307 | SET representative_picture_id = '.$page['image_id'].' |
---|
[1861] | 308 | WHERE id = '.$page['category']['id'].' |
---|
[1082] | 309 | ;'; |
---|
| 310 | pwg_query($query); |
---|
[8802] | 311 | |
---|
| 312 | $query = ' |
---|
| 313 | UPDATE '.USER_CACHE_CATEGORIES_TABLE.' |
---|
| 314 | SET user_representative_picture_id = NULL |
---|
| 315 | WHERE user_id = '.$user['id'].' |
---|
| 316 | AND cat_id = '.$page['category']['id'].' |
---|
| 317 | ;'; |
---|
| 318 | pwg_query($query); |
---|
[1082] | 319 | } |
---|
[1086] | 320 | |
---|
[1082] | 321 | redirect($url_self); |
---|
[1086] | 322 | |
---|
[1082] | 323 | break; |
---|
| 324 | } |
---|
| 325 | case 'add_to_caddie' : |
---|
| 326 | { |
---|
[1106] | 327 | fill_caddie(array($page['image_id'])); |
---|
[1082] | 328 | redirect($url_self); |
---|
| 329 | break; |
---|
| 330 | } |
---|
| 331 | case 'rate' : |
---|
| 332 | { |
---|
[1107] | 333 | include_once(PHPWG_ROOT_PATH.'include/functions_rate.inc.php'); |
---|
[11839] | 334 | rate_picture($page['image_id'], $_POST['rate']); |
---|
[1082] | 335 | redirect($url_self); |
---|
| 336 | } |
---|
[13865] | 337 | case 'edit_comment': |
---|
[3445] | 338 | { |
---|
[5127] | 339 | include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php'); |
---|
[5195] | 340 | check_input_parameter('comment_to_edit', $_GET, false, PATTERN_ID); |
---|
| 341 | $author_id = get_comment_author_id($_GET['comment_to_edit']); |
---|
[12920] | 342 | |
---|
[5195] | 343 | if (can_manage_comment('edit', $author_id)) |
---|
[3445] | 344 | { |
---|
[5127] | 345 | if (!empty($_POST['content'])) |
---|
| 346 | { |
---|
[13865] | 347 | check_pwg_token(); |
---|
[10097] | 348 | $comment_action = update_user_comment( |
---|
[5195] | 349 | array( |
---|
| 350 | 'comment_id' => $_GET['comment_to_edit'], |
---|
| 351 | 'image_id' => $page['image_id'], |
---|
| 352 | 'content' => $_POST['content'] |
---|
| 353 | ), |
---|
| 354 | $_POST['key'] |
---|
| 355 | ); |
---|
[6615] | 356 | |
---|
[12767] | 357 | $perform_redirect = false; |
---|
[10097] | 358 | switch ($comment_action) |
---|
| 359 | { |
---|
| 360 | case 'moderate': |
---|
[12767] | 361 | $_SESSION['page_infos'][] = l10n('An administrator must authorize your comment before it is visible.'); |
---|
[10097] | 362 | case 'validate': |
---|
[12767] | 363 | $_SESSION['page_infos'][] = l10n('Your comment has been registered'); |
---|
| 364 | $perform_redirect = true; |
---|
[10097] | 365 | break; |
---|
| 366 | case 'reject': |
---|
[12767] | 367 | $_SESSION['page_errors'][] = l10n('Your comment has NOT been registered because it did not pass the validation rules'); |
---|
| 368 | $perform_redirect = true; |
---|
[10097] | 369 | break; |
---|
| 370 | default: |
---|
| 371 | trigger_error('Invalid comment action '.$comment_action, E_USER_WARNING); |
---|
| 372 | } |
---|
[12920] | 373 | |
---|
[12767] | 374 | if ($perform_redirect) |
---|
| 375 | { |
---|
| 376 | redirect($url_self); |
---|
| 377 | } |
---|
[10122] | 378 | unset($_POST['content']); |
---|
[5195] | 379 | } |
---|
| 380 | else |
---|
| 381 | { |
---|
[5127] | 382 | $edit_comment = $_GET['comment_to_edit']; |
---|
| 383 | } |
---|
[3445] | 384 | } |
---|
[13865] | 385 | break; |
---|
[3445] | 386 | } |
---|
[1082] | 387 | case 'delete_comment' : |
---|
| 388 | { |
---|
[5195] | 389 | check_pwg_token(); |
---|
[6615] | 390 | |
---|
[5127] | 391 | include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php'); |
---|
[6615] | 392 | |
---|
[5195] | 393 | check_input_parameter('comment_to_delete', $_GET, false, PATTERN_ID); |
---|
| 394 | |
---|
| 395 | $author_id = get_comment_author_id($_GET['comment_to_delete']); |
---|
[6615] | 396 | |
---|
[5195] | 397 | if (can_manage_comment('delete', $author_id)) |
---|
[1082] | 398 | { |
---|
[5127] | 399 | delete_user_comment($_GET['comment_to_delete']); |
---|
[1082] | 400 | } |
---|
[6615] | 401 | |
---|
[1082] | 402 | redirect($url_self); |
---|
| 403 | } |
---|
[3409] | 404 | case 'validate_comment' : |
---|
| 405 | { |
---|
[5195] | 406 | check_pwg_token(); |
---|
[6615] | 407 | |
---|
[5127] | 408 | include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php'); |
---|
[5195] | 409 | |
---|
| 410 | check_input_parameter('comment_to_validate', $_GET, false, PATTERN_ID); |
---|
[6615] | 411 | |
---|
[5653] | 412 | $author_id = get_comment_author_id($_GET['comment_to_validate']); |
---|
[6615] | 413 | |
---|
[5195] | 414 | if (can_manage_comment('validate', $author_id)) |
---|
[3409] | 415 | { |
---|
[5195] | 416 | validate_user_comment($_GET['comment_to_validate']); |
---|
[3409] | 417 | } |
---|
[6615] | 418 | |
---|
[3409] | 419 | redirect($url_self); |
---|
| 420 | } |
---|
| 421 | |
---|
[1082] | 422 | } |
---|
[1041] | 423 | } |
---|
| 424 | |
---|
[17346] | 425 | |
---|
| 426 | //---------- incrementation of the number of hits |
---|
| 427 | // don't increment counter if in the Mozilla Firefox prefetch |
---|
| 428 | if (isset($_SERVER['HTTP_X_MOZ']) and $_SERVER['HTTP_X_MOZ'] == 'prefetch') |
---|
| 429 | { |
---|
| 430 | add_event_handler('allow_increment_element_hit_count', create_function('$b', 'return false;')); |
---|
| 431 | } |
---|
| 432 | else |
---|
| 433 | { |
---|
| 434 | // don't increment counter if comming from the same picture (actions) |
---|
| 435 | if (pwg_get_session_var('referer_image_id',0) == $page['image_id']) |
---|
| 436 | { |
---|
| 437 | add_event_handler('allow_increment_element_hit_count', create_function('$b', 'return false;')); |
---|
| 438 | } |
---|
| 439 | pwg_set_session_var('referer_image_id', $page['image_id']); |
---|
| 440 | } |
---|
| 441 | |
---|
| 442 | // don't increment if adding a comment |
---|
[2155] | 443 | if (trigger_event('allow_increment_element_hit_count', !isset($_POST['content']) ) ) |
---|
[2048] | 444 | { |
---|
| 445 | $query = ' |
---|
[1082] | 446 | UPDATE |
---|
| 447 | '.IMAGES_TABLE.' |
---|
| 448 | SET hit = hit+1 |
---|
| 449 | WHERE id = '.$page['image_id'].' |
---|
| 450 | ;'; |
---|
[2048] | 451 | pwg_query($query); |
---|
| 452 | } |
---|
[17346] | 453 | |
---|
[745] | 454 | //---------------------------------------------------------- related categories |
---|
| 455 | $query = ' |
---|
| 456 | SELECT category_id,uppercats,commentable,global_rank |
---|
| 457 | FROM '.IMAGE_CATEGORY_TABLE.' |
---|
| 458 | INNER JOIN '.CATEGORIES_TABLE.' ON category_id = id |
---|
[1082] | 459 | WHERE image_id = '.$page['image_id'].' |
---|
[1677] | 460 | '.get_sql_condition_FandF |
---|
| 461 | ( |
---|
| 462 | array |
---|
| 463 | ( |
---|
| 464 | 'forbidden_categories' => 'category_id', |
---|
| 465 | 'visible_categories' => 'category_id' |
---|
| 466 | ), |
---|
| 467 | 'AND' |
---|
| 468 | ).' |
---|
[745] | 469 | ;'; |
---|
| 470 | $result = pwg_query($query); |
---|
| 471 | $related_categories = array(); |
---|
[4325] | 472 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[745] | 473 | { |
---|
[11839] | 474 | $row['commentable'] = get_boolean($row['commentable']); |
---|
[745] | 475 | array_push($related_categories, $row); |
---|
| 476 | } |
---|
| 477 | usort($related_categories, 'global_rank_compare'); |
---|
[1086] | 478 | //-------------------------first, prev, current, next & last picture management |
---|
[402] | 479 | $picture = array(); |
---|
[368] | 480 | |
---|
[1082] | 481 | $ids = array($page['image_id']); |
---|
[1036] | 482 | if (isset($page['previous_item'])) |
---|
[465] | 483 | { |
---|
[1036] | 484 | array_push($ids, $page['previous_item']); |
---|
[1086] | 485 | array_push($ids, $page['first_item']); |
---|
[465] | 486 | } |
---|
[1036] | 487 | if (isset($page['next_item'])) |
---|
[465] | 488 | { |
---|
[1036] | 489 | array_push($ids, $page['next_item']); |
---|
[1086] | 490 | array_push($ids, $page['last_item']); |
---|
[465] | 491 | } |
---|
[368] | 492 | |
---|
[454] | 493 | $query = ' |
---|
[1036] | 494 | SELECT * |
---|
| 495 | FROM '.IMAGES_TABLE.' |
---|
| 496 | WHERE id IN ('.implode(',', $ids).') |
---|
| 497 | ;'; |
---|
[368] | 498 | |
---|
[1036] | 499 | $result = pwg_query($query); |
---|
[368] | 500 | |
---|
[4325] | 501 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[345] | 502 | { |
---|
[1036] | 503 | if (isset($page['previous_item']) and $row['id'] == $page['previous_item']) |
---|
[465] | 504 | { |
---|
[1086] | 505 | $i = 'previous'; |
---|
[465] | 506 | } |
---|
[12797] | 507 | elseif (isset($page['next_item']) and $row['id'] == $page['next_item']) |
---|
[465] | 508 | { |
---|
[1036] | 509 | $i = 'next'; |
---|
[465] | 510 | } |
---|
[12797] | 511 | elseif (isset($page['first_item']) and $row['id'] == $page['first_item']) |
---|
[1086] | 512 | { |
---|
| 513 | $i = 'first'; |
---|
| 514 | } |
---|
[12797] | 515 | elseif (isset($page['last_item']) and $row['id'] == $page['last_item']) |
---|
[1086] | 516 | { |
---|
| 517 | $i = 'last'; |
---|
| 518 | } |
---|
[1036] | 519 | else |
---|
| 520 | { |
---|
| 521 | $i = 'current'; |
---|
| 522 | } |
---|
[1059] | 523 | |
---|
[12855] | 524 | $row['src_image'] = new SrcImage($row); |
---|
| 525 | $row['derivatives'] = DerivativeImage::get_all($row['src_image']); |
---|
[12920] | 526 | |
---|
[1612] | 527 | if ($i=='current') |
---|
[465] | 528 | { |
---|
[12855] | 529 | $row['element_path'] = get_element_path($row); |
---|
| 530 | |
---|
[12797] | 531 | if ( $row['src_image']->is_original() ) |
---|
[12855] | 532 | {// we have a photo |
---|
[1612] | 533 | if ( $user['enabled_high']=='true' ) |
---|
[536] | 534 | { |
---|
[12855] | 535 | $row['element_url'] = $row['src_image']->get_url(); |
---|
| 536 | $row['download_url'] = get_action_url($row['id'], 'e', true); |
---|
[536] | 537 | } |
---|
| 538 | } |
---|
[1590] | 539 | else |
---|
[1612] | 540 | { // not a pic - need download link |
---|
[12855] | 541 | $row['download_url'] = $row['element_url'] = get_element_url($row);; |
---|
[1590] | 542 | } |
---|
| 543 | } |
---|
| 544 | |
---|
[12797] | 545 | $row['url'] = duplicate_picture_url( |
---|
| 546 | array( |
---|
| 547 | 'image_id' => $row['id'], |
---|
| 548 | 'image_file' => $row['file'], |
---|
| 549 | ), |
---|
| 550 | array( |
---|
| 551 | 'start', |
---|
| 552 | ) |
---|
| 553 | ); |
---|
[1059] | 554 | |
---|
[12797] | 555 | $picture[$i] = $row; |
---|
[12920] | 556 | $picture[$i]['TITLE'] = render_element_name($row); |
---|
[12797] | 557 | |
---|
[1086] | 558 | if ('previous'==$i and $page['previous_item']==$page['first_item']) |
---|
| 559 | { |
---|
| 560 | $picture['first'] = $picture[$i]; |
---|
| 561 | } |
---|
| 562 | if ('next'==$i and $page['next_item']==$page['last_item']) |
---|
| 563 | { |
---|
| 564 | $picture['last'] = $picture[$i]; |
---|
| 565 | } |
---|
[345] | 566 | } |
---|
[368] | 567 | |
---|
[2218] | 568 | $slideshow_params = array(); |
---|
| 569 | $slideshow_url_params = array(); |
---|
[858] | 570 | |
---|
[2218] | 571 | if (isset($_GET['slideshow'])) |
---|
[2] | 572 | { |
---|
[1793] | 573 | $page['slideshow'] = true; |
---|
[2218] | 574 | $page['meta_robots'] = array('noindex'=>1, 'nofollow'=>1); |
---|
| 575 | |
---|
| 576 | $slideshow_params = decode_slideshow_params($_GET['slideshow']); |
---|
| 577 | $slideshow_url_params['slideshow'] = encode_slideshow_params($slideshow_params); |
---|
| 578 | |
---|
| 579 | if ($slideshow_params['play']) |
---|
| 580 | { |
---|
| 581 | $id_pict_redirect = ''; |
---|
| 582 | if (isset($page['next_item'])) |
---|
[2169] | 583 | { |
---|
[2218] | 584 | $id_pict_redirect = 'next'; |
---|
[2169] | 585 | } |
---|
[2218] | 586 | else |
---|
| 587 | { |
---|
| 588 | if ($slideshow_params['repeat'] and isset($page['first_item'])) |
---|
| 589 | { |
---|
| 590 | $id_pict_redirect = 'first'; |
---|
| 591 | } |
---|
| 592 | } |
---|
| 593 | |
---|
| 594 | if (!empty($id_pict_redirect)) |
---|
| 595 | { |
---|
[2521] | 596 | // $refresh, $url_link and $title are required for creating |
---|
[2218] | 597 | // an automated refresh page in header.tpl |
---|
| 598 | $refresh = $slideshow_params['period']; |
---|
| 599 | $url_link = add_url_params( |
---|
| 600 | $picture[$id_pict_redirect]['url'], |
---|
| 601 | $slideshow_url_params |
---|
| 602 | ); |
---|
| 603 | } |
---|
[1793] | 604 | } |
---|
[2218] | 605 | } |
---|
| 606 | else |
---|
| 607 | { |
---|
| 608 | $page['slideshow'] = false; |
---|
| 609 | } |
---|
[2549] | 610 | if ($page['slideshow'] and $conf['light_slideshow']) |
---|
| 611 | { |
---|
| 612 | $template->set_filenames( array('slideshow' => 'slideshow.tpl')); |
---|
| 613 | } |
---|
| 614 | else |
---|
| 615 | { |
---|
| 616 | $template->set_filenames( array('picture' => 'picture.tpl')); |
---|
| 617 | } |
---|
[2218] | 618 | |
---|
[12920] | 619 | $title = $picture['current']['TITLE']; |
---|
[1820] | 620 | $title_nb = ($page['current_rank'] + 1).'/'.count($page['items']); |
---|
[2] | 621 | |
---|
[531] | 622 | // metadata |
---|
[1503] | 623 | $url_metadata = duplicate_picture_url(); |
---|
[2407] | 624 | $url_metadata = add_url_params( $url_metadata, array('metadata'=>null) ); |
---|
[1590] | 625 | |
---|
[2407] | 626 | |
---|
[1590] | 627 | // do we have a plugin that can show metadata for something else than images? |
---|
[1787] | 628 | $metadata_showable = trigger_event( |
---|
| 629 | 'get_element_metadata_available', |
---|
| 630 | ( |
---|
| 631 | ($conf['show_exif'] or $conf['show_iptc']) |
---|
[12797] | 632 | and !$picture['current']['src_image']->is_mimetype() |
---|
[1590] | 633 | ), |
---|
[12797] | 634 | $picture['current'] |
---|
[1787] | 635 | ); |
---|
| 636 | |
---|
[2407] | 637 | if ( $metadata_showable and pwg_get_session_var('show_metadata') ) |
---|
[531] | 638 | { |
---|
[2407] | 639 | $page['meta_robots']=array('noindex'=>1, 'nofollow'=>1); |
---|
[531] | 640 | } |
---|
[1590] | 641 | |
---|
[2407] | 642 | |
---|
[1590] | 643 | $page['body_id'] = 'thePicturePage'; |
---|
| 644 | |
---|
[1882] | 645 | // allow plugins to change what we computed before passing data to template |
---|
| 646 | $picture = trigger_event('picture_pictures_data', $picture); |
---|
[1787] | 647 | |
---|
[1036] | 648 | //------------------------------------------------------- navigation management |
---|
[2227] | 649 | foreach (array('first','previous','next','last', 'current') as $which_image) |
---|
[1020] | 650 | { |
---|
[1086] | 651 | if (isset($picture[$which_image])) |
---|
| 652 | { |
---|
[2227] | 653 | $template->assign( |
---|
[1086] | 654 | $which_image, |
---|
[2413] | 655 | array_merge( |
---|
| 656 | $picture[$which_image], |
---|
| 657 | array( |
---|
[12797] | 658 | 'THUMB_SRC' => $picture[$which_image]['derivatives'][IMG_THUMB]->get_url(), |
---|
[2413] | 659 | // Params slideshow was transmit to navigation buttons |
---|
| 660 | 'U_IMG' => |
---|
| 661 | add_url_params( |
---|
| 662 | $picture[$which_image]['url'], $slideshow_url_params), |
---|
| 663 | ) |
---|
[1086] | 664 | ) |
---|
| 665 | ); |
---|
| 666 | } |
---|
[1020] | 667 | } |
---|
[12920] | 668 | if ($conf['picture_download_icon'] and !empty($picture['current']['download_url'])) |
---|
| 669 | { |
---|
| 670 | $template->append('current', array('U_DOWNLOAD' => $picture['current']['download_url']), true); |
---|
| 671 | } |
---|
[1020] | 672 | |
---|
[2218] | 673 | |
---|
| 674 | if ($page['slideshow']) |
---|
| 675 | { |
---|
[2227] | 676 | $tpl_slideshow = array(); |
---|
| 677 | |
---|
[2218] | 678 | //slideshow end |
---|
[2227] | 679 | $template->assign( |
---|
[2218] | 680 | array( |
---|
[2227] | 681 | 'U_SLIDESHOW_STOP' => $picture['current']['url'], |
---|
[2218] | 682 | ) |
---|
| 683 | ); |
---|
| 684 | |
---|
| 685 | foreach (array('repeat', 'play') as $p) |
---|
| 686 | { |
---|
[2227] | 687 | $var_name = |
---|
| 688 | 'U_' |
---|
| 689 | .($slideshow_params[$p] ? 'STOP_' : 'START_') |
---|
| 690 | .strtoupper($p); |
---|
| 691 | |
---|
| 692 | $tpl_slideshow[$var_name] = |
---|
[2218] | 693 | add_url_params( |
---|
| 694 | $picture['current']['url'], |
---|
| 695 | array('slideshow' => |
---|
| 696 | encode_slideshow_params( |
---|
[2227] | 697 | array_merge($slideshow_params, |
---|
[2218] | 698 | array($p => ! $slideshow_params[$p])) |
---|
| 699 | ) |
---|
| 700 | ) |
---|
[2227] | 701 | ); |
---|
[2218] | 702 | } |
---|
| 703 | |
---|
| 704 | foreach (array('dec', 'inc') as $op) |
---|
| 705 | { |
---|
| 706 | $new_period = $slideshow_params['period'] + ((($op == 'dec') ? -1 : 1) * $conf['slideshow_period_step']); |
---|
| 707 | $new_slideshow_params = |
---|
| 708 | correct_slideshow_params( |
---|
[2227] | 709 | array_merge($slideshow_params, |
---|
[2218] | 710 | array('period' => $new_period))); |
---|
| 711 | |
---|
| 712 | if ($new_slideshow_params['period'] === $new_period) |
---|
| 713 | { |
---|
[2227] | 714 | $var_name = 'U_'.strtoupper($op).'_PERIOD'; |
---|
| 715 | $tpl_slideshow[$var_name] = |
---|
[2218] | 716 | add_url_params( |
---|
| 717 | $picture['current']['url'], |
---|
| 718 | array('slideshow' => encode_slideshow_params($new_slideshow_params) |
---|
| 719 | ) |
---|
| 720 | ); |
---|
| 721 | } |
---|
| 722 | } |
---|
[2227] | 723 | $template->assign('slideshow', $tpl_slideshow ); |
---|
[2218] | 724 | } |
---|
[5293] | 725 | elseif ($conf['picture_slideshow_icon']) |
---|
[2218] | 726 | { |
---|
[2227] | 727 | $template->assign( |
---|
[2218] | 728 | array( |
---|
[2227] | 729 | 'U_SLIDESHOW_START' => |
---|
[2218] | 730 | add_url_params( |
---|
| 731 | $picture['current']['url'], |
---|
| 732 | array( 'slideshow'=>'')) |
---|
| 733 | ) |
---|
| 734 | ); |
---|
| 735 | } |
---|
| 736 | |
---|
[2227] | 737 | $template->assign( |
---|
[1082] | 738 | array( |
---|
[1128] | 739 | 'SECTION_TITLE' => $page['title'], |
---|
[1082] | 740 | 'PHOTO' => $title_nb, |
---|
[2759] | 741 | 'IS_HOME' => ('categories'==$page['section'] and !isset($page['category']) ), |
---|
[368] | 742 | |
---|
[1082] | 743 | 'LEVEL_SEPARATOR' => $conf['level_separator'], |
---|
[2309] | 744 | |
---|
[2227] | 745 | 'U_UP' => $url_up, |
---|
[5293] | 746 | 'DISPLAY_NAV_BUTTONS' => $conf['picture_navigation_icons'], |
---|
| 747 | 'DISPLAY_NAV_THUMB' => $conf['picture_navigation_thumb'] |
---|
[1082] | 748 | ) |
---|
| 749 | ); |
---|
[803] | 750 | |
---|
[5293] | 751 | if ($conf['picture_metadata_icon']) |
---|
| 752 | { |
---|
| 753 | $template->assign('U_METADATA', $url_metadata); |
---|
| 754 | } |
---|
[803] | 755 | |
---|
[5293] | 756 | |
---|
[536] | 757 | //------------------------------------------------------- upper menu management |
---|
[1082] | 758 | |
---|
[2227] | 759 | // admin links |
---|
[1070] | 760 | if (is_admin()) |
---|
[858] | 761 | { |
---|
[2227] | 762 | if (isset($page['category'])) |
---|
| 763 | { |
---|
| 764 | $template->assign( |
---|
| 765 | array( |
---|
| 766 | 'U_SET_AS_REPRESENTATIVE' => add_url_params($url_self, |
---|
| 767 | array('action'=>'set_as_representative') |
---|
| 768 | ) |
---|
| 769 | ) |
---|
| 770 | ); |
---|
| 771 | } |
---|
[2309] | 772 | |
---|
[3167] | 773 | $url_admin = |
---|
[13077] | 774 | get_root_url().'admin.php?page=photo-'.$page['image_id'] |
---|
| 775 | .(isset($page['category']) ? '&cat_id='.$page['category']['id'] : '') |
---|
| 776 | ; |
---|
[3167] | 777 | |
---|
[2227] | 778 | $template->assign( |
---|
[858] | 779 | array( |
---|
[2227] | 780 | 'U_CADDIE' => add_url_params($url_self, |
---|
[1094] | 781 | array('action'=>'add_to_caddie') |
---|
[2227] | 782 | ), |
---|
| 783 | 'U_ADMIN' => $url_admin, |
---|
[1082] | 784 | ) |
---|
[858] | 785 | ); |
---|
[3167] | 786 | |
---|
[6025] | 787 | $template->assign('available_permission_levels', get_privacy_level_options()); |
---|
[858] | 788 | } |
---|
| 789 | |
---|
[1082] | 790 | // favorite manipulation |
---|
[5305] | 791 | if (!is_a_guest() and $conf['picture_favorite_icon']) |
---|
[531] | 792 | { |
---|
| 793 | // verify if the picture is already in the favorite of the user |
---|
[1082] | 794 | $query = ' |
---|
| 795 | SELECT COUNT(*) AS nb_fav |
---|
| 796 | FROM '.FAVORITES_TABLE.' |
---|
| 797 | WHERE image_id = '.$page['image_id'].' |
---|
| 798 | AND user_id = '.$user['id'].' |
---|
| 799 | ;'; |
---|
[6615] | 800 | $row = pwg_db_fetch_assoc( pwg_query($query) ); |
---|
| 801 | $is_favorite = $row['nb_fav'] != 0; |
---|
[1086] | 802 | |
---|
[6615] | 803 | $template->assign( |
---|
| 804 | 'favorite', |
---|
| 805 | array( |
---|
| 806 | 'IS_FAVORITE' => $is_favorite, |
---|
| 807 | 'U_FAVORITE' => add_url_params( |
---|
| 808 | $url_self, |
---|
| 809 | array('action'=> !$is_favorite ? 'add_to_favorites' : 'remove_from_favorites' ) |
---|
| 810 | ), |
---|
| 811 | ) |
---|
| 812 | ); |
---|
[2] | 813 | } |
---|
[368] | 814 | |
---|
[2] | 815 | //--------------------------------------------------------- picture information |
---|
[393] | 816 | // legend |
---|
[465] | 817 | if (isset($picture['current']['comment']) |
---|
| 818 | and !empty($picture['current']['comment'])) |
---|
[393] | 819 | { |
---|
[2227] | 820 | $template->assign( |
---|
| 821 | 'COMMENT_IMG', |
---|
[2079] | 822 | trigger_event('render_element_description', |
---|
| 823 | $picture['current']['comment']) |
---|
[2227] | 824 | ); |
---|
[393] | 825 | } |
---|
| 826 | |
---|
[847] | 827 | // author |
---|
| 828 | if (!empty($picture['current']['author'])) |
---|
[51] | 829 | { |
---|
[13074] | 830 | $infos['INFO_AUTHOR'] = $picture['current']['author']; |
---|
[51] | 831 | } |
---|
[774] | 832 | |
---|
[847] | 833 | // creation date |
---|
| 834 | if (!empty($picture['current']['date_creation'])) |
---|
[635] | 835 | { |
---|
[1051] | 836 | $val = format_date($picture['current']['date_creation']); |
---|
[1503] | 837 | $url = make_index_url( |
---|
[1825] | 838 | array( |
---|
| 839 | 'chronology_field'=>'created', |
---|
| 840 | 'chronology_style'=>'monthly', |
---|
| 841 | 'chronology_view'=>'list', |
---|
[9073] | 842 | 'chronology_date' => explode('-', substr($picture['current']['date_creation'], 0, 10)) |
---|
[1825] | 843 | ) |
---|
| 844 | ); |
---|
| 845 | $infos['INFO_CREATION_DATE'] = |
---|
| 846 | '<a href="'.$url.'" rel="nofollow">'.$val.'</a>'; |
---|
[847] | 847 | } |
---|
| 848 | |
---|
| 849 | // date of availability |
---|
[3122] | 850 | $val = format_date($picture['current']['date_available']); |
---|
[1503] | 851 | $url = make_index_url( |
---|
[1825] | 852 | array( |
---|
| 853 | 'chronology_field'=>'posted', |
---|
| 854 | 'chronology_style'=>'monthly', |
---|
| 855 | 'chronology_view'=>'list', |
---|
| 856 | 'chronology_date' => explode( |
---|
| 857 | '-', |
---|
| 858 | substr($picture['current']['date_available'], 0, 10) |
---|
[1090] | 859 | ) |
---|
[1825] | 860 | ) |
---|
| 861 | ); |
---|
[1135] | 862 | $infos['INFO_POSTED_DATE'] = '<a href="'.$url.'" rel="nofollow">'.$val.'</a>'; |
---|
[847] | 863 | |
---|
| 864 | // size in pixels |
---|
[12797] | 865 | if ($picture['current']['src_image']->is_original() and isset($picture['current']['width']) ) |
---|
[847] | 866 | { |
---|
[12796] | 867 | $infos['INFO_DIMENSIONS'] = |
---|
| 868 | $picture['current']['width'].'*'.$picture['current']['height']; |
---|
[10160] | 869 | } |
---|
[774] | 870 | |
---|
[847] | 871 | // filesize |
---|
[12796] | 872 | if (!empty($picture['current']['filesize'])) |
---|
[847] | 873 | { |
---|
| 874 | $infos['INFO_FILESIZE'] = |
---|
[10160] | 875 | sprintf(l10n('%d Kb'), $picture['current']['filesize']); |
---|
[10157] | 876 | } |
---|
| 877 | |
---|
[847] | 878 | // number of visits |
---|
| 879 | $infos['INFO_VISITS'] = $picture['current']['hit']; |
---|
| 880 | |
---|
| 881 | // file |
---|
| 882 | $infos['INFO_FILE'] = $picture['current']['file']; |
---|
| 883 | |
---|
[2227] | 884 | $template->assign($infos); |
---|
[5304] | 885 | $template->assign('display_info', unserialize($conf['picture_informations'])); |
---|
[2227] | 886 | |
---|
| 887 | // related tags |
---|
[1827] | 888 | $tags = get_common_tags( array($page['image_id']), -1); |
---|
| 889 | if ( count($tags) ) |
---|
[847] | 890 | { |
---|
[2227] | 891 | foreach ($tags as $tag) |
---|
[1119] | 892 | { |
---|
[2227] | 893 | $template->append( |
---|
| 894 | 'related_tags', |
---|
[2413] | 895 | array_merge( $tag, |
---|
| 896 | array( |
---|
| 897 | 'URL' => make_index_url( |
---|
[2227] | 898 | array( |
---|
| 899 | 'tags' => array($tag) |
---|
| 900 | ) |
---|
| 901 | ), |
---|
[2413] | 902 | 'U_TAG_IMAGE' => duplicate_picture_url( |
---|
[2227] | 903 | array( |
---|
| 904 | 'section' => 'tags', |
---|
| 905 | 'tags' => array($tag) |
---|
| 906 | ) |
---|
| 907 | ) |
---|
[1119] | 908 | ) |
---|
[2413] | 909 | ) |
---|
[2227] | 910 | ); |
---|
[1119] | 911 | } |
---|
[847] | 912 | } |
---|
| 913 | |
---|
| 914 | // related categories |
---|
[2309] | 915 | if ( count($related_categories)==1 and |
---|
| 916 | isset($page['category']) and |
---|
| 917 | $related_categories[0]['category_id']==$page['category']['id'] ) |
---|
| 918 | { // no need to go to db, we have all the info |
---|
[2227] | 919 | $template->append( |
---|
[2309] | 920 | 'related_categories', |
---|
| 921 | get_cat_display_name( $page['category']['upper_names'] ) |
---|
[847] | 922 | ); |
---|
| 923 | } |
---|
[2309] | 924 | else |
---|
| 925 | { // use only 1 sql query to get names for all related categories |
---|
| 926 | $ids = array(); |
---|
| 927 | foreach ($related_categories as $category) |
---|
| 928 | {// add all uppercats to $ids |
---|
| 929 | $ids = array_merge($ids, explode(',', $category['uppercats']) ); |
---|
| 930 | } |
---|
| 931 | $ids = array_unique($ids); |
---|
| 932 | $query = ' |
---|
| 933 | SELECT id, name, permalink |
---|
| 934 | FROM '.CATEGORIES_TABLE.' |
---|
| 935 | WHERE id IN ('.implode(',',$ids).')'; |
---|
| 936 | $cat_map = hash_from_query($query, 'id'); |
---|
| 937 | foreach ($related_categories as $category) |
---|
| 938 | { |
---|
| 939 | $cats = array(); |
---|
| 940 | foreach ( explode(',', $category['uppercats']) as $id ) |
---|
| 941 | { |
---|
| 942 | $cats[] = $cat_map[$id]; |
---|
| 943 | } |
---|
| 944 | $template->append('related_categories', get_cat_display_name($cats) ); |
---|
| 945 | } |
---|
| 946 | } |
---|
[847] | 947 | |
---|
[1882] | 948 | // maybe someone wants a special display (call it before page_header so that |
---|
| 949 | // they can add stylesheets) |
---|
| 950 | $element_content = trigger_event( |
---|
| 951 | 'render_element_content', |
---|
| 952 | '', |
---|
| 953 | $picture['current'] |
---|
| 954 | ); |
---|
[2227] | 955 | $template->assign( 'ELEMENT_CONTENT', $element_content ); |
---|
[1882] | 956 | |
---|
[12797] | 957 | if (isset($picture['next']) |
---|
| 958 | and $picture['next']['src_image']->is_original() |
---|
| 959 | and strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome/') === false) |
---|
| 960 | { |
---|
[15299] | 961 | $template->assign( |
---|
| 962 | 'U_PREFETCH', |
---|
| 963 | $picture['next']['derivatives'][pwg_get_session_var('picture_deriv', $conf['derivative_default_size'])]->get_url() |
---|
| 964 | ); |
---|
[12797] | 965 | } |
---|
| 966 | |
---|
[15299] | 967 | $template->assign( |
---|
| 968 | 'U_CANONICAL', |
---|
| 969 | make_picture_url( |
---|
| 970 | array( |
---|
| 971 | 'image_id' => $picture['current']['id'], |
---|
| 972 | 'image_file' => $picture['current']['file']) |
---|
| 973 | ) |
---|
| 974 | ); |
---|
[12797] | 975 | |
---|
[1082] | 976 | // +-----------------------------------------------------------------------+ |
---|
| 977 | // | sub pages | |
---|
| 978 | // +-----------------------------------------------------------------------+ |
---|
[847] | 979 | |
---|
[1082] | 980 | include(PHPWG_ROOT_PATH.'include/picture_rate.inc.php'); |
---|
[12887] | 981 | if ($conf['activate_comments']) |
---|
| 982 | { |
---|
| 983 | include(PHPWG_ROOT_PATH.'include/picture_comment.inc.php'); |
---|
| 984 | } |
---|
[2407] | 985 | if ($metadata_showable and pwg_get_session_var('show_metadata') <> null ) |
---|
[1107] | 986 | { |
---|
| 987 | include(PHPWG_ROOT_PATH.'include/picture_metadata.inc.php'); |
---|
| 988 | } |
---|
[345] | 989 | |
---|
[10812] | 990 | // include menubar |
---|
| 991 | $themeconf = $template->get_template_vars('themeconf'); |
---|
[10824] | 992 | if ($conf['picture_menu'] AND (!isset($themeconf['hide_menu_on']) OR !in_array('thePicturePage', $themeconf['hide_menu_on']))) |
---|
[10812] | 993 | { |
---|
[10970] | 994 | if (!isset($page['start'])) $page['start'] = 0; |
---|
[10812] | 995 | include( PHPWG_ROOT_PATH.'include/menubar.inc.php'); |
---|
[10814] | 996 | if (is_admin()) $template->assign('U_ADMIN', $url_admin); // overwrited by the menu |
---|
[10812] | 997 | } |
---|
| 998 | |
---|
[1627] | 999 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
---|
[1793] | 1000 | trigger_action('loc_end_picture'); |
---|
[15578] | 1001 | include(PHPWG_ROOT_PATH.'include/page_messages.php'); |
---|
[2549] | 1002 | if ($page['slideshow'] and $conf['light_slideshow']) |
---|
| 1003 | { |
---|
| 1004 | $template->pparse('slideshow'); |
---|
| 1005 | } |
---|
| 1006 | else |
---|
| 1007 | { |
---|
| 1008 | $template->pparse('picture'); |
---|
| 1009 | } |
---|
[2327] | 1010 | //------------------------------------------------------------ log informations |
---|
| 1011 | pwg_log($picture['current']['id'], 'picture'); |
---|
[369] | 1012 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
[6615] | 1013 | ?> |
---|