function MG_adminEXIF() { global $_TABLES, $_MG_CONF, $_CONF, $LANG_MG01, $LANG_MG04; $retval = ''; $T = new Template($_MG_CONF['template_path'] . '/admin/'); $T->set_file('admin', 'exif_tags.thtml'); $T->set_var('site_url', $_CONF['site_url']); $T->set_var('site_admin_url', $_CONF['site_admin_url']); $T->set_block('admin', 'exifRow', 'eRow'); $sql = "SELECT * FROM {$_TABLES['mg_exif_tags']}"; $result = DB_query($sql); $nRows = DB_numRows($result); for ($i = 0; $i < $nRows; $i++) { $row = DB_fetchArray($result); $properties[] = $row['name']; $tag[$row['name']][] = $row['selected']; } $exifKeys = getExifKeys(); $x = 0; foreach ($properties as $property) { $title = $exifKeys[$property][0]; $T->set_var(array('exif_tag' => $title, 'selected' => $tag[$property][0] ? ' checked="checked"' : '', 'tag' => $property, 'rowcounter' => $x % 2)); $T->parse('eRow', 'exifRow', true); $x++; } $T->set_var(array('lang_select' => $LANG_MG01['select'], 'lang_exiftag' => $LANG_MG01['exiftag'], 'lang_exif_admin_help' => $LANG_MG01['exif_admin_help'], 'lang_check_all' => $LANG_MG01['check_all'], 'lang_uncheck_all' => $LANG_MG01['uncheck_all'], 'lang_save' => $LANG_MG01['save'], 'lang_cancel' => $LANG_MG01['cancel'], 's_form_action' => $_MG_CONF['admin_url'] . 'exif_admin.php')); $T->parse('output', 'admin'); $retval .= $T->finish($T->get_var('output')); return $retval; }
/** * Read EXIF/IPTC data of a file * * Pulls the metadata from an item * * @param string $file filename to read metadata from * @return array The EXIF/IPTC items for this file * * This code from here to the end of this file was borrowed from * the Gallery v2 EXIF module written by: * Bharat Mediratta <*****@*****.**> * Georg Rehfeld <*****@*****.**> * */ function ExifProcessor($file) { $rawExifData = array(); $iptc = new JPEG($file); $rawExifData = read_exif_data_raw($file, false); $exifKeys = getExifKeys(); // builds an array of the EXIF data we care about... $properties = getProperties(); $results = array(); $pCount = count($properties); if ($pCount > 0) { foreach ($properties as $property) { $title = $exifKeys[$property][0]; for ($i = 1; $i < sizeof($exifKeys[$property]); $i++) { $value = getExifValue($rawExifData, explode('.', $exifKeys[$property][$i])); if (!isset($value)) { $value = getIptcValue($iptc, explode('.', $exifKeys[$property][$i])); } if (isset($value)) { $value = postProcessValue($property, $value); $results[] = array('title' => $title, 'value' => $value); break; } } } } return $results; }