Dotclear


Ignore:
Timestamp:
06/06/10 00:50:39 (13 years ago)
Author:
JcDenis
Message:

efiMetadatas 0.3

  • Switched to DC 2.2
File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/efiMetadatas/inc/class.efimetadatas.php

    r1989 r2304  
    33# This file is part of efiMetadatas, a plugin for Dotclear 2. 
    44#  
    5 # Copyright (c) 2009 JC Denis and contributors 
     5# Copyright (c) 2009-2010 JC Denis and contributors 
    66# jcdenis@gdwd.com 
    77#  
     
    1111# -- END LICENSE BLOCK ------------------------------------ 
    1212 
    13  
    1413class efiMetadatas 
    1514{ 
     
    1716     { 
    1817          # Path and url 
    19           $p_url = $core->blog->settings->public_url; 
     18          $p_url = $core->blog->settings->system->public_url; 
    2019          $p_site = preg_replace('#^(.+?//.+?)/(.*)$#','$1',$core->blog->url); 
    2120          $p_root = $core->blog->public_path; 
    22  
     21           
    2322          # Image pattern 
    2423          $pattern = '(?:'.preg_quote($p_site,'/').')?'.preg_quote($p_url,'/'); 
    2524          $pattern = sprintf('/<img.+?src="%s(.*?\.(?:jpg|gif|png))"[^>]+/msu',$pattern); 
    26  
     25           
    2726          # No image 
    2827          if (!preg_match_all($pattern,$subject,$m)) return; 
    29  
     28           
    3029          $src = $thb = $alt = false; 
    3130          $alt = $metas = $thumb = ''; 
    3231          $allowed_ext = array('.jpg','.JPG','.png','.PNG','.gif','.GIF'); 
    33  
     32           
    3433          # Loop through images 
    3534          foreach ($m[1] as $i => $img) 
     
    3938               $base = $info['base']; 
    4039               $ext = $info['extension']; 
    41  
     40                
    4241               # Not original 
    4342               if (preg_match('/^\.(.+)_(sq|t|s|m)$/',$base,$mbase)) 
     
    4544                    $base = $mbase[1]; 
    4645               } 
    47  
     46                
    4847               # Full path 
    4948               $f = $p_root.'/'.$info['dirname'].'/'.$base; 
    50  
     49                
    5150               # Find extension 
    5251               foreach($allowed_ext as $end) 
     
    5857                    } 
    5958               } 
    60  
     59                
    6160               # No file 
    6261               if (!$src) continue; 
    63  
     62                
    6463               # Find thumbnail 
    6564               if (!empty($size)) 
     
    7170                    } 
    7271               } 
    73  
     72                
    7473               # Find image description 
    7574               if (preg_match('/alt="([^"]+)"/',$m[0][$i],$malt)) 
     
    8281          return array('source' => $src, 'thumb' => $thb, 'title' => $alt); 
    8382     } 
    84  
     83      
    8584     public static function imgMeta($core,$src) 
    8685     { 
     
    101100               'MeteringMode' => array(__('Metering mode'),'') 
    102101          ); 
    103  
     102           
    104103          $exp_prog = array( 
    105104               0 => __('Not defined'), 
     
    113112               8 => __('Landscape mode') 
    114113          ); 
    115  
     114           
    116115          $met_mod = array( 
    117116               0 => __('Unknow'), 
     
    124123               7 => __('Other') 
    125124          ); 
    126  
     125           
    127126          if (!$src || !file_exists($src)) return $metas; 
    128  
     127           
    129128          $m = imageMeta::readMeta($src); 
    130  
     129           
    131130          # Title 
    132131          if (!empty($m['Title'])) 
     
    134133               $metas['Title'][1] = html::escapeHTML($m['Title']); 
    135134          } 
    136  
     135           
    137136          # Description 
    138137          if (!empty($m['Description'])) 
     
    143142               } 
    144143          } 
    145  
     144           
    146145          # Location 
    147146          if (!empty($m['City'])) 
     
    161160          if (!empty($m['DateTimeOriginal'])) 
    162161          { 
    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; 
    165164               $metas['DateTimeOriginal'][1] = dt::dt2str($dt_ft,$m['DateTimeOriginal'],$dt_tz); 
    166165          } 
    167  
     166           
    168167          # Make 
    169168          if (isset($m['Make'])) 
     
    171170               $metas['Make'][1] = html::escapeHTML($m['Make']); 
    172171          } 
    173  
     172           
    174173          # Model 
    175174          if (isset($m['Model'])) 
     
    177176               $metas['Model'][1] = html::escapeHTML($m['Model']); 
    178177          } 
    179  
     178           
    180179          # Lens 
    181180          if (isset($m['Lens'])) 
     
    190189               $exp_prog[$m['ExposureProgram']] : $m['ExposureProgram']; 
    191190          } 
    192  
     191           
    193192          # Exposure 
    194193          if (!empty($m['Exposure'])) 
     
    196195               $metas['Exposure'][1] = $m['Exposure'].'s'; 
    197196          } 
    198  
     197           
    199198          # FNumber 
    200199          if (!empty($m['FNumber'])) 
     
    203202               $metas['FNumber'][1] = $ap ? 'f/'.( $ap[0] / $ap[1]) : $m['FNumber']; 
    204203          } 
    205  
     204           
    206205          # ISOSpeedRatings 
    207206          if (!empty($m['ISOSpeedRatings'])) 
     
    209208               $metas['ISOSpeedRatings'][1] = $m['ISOSpeedRatings']; 
    210209          } 
    211  
     210           
    212211          # FocalLength 
    213212          if (!empty($m['FocalLength'])) 
     
    216215               $metas['FocalLength'][1] = $fl ? $fl[0]/$fl[1].'mm' : $m['FocalLength']; 
    217216          } 
    218  
     217           
    219218          # ExposureBiasValue 
    220219          if (isset($m['ExposureBiasValue'])) 
     
    222221               $metas['ExposureBiasValue'][1] = $m['ExposureBiasValue']; 
    223222          } 
    224  
     223           
    225224          # MeteringMode 
    226225          if (isset($m['MeteringMode'])) 
     
    229228               $exp_prog[$m['MeteringMode']] : $m['MeteringMode']; 
    230229          } 
    231  
     230           
    232231          return $metas; 
    233232     } 
Note: See TracChangeset for help on using the changeset viewer.

Sites map