diff -up exif.old\exif.info exif\exif.info --- exif.old\exif.info Tue Feb 26 22:37:26 2008 +++ exif\exif.info Tue Feb 26 10:53:06 2008 @@ -1,14 +1,6 @@ -; $Id: exif.info,v 1.1.2.3 2007/06/18 23:06:42 dww Exp $ +; $Id$ name = Exif description = "Display Exif metadata on image nodes." dependencies[] = image package = Image core = 6.x - -; Information added by drupal.org packaging script on 2007-08-13 -version = "5.x-1.1" -project = "exif" -datestamp = "1187020805" - - - diff -up exif.old\exif.install exif\exif.install --- exif.old\exif.install Tue Feb 26 22:36:00 2008 +++ exif\exif.install Tue Feb 26 11:17:56 2008 @@ -1,5 +1,5 @@ type != 'image') { - return; - } - - switch ($op) { +function exif_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { + switch($op) { case 'view': - // Access the file's EXIF data. Simply break when no EXIF data is found. - $file = file_create_path($node->images['_original']); - if (!file_exists($file)) { - watchdog('exif', t('Image %file not found.', array('%file' => $file)), WATCHDOG_WARNING); - break; - } - if (exif_imagetype($file) != IMAGETYPE_JPEG) break; - $jpeg = new PelJpeg($file); - $exif = $jpeg->getExif(); - if (!$exif) break; - $tiff = $exif->getTiff(); - if (!$tiff) break; - $ifd0 = $tiff->getIfd(); - if (!$ifd0) break; - $ifds[PelIfd::IFD0] = $ifd0; - if ($exif = $ifd0->getSubIfd(PelIfd::EXIF)) { - $ifds[PelIfd::EXIF] = $exif; - } - if ($gps = $ifd0->getSubIfd(PelIfd::GPS)) { - $ifds[PelIfd::GPS] = $gps; - } - - // Retrieve the desired tag values from the file - $tags = exif_get_enabled_tags(); - $rows = array(); - foreach ($tags as $tag) { - if (isset($ifds[$tag->ifd])) { - $entry = $ifds[$tag->ifd]->getEntry($tag->tag); - if ($entry) { - $row = array(); - $row[] = array('data' => utf8_encode(PelTag::getTitle($tag->ifd, $tag->tag)), 'class' => 'exif-title'); - switch($tag->tag) { - case PelTag::DATE_TIME: - case PelTag::DATE_TIME_ORIGINAL: - case PelTag::DATE_TIME_DIGITIZED: - // Use Drupal's date formatting instead of Pel's - $row[] = array('data' => format_date($entry->getValue(), 'medium', '', 0), 'class' => 'exif-value'); - break; - - default: - $row[] = array('data' => utf8_encode($entry->getText()), 'class' => 'exif-value'); - } - $rows[] = $row; - } - } - } - if ($rows) { - $header = array(array('data' => t('Image information'), 'colspan' => 2)); + if ($page && !$teaser && $node->type == 'image') { $node->content['exif'] = array( - '#value' => theme('exif_table', $header, $rows), - '#weight' => 10, + '#value' => '
'.drupal_get_form('exif_form',$node).'
', + '#weight' => 5, ); } break; + default: + break; + } +} + +function exif_init() { + drupal_add_css(drupal_get_path('module', 'exif') .'/exif.css'); +} + +function exif_form(&$form_state, $node = NULL) { + $form = array(); + $form['button'] = array( + '#type' => 'button', + '#button_type' => 'button', + '#value' => 'Show EXIF', + '#attributes' => array('class' => 'exif'), + '#ahah' => array( + 'effect' => 'fade', + 'path' => 'exif/'.$node->nid, + 'wrapper' => 'exif', + 'method' => 'replace', + 'progress' => array( + 'type' => 'throbber', + 'message' => 'Loading EXIF data, please wait...' + ) + ), + ); + return $form; +} + +function exif_callback($node) { + // Access the file's EXIF data. Simply break when no EXIF data is found. + $file = file_create_path($node->images['_original']); + if (!file_exists($file)) { + watchdog('exif', t('Image %file not found.', array('%file' => $file)), WATCHDOG_WARNING); + break; + } + if (exif_imagetype($file) != IMAGETYPE_JPEG) break; + $jpeg = new PelJpeg($file); + $exif = $jpeg->getExif(); + if (!$exif) break; + $tiff = $exif->getTiff(); + if (!$tiff) break; + $ifd0 = $tiff->getIfd(); + if (!$ifd0) break; + $ifds[PelIfd::IFD0] = $ifd0; + if ($exif = $ifd0->getSubIfd(PelIfd::EXIF)) { + $ifds[PelIfd::EXIF] = $exif; + } + if ($gps = $ifd0->getSubIfd(PelIfd::GPS)) { + $ifds[PelIfd::GPS] = $gps; + } + // Retrieve the desired tag values from the file + $tags = exif_get_enabled_tags(); + $rows = array(); + foreach ($tags as $tag) { + if (isset($ifds[$tag->ifd])) { + $entry = $ifds[$tag->ifd]->getEntry($tag->tag); + if ($entry) { + $row = array(); + $row[] = array('data' => utf8_encode(PelTag::getTitle($tag->ifd, $tag->tag)), 'class' => 'exif-title'); + switch($tag->tag) { + case PelTag::DATE_TIME: + case PelTag::DATE_TIME_ORIGINAL: + case PelTag::DATE_TIME_DIGITIZED: + // Use Drupal's date formatting instead of Pel's + $row[] = array('data' => format_date($entry->getValue(), 'medium', '', 0), 'class' => 'exif-value'); + break; + + default: + $row[] = array('data' => utf8_encode($entry->getText()), 'class' => 'exif-value'); + } + $rows[] = $row; + } + } + } + if ($rows) { + $header = array(array('data' => t('Image information'), 'colspan' => 2)); + $result = theme('exif_table', $header, $rows, array('class' => 'exif')); } + print(drupal_to_js($result)); } /** Common subdirectories: exif.old\po and exif\po