source: trunk/picture.php @ 2413

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