source: trunk/picture.php @ 2309

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