Changeset 2304 for plugins/efiMetadatas/inc/class.efimetadatas.php
- Timestamp:
- 06/06/10 00:50:39 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/efiMetadatas/inc/class.efimetadatas.php
r1989 r2304 3 3 # This file is part of efiMetadatas, a plugin for Dotclear 2. 4 4 # 5 # Copyright (c) 2009 JC Denis and contributors5 # Copyright (c) 2009-2010 JC Denis and contributors 6 6 # jcdenis@gdwd.com 7 7 # … … 11 11 # -- END LICENSE BLOCK ------------------------------------ 12 12 13 14 13 class efiMetadatas 15 14 { … … 17 16 { 18 17 # Path and url 19 $p_url = $core->blog->settings-> public_url;18 $p_url = $core->blog->settings->system->public_url; 20 19 $p_site = preg_replace('#^(.+?//.+?)/(.*)$#','$1',$core->blog->url); 21 20 $p_root = $core->blog->public_path; 22 21 23 22 # Image pattern 24 23 $pattern = '(?:'.preg_quote($p_site,'/').')?'.preg_quote($p_url,'/'); 25 24 $pattern = sprintf('/<img.+?src="%s(.*?\.(?:jpg|gif|png))"[^>]+/msu',$pattern); 26 25 27 26 # No image 28 27 if (!preg_match_all($pattern,$subject,$m)) return; 29 28 30 29 $src = $thb = $alt = false; 31 30 $alt = $metas = $thumb = ''; 32 31 $allowed_ext = array('.jpg','.JPG','.png','.PNG','.gif','.GIF'); 33 32 34 33 # Loop through images 35 34 foreach ($m[1] as $i => $img) … … 39 38 $base = $info['base']; 40 39 $ext = $info['extension']; 41 40 42 41 # Not original 43 42 if (preg_match('/^\.(.+)_(sq|t|s|m)$/',$base,$mbase)) … … 45 44 $base = $mbase[1]; 46 45 } 47 46 48 47 # Full path 49 48 $f = $p_root.'/'.$info['dirname'].'/'.$base; 50 49 51 50 # Find extension 52 51 foreach($allowed_ext as $end) … … 58 57 } 59 58 } 60 59 61 60 # No file 62 61 if (!$src) continue; 63 62 64 63 # Find thumbnail 65 64 if (!empty($size)) … … 71 70 } 72 71 } 73 72 74 73 # Find image description 75 74 if (preg_match('/alt="([^"]+)"/',$m[0][$i],$malt)) … … 82 81 return array('source' => $src, 'thumb' => $thb, 'title' => $alt); 83 82 } 84 83 85 84 public static function imgMeta($core,$src) 86 85 { … … 101 100 'MeteringMode' => array(__('Metering mode'),'') 102 101 ); 103 102 104 103 $exp_prog = array( 105 104 0 => __('Not defined'), … … 113 112 8 => __('Landscape mode') 114 113 ); 115 114 116 115 $met_mod = array( 117 116 0 => __('Unknow'), … … 124 123 7 => __('Other') 125 124 ); 126 125 127 126 if (!$src || !file_exists($src)) return $metas; 128 127 129 128 $m = imageMeta::readMeta($src); 130 129 131 130 # Title 132 131 if (!empty($m['Title'])) … … 134 133 $metas['Title'][1] = html::escapeHTML($m['Title']); 135 134 } 136 135 137 136 # Description 138 137 if (!empty($m['Description'])) … … 143 142 } 144 143 } 145 144 146 145 # Location 147 146 if (!empty($m['City'])) … … 161 160 if (!empty($m['DateTimeOriginal'])) 162 161 { 163 $dt_ft = $core->blog->settings-> date_format.', '.$core->blog->settings->time_format;164 $dt_tz = $core->blog->settings-> blog_timezone;162 $dt_ft = $core->blog->settings->system->date_format.', '.$core->blog->settings->system->time_format; 163 $dt_tz = $core->blog->settings->system->blog_timezone; 165 164 $metas['DateTimeOriginal'][1] = dt::dt2str($dt_ft,$m['DateTimeOriginal'],$dt_tz); 166 165 } 167 166 168 167 # Make 169 168 if (isset($m['Make'])) … … 171 170 $metas['Make'][1] = html::escapeHTML($m['Make']); 172 171 } 173 172 174 173 # Model 175 174 if (isset($m['Model'])) … … 177 176 $metas['Model'][1] = html::escapeHTML($m['Model']); 178 177 } 179 178 180 179 # Lens 181 180 if (isset($m['Lens'])) … … 190 189 $exp_prog[$m['ExposureProgram']] : $m['ExposureProgram']; 191 190 } 192 191 193 192 # Exposure 194 193 if (!empty($m['Exposure'])) … … 196 195 $metas['Exposure'][1] = $m['Exposure'].'s'; 197 196 } 198 197 199 198 # FNumber 200 199 if (!empty($m['FNumber'])) … … 203 202 $metas['FNumber'][1] = $ap ? 'f/'.( $ap[0] / $ap[1]) : $m['FNumber']; 204 203 } 205 204 206 205 # ISOSpeedRatings 207 206 if (!empty($m['ISOSpeedRatings'])) … … 209 208 $metas['ISOSpeedRatings'][1] = $m['ISOSpeedRatings']; 210 209 } 211 210 212 211 # FocalLength 213 212 if (!empty($m['FocalLength'])) … … 216 215 $metas['FocalLength'][1] = $fl ? $fl[0]/$fl[1].'mm' : $m['FocalLength']; 217 216 } 218 217 219 218 # ExposureBiasValue 220 219 if (isset($m['ExposureBiasValue'])) … … 222 221 $metas['ExposureBiasValue'][1] = $m['ExposureBiasValue']; 223 222 } 224 223 225 224 # MeteringMode 226 225 if (isset($m['MeteringMode'])) … … 229 228 $exp_prog[$m['MeteringMode']] : $m['MeteringMode']; 230 229 } 231 230 232 231 return $metas; 233 232 }
Note: See TracChangeset
for help on using the changeset viewer.