[2] | 1 | <?php |
---|
[354] | 2 | // +-----------------------------------------------------------------------+ |
---|
[593] | 3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
| 4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
[1078] | 5 | // | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net | |
---|
[354] | 6 | // +-----------------------------------------------------------------------+ |
---|
[593] | 7 | // | branch : BSF (Best So Far) |
---|
[354] | 8 | // | file : $RCSfile$ |
---|
| 9 | // | last update : $Date: 2006-03-28 01:26:37 +0000 (Tue, 28 Mar 2006) $ |
---|
| 10 | // | last modifier : $Author: rvelices $ |
---|
| 11 | // | revision : $Revision: 1107 $ |
---|
| 12 | // +-----------------------------------------------------------------------+ |
---|
| 13 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 14 | // | it under the terms of the GNU General Public License as published by | |
---|
| 15 | // | the Free Software Foundation | |
---|
| 16 | // | | |
---|
| 17 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 18 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 19 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 20 | // | General Public License for more details. | |
---|
| 21 | // | | |
---|
| 22 | // | You should have received a copy of the GNU General Public License | |
---|
| 23 | // | along with this program; if not, write to the Free Software | |
---|
| 24 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 25 | // | USA. | |
---|
| 26 | // +-----------------------------------------------------------------------+ |
---|
[420] | 27 | |
---|
[364] | 28 | define('PHPWG_ROOT_PATH','./'); |
---|
[613] | 29 | include_once(PHPWG_ROOT_PATH.'include/common.inc.php'); |
---|
[1082] | 30 | include(PHPWG_ROOT_PATH.'include/section_init.inc.php'); |
---|
[1052] | 31 | |
---|
[1082] | 32 | // Check Access and exit when user status is not ok |
---|
[1072] | 33 | check_status(ACCESS_GUEST); |
---|
| 34 | |
---|
[1082] | 35 | // access authorization check |
---|
| 36 | if (isset($page['category'])) |
---|
[1036] | 37 | { |
---|
[1082] | 38 | check_restrictions($page['category']); |
---|
[1036] | 39 | } |
---|
[1082] | 40 | |
---|
[1036] | 41 | // if this image_id doesn't correspond to this category, an error message is |
---|
| 42 | // displayed, and execution is stopped |
---|
[1082] | 43 | if (!in_array($page['image_id'], $page['items'])) |
---|
[934] | 44 | { |
---|
[1082] | 45 | die('Fatal: this picture does not belong to this section'); |
---|
[934] | 46 | } |
---|
| 47 | |
---|
[1082] | 48 | // +-----------------------------------------------------------------------+ |
---|
| 49 | // | initialization | |
---|
| 50 | // +-----------------------------------------------------------------------+ |
---|
| 51 | |
---|
[1036] | 52 | $page['rank_of'] = array_flip($page['items']); |
---|
| 53 | |
---|
| 54 | // caching first_rank, last_rank, current_rank in the displayed |
---|
| 55 | // section. This should also help in readability. |
---|
| 56 | $page['first_rank'] = 0; |
---|
| 57 | $page['last_rank'] = count($page['items']) - 1; |
---|
[1082] | 58 | $page['current_rank'] = $page['rank_of'][ $page['image_id'] ]; |
---|
[1036] | 59 | |
---|
| 60 | // caching current item : readability purpose |
---|
[1082] | 61 | $page['current_item'] = $page['image_id']; |
---|
[1036] | 62 | |
---|
| 63 | if ($page['current_rank'] != $page['first_rank']) |
---|
[2] | 64 | { |
---|
[1086] | 65 | // caching first & previous item : readability purpose |
---|
[1036] | 66 | $page['previous_item'] = $page['items'][ $page['current_rank'] - 1 ]; |
---|
[1086] | 67 | $page['first_item'] = $page['items'][ $page['first_rank'] ]; |
---|
[2] | 68 | } |
---|
[1036] | 69 | |
---|
| 70 | if ($page['current_rank'] != $page['last_rank']) |
---|
| 71 | { |
---|
[1086] | 72 | // caching next & last item : readability purpose |
---|
[1036] | 73 | $page['next_item'] = $page['items'][ $page['current_rank'] + 1 ]; |
---|
[1086] | 74 | $page['last_item'] = $page['items'][ $page['last_rank'] ]; |
---|
[1036] | 75 | } |
---|
| 76 | |
---|
[1082] | 77 | $url_up = duplicate_index_URL( |
---|
| 78 | array( |
---|
| 79 | 'start' => |
---|
| 80 | floor($page['current_rank'] / $user['nb_image_page']) |
---|
| 81 | * $user['nb_image_page'] |
---|
| 82 | ), |
---|
| 83 | array( |
---|
| 84 | 'start', |
---|
| 85 | ) |
---|
| 86 | ); |
---|
[1014] | 87 | |
---|
[1082] | 88 | $url_self = duplicate_picture_URL(); |
---|
[811] | 89 | |
---|
[1082] | 90 | // +-----------------------------------------------------------------------+ |
---|
| 91 | // | actions | |
---|
| 92 | // +-----------------------------------------------------------------------+ |
---|
[858] | 93 | |
---|
[1082] | 94 | /** |
---|
| 95 | * Actions are favorite adding, user comment deletion, setting the picture |
---|
| 96 | * as representative of the current category... |
---|
| 97 | * |
---|
| 98 | * Actions finish by a redirection |
---|
| 99 | */ |
---|
[858] | 100 | |
---|
[1106] | 101 | if (isset($_GET['action']) and !is_adviser()) |
---|
[858] | 102 | { |
---|
[1082] | 103 | switch ($_GET['action']) |
---|
[1041] | 104 | { |
---|
[1082] | 105 | case 'add_to_favorites' : |
---|
[1041] | 106 | { |
---|
[1082] | 107 | $query = ' |
---|
| 108 | INSERT INTO '.FAVORITES_TABLE.' |
---|
| 109 | (image_id,user_id) |
---|
| 110 | VALUES |
---|
| 111 | ('.$page['image_id'].','.$user['id'].') |
---|
| 112 | ;'; |
---|
| 113 | pwg_query($query); |
---|
| 114 | |
---|
| 115 | redirect($url_self); |
---|
[1086] | 116 | |
---|
[1082] | 117 | break; |
---|
[1041] | 118 | } |
---|
[1082] | 119 | case 'remove_from_favorites' : |
---|
| 120 | { |
---|
| 121 | $query = ' |
---|
| 122 | DELETE FROM '.FAVORITES_TABLE.' |
---|
| 123 | WHERE user_id = '.$user['id'].' |
---|
| 124 | AND image_id = '.$page['image_id'].' |
---|
| 125 | ;'; |
---|
| 126 | pwg_query($query); |
---|
[1041] | 127 | |
---|
[1082] | 128 | if ('favorites' == $page['section']) |
---|
| 129 | { |
---|
| 130 | redirect($url_up); |
---|
| 131 | } |
---|
| 132 | else |
---|
| 133 | { |
---|
| 134 | redirect($url_self); |
---|
| 135 | } |
---|
[1086] | 136 | |
---|
[1082] | 137 | break; |
---|
| 138 | } |
---|
| 139 | case 'set_as_representative' : |
---|
[1041] | 140 | { |
---|
[1106] | 141 | if (is_admin() and isset($page['category'])) |
---|
[1082] | 142 | { |
---|
[1041] | 143 | $query = ' |
---|
[1082] | 144 | UPDATE '.CATEGORIES_TABLE.' |
---|
| 145 | SET representative_picture_id = '.$page['image_id'].' |
---|
| 146 | WHERE id = '.$page['category'].' |
---|
| 147 | ;'; |
---|
| 148 | pwg_query($query); |
---|
| 149 | } |
---|
[1086] | 150 | |
---|
[1082] | 151 | redirect($url_self); |
---|
[1086] | 152 | |
---|
[1082] | 153 | break; |
---|
| 154 | } |
---|
| 155 | case 'toggle_metadata' : |
---|
| 156 | { |
---|
| 157 | break; |
---|
| 158 | } |
---|
| 159 | case 'add_to_caddie' : |
---|
| 160 | { |
---|
[1106] | 161 | fill_caddie(array($page['image_id'])); |
---|
[1082] | 162 | redirect($url_self); |
---|
| 163 | break; |
---|
| 164 | } |
---|
| 165 | case 'rate' : |
---|
| 166 | { |
---|
[1107] | 167 | include_once(PHPWG_ROOT_PATH.'include/functions_rate.inc.php'); |
---|
[1092] | 168 | rate_picture($page['image_id'], $_GET['rate']); |
---|
[1082] | 169 | redirect($url_self); |
---|
| 170 | } |
---|
| 171 | case 'delete_comment' : |
---|
| 172 | { |
---|
| 173 | if (isset($_GET['comment_to_delete']) |
---|
| 174 | and is_numeric($_GET['comment_to_delete']) |
---|
| 175 | and is_admin()) |
---|
| 176 | { |
---|
| 177 | $query = ' |
---|
| 178 | DELETE FROM '.COMMENTS_TABLE.' |
---|
| 179 | WHERE id = '.$_GET['comment_to_delete'].' |
---|
| 180 | ;'; |
---|
| 181 | pwg_query( $query ); |
---|
| 182 | } |
---|
| 183 | |
---|
| 184 | redirect($url_self); |
---|
| 185 | } |
---|
| 186 | } |
---|
[1041] | 187 | } |
---|
| 188 | |
---|
[1082] | 189 | // incrementation of the number of hits, we do this only if no action |
---|
| 190 | $query = ' |
---|
| 191 | UPDATE |
---|
| 192 | '.IMAGES_TABLE.' |
---|
| 193 | SET hit = hit+1 |
---|
| 194 | WHERE id = '.$page['image_id'].' |
---|
| 195 | ;'; |
---|
| 196 | pwg_query($query); |
---|
[1041] | 197 | |
---|
[745] | 198 | //---------------------------------------------------------- related categories |
---|
| 199 | $query = ' |
---|
| 200 | SELECT category_id,uppercats,commentable,global_rank |
---|
| 201 | FROM '.IMAGE_CATEGORY_TABLE.' |
---|
| 202 | INNER JOIN '.CATEGORIES_TABLE.' ON category_id = id |
---|
[1082] | 203 | WHERE image_id = '.$page['image_id'].' |
---|
[847] | 204 | AND category_id NOT IN ('.$user['forbidden_categories'].') |
---|
[745] | 205 | ;'; |
---|
| 206 | $result = pwg_query($query); |
---|
| 207 | $related_categories = array(); |
---|
| 208 | while ($row = mysql_fetch_array($result)) |
---|
| 209 | { |
---|
| 210 | array_push($related_categories, $row); |
---|
| 211 | } |
---|
| 212 | usort($related_categories, 'global_rank_compare'); |
---|
[1086] | 213 | //-------------------------first, prev, current, next & last picture management |
---|
[402] | 214 | $picture = array(); |
---|
[368] | 215 | |
---|
[1082] | 216 | $ids = array($page['image_id']); |
---|
[1036] | 217 | if (isset($page['previous_item'])) |
---|
[465] | 218 | { |
---|
[1036] | 219 | array_push($ids, $page['previous_item']); |
---|
[1086] | 220 | array_push($ids, $page['first_item']); |
---|
[465] | 221 | } |
---|
[1036] | 222 | if (isset($page['next_item'])) |
---|
[465] | 223 | { |
---|
[1036] | 224 | array_push($ids, $page['next_item']); |
---|
[1086] | 225 | array_push($ids, $page['last_item']); |
---|
[465] | 226 | } |
---|
[368] | 227 | |
---|
[454] | 228 | $query = ' |
---|
[1036] | 229 | SELECT * |
---|
| 230 | FROM '.IMAGES_TABLE.' |
---|
| 231 | WHERE id IN ('.implode(',', $ids).') |
---|
| 232 | ;'; |
---|
[368] | 233 | |
---|
[1036] | 234 | $result = pwg_query($query); |
---|
[368] | 235 | |
---|
[1036] | 236 | while ($row = mysql_fetch_array($result)) |
---|
[345] | 237 | { |
---|
[1036] | 238 | if (isset($page['previous_item']) and $row['id'] == $page['previous_item']) |
---|
[465] | 239 | { |
---|
[1086] | 240 | $i = 'previous'; |
---|
[465] | 241 | } |
---|
[1036] | 242 | else if (isset($page['next_item']) and $row['id'] == $page['next_item']) |
---|
[465] | 243 | { |
---|
[1036] | 244 | $i = 'next'; |
---|
[465] | 245 | } |
---|
[1086] | 246 | else if (isset($page['first_item']) and $row['id'] == $page['first_item']) |
---|
| 247 | { |
---|
| 248 | $i = 'first'; |
---|
| 249 | } |
---|
| 250 | else if (isset($page['last_item']) and $row['id'] == $page['last_item']) |
---|
| 251 | { |
---|
| 252 | $i = 'last'; |
---|
| 253 | } |
---|
[1036] | 254 | else |
---|
| 255 | { |
---|
| 256 | $i = 'current'; |
---|
| 257 | } |
---|
[1059] | 258 | |
---|
[465] | 259 | foreach (array_keys($row) as $key) |
---|
| 260 | { |
---|
| 261 | if (!is_numeric($key)) |
---|
| 262 | { |
---|
| 263 | $picture[$i][$key] = $row[$key]; |
---|
| 264 | } |
---|
| 265 | } |
---|
| 266 | |
---|
| 267 | $picture[$i]['is_picture'] = false; |
---|
| 268 | if (in_array(get_extension($row['file']), $conf['picture_ext'])) |
---|
| 269 | { |
---|
| 270 | $picture[$i]['is_picture'] = true; |
---|
| 271 | } |
---|
[1059] | 272 | |
---|
[606] | 273 | $cat_directory = dirname($row['path']); |
---|
[465] | 274 | $file_wo_ext = get_filename_wo_extension($row['file']); |
---|
[402] | 275 | |
---|
[731] | 276 | if (isset($row['representative_ext']) and $row['representative_ext'] != '') |
---|
[465] | 277 | { |
---|
[1036] | 278 | $picture[$i]['src'] = |
---|
| 279 | $cat_directory.'/pwg_representative/' |
---|
| 280 | .$file_wo_ext.'.'.$row['representative_ext']; |
---|
[465] | 281 | } |
---|
| 282 | else |
---|
| 283 | { |
---|
[1090] | 284 | $icon = get_themeconf('mime_icon_dir'); |
---|
| 285 | $icon.= strtolower(get_extension($row['file'])).'.png'; |
---|
[465] | 286 | $picture[$i]['src'] = $icon; |
---|
| 287 | } |
---|
| 288 | // special case for picture files |
---|
| 289 | if ($picture[$i]['is_picture']) |
---|
| 290 | { |
---|
[606] | 291 | $picture[$i]['src'] = $row['path']; |
---|
[536] | 292 | // if we are working on the "current" element, we search if there is a |
---|
| 293 | // high quality picture |
---|
| 294 | if ($i == 'current') |
---|
| 295 | { |
---|
[1078] | 296 | if (($row['has_high'] == 'true') and ($user['enabled_high'] == 'true')) |
---|
[536] | 297 | { |
---|
[1029] | 298 | $url_high=$cat_directory.'/pwg_high/'.$row['file']; |
---|
[1090] | 299 | $picture[$i]['high_file_system'] = $picture[$i]['high'] = $url_high; |
---|
| 300 | if ( ! url_is_remote($picture[$i]['high']) ) |
---|
| 301 | { |
---|
| 302 | $picture[$i]['high'] = get_root_url().$picture[$i]['high']; |
---|
| 303 | } |
---|
[536] | 304 | } |
---|
| 305 | } |
---|
[465] | 306 | } |
---|
[1090] | 307 | $picture[$i]['src_file_system'] = $picture[$i]['src']; |
---|
| 308 | if ( ! url_is_remote($picture[$i]['src']) ) |
---|
| 309 | { |
---|
| 310 | $picture[$i]['src'] = get_root_url(). $picture[$i]['src']; |
---|
| 311 | } |
---|
[465] | 312 | |
---|
| 313 | // if picture is not a file, we need the download link |
---|
| 314 | if (!$picture[$i]['is_picture']) |
---|
| 315 | { |
---|
[1090] | 316 | $picture[$i]['download'] = url_is_remote($row['path']) ? '' : get_root_url(); |
---|
| 317 | $picture[$i]['download'].= $row['path']; |
---|
[465] | 318 | } |
---|
| 319 | |
---|
[606] | 320 | $picture[$i]['thumbnail'] = get_thumbnail_src($row['path'], @$row['tn_ext']); |
---|
[1059] | 321 | |
---|
[402] | 322 | if ( !empty( $row['name'] ) ) |
---|
[345] | 323 | { |
---|
[465] | 324 | $picture[$i]['name'] = $row['name']; |
---|
[345] | 325 | } |
---|
| 326 | else |
---|
| 327 | { |
---|
[465] | 328 | $picture[$i]['name'] = str_replace('_', ' ', $file_wo_ext); |
---|
[345] | 329 | } |
---|
| 330 | |
---|
[1082] | 331 | $picture[$i]['url'] = duplicate_picture_URL( |
---|
| 332 | array( |
---|
| 333 | 'image_id' => $row['id'], |
---|
[1090] | 334 | 'image_file' => $row['file'], |
---|
[1082] | 335 | ), |
---|
| 336 | array( |
---|
| 337 | 'start', |
---|
| 338 | ) |
---|
| 339 | ); |
---|
[1086] | 340 | |
---|
| 341 | if ('previous'==$i and $page['previous_item']==$page['first_item']) |
---|
| 342 | { |
---|
| 343 | $picture['first'] = $picture[$i]; |
---|
| 344 | } |
---|
| 345 | if ('next'==$i and $page['next_item']==$page['last_item']) |
---|
| 346 | { |
---|
| 347 | $picture['last'] = $picture[$i]; |
---|
| 348 | } |
---|
[345] | 349 | } |
---|
[368] | 350 | |
---|
[1036] | 351 | $url_admin = |
---|
[1090] | 352 | get_root_url().'admin.php?page=picture_modify' |
---|
[1082] | 353 | .'&cat_id='.(isset($page['category']) ? $page['category'] : '') |
---|
| 354 | .'&image_id='.$page['image_id'] |
---|
| 355 | ; |
---|
[531] | 356 | |
---|
[1094] | 357 | $url_slide = add_url_params( |
---|
[1090] | 358 | $picture['current']['url'], |
---|
[1094] | 359 | array( 'slideshow'=>$conf['slideshow_period'] ) |
---|
| 360 | ); |
---|
[858] | 361 | |
---|
[368] | 362 | $title = $picture['current']['name']; |
---|
| 363 | $refresh = 0; |
---|
[1041] | 364 | if ( isset( $_GET['slideshow'] ) and isset($page['next_item']) ) |
---|
[2] | 365 | { |
---|
[402] | 366 | $refresh= $_GET['slideshow']; |
---|
[1094] | 367 | $url_link = add_url_params( |
---|
| 368 | $picture['next']['url'], |
---|
| 369 | array('slideshow'=>$refresh) |
---|
| 370 | ); |
---|
[2] | 371 | } |
---|
[61] | 372 | |
---|
[368] | 373 | $title_img = $picture['current']['name']; |
---|
[1092] | 374 | if ( isset( $page['category'] ) ) |
---|
[61] | 375 | { |
---|
[1092] | 376 | if (is_numeric( $page['category'] )) |
---|
[1056] | 377 | { |
---|
| 378 | $title_img = replace_space(get_cat_display_name($page['cat_name'])); |
---|
| 379 | } |
---|
| 380 | else if ( $page['cat'] == 'search' ) |
---|
[1092] | 381 | { // ??? TODO -remove or change some remainings from old variables |
---|
[1056] | 382 | $title_img = replace_search( $title_img, $_GET['search'] ); |
---|
| 383 | } |
---|
[61] | 384 | } |
---|
[1046] | 385 | $title_nb = ($page['current_rank'] + 1).'/'.$page['cat_nb_images']; |
---|
[2] | 386 | |
---|
[41] | 387 | // calculation of width and height |
---|
[484] | 388 | if (empty($picture['current']['width'])) |
---|
[2] | 389 | { |
---|
[1090] | 390 | $taille_image = @getimagesize($picture['current']['src_file_system']); |
---|
[2] | 391 | $original_width = $taille_image[0]; |
---|
| 392 | $original_height = $taille_image[1]; |
---|
| 393 | } |
---|
| 394 | else |
---|
| 395 | { |
---|
[368] | 396 | $original_width = $picture['current']['width']; |
---|
| 397 | $original_height = $picture['current']['height']; |
---|
[2] | 398 | } |
---|
| 399 | |
---|
[1082] | 400 | $picture_size = get_picture_size( |
---|
| 401 | $original_width, |
---|
| 402 | $original_height, |
---|
| 403 | @$user['maxwidth'], |
---|
| 404 | @$user['maxheight'] |
---|
| 405 | ); |
---|
[531] | 406 | |
---|
| 407 | // metadata |
---|
[1092] | 408 | $url_metadata = duplicate_picture_URL(); |
---|
[531] | 409 | if ($conf['show_exif'] or $conf['show_iptc']) |
---|
| 410 | { |
---|
| 411 | $metadata_showable = true; |
---|
[1092] | 412 | if ( !isset($_GET['metadata']) ) |
---|
| 413 | { |
---|
[1094] | 414 | $url_metadata = add_url_params( $url_metadata, array('metadata'=>null) ); |
---|
[1092] | 415 | } |
---|
[531] | 416 | } |
---|
| 417 | else |
---|
| 418 | { |
---|
| 419 | $metadata_showable = false; |
---|
| 420 | } |
---|
| 421 | |
---|
[850] | 422 | $page['body_id'] = 'thePicturePage'; |
---|
[1036] | 423 | //------------------------------------------------------- navigation management |
---|
[1086] | 424 | foreach ( array('first','previous','next','last') as $which_image ) |
---|
[1020] | 425 | { |
---|
[1086] | 426 | if (isset($picture[$which_image])) |
---|
| 427 | { |
---|
| 428 | $template->assign_block_vars( |
---|
| 429 | $which_image, |
---|
| 430 | array( |
---|
| 431 | 'TITLE_IMG' => $picture[$which_image]['name'], |
---|
| 432 | 'IMG' => $picture[$which_image]['thumbnail'], |
---|
| 433 | 'U_IMG' => $picture[$which_image]['url'], |
---|
| 434 | 'U_IMG_SRC' => $picture[$which_image]['src'] |
---|
| 435 | ) |
---|
| 436 | ); |
---|
| 437 | } |
---|
[1020] | 438 | } |
---|
| 439 | |
---|
[369] | 440 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
---|
[368] | 441 | $template->set_filenames(array('picture'=>'picture.tpl')); |
---|
| 442 | |
---|
[1082] | 443 | $template->assign_vars( |
---|
| 444 | array( |
---|
| 445 | 'CATEGORY' => $title_img, |
---|
| 446 | 'PHOTO' => $title_nb, |
---|
| 447 | 'TITLE' => $picture['current']['name'], |
---|
| 448 | 'SRC_IMG' => $picture['current']['src'], |
---|
| 449 | 'ALT_IMG' => $picture['current']['file'], |
---|
| 450 | 'WIDTH_IMG' => $picture_size[0], |
---|
| 451 | 'HEIGHT_IMG' => $picture_size[1], |
---|
[368] | 452 | |
---|
[1082] | 453 | 'LEVEL_SEPARATOR' => $conf['level_separator'], |
---|
[642] | 454 | |
---|
[1082] | 455 | 'L_HOME' => $lang['home'], |
---|
| 456 | 'L_SLIDESHOW' => $lang['slideshow'], |
---|
| 457 | 'L_STOP_SLIDESHOW' => $lang['slideshow_stop'], |
---|
| 458 | 'L_PREV_IMG' =>$lang['previous_page'].' : ', |
---|
| 459 | 'L_NEXT_IMG' =>$lang['next_page'].' : ', |
---|
| 460 | 'L_ADMIN' =>$lang['link_info_image'], |
---|
| 461 | 'L_COMMENT_TITLE' =>$lang['comments_title'], |
---|
| 462 | 'L_ADD_COMMENT' =>$lang['comments_add'], |
---|
| 463 | 'L_DELETE_COMMENT' =>$lang['comments_del'], |
---|
| 464 | 'L_DELETE' =>$lang['delete'], |
---|
| 465 | 'L_SUBMIT' =>$lang['submit'], |
---|
| 466 | 'L_AUTHOR' => $lang['upload_author'], |
---|
| 467 | 'L_COMMENT' =>$lang['comment'], |
---|
| 468 | 'L_DOWNLOAD' => $lang['download'], |
---|
| 469 | 'L_DOWNLOAD_HINT' => $lang['download_hint'], |
---|
| 470 | 'L_PICTURE_METADATA' => $lang['picture_show_metadata'], |
---|
| 471 | 'L_PICTURE_HIGH' => $lang['picture_high'], |
---|
| 472 | 'L_UP_HINT' => $lang['home_hint'], |
---|
| 473 | 'L_UP_ALT' => $lang['home'], |
---|
[1059] | 474 | |
---|
[1082] | 475 | 'U_HOME' => make_index_URL(), |
---|
| 476 | 'U_UP' => $url_up, |
---|
| 477 | 'U_METADATA' => $url_metadata, |
---|
| 478 | 'U_ADMIN' => $url_admin, |
---|
| 479 | 'U_SLIDESHOW'=> $url_slide, |
---|
| 480 | 'U_ADD_COMMENT' => $url_self, |
---|
| 481 | ) |
---|
| 482 | ); |
---|
[803] | 483 | |
---|
| 484 | if ($conf['show_picture_name_on_title']) |
---|
| 485 | { |
---|
| 486 | $template->assign_block_vars('title', array()); |
---|
| 487 | } |
---|
| 488 | |
---|
[536] | 489 | //------------------------------------------------------- upper menu management |
---|
[1082] | 490 | |
---|
[531] | 491 | // download link if file is not a picture |
---|
| 492 | if (!$picture['current']['is_picture']) |
---|
[2] | 493 | { |
---|
[536] | 494 | $template->assign_block_vars( |
---|
| 495 | 'download', |
---|
[1082] | 496 | array( |
---|
| 497 | 'U_DOWNLOAD' => $picture['current']['download'] |
---|
| 498 | ) |
---|
| 499 | ); |
---|
[2] | 500 | } |
---|
[1082] | 501 | |
---|
[536] | 502 | // display a high quality link if present |
---|
| 503 | if (isset($picture['current']['high'])) |
---|
| 504 | { |
---|
[539] | 505 | $uuid = uniqid(rand()); |
---|
[1086] | 506 | |
---|
[985] | 507 | $template->assign_block_vars( |
---|
[1082] | 508 | 'high', |
---|
| 509 | array( |
---|
| 510 | 'U_HIGH' => $picture['current']['high'], |
---|
| 511 | 'UUID' => $uuid, |
---|
| 512 | ) |
---|
| 513 | ); |
---|
[1086] | 514 | |
---|
[1082] | 515 | $template->assign_block_vars( |
---|
[985] | 516 | 'download', |
---|
[1082] | 517 | array( |
---|
[1090] | 518 | 'U_DOWNLOAD' => get_root_url().'action.php?dwn=' |
---|
| 519 | .$picture['current']['high_file_system'] |
---|
[1082] | 520 | ) |
---|
| 521 | ); |
---|
[536] | 522 | } |
---|
[1082] | 523 | |
---|
[811] | 524 | // button to set the current picture as representative |
---|
[1082] | 525 | if (is_admin() and isset($page['category'])) |
---|
[811] | 526 | { |
---|
| 527 | $template->assign_block_vars( |
---|
| 528 | 'representative', |
---|
| 529 | array( |
---|
[1094] | 530 | 'URL' => add_url_params($url_self, |
---|
| 531 | array('action'=>'set_as_representative') |
---|
| 532 | ) |
---|
[811] | 533 | ) |
---|
| 534 | ); |
---|
| 535 | } |
---|
[858] | 536 | |
---|
[1082] | 537 | // caddie button |
---|
[1070] | 538 | if (is_admin()) |
---|
[858] | 539 | { |
---|
| 540 | $template->assign_block_vars( |
---|
| 541 | 'caddie', |
---|
| 542 | array( |
---|
[1094] | 543 | 'URL' => add_url_params($url_self, |
---|
| 544 | array('action'=>'add_to_caddie') |
---|
| 545 | ) |
---|
[1082] | 546 | ) |
---|
[858] | 547 | ); |
---|
| 548 | } |
---|
| 549 | |
---|
[1082] | 550 | // favorite manipulation |
---|
| 551 | if (!$user['is_the_guest']) |
---|
[531] | 552 | { |
---|
| 553 | // verify if the picture is already in the favorite of the user |
---|
[1082] | 554 | $query = ' |
---|
| 555 | SELECT COUNT(*) AS nb_fav |
---|
| 556 | FROM '.FAVORITES_TABLE.' |
---|
| 557 | WHERE image_id = '.$page['image_id'].' |
---|
| 558 | AND user_id = '.$user['id'].' |
---|
| 559 | ;'; |
---|
| 560 | $result = pwg_query($query); |
---|
| 561 | $row = mysql_fetch_array($result); |
---|
[1086] | 562 | |
---|
[1082] | 563 | if ($row['nb_fav'] == 0) |
---|
[2] | 564 | { |
---|
[531] | 565 | $template->assign_block_vars( |
---|
| 566 | 'favorite', |
---|
| 567 | array( |
---|
[1090] | 568 | 'FAVORITE_IMG' => get_root_url().get_themeconf('icon_dir').'/favorite.png', |
---|
[1082] | 569 | 'FAVORITE_HINT' => $lang['add_favorites_hint'], |
---|
| 570 | 'FAVORITE_ALT' => $lang['add_favorites_alt'], |
---|
[1094] | 571 | 'U_FAVORITE' => add_url_params( |
---|
| 572 | $url_self, |
---|
| 573 | array('action'=>'add_to_favorites') |
---|
| 574 | ), |
---|
[1082] | 575 | ) |
---|
| 576 | ); |
---|
[2] | 577 | } |
---|
[531] | 578 | else |
---|
| 579 | { |
---|
| 580 | $template->assign_block_vars( |
---|
| 581 | 'favorite', |
---|
| 582 | array( |
---|
[1090] | 583 | 'FAVORITE_IMG' => get_root_url().get_themeconf('icon_dir').'/del_favorite.png', |
---|
[1082] | 584 | 'FAVORITE_HINT' => $lang['del_favorites_hint'], |
---|
| 585 | 'FAVORITE_ALT' => $lang['del_favorites_alt'], |
---|
[1094] | 586 | 'U_FAVORITE' => add_url_params( |
---|
| 587 | $url_self, |
---|
| 588 | array('action'=>'remove_from_favorites') |
---|
| 589 | ) |
---|
[1082] | 590 | ) |
---|
| 591 | ); |
---|
[531] | 592 | } |
---|
[2] | 593 | } |
---|
[531] | 594 | //------------------------------------ admin link for information modifications |
---|
[1070] | 595 | if ( is_admin() ) |
---|
[531] | 596 | { |
---|
| 597 | $template->assign_block_vars('admin', array()); |
---|
| 598 | } |
---|
[368] | 599 | |
---|
[2] | 600 | //--------------------------------------------------------- picture information |
---|
[393] | 601 | // legend |
---|
[465] | 602 | if (isset($picture['current']['comment']) |
---|
| 603 | and !empty($picture['current']['comment'])) |
---|
[393] | 604 | { |
---|
[465] | 605 | $template->assign_block_vars( |
---|
| 606 | 'legend', |
---|
| 607 | array( |
---|
[745] | 608 | 'COMMENT_IMG' => nl2br($picture['current']['comment']) |
---|
[465] | 609 | )); |
---|
[393] | 610 | } |
---|
| 611 | |
---|
[847] | 612 | $infos = array(); |
---|
| 613 | |
---|
| 614 | // author |
---|
| 615 | if (!empty($picture['current']['author'])) |
---|
[51] | 616 | { |
---|
[847] | 617 | $infos['INFO_AUTHOR'] = |
---|
[1008] | 618 | // FIXME because of search engine partial rewrite, giving the author |
---|
| 619 | // name threw GET is not supported anymore. This feature should come |
---|
| 620 | // back later, with a better design |
---|
| 621 | // '<a href="'. |
---|
| 622 | // PHPWG_ROOT_PATH.'category.php?cat=search'. |
---|
| 623 | // '&search=author:'.$picture['current']['author'] |
---|
| 624 | // .'">'.$picture['current']['author'].'</a>'; |
---|
| 625 | $picture['current']['author']; |
---|
[51] | 626 | } |
---|
[847] | 627 | else |
---|
| 628 | { |
---|
| 629 | $infos['INFO_AUTHOR'] = l10n('N/A'); |
---|
| 630 | } |
---|
[774] | 631 | |
---|
[847] | 632 | // creation date |
---|
| 633 | if (!empty($picture['current']['date_creation'])) |
---|
[635] | 634 | { |
---|
[1051] | 635 | $val = format_date($picture['current']['date_creation']); |
---|
[1086] | 636 | $url = make_index_URL( |
---|
[1090] | 637 | array( |
---|
| 638 | 'chronology_field'=>'created', |
---|
| 639 | 'chronology_style'=>'monthly', |
---|
| 640 | 'chronology_view'=>'list', |
---|
| 641 | 'chronology_date' => explode('-', $picture['current']['date_creation']) |
---|
| 642 | ) |
---|
| 643 | ); |
---|
[1086] | 644 | $infos['INFO_CREATION_DATE'] = '<a href="'.$url.'">'.$val.'</a>'; |
---|
[847] | 645 | } |
---|
| 646 | else |
---|
| 647 | { |
---|
| 648 | $infos['INFO_CREATION_DATE'] = l10n('N/A'); |
---|
| 649 | } |
---|
| 650 | |
---|
| 651 | // date of availability |
---|
[1051] | 652 | $val = format_date($picture['current']['date_available'], 'mysql_datetime'); |
---|
[1086] | 653 | $url = make_index_URL( |
---|
[1090] | 654 | array( |
---|
| 655 | 'chronology_field'=>'posted', |
---|
| 656 | 'chronology_style'=>'monthly', |
---|
| 657 | 'chronology_view'=>'list', |
---|
| 658 | 'chronology_date'=>explode('-', substr($picture['current']['date_available'],0,10)) |
---|
| 659 | ) |
---|
| 660 | ); |
---|
[1086] | 661 | $infos['INFO_POSTED_DATE'] = '<a href="'.$url.'">'.$val.'</a>'; |
---|
[847] | 662 | |
---|
| 663 | // size in pixels |
---|
| 664 | if ($picture['current']['is_picture']) |
---|
| 665 | { |
---|
| 666 | if ($original_width != $picture_size[0] |
---|
| 667 | or $original_height != $picture_size[1]) |
---|
[568] | 668 | { |
---|
[847] | 669 | $infos['INFO_DIMENSIONS'] = |
---|
| 670 | '<a href="'.$picture['current']['src'].'" title="'. |
---|
| 671 | l10n('Original dimensions').'">'. |
---|
| 672 | $original_width.'*'.$original_height.'</a>'; |
---|
[568] | 673 | } |
---|
[635] | 674 | else |
---|
| 675 | { |
---|
[847] | 676 | $infos['INFO_DIMENSIONS'] = $original_width.'*'.$original_height; |
---|
[635] | 677 | } |
---|
[568] | 678 | } |
---|
[847] | 679 | else |
---|
| 680 | { |
---|
| 681 | $infos['INFO_DIMENSIONS'] = l10n('N/A'); |
---|
| 682 | } |
---|
[774] | 683 | |
---|
[847] | 684 | // filesize |
---|
| 685 | if (!empty($picture['current']['filesize'])) |
---|
| 686 | { |
---|
| 687 | $infos['INFO_FILESIZE'] = |
---|
| 688 | sprintf(l10n('%d Kb'), $picture['current']['filesize']); |
---|
| 689 | } |
---|
| 690 | else |
---|
| 691 | { |
---|
| 692 | $infos['INFO_FILESIZE'] = l10n('N/A'); |
---|
| 693 | } |
---|
| 694 | |
---|
| 695 | // number of visits |
---|
| 696 | $infos['INFO_VISITS'] = $picture['current']['hit']; |
---|
| 697 | |
---|
| 698 | // file |
---|
| 699 | $infos['INFO_FILE'] = $picture['current']['file']; |
---|
| 700 | |
---|
| 701 | // keywords |
---|
| 702 | if (!empty($picture['current']['keywords'])) |
---|
| 703 | { |
---|
| 704 | $infos['INFO_KEYWORDS'] = |
---|
[1008] | 705 | // FIXME because of search engine partial rewrite, giving the author |
---|
| 706 | // name threw GET is not supported anymore. This feature should come |
---|
| 707 | // back later, with a better design (tag classification). |
---|
| 708 | // preg_replace( |
---|
| 709 | // '/([^,]+)/', |
---|
| 710 | // '<a href="'. |
---|
| 711 | // PHPWG_ROOT_PATH.'category.php?cat=search&search=keywords:$1' |
---|
| 712 | // .'">$1</a>', |
---|
| 713 | // $picture['current']['keywords'] |
---|
| 714 | // ); |
---|
| 715 | $picture['current']['keywords']; |
---|
[847] | 716 | } |
---|
| 717 | else |
---|
| 718 | { |
---|
| 719 | $infos['INFO_KEYWORDS'] = l10n('N/A'); |
---|
| 720 | } |
---|
| 721 | |
---|
| 722 | $template->assign_vars($infos); |
---|
| 723 | |
---|
| 724 | // related categories |
---|
| 725 | foreach ($related_categories as $category) |
---|
| 726 | { |
---|
| 727 | $template->assign_block_vars( |
---|
| 728 | 'category', |
---|
| 729 | array( |
---|
| 730 | 'LINE' => count($related_categories) > 3 |
---|
| 731 | ? get_cat_display_name_cache($category['uppercats']) |
---|
| 732 | : get_cat_display_name_from_id($category['category_id']) |
---|
| 733 | ) |
---|
| 734 | ); |
---|
| 735 | } |
---|
| 736 | |
---|
[531] | 737 | //slideshow end |
---|
[1082] | 738 | if (isset($_GET['slideshow'])) |
---|
[531] | 739 | { |
---|
[1082] | 740 | if (!is_numeric($_GET['slideshow'])) |
---|
[774] | 741 | { |
---|
[1082] | 742 | $_GET['slideshow'] = $conf['slideshow_period']; |
---|
[774] | 743 | } |
---|
[847] | 744 | |
---|
[1082] | 745 | $template->assign_block_vars( |
---|
| 746 | 'stop_slideshow', |
---|
| 747 | array( |
---|
| 748 | 'U_SLIDESHOW' => $picture['current']['url'], |
---|
| 749 | ) |
---|
| 750 | ); |
---|
[507] | 751 | } |
---|
[774] | 752 | |
---|
[1082] | 753 | // +-----------------------------------------------------------------------+ |
---|
| 754 | // | sub pages | |
---|
| 755 | // +-----------------------------------------------------------------------+ |
---|
[847] | 756 | |
---|
[1082] | 757 | include(PHPWG_ROOT_PATH.'include/picture_rate.inc.php'); |
---|
| 758 | include(PHPWG_ROOT_PATH.'include/picture_comment.inc.php'); |
---|
[1107] | 759 | if ($metadata_showable and isset($_GET['metadata'])) |
---|
| 760 | { |
---|
| 761 | include(PHPWG_ROOT_PATH.'include/picture_metadata.inc.php'); |
---|
| 762 | } |
---|
[2] | 763 | //------------------------------------------------------------ log informations |
---|
[368] | 764 | pwg_log( 'picture', $title_img, $picture['current']['file'] ); |
---|
[345] | 765 | |
---|
[688] | 766 | $template->parse('picture'); |
---|
[369] | 767 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
[362] | 768 | ?> |
---|