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