source: branches/2.3/include/picture_metadata.inc.php @ 28890

Last change on this file since 28890 was 12131, checked in by ddtddt, 13 years ago

[trunk] - language - add key - feature:2428

  • Property svn:eol-style set to LF
File size: 3.9 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2011 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/**
25 * This file is included by the picture page to manage picture metadata
26 *
27 */
28
29// $picture['current']['high_url'] may not be set if the user has no access
30// to the high definition, but we may want to display metadata and read the
31// high definition is available
32$high_url = null;
33if (isset($picture['current']['high_url']))
34{
35  $high_url = $picture['current']['high_url'];
36}
37else
38{
39  $high_url = get_high_url($picture['current']);
40}
41
42include_once(PHPWG_ROOT_PATH.'/include/functions_metadata.inc.php');
43if (($conf['show_exif']) and (function_exists('read_exif_data')))
44{
45  $exif_mapping = array();
46  foreach ($conf['show_exif_fields'] as $field)
47  {
48    $exif_mapping[$field] = $field;
49  }
50
51  $exif = get_exif_data($picture['current']['image_path'], $exif_mapping);
52  if (count($exif) == 0 and $picture['current']['has_high'])
53  {
54    $exif = get_exif_data($high_url, $exif_mapping);
55  }
56 
57  if (count($exif) > 0)
58  {
59    $tpl_meta = array(
60        'TITLE' => l10n('EXIF Metadata'),
61        'lines' => array(),
62      );
63
64    foreach ($conf['show_exif_fields'] as $field)
65    {
66      if (strpos($field, ';') === false)
67      {
68        if (isset($exif[$field]))
69        {
70          $key = $field;
71          if (isset($lang['exif_field_'.$field]))
72          {
73            $key = $lang['exif_field_'.$field];
74          }
75          $tpl_meta['lines'][$key] = $exif[$field];
76        }
77      }
78      else
79      {
80        $tokens = explode(';', $field);
81        if (isset($exif[$field]))
82        {
83          $key = $tokens[1];
84          if (isset($lang['exif_field_'.$key]))
85          {
86            $key = $lang['exif_field_'.$key];
87          }
88          $tpl_meta['lines'][$key] = $exif[$field];
89        }
90      }
91    }
92    $template->append('metadata', $tpl_meta);
93  }
94}
95
96if ($conf['show_iptc'])
97{
98  $iptc = get_iptc_data($picture['current']['image_path'], $conf['show_iptc_mapping']);
99  if (count($iptc) == 0 and $picture['current']['has_high'])
100  {
101    $iptc = get_iptc_data($high_url, $conf['show_iptc_mapping']);
102  }
103
104  if (count($iptc) > 0)
105  {
106    $tpl_meta = array(
107        'TITLE' => l10n('IPTC Metadata'),
108        'lines' => array(),
109      );
110
111    foreach ($iptc as $field => $value)
112    {
113      $key = $field;
114      if (isset($lang[$field]))
115      {
116        $key = $lang[$field];
117      }
118      $tpl_meta['lines'][$key] = $value;
119    }
120    $template->append('metadata', $tpl_meta);
121  }
122}
123
124
125?>
Note: See TracBrowser for help on using the repository browser.