aboutsummaryrefslogtreecommitdiff
path: root/exif.module
diff options
context:
space:
mode:
authorSilvio <s1lv10@uol.com.br>2010-08-17 18:18:54 -0300
committerSilvio <s1lv10@uol.com.br>2010-08-17 18:18:54 -0300
commitc1159f9872aca3275af2a79b86692dc902726fcc (patch)
treeebce822f155bcdbabe510093868e3a1d150b0939 /exif.module
parent4bbaad3b1b0bba584ea8b817e8b21801839256de (diff)
downloadexif-c1159f9872aca3275af2a79b86692dc902726fcc.tar.gz
exif-c1159f9872aca3275af2a79b86692dc902726fcc.tar.bz2
Syncing with CVS changes
Diffstat (limited to 'exif.module')
-rwxr-xr-xexif.module157
1 files changed, 58 insertions, 99 deletions
diff --git a/exif.module b/exif.module
index 734ee92..ecbbd6e 100755
--- a/exif.module
+++ b/exif.module
@@ -1,5 +1,5 @@
<?php
-// $Id: exif.module,v 1.9.2.15 2010/04/27 20:53:13 rapsli Exp $:
+// $Id: exif.module,v 1.9.2.18 2010/07/23 17:47:46 rapsli Exp $:
/**
* @file implementing the drupal api
@@ -15,6 +15,7 @@ function exif_menu() {
'access arguments' => array('administer site configuration'),
'description' => t('Display available fields'),
'access callback' => 'user_access',
+ 'file' => 'exif.admin.inc',
'type' => MENU_NORMAL_ITEM,
);
$items['admin/settings/exif/general'] = array(
@@ -23,6 +24,7 @@ function exif_menu() {
'access arguments' => array('administer site configuration'),
'description' => t('Display available fields'),
'access callback' => 'user_access',
+ 'file' => 'exif.admin.inc',
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/settings/exif/config'] = array(
@@ -32,48 +34,13 @@ function exif_menu() {
'access arguments' => array('administer site configuration'),
'description' => t('Some Settings'),
'access callback' => 'user_access',
+ 'file' => 'exif.admin.inc',
'type' => MENU_LOCAL_TASK,
);
return $items;
}
/**
- * The form definition for the admin settings
- * @return array
- * form definition
- */
-function exif_admin_settings_form() {
- $forms = array();
- /*$forms['exif_granularity'] = array(
- '#type' => 'select',
- '#title' => t('Granularity'),
- '#options' => array(0 => t('Default'), 1 => ('Day')),
- '#default_value' => variable_get('exif_granularity', 0),
- '#description' => t('If a timestamp is select (for example the date the picture was taken), you can specify here how granular the timestamp should be. If you select default it will just take whatever is available in the picture. If you select Day, the Date saved will look something like 13-12-2008. This can be useful if you want to use some kind of grouping on the data.'),
- );*/
-
- $all_nodetypes = node_get_types();
- $all_nt = array();
- foreach ($all_nodetypes as $item) {
- $all_nt[$item->type] = $item->name;
- }
- $forms['exif_nodetypes'] = array(
- '#type' => 'checkboxes',
- '#title' => t('Nodetypes'),
- '#options' => $all_nt,
- '#default_value' => variable_get('exif_nodetypes', array()),
- '#description' => t('Select nodetypes which should be checked for exif data. Incase the nodetypes contains more than one filefield, make sure that the imagefield is the first one!!!!'),
- );
-
- $forms['exif_update'] = array(
- '#type' => 'checkbox',
- '#title' => t('Refresh on node update'),
- '#default_value' => variable_get('exif_update', TRUE),
- '#description' => t('If you enable this option, Exif data is being updated when the node is being updated.'),
- );
- return system_settings_form($forms);
-}
-/**
* implementation of hook_nodeapi
*/
function exif_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
@@ -108,7 +75,7 @@ function exif_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
$data1 = _exif_reformat($exif->readExifTags($file, $ar_exif_fields));
$data2 = $exif->readIPTCTags($file, $ar_exif_fields);
-
+
if (class_exists('SXMPFiles')) {
$data3 = $exif->readXMPTags($file, $ar_exif_fields);
$data = array_merge($data1, $data2, $data3);
@@ -124,9 +91,12 @@ function exif_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
foreach ($ar_exif_fields as $ar_exif_field) {
$exif_name = $ar_exif_field['section'] .'_'. $ar_exif_field['tag'];
$exif_value = isset($data[$exif_name]) ? $data[$exif_name] : NULL;
+
$field_name = 'field_'. $exif_name;
if (! $exif_value) {
- $node->{$field_name}[0]['value'] = NULL;
+ if (variable_get('exif_empty_values', TRUE)) {
+ $node->{$field_name}[0]['value'] = NULL;
+ }
continue;
}
$field = $fields[$field_name];
@@ -165,10 +135,10 @@ function exif_date_format_types() {
*/
function exif_date_formats() {
return array(
- array(
+ array(
'type' => 'exif',
'format' => 'Y:m:d H:i:s',
- ),
+ ),
);
}
@@ -264,62 +234,6 @@ function _exif_get_image_path($fields, &$node) {
return NULL;
}
-/**
- * Just some help page. Gives you an overview over the available tags
- * @return string html
- */
-function exif_admin_settings() {
- drupal_add_css(drupal_get_path('module', 'exif') .'/exif.css');
- $filepath = drupal_get_path('module', 'exif') .'/sample.jpg';
- $exif = _exif_get_class();
- $ar_exif = read_exif_data($filepath, 0, TRUE);
- // CCK field names must be lowercase
- $ar_exif = array_change_key_case($ar_exif, CASE_LOWER);
-
- $out = t('This is an overview over the most common data that is extracted with the exif module. How to read this table: The grey table header would be the key identifier and the following attributes would be the field to read.');
- $out .= ' ' . t('For example: If you want to import datetimeoriginal into an CCK field, you would name the CCK field field_exif_datetimeoriginal. Since this is a date field you can use a datetime field.');
- $rows1 = array();
- $help = t('This would be the keyword for your CCK field.');
- foreach ($ar_exif as $key => $value) {
- if (is_array($value)) {
- $value = _exif_reformat($value);
- $rows1[] = array('data' => array($key, $help), 'class' => 'tag_type');
- foreach ($value as $key2 => $value2) {
- $rows1[] = array('data' => array($key2, check_plain(utf8_encode($value2))));
- }
- }
-
- }
- $human_readable_key = $exif->getHumanReadableIPTCkey();
- $size = GetImageSize($filepath, $info_image);
- $iptc = iptcparse($info_image["APP13"]);
- $rows2 = array();
- $help = t('This would be the keyword for your CCK field.');
- if (is_array($iptc)) {
- $rows2[] = array('data' => array('IPTC', $help), 'class' => 'tag_type');
- foreach ($iptc as $key => $value) {
- $result_tag = "";
- foreach ($value as $innerkey => $innervalue) {
- if ( ($innerkey+1) != count($value) ) {
- $result_tag .= $innervalue .", ";
- }
- else {
- $result_tag .= $innervalue;
- }
- }
- $rows2[] = array('data' => array($human_readable_key[$key], check_plain(utf8_encode($result_tag))));
- }
- }
-
-
- $rows = array_merge($rows1, $rows2);
- $header = array(t('Key'), t('Value'));
- $out .= theme('table', $header, $rows, array('id' => 'exif-fields'));
- // TODO Prevent binary data values from busting the page layout
- return $out;
-}
-
-
/**
* Helper function to reformat fields where required.
@@ -336,7 +250,7 @@ function _exif_reformat($data) {
if (is_array($value)) {
$value = array_change_key_case($value, CASE_LOWER);
}
-
+
// Check for individual keys
switch ($key) {
case 'gpslatitude':
@@ -354,7 +268,7 @@ function _exif_reformat($data) {
case 'gps_gpslongitude':
$value = _exif_DMS2D($value, $data['gps_gpslongituderef']);
break;
-
+
}
}
return $data;
@@ -386,3 +300,48 @@ function _exif_get_class() {
$exif = Exif::getInstance();
return $exif;
}
+
+/**
+ * Implementation of hook_hoken_list
+ * @param array $type
+ */
+function fast_gallery_token_list($type = 'node') {
+ if ($type == 'node') {
+ $exif = _exif_get_class();
+ $ar_iptc = $exif->getHumanReadableIPTCkey();
+ foreach ($ar_iptc as $iptc) {
+ $tokens['iptc']['iptc_' . $iptc] = 'IPTC Field: ' . $iptc;
+ }
+ return $tokens;
+ }
+}
+
+/**
+ * implementation of hook_token_values
+ * @param unknown_type $type
+ * @param unknown_type $object
+ * @param unknown_type $options
+ */
+function fast_gallery_token_values($type, $object = NULL, $options = array()) {
+ if ($type == 'node') {
+ $node = $object;
+ $exif = _exif_get_class();
+ $ar_iptc = $exif->getHumanReadableIPTCkey();
+
+ $info = content_types($node->type);
+ $fields = $info['fields'];
+ //get the path to the image
+ $image_path = _exif_get_image_path($fields, $node);
+
+ //dsm("start reading");
+ $iptc_values = $exif->readIPTCTags($image_path, array(), array('style' => 'fullSmall'));
+ //dsm($iptc_values);
+
+ // TODO: needs to be finished
+ foreach ($iptc_values as $key => $iptc) {
+ $tokens['iptc_' . $key] = 'IPTC Field: ' . utf8_encode($iptc);
+ }
+ //dsm($tokens);
+ return $tokens;
+ }
+} \ No newline at end of file