[1082] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 3 | // | Piwigo - a PHP based photo gallery | |
---|
[2297] | 4 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 5 | // | Copyright(C) 2008-2011 Piwigo Team http://piwigo.org | |
---|
[2297] | 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 | // +-----------------------------------------------------------------------+ |
---|
[1082] | 23 | |
---|
| 24 | /** |
---|
| 25 | * This file is included by the picture page to manage picture metadata |
---|
[1092] | 26 | * |
---|
[1082] | 27 | */ |
---|
| 28 | |
---|
[8631] | 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; |
---|
| 33 | if (isset($picture['current']['high_url'])) |
---|
| 34 | { |
---|
| 35 | $high_url = $picture['current']['high_url']; |
---|
| 36 | } |
---|
| 37 | else |
---|
| 38 | { |
---|
| 39 | $high_url = get_high_url($picture['current']); |
---|
| 40 | } |
---|
| 41 | |
---|
[1126] | 42 | include_once(PHPWG_ROOT_PATH.'/include/functions_metadata.inc.php'); |
---|
[1682] | 43 | if (($conf['show_exif']) and (function_exists('read_exif_data'))) |
---|
[1082] | 44 | { |
---|
[6484] | 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); |
---|
[6093] | 52 | if (count($exif) == 0 and $picture['current']['has_high']) |
---|
| 53 | { |
---|
[8631] | 54 | $exif = get_exif_data($high_url, $exif_mapping); |
---|
[6093] | 55 | } |
---|
[6484] | 56 | |
---|
[6093] | 57 | if (count($exif) > 0) |
---|
| 58 | { |
---|
[2227] | 59 | $tpl_meta = array( |
---|
[12131] | 60 | 'TITLE' => l10n('EXIF Metadata'), |
---|
[2227] | 61 | 'lines' => array(), |
---|
[1126] | 62 | ); |
---|
| 63 | |
---|
| 64 | foreach ($conf['show_exif_fields'] as $field) |
---|
[1082] | 65 | { |
---|
[1126] | 66 | if (strpos($field, ';') === false) |
---|
[1082] | 67 | { |
---|
[1126] | 68 | if (isset($exif[$field])) |
---|
[1082] | 69 | { |
---|
[1126] | 70 | $key = $field; |
---|
| 71 | if (isset($lang['exif_field_'.$field])) |
---|
[1082] | 72 | { |
---|
[1126] | 73 | $key = $lang['exif_field_'.$field]; |
---|
| 74 | } |
---|
[2227] | 75 | $tpl_meta['lines'][$key] = $exif[$field]; |
---|
[1082] | 76 | } |
---|
[1126] | 77 | } |
---|
| 78 | else |
---|
| 79 | { |
---|
| 80 | $tokens = explode(';', $field); |
---|
[6484] | 81 | if (isset($exif[$field])) |
---|
[1082] | 82 | { |
---|
[1126] | 83 | $key = $tokens[1]; |
---|
[6484] | 84 | if (isset($lang['exif_field_'.$key])) |
---|
[1082] | 85 | { |
---|
[6484] | 86 | $key = $lang['exif_field_'.$key]; |
---|
[1126] | 87 | } |
---|
[6484] | 88 | $tpl_meta['lines'][$key] = $exif[$field]; |
---|
[1082] | 89 | } |
---|
| 90 | } |
---|
| 91 | } |
---|
[2227] | 92 | $template->append('metadata', $tpl_meta); |
---|
[1082] | 93 | } |
---|
[1126] | 94 | } |
---|
[2227] | 95 | |
---|
[1126] | 96 | if ($conf['show_iptc']) |
---|
| 97 | { |
---|
[6093] | 98 | $iptc = get_iptc_data($picture['current']['image_path'], $conf['show_iptc_mapping']); |
---|
| 99 | if (count($iptc) == 0 and $picture['current']['has_high']) |
---|
| 100 | { |
---|
[8631] | 101 | $iptc = get_iptc_data($high_url, $conf['show_iptc_mapping']); |
---|
[6093] | 102 | } |
---|
[1126] | 103 | |
---|
| 104 | if (count($iptc) > 0) |
---|
[1082] | 105 | { |
---|
[2227] | 106 | $tpl_meta = array( |
---|
[12131] | 107 | 'TITLE' => l10n('IPTC Metadata'), |
---|
[2227] | 108 | 'lines' => array(), |
---|
[1126] | 109 | ); |
---|
[1082] | 110 | |
---|
[2227] | 111 | foreach ($iptc as $field => $value) |
---|
[1082] | 112 | { |
---|
[2227] | 113 | $key = $field; |
---|
| 114 | if (isset($lang[$field])) |
---|
| 115 | { |
---|
| 116 | $key = $lang[$field]; |
---|
| 117 | } |
---|
| 118 | $tpl_meta['lines'][$key] = $value; |
---|
[1082] | 119 | } |
---|
[2227] | 120 | $template->append('metadata', $tpl_meta); |
---|
[1082] | 121 | } |
---|
| 122 | } |
---|
| 123 | |
---|
[1126] | 124 | |
---|
[1903] | 125 | ?> |
---|