Changeset 493 for trunk/admin
- Timestamp:
- Aug 25, 2004, 11:09:09 PM (20 years ago)
- Location:
- trunk/admin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/configuration.php
r486 r493 211 211 $use_exif = ($conf['use_exif']=='true')?'USE_EXIF_YES':'USE_EXIF_NO'; 212 212 $use_iptc = ($conf['use_iptc']=='true')?'USE_IPTC_YES':'USE_IPTC_NO'; 213 $show_exif = ($conf['show_exif']=='true')?'SHOW_EXIF_YES':'SHOW_EXIF_NO'; 214 $show_iptc = ($conf['show_iptc']=='true')?'SHOW_IPTC_YES':'SHOW_IPTC_NO'; 213 215 214 216 //----------------------------------------------------- template initialization … … 245 247 $use_exif=>'checked="checked"', 246 248 $use_iptc=>'checked="checked"', 249 $show_exif=>'checked="checked"', 250 $show_iptc=>'checked="checked"', 247 251 248 252 'L_CONFIRM'=>$lang['conf_confirmation'], … … 314 318 'L_USE_IPTC'=>$lang['conf_use_iptc'], 315 319 'L_USE_IPTC_INFO'=>$lang['conf_use_iptc_info'], 320 'L_SHOW_EXIF'=>$lang['conf_show_exif'], 321 'L_SHOW_EXIF_INFO'=>$lang['conf_show_exif_info'], 322 'L_SHOW_IPTC'=>$lang['conf_show_iptc'], 323 'L_SHOW_IPTC_INFO'=>$lang['conf_show_iptc_info'], 316 324 317 325 'F_ACTION'=>add_session_id(PHPWG_ROOT_PATH.'admin.php?page=configuration') -
trunk/admin/include/functions_metadata.php
r486 r493 26 26 // +-----------------------------------------------------------------------+ 27 27 28 /** 29 * returns informations from IPTC metadata, mapping is done at the beginning 30 * of the function 31 * 32 * @param string $filename 33 * @return array 34 */ 35 function get_iptc_data($filename) 28 include_once(PHPWG_ROOT_PATH.'/include/functions_metadata.inc.php'); 29 30 function get_sync_iptc_data($file) 36 31 { 37 global $getimagesize_time;38 39 32 $map = array( 40 33 'keywords' => '2#025', … … 46 39 $datefields = array('date_creation', 'date_available'); 47 40 48 $result = array(); 49 50 // Read IPTC data 51 $iptc = array(); 52 53 $start = get_moment(); 54 getimagesize($filename, &$imginfo); 55 $getimagesize_time+= get_moment() - $start; 56 57 if (is_array($imginfo) and isset($imginfo['APP13'])) 58 { 59 $iptc = iptcparse($imginfo['APP13']); 60 if (is_array($iptc)) 61 { 62 $rmap = array_flip($map); 63 foreach (array_keys($rmap) as $iptc_key) 64 { 65 if (isset($iptc[$iptc_key][0]) and $value = $iptc[$iptc_key][0]) 66 { 67 // strip leading zeros (weird Kodak Scanner software) 68 while ($value[0] == chr(0)) 69 { 70 $value = substr($value, 1); 71 } 72 // remove binary nulls 73 $value = str_replace(chr(0x00), ' ', $value); 74 75 foreach (array_keys($map, $iptc_key) as $pwg_key) 76 { 77 if (in_array($pwg_key, $datefields)) 78 { 79 if ( preg_match('/(\d{4})(\d{2})(\d{2})/', $value, $matches)) 80 { 81 $value = $matches[1].'-'.$matches[2].'-'.$matches[3]; 82 } 83 else 84 { 85 continue; 86 } 87 } 88 $result[$pwg_key] = $value; 89 } 90 } 91 } 92 } 93 } 94 return $result; 41 $iptc = get_iptc_data($file, $map); 42 43 foreach ($iptc as $pwg_key => $value) 44 { 45 if (in_array($pwg_key, $datefields)) 46 { 47 if ( preg_match('/(\d{4})(\d{2})(\d{2})/', $value, $matches)) 48 { 49 $iptc[$pwg_key] = $matches[1].'-'.$matches[2].'-'.$matches[3]; 50 } 51 } 52 } 53 54 return $iptc; 95 55 } 96 56 … … 98 58 { 99 59 global $conf; 100 101 // $conf['use_iptc'] = true;102 // $conf['use_exif'] = true;103 60 104 61 $inserts = array(); … … 133 90 if ($conf['use_iptc']) 134 91 { 135 $iptc = get_iptc_data($file); 136 foreach (array_keys($iptc) as $key) 137 { 138 $insert[$key] = "'".addslashes($iptc[$key])."'"; 92 $iptc = get_sync_iptc_data($file); 93 if (count($iptc) > 0) 94 { 95 foreach (array_keys($iptc) as $key) 96 { 97 $insert[$key] = "'".addslashes($iptc[$key])."'"; 98 } 139 99 } 140 100 }
Note: See TracChangeset
for help on using the changeset viewer.