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