source: trunk/picture.php @ 1082

Last change on this file since 1082 was 1082, checked in by plg, 18 years ago

new: cleaner URL. Instead of category.php?cat=search&search=123&start=42,
you now have category.php?/search/123/start-42. Functions make_index_url and
make_picture_url build these new URLs. Functions duplicate_picture_url and
duplicate_index_url provide shortcuts to URL creation. The current main page
page is still category.php but this can be modified easily in make_index_url
function. In this first version, no backward compatibility. Calendar
definition in URL must be discussed with rvelices.

improvement: picture.php redesigned. First actions like "set as
representative" or "delete a comment" which all lead to a redirection. Then
the page (the big mess) and includes of new sub pages to manage specific
parts of the page (metadata, user comments, rates).

new: with the cleaner URL comes a new terminology. $pagecat doesn't
exist anymore. $pagesection is among 'categories', 'tags' (TODO),
'list', 'most_seen'... And sub parameters are set : $pagecategory if
$pagesection is "categories". See URL analyse in
include/section_init.inc.php for details.

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