source: branches/branch-1_7/picture.php @ 2698

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