source: trunk/picture.php @ 2297

Last change on this file since 2297 was 2297, checked in by plg, 16 years ago

Modification: new header on PHP files, PhpWebGallery renamed Piwigo.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 24.1 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008      Piwigo Team                  http://piwigo.org |
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// +-----------------------------------------------------------------------+
23// +-----------------------------------------------------------------------+
24// | PhpWebGallery - a PHP based picture gallery                           |
25// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
26// | Copyright (C) 2003-2008 PhpWebGallery Team - http://phpwebgallery.net |
27// +-----------------------------------------------------------------------+
28// | file          : $Id: picture.php 2297 2008-04-04 22:57:23Z plg $
29// | last update   : $Date: 2008-04-04 22:57:23 +0000 (Fri, 04 Apr 2008) $
30// | last modifier : $Author: plg $
31// | revision      : $Revision: 2297 $
32// +-----------------------------------------------------------------------+
33// | This program is free software; you can redistribute it and/or modify  |
34// | it under the terms of the GNU General Public License as published by  |
35// | the Free Software Foundation                                          |
36// |                                                                       |
37// | This program is distributed in the hope that it will be useful, but   |
38// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
39// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
40// | General Public License for more details.                              |
41// |                                                                       |
42// | You should have received a copy of the GNU General Public License     |
43// | along with this program; if not, write to the Free Software           |
44// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
45// | USA.                                                                  |
46// +-----------------------------------------------------------------------+
47
48define('PHPWG_ROOT_PATH','./');
49include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
50include(PHPWG_ROOT_PATH.'include/section_init.inc.php');
51include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
52
53// Check Access and exit when user status is not ok
54check_status(ACCESS_GUEST);
55
56// access authorization check
57if (isset($page['category']))
58{
59  check_restrictions($page['category']['id']);
60}
61
62// if this image_id doesn't correspond to this category, an error message is
63// displayed, and execution is stopped
64if (!in_array($page['image_id'], $page['items']))
65{
66  page_not_found(
67    'The requested image does not belong to this image set',
68    duplicate_index_url()
69    );
70}
71
72// add default event handler for rendering element content
73add_event_handler(
74  'render_element_content',
75  'default_picture_content',
76  EVENT_HANDLER_PRIORITY_NEUTRAL,
77  2
78  );
79// add default event handler for rendering element description
80add_event_handler('render_element_description', 'nl2br');
81
82trigger_action('loc_begin_picture');
83
84// this is the default handler that generates the display for the element
85function default_picture_content($content, $element_info)
86{
87  if ( !empty($content) )
88  {// someone hooked us - so we skip;
89    return $content;
90  }
91  if (!isset($element_info['image_url']))
92  { // nothing to do
93    return $content;
94  }
95
96  global $user, $page, $template;
97
98  $template->set_filenames(
99    array('default_content'=>'picture_content.tpl')
100    );
101
102  if ( !$page['slideshow'] and isset($element_info['high_url']) )
103  {
104    $uuid = uniqid(rand());
105    $template->assign(
106      'high',
107      array(
108        'U_HIGH' => $element_info['high_url'],
109        'UUID'   => $uuid,
110        )
111      );
112  }
113  $template->assign( array(
114      'SRC_IMG' => $element_info['image_url'],
115      'ALT_IMG' => $element_info['file'],
116      'WIDTH_IMG' => @$element_info['scaled_width'],
117      'HEIGHT_IMG' => @$element_info['scaled_height'],
118      )
119    );
120  return $template->parse( 'default_content', true);
121}
122
123// +-----------------------------------------------------------------------+
124// |                            initialization                             |
125// +-----------------------------------------------------------------------+
126
127$page['rank_of'] = array_flip($page['items']);
128
129// caching first_rank, last_rank, current_rank in the displayed
130// section. This should also help in readability.
131$page['first_rank']   = 0;
132$page['last_rank']    = count($page['items']) - 1;
133$page['current_rank'] = $page['rank_of'][ $page['image_id'] ];
134
135// caching current item : readability purpose
136$page['current_item'] = $page['image_id'];
137
138if ($page['current_rank'] != $page['first_rank'])
139{
140  // caching first & previous item : readability purpose
141  $page['previous_item'] = $page['items'][ $page['current_rank'] - 1 ];
142  $page['first_item'] = $page['items'][ $page['first_rank'] ];
143}
144
145if ($page['current_rank'] != $page['last_rank'])
146{
147  // caching next & last item : readability purpose
148  $page['next_item'] = $page['items'][ $page['current_rank'] + 1 ];
149  $page['last_item'] = $page['items'][ $page['last_rank'] ];
150}
151
152$url_up = duplicate_index_url(
153  array(
154    'start' =>
155      floor($page['current_rank'] / $user['nb_image_page'])
156      * $user['nb_image_page']
157    ),
158  array(
159    'start',
160    )
161  );
162
163$url_self = duplicate_picture_url();
164
165// +-----------------------------------------------------------------------+
166// |                                actions                                |
167// +-----------------------------------------------------------------------+
168
169/**
170 * Actions are favorite adding, user comment deletion, setting the picture
171 * as representative of the current category...
172 *
173 * Actions finish by a redirection
174 */
175
176if (isset($_GET['action']))
177{
178  switch ($_GET['action'])
179  {
180    case 'add_to_favorites' :
181    {
182      $query = '
183INSERT INTO '.FAVORITES_TABLE.'
184  (image_id,user_id)
185  VALUES
186  ('.$page['image_id'].','.$user['id'].')
187;';
188      pwg_query($query);
189
190      redirect($url_self);
191
192      break;
193    }
194    case 'remove_from_favorites' :
195    {
196      $query = '
197DELETE FROM '.FAVORITES_TABLE.'
198  WHERE user_id = '.$user['id'].'
199    AND image_id = '.$page['image_id'].'
200;';
201      pwg_query($query);
202
203      if ('favorites' == $page['section'])
204      {
205        redirect($url_up);
206      }
207      else
208      {
209        redirect($url_self);
210      }
211
212      break;
213    }
214    case 'set_as_representative' :
215    {
216      if (is_admin() and !is_adviser() and isset($page['category']))
217      {
218        $query = '
219UPDATE '.CATEGORIES_TABLE.'
220  SET representative_picture_id = '.$page['image_id'].'
221  WHERE id = '.$page['category']['id'].'
222;';
223        pwg_query($query);
224      }
225
226      redirect($url_self);
227
228      break;
229    }
230    case 'toggle_metadata' :
231    {
232      break;
233    }
234    case 'add_to_caddie' :
235    {
236      fill_caddie(array($page['image_id']));
237      redirect($url_self);
238      break;
239    }
240    case 'rate' :
241    {
242      include_once(PHPWG_ROOT_PATH.'include/functions_rate.inc.php');
243      rate_picture(
244        $page['image_id'],
245        isset($_POST['rate']) ? $_POST['rate'] : $_GET['rate']
246        );
247      redirect($url_self);
248    }
249    case 'delete_comment' :
250    {
251      if (isset($_GET['comment_to_delete'])
252          and is_numeric($_GET['comment_to_delete'])
253          and is_admin() and !is_adviser() )
254      {
255        $query = '
256DELETE FROM '.COMMENTS_TABLE.'
257  WHERE id = '.$_GET['comment_to_delete'].'
258;';
259        pwg_query( $query );
260      }
261
262      redirect($url_self);
263    }
264  }
265}
266
267// incrementation of the number of hits, we do this only if no action
268if (trigger_event('allow_increment_element_hit_count', !isset($_POST['content']) ) )
269{
270  $query = '
271UPDATE
272  '.IMAGES_TABLE.'
273  SET hit = hit+1
274  WHERE id = '.$page['image_id'].'
275;';
276  pwg_query($query);
277}
278//---------------------------------------------------------- related categories
279$query = '
280SELECT category_id,uppercats,commentable,global_rank
281  FROM '.IMAGE_CATEGORY_TABLE.'
282    INNER JOIN '.CATEGORIES_TABLE.' ON category_id = id
283  WHERE image_id = '.$page['image_id'].'
284'.get_sql_condition_FandF
285  (
286    array
287      (
288        'forbidden_categories' => 'category_id',
289        'visible_categories' => 'category_id'
290      ),
291    'AND'
292  ).'
293;';
294$result = pwg_query($query);
295$related_categories = array();
296while ($row = mysql_fetch_array($result))
297{
298  array_push($related_categories, $row);
299}
300usort($related_categories, 'global_rank_compare');
301//-------------------------first, prev, current, next & last picture management
302$picture = array();
303
304$ids = array($page['image_id']);
305if (isset($page['previous_item']))
306{
307  array_push($ids, $page['previous_item']);
308  array_push($ids, $page['first_item']);
309}
310if (isset($page['next_item']))
311{
312  array_push($ids, $page['next_item']);
313  array_push($ids, $page['last_item']);
314}
315
316$query = '
317SELECT *
318  FROM '.IMAGES_TABLE.'
319  WHERE id IN ('.implode(',', $ids).')
320;';
321
322$result = pwg_query($query);
323
324while ($row = mysql_fetch_assoc($result))
325{
326  if (isset($page['previous_item']) and $row['id'] == $page['previous_item'])
327  {
328    $i = 'previous';
329  }
330  else if (isset($page['next_item']) and $row['id'] == $page['next_item'])
331  {
332    $i = 'next';
333  }
334  else if (isset($page['first_item']) and $row['id'] == $page['first_item'])
335  {
336    $i = 'first';
337  }
338  else if (isset($page['last_item']) and $row['id'] == $page['last_item'])
339  {
340    $i = 'last';
341  }
342  else
343  {
344    $i = 'current';
345  }
346
347  $picture[$i] = $row;
348
349  $picture[$i]['is_picture'] = false;
350  if (in_array(get_extension($row['file']), $conf['picture_ext']))
351  {
352    $picture[$i]['is_picture'] = true;
353  }
354
355  // ------ build element_path and element_url
356  $picture[$i]['element_path'] = get_element_path($picture[$i]);
357  $picture[$i]['element_url'] = get_element_url($picture[$i]);
358
359  // ------ build image_path and image_url
360  if ($i=='current' or $i=='next')
361  {
362    $picture[$i]['image_path'] = get_image_path( $picture[$i] );
363    $picture[$i]['image_url'] = get_image_url( $picture[$i] );
364  }
365
366  if ($i=='current')
367  {
368    if ( $picture[$i]['is_picture'] )
369    {
370      if ( $user['enabled_high']=='true' )
371      {
372        $hi_url=get_high_url($picture[$i]);
373        if ( !empty($hi_url) )
374        {
375          $picture[$i]['high_url'] = $hi_url;
376          $picture[$i]['download_url'] = get_download_url('h',$picture[$i]);
377        }
378      }
379    }
380    else
381    { // not a pic - need download link
382      $picture[$i]['download_url'] = get_download_url('e',$picture[$i]);
383    }
384  }
385
386  $picture[$i]['thumbnail'] = get_thumbnail_url($row);
387
388  if ( !empty( $row['name'] ) )
389  {
390    $picture[$i]['name'] = $row['name'];
391  }
392  else
393  {
394    $file_wo_ext = get_filename_wo_extension($row['file']);
395    $picture[$i]['name'] = str_replace('_', ' ', $file_wo_ext);
396  }
397
398  $picture[$i]['url'] = duplicate_picture_url(
399    array(
400      'image_id' => $row['id'],
401      'image_file' => $row['file'],
402      ),
403    array(
404      'start',
405      )
406    );
407
408  if ('previous'==$i and $page['previous_item']==$page['first_item'])
409  {
410    $picture['first'] = $picture[$i];
411  }
412  if ('next'==$i and $page['next_item']==$page['last_item'])
413  {
414    $picture['last'] = $picture[$i];
415  }
416}
417
418// calculation of width and height for the current picture
419if (empty($picture['current']['width']))
420{
421  $taille_image = @getimagesize($picture['current']['image_path']);
422  if ($taille_image!==false)
423  {
424    $picture['current']['width'] = $taille_image[0];
425    $picture['current']['height']= $taille_image[1];
426  }
427}
428
429if (!empty($picture['current']['width']))
430{
431  list(
432    $picture['current']['scaled_width'],
433    $picture['current']['scaled_height']
434    ) = get_picture_size(
435      $picture['current']['width'],
436      $picture['current']['height'],
437      @$user['maxwidth'],
438      @$user['maxheight']
439    );
440}
441
442$url_admin =
443  get_root_url().'admin.php?page=picture_modify'
444  .'&amp;cat_id='.(isset($page['category']) ? $page['category']['id'] : '')
445  .'&amp;image_id='.$page['image_id']
446;
447
448$slideshow_params = array();
449$slideshow_url_params = array();
450
451if (isset($_GET['slideshow']))
452{
453  $page['slideshow'] = true;
454  $page['meta_robots'] = array('noindex'=>1, 'nofollow'=>1);
455
456  $slideshow_params = decode_slideshow_params($_GET['slideshow']);
457  $slideshow_url_params['slideshow'] = encode_slideshow_params($slideshow_params);
458
459  if ($slideshow_params['play'])
460  {
461    $id_pict_redirect = '';
462    if (isset($page['next_item']))
463    {
464      $id_pict_redirect = 'next';
465    }
466    else
467    {
468      if ($slideshow_params['repeat'] and isset($page['first_item']))
469      {
470        $id_pict_redirect = 'first';
471      }
472    }
473
474    if (!empty($id_pict_redirect))
475    {
476      // $redirect_msg, $refresh, $url_link and $title are required for creating
477      // an automated refresh page in header.tpl
478      $refresh = $slideshow_params['period'];
479      $url_link = add_url_params(
480          $picture[$id_pict_redirect]['url'],
481          $slideshow_url_params
482        );
483      $redirect_msg = nl2br(l10n('redirect_msg'));
484    }
485  }
486}
487else
488{
489  $page['slideshow'] = false;
490}
491
492$template->set_filenames(
493  array(
494    'picture' =>
495      (($page['slideshow'] and $conf['light_slideshow']) ? 'slideshow.tpl' : 'picture.tpl'),
496    ));
497
498
499$title =  $picture['current']['name'];
500$title_nb = ($page['current_rank'] + 1).'/'.count($page['items']);
501
502// metadata
503$url_metadata = duplicate_picture_url();
504
505// do we have a plugin that can show metadata for something else than images?
506$metadata_showable = trigger_event(
507  'get_element_metadata_available',
508  (
509    ($conf['show_exif'] or $conf['show_iptc'])
510    and isset($picture['current']['image_path'])
511    ),
512  $picture['current']['path']
513  );
514
515if ($metadata_showable)
516{
517  if ( !isset($_GET['metadata']) )
518  {
519    $url_metadata = add_url_params( $url_metadata, array('metadata'=>null) );
520  }
521  else
522  {
523    $page['meta_robots']=array('noindex'=>1, 'nofollow'=>1);
524  }
525}
526
527$page['body_id'] = 'thePicturePage';
528
529// allow plugins to change what we computed before passing data to template
530$picture = trigger_event('picture_pictures_data', $picture);
531
532
533if (isset($picture['next']['image_url'])
534    and $picture['next']['is_picture'] )
535{
536  $template->assign('U_PREFETCH', $picture['next']['image_url'] );
537}
538
539//------------------------------------------------------- navigation management
540foreach (array('first','previous','next','last', 'current') as $which_image)
541{
542  if (isset($picture[$which_image]))
543  {
544    $template->assign(
545      $which_image,
546      array(
547        'TITLE' => $picture[$which_image]['name'],
548        'THUMB_SRC' => $picture[$which_image]['thumbnail'],
549        // Params slideshow was transmit to navigation buttons
550        'U_IMG' =>
551          add_url_params(
552            $picture[$which_image]['url'], $slideshow_url_params),
553        'U_DOWNLOAD' => @$picture['current']['download_url'],
554        )
555      );
556  }
557}
558
559
560if ($page['slideshow'])
561{
562  // Add local-slideshow.css file if exists
563  // Not only for ligth
564  $css = PHPWG_ROOT_PATH . get_themeconf('template_dir') . '/theme/'
565       . get_themeconf('theme') . '/local-slideshow.css';
566  if (file_exists($css))
567  {
568    //TODO CORRECT THIS $template->assign_block_vars('slideshow', array());
569  }
570
571  $tpl_slideshow = array();
572
573  //slideshow end
574  $template->assign(
575    array(
576      'U_SLIDESHOW_STOP' => $picture['current']['url'],
577      )
578    );
579
580  foreach (array('repeat', 'play') as $p)
581  {
582    $var_name =
583      'U_'
584      .($slideshow_params[$p] ? 'STOP_' : 'START_')
585      .strtoupper($p);
586
587    $tpl_slideshow[$var_name] =
588          add_url_params(
589            $picture['current']['url'],
590            array('slideshow' =>
591              encode_slideshow_params(
592                array_merge($slideshow_params,
593                  array($p => ! $slideshow_params[$p]))
594                )
595              )
596          );
597  }
598
599  foreach (array('dec', 'inc') as $op)
600  {
601    $new_period = $slideshow_params['period'] + ((($op == 'dec') ? -1 : 1) * $conf['slideshow_period_step']);
602    $new_slideshow_params =
603      correct_slideshow_params(
604        array_merge($slideshow_params,
605                  array('period' => $new_period)));
606
607    if ($new_slideshow_params['period'] === $new_period)
608    {
609      $var_name = 'U_'.strtoupper($op).'_PERIOD';
610      $tpl_slideshow[$var_name] =
611            add_url_params(
612              $picture['current']['url'],
613              array('slideshow' => encode_slideshow_params($new_slideshow_params)
614                  )
615          );
616    }
617  }
618  $template->assign('slideshow', $tpl_slideshow );
619}
620else
621{
622  $template->assign(
623    array(
624      'U_SLIDESHOW_START' =>
625        add_url_params(
626          $picture['current']['url'],
627          array( 'slideshow'=>''))
628      )
629    );
630}
631
632$template->assign(
633  array(
634    'SECTION_TITLE' => $page['title'],
635    'PHOTO' => $title_nb,
636    'SHOW_PICTURE_NAME_ON_TITLE' => $conf['show_picture_name_on_title'],
637
638    'LEVEL_SEPARATOR' => $conf['level_separator'],
639   
640    'FILE_PICTURE_NAV_BUTTONS' => 'picture_nav_buttons.tpl',
641
642    'U_HOME' => make_index_url(),
643    'U_UP' => $url_up,
644    'U_METADATA' => $url_metadata,
645    )
646  );
647
648
649//------------------------------------------------------- upper menu management
650
651// admin links
652if (is_admin())
653{
654  if (isset($page['category']))
655  {
656    $template->assign(
657      array(
658        'U_SET_AS_REPRESENTATIVE' => add_url_params($url_self,
659                    array('action'=>'set_as_representative')
660                 )
661        )
662      );
663  }
664 
665  $template->assign(
666    array(
667      'U_CADDIE' => add_url_params($url_self,
668                  array('action'=>'add_to_caddie')
669               ),
670      'U_ADMIN' => $url_admin,
671      )
672    );
673}
674
675// favorite manipulation
676if (!is_a_guest())
677{
678  // verify if the picture is already in the favorite of the user
679  $query = '
680SELECT COUNT(*) AS nb_fav
681  FROM '.FAVORITES_TABLE.'
682  WHERE image_id = '.$page['image_id'].'
683    AND user_id = '.$user['id'].'
684;';
685  $result = pwg_query($query);
686  $row = mysql_fetch_array($result);
687
688  if ($row['nb_fav'] == 0)
689  {
690    $template->assign(
691      'favorite',
692      array(
693        'FAVORITE_IMG'  =>
694          get_root_url().get_themeconf('icon_dir').'/favorite.png',
695        'FAVORITE_HINT' => l10n('add_favorites_hint'),
696        'U_FAVORITE'    => add_url_params(
697          $url_self,
698          array('action'=>'add_to_favorites')
699          ),
700        )
701      );
702  }
703  else
704  {
705    $template->assign(
706      'favorite',
707      array(
708        'FAVORITE_IMG'  =>
709          get_root_url().get_themeconf('icon_dir').'/del_favorite.png',
710        'FAVORITE_HINT' => l10n('del_favorites_hint'),
711        'U_FAVORITE'    => add_url_params(
712          $url_self,
713          array('action'=>'remove_from_favorites')
714          ),
715        )
716      );
717  }
718}
719
720//--------------------------------------------------------- picture information
721$header_infos = array(); //for html header use
722// legend
723if (isset($picture['current']['comment'])
724    and !empty($picture['current']['comment']))
725{
726  $template->assign(
727      'COMMENT_IMG',
728        trigger_event('render_element_description',
729          $picture['current']['comment'])
730      );
731  $header_infos['COMMENT'] = strip_tags($picture['current']['comment']);
732}
733
734$infos = array();
735
736// author
737if (!empty($picture['current']['author']))
738{
739  $infos['INFO_AUTHOR'] =
740// FIXME because of search engine partial rewrite, giving the author
741// name threw GET is not supported anymore. This feature should come
742// back later, with a better design
743//     '<a href="'.
744//       PHPWG_ROOT_PATH.'category.php?cat=search'.
745//       '&amp;search=author:'.$picture['current']['author']
746//       .'">'.$picture['current']['author'].'</a>';
747    $picture['current']['author'];
748  $header_infos['INFO_AUTHOR'] = $picture['current']['author'];
749}
750
751// creation date
752if (!empty($picture['current']['date_creation']))
753{
754  $val = format_date($picture['current']['date_creation']);
755  $url = make_index_url(
756    array(
757      'chronology_field'=>'created',
758      'chronology_style'=>'monthly',
759      'chronology_view'=>'list',
760      'chronology_date' => explode('-', $picture['current']['date_creation'])
761      )
762    );
763  $infos['INFO_CREATION_DATE'] =
764    '<a href="'.$url.'" rel="nofollow">'.$val.'</a>';
765}
766
767// date of availability
768$val = format_date($picture['current']['date_available'], 'mysql_datetime');
769$url = make_index_url(
770  array(
771    'chronology_field'=>'posted',
772    'chronology_style'=>'monthly',
773    'chronology_view'=>'list',
774    'chronology_date' => explode(
775      '-',
776      substr($picture['current']['date_available'], 0, 10)
777      )
778    )
779  );
780$infos['INFO_POSTED_DATE'] = '<a href="'.$url.'" rel="nofollow">'.$val.'</a>';
781
782// size in pixels
783if ($picture['current']['is_picture'] and isset($picture['current']['width']) )
784{
785  if ($picture['current']['scaled_width'] !== $picture['current']['width'] )
786  {
787    $infos['INFO_DIMENSIONS'] =
788      '<a href="'.$picture['current']['image_url'].'" title="'.
789      l10n('Original dimensions').'">'.
790      $picture['current']['width'].'*'.$picture['current']['height'].'</a>';
791  }
792  else
793  {
794    $infos['INFO_DIMENSIONS'] =
795      $picture['current']['width'].'*'.$picture['current']['height'];
796  }
797}
798
799// filesize
800if (!empty($picture['current']['filesize']))
801{
802  $infos['INFO_FILESIZE'] =
803    sprintf(l10n('%d Kb'), $picture['current']['filesize']);
804}
805
806// number of visits
807$infos['INFO_VISITS'] = $picture['current']['hit'];
808
809// file
810$infos['INFO_FILE'] = $picture['current']['file'];
811
812$template->assign($infos);
813
814// related tags
815$tags = get_common_tags( array($page['image_id']), -1);
816if ( count($tags) )
817{
818  foreach ($tags as $tag)
819  {
820    $template->append(
821        'related_tags',
822        array(
823          'ID'    => $tag['id'],
824          'NAME'  => $tag['name'],
825          'U_TAG' => make_index_url(
826                      array(
827                        'tags' => array($tag)
828                        )
829                      ),
830          'U_TAG_IMAGE' => duplicate_picture_url(
831                      array(
832                        'section' => 'tags',
833                        'tags' => array($tag)
834                        )
835                    )
836          )
837      );
838  }
839}
840
841// related categories
842foreach ($related_categories as $category)
843{
844  $template->append(
845    'related_categories',
846      count($related_categories) > 3
847        ? get_cat_display_name_cache($category['uppercats'])
848        : get_cat_display_name_from_id($category['category_id'])
849    );
850}
851
852// maybe someone wants a special display (call it before page_header so that
853// they can add stylesheets)
854$element_content = trigger_event(
855  'render_element_content',
856  '',
857  $picture['current']
858  );
859$template->assign( 'ELEMENT_CONTENT', $element_content );
860
861// +-----------------------------------------------------------------------+
862// |                               sub pages                               |
863// +-----------------------------------------------------------------------+
864
865include(PHPWG_ROOT_PATH.'include/picture_rate.inc.php');
866include(PHPWG_ROOT_PATH.'include/picture_comment.inc.php');
867if ($metadata_showable and isset($_GET['metadata']))
868{
869  include(PHPWG_ROOT_PATH.'include/picture_metadata.inc.php');
870}
871//------------------------------------------------------------ log informations
872pwg_log($picture['current']['id'], 'picture');
873
874include(PHPWG_ROOT_PATH.'include/page_header.php');
875trigger_action('loc_end_picture');
876$template->pparse('picture');
877include(PHPWG_ROOT_PATH.'include/page_tail.php');
878?>
Note: See TracBrowser for help on using the repository browser.