Dotclear


Ignore:
Timestamp:
11/17/13 20:25:53 (12 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
2.6
Children:
2567:6c11245cbf04, 2568:61c67a7d17fa
Message:

Add some people in CREDITS, remove trailing spaces and tabs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/core/class.dc.media.php

    r2098 r2566  
    2626     protected $postmedia; 
    2727     protected $file_sort = 'name-asc'; 
    28       
     28 
    2929     protected $file_handler = array(); ///< <b>array</b> Array of callbacks 
    30       
     30 
    3131     public $thumb_tp = '%s/.%s_%s.jpg';     ///< <b>string</b> Thumbnail file pattern 
    3232     public $thumb_tp_alpha = '%s/.%s_%s.png'; ///< <b>string</b> Thumbnail file pattern (with alpha layer) 
    33       
     33 
    3434     /** 
    3535     <b>array</b> Tubmnail sizes: 
     
    3939     - sq: square image 
    4040     */ 
    41      public $thumb_sizes = array(   
     41     public $thumb_sizes = array( 
    4242          'm' => array(448,'ratio','medium'), 
    4343          's' => array(240,'ratio','small'), 
     
    4545          'sq' => array(48,'crop','square') 
    4646     ); 
    47       
     47 
    4848     public $icon_img = 'images/media/%s.png';    ///< <b>string</b> Icon file pattern 
    49       
     49 
    5050     /** 
    5151     Object constructor. 
    52       
     52 
    5353     @param    core      <b>dcCore</b>       dcCore instance 
    5454     @param    type      <b>string</b>       Media type filter 
     
    5959          $this->con =& $core->con; 
    6060          $this->postmedia = new dcPostMedia($core); 
    61            
     61 
    6262          if ($this->core->blog == null) { 
    6363               throw new Exception(__('No blog defined.')); 
    6464          } 
    65            
     65 
    6666          $this->table = $this->core->prefix.'media'; 
    6767          $root = $this->core->blog->public_path; 
    68            
     68 
    6969          if (preg_match('#^http(s)?://#',$this->core->blog->settings->system->public_url)) { 
    7070               $root_url = rawurldecode($this->core->blog->settings->system->public_url); 
     
    7272               $root_url = rawurldecode($this->core->blog->host.path::clean($this->core->blog->settings->system->public_url)); 
    7373          } 
    74            
     74 
    7575          if (!is_dir($root)) { 
    7676               # Check public directory 
     
    8181               } 
    8282          } 
    83            
     83 
    8484          $this->type = $type; 
    85            
     85 
    8686          parent::__construct($root,$root_url); 
    8787          $this->chdir(''); 
    88            
     88 
    8989          $this->path = $this->core->blog->settings->system->public_path; 
    90            
     90 
    9191          $this->addExclusion(DC_RC_PATH); 
    9292          $this->addExclusion(dirname(__FILE__).'/../'); 
    93            
     93 
    9494          $this->exclude_pattern = $core->blog->settings->system->media_exclusion; 
    95            
     95 
    9696          # Event handlers 
    9797          $this->addFileHandler('image/jpeg','create',array($this,'imageThumbCreate')); 
    9898          $this->addFileHandler('image/png','create',array($this,'imageThumbCreate')); 
    9999          $this->addFileHandler('image/gif','create',array($this,'imageThumbCreate')); 
    100            
     100 
    101101          $this->addFileHandler('image/png','update',array($this,'imageThumbUpdate')); 
    102102          $this->addFileHandler('image/jpeg','update',array($this,'imageThumbUpdate')); 
    103103          $this->addFileHandler('image/gif','update',array($this,'imageThumbUpdate')); 
    104            
     104 
    105105          $this->addFileHandler('image/png','remove',array($this,'imageThumbRemove')); 
    106106          $this->addFileHandler('image/jpeg','remove',array($this,'imageThumbRemove')); 
    107107          $this->addFileHandler('image/gif','remove',array($this,'imageThumbRemove')); 
    108            
     108 
    109109          $this->addFileHandler('image/jpeg','create',array($this,'imageMetaCreate')); 
    110            
     110 
    111111          $this->addFileHandler('image/jpeg','recreate',array($this,'imageThumbCreate')); 
    112112          $this->addFileHandler('image/png','recreate',array($this,'imageThumbCreate')); 
    113113          $this->addFileHandler('image/gif','recreate',array($this,'imageThumbCreate')); 
    114            
     114 
    115115          $this->addFileHandler('image/jpeg','recreate',array($this,'imageThumbCreate')); 
    116116          $this->addFileHandler('image/png','recreate',array($this,'imageThumbCreate')); 
    117117          $this->addFileHandler('image/gif','recreate',array($this,'imageThumbCreate')); 
    118            
     118 
    119119          # Thumbnails sizes 
    120120          $this->thumb_sizes['m'][0] = abs($core->blog->settings->system->media_img_m_size); 
    121121          $this->thumb_sizes['s'][0] = abs($core->blog->settings->system->media_img_s_size); 
    122122          $this->thumb_sizes['t'][0] = abs($core->blog->settings->system->media_img_t_size); 
    123            
     123 
    124124          # Thumbnails sizes names 
    125125          $this->thumb_sizes['m'][2] = __($this->thumb_sizes['m'][2]); 
     
    127127          $this->thumb_sizes['t'][2] = __($this->thumb_sizes['t'][2]); 
    128128          $this->thumb_sizes['sq'][2] = __($this->thumb_sizes['sq'][2]); 
    129            
     129 
    130130          # --BEHAVIOR-- coreMediaConstruct 
    131           $this->core->callBehavior('coreMediaConstruct',$this);  
    132      } 
    133       
     131          $this->core->callBehavior('coreMediaConstruct',$this); 
     132     } 
     133 
    134134     /** 
    135135     Changes working directory. 
    136       
     136 
    137137     @param    dir       <b>string</b>       Directory name. 
    138138     */ 
     
    142142          $this->relpwd = preg_replace('/^'.preg_quote($this->root,'/').'\/?/','',$this->pwd); 
    143143     } 
    144       
     144 
    145145     /** 
    146146     Adds a new file handler for a given media type and event. 
    147       
     147 
    148148     Available events are: 
    149149     - create: file creation 
    150150     - update: file update 
    151151     - remove: file deletion 
    152       
     152 
    153153     @param    type      <b>string</b>       Media type 
    154154     @param    event     <b>string</b>       Event 
     
    161161          } 
    162162     } 
    163       
     163 
    164164     protected function callFileHandler($type,$event) 
    165165     { 
     
    169169               array_shift($args); 
    170170               array_shift($args); 
    171                 
     171 
    172172               foreach ($this->file_handler[$type][$event] as $f) 
    173173               { 
     
    176176          } 
    177177     } 
    178       
     178 
    179179     /** 
    180180     Returns HTML breadCrumb for media manager navigation. 
    181       
     181 
    182182     @param    href      <b>string</b>       URL pattern 
    183183     @param    last      <b>string</b>       Last item pattern 
     
    201201          } 
    202202          return $res; 
    203            
    204      } 
    205       
     203 
     204     } 
     205 
    206206     protected function fileRecord($rs) 
    207207     { 
    208208          if ($rs->isEmpty()) { return null; } 
    209            
     209 
    210210          if (!$this->isFileExclude($this->root.'/'.$rs->media_file) && is_file($this->root.'/'.$rs->media_file)) 
    211211          { 
    212212               $f = new fileItem($this->root.'/'.$rs->media_file,$this->root,$this->root_url); 
    213                 
     213 
    214214               if ($this->type && $f->type_prefix != $this->type) { 
    215215                    return null; 
    216216               } 
    217                 
     217 
    218218               $meta = @simplexml_load_string($rs->media_meta); 
    219                 
     219 
    220220               $f->editable = true; 
    221221               $f->media_id = $rs->media_id; 
     
    226226               $f->media_dt = strtotime($rs->media_dt); 
    227227               $f->media_dtstr = dt::str('%Y-%m-%d %H:%M',$f->media_dt); 
    228                 
     228 
    229229               $f->media_image = false; 
    230                 
     230 
    231231               if (!$this->core->auth->check('media_admin',$this->core->blog->id) 
    232232               && $this->core->auth->userID() != $f->media_user) { 
     
    234234                    $f->editable = false; 
    235235               } 
    236                 
     236 
    237237               $type_prefix = explode('/',$f->type); 
    238238               $type_prefix = $type_prefix[0]; 
    239                 
     239 
    240240               switch ($type_prefix) { 
    241241                    case 'image': 
     
    297297                         break; 
    298298               } 
    299                 
     299 
    300300               $f->media_type = $f->media_icon; 
    301301               $f->media_icon = sprintf($this->icon_img,$f->media_icon); 
    302                 
     302 
    303303               # Thumbnails 
    304304               $f->media_thumb = array(); 
     
    309309               $thumb = sprintf(($alpha ? $this->thumb_tp_alpha : $this->thumb_tp),$this->root.'/'.$p['dirname'],$p['base'],'%s'); 
    310310               $thumb_url = sprintf(($alpha ? $this->thumb_tp_alpha : $this->thumb_tp),$this->root_url.$p['dirname'],$p['base'],'%s'); 
    311                 
     311 
    312312               # Cleaner URLs 
    313313               $thumb_url = preg_replace('#\./#','/',$thumb_url); 
     
    321321                    $thumb_url_alt = preg_replace('#(?<!:)/+#','/',$thumb_url_alt); 
    322322               } 
    323                 
     323 
    324324               foreach ($this->thumb_sizes as $suffix => $s) { 
    325325                    if (file_exists(sprintf($thumb,$suffix))) { 
     
    329329                    } 
    330330               } 
    331                 
     331 
    332332               if (isset($f->media_thumb['sq']) && $f->media_type == 'image') { 
    333333                    $f->media_icon = $f->media_thumb['sq']; 
    334334               } 
    335                 
     335 
    336336               return $f; 
    337337          } 
    338            
     338 
    339339          return null; 
    340340     } 
    341       
    342       
     341 
     342 
    343343     public function setFileSort($type='name') 
    344344     { 
     
    347347          } 
    348348     } 
    349       
     349 
    350350     protected function sortFileHandler($a,$b) 
    351351     { 
     
    368368                    return strcasecmp($a->basename,$b->basename); 
    369369          } 
    370            
     370 
    371371     } 
    372372 
     
    381381 
    382382     /** 
    383      Gets current working directory content.  
    384       
     383     Gets current working directory content. 
     384 
    385385     @param    type      <b>string</b>       Media type filter 
    386386     */ 
     
    390390               $this->type = $type; 
    391391          } 
    392            
     392 
    393393          $media_dir = $this->relpwd ? $this->relpwd : '.'; 
    394            
     394 
    395395          $strReq = 
    396396          'SELECT media_file, media_id, media_path, media_title, media_meta, media_dt, '. 
     
    399399          "WHERE media_path = '".$this->path."' ". 
    400400          "AND media_dir = '".$this->con->escape($media_dir)."' "; 
    401            
     401 
    402402          if (!$this->core->auth->check('media_admin',$this->core->blog->id)) 
    403403          { 
    404404               $strReq .= 'AND (media_private <> 1 '; 
    405                 
     405 
    406406               if ($this->core->auth->userID()) { 
    407407                    $strReq .= "OR user_id = '".$this->con->escape($this->core->auth->userID())."'"; 
     
    409409               $strReq .= ') '; 
    410410          } 
    411            
     411 
    412412          $rs = $this->con->select($strReq); 
    413            
     413 
    414414          parent::getDir(); 
    415            
     415 
    416416          $f_res = array(); 
    417417          $p_dir = $this->dir; 
    418            
     418 
    419419          # If type is set, remove items from p_dir 
    420420          if ($this->type) 
     
    426426               } 
    427427          } 
    428            
     428 
    429429          $f_reg = array(); 
    430            
     430 
    431431          while ($rs->fetch()) 
    432432          { 
     
    435435                    continue; 
    436436               } 
    437                 
     437 
    438438               if ($this->inFiles($rs->media_file)) 
    439439               { 
     
    442442                         if (isset($f_reg[$rs->media_file])) 
    443443                         { 
    444                               # That media is duplicated in the database,  
     444                              # That media is duplicated in the database, 
    445445                              # time to do a bit of house cleaning. 
    446446                              $this->con->execute( 
     
    468468               } 
    469469          } 
    470            
     470 
    471471          $this->dir['files'] = $f_res; 
    472472          foreach ($this->dir['dirs'] as $k => $v) { 
    473473               $v->media_icon = sprintf($this->icon_img,($v->parent ? 'folder-up' : 'folder')); 
    474474          } 
    475            
     475 
    476476          # Check files that don't exist in database and create them 
    477477          if ($this->core->auth->check('media,media_admin',$this->core->blog->id)) 
     
    488488          usort($this->dir['files'],array($this,'sortFileHandler')); 
    489489     } 
    490       
     490 
    491491     /** 
    492492     Gets file by its id. Returns a filteItem object. 
    493       
     493 
    494494     @param    id        <b>integer</b>      File ID 
    495495     @return   <b>fileItem</b> 
     
    504504          "WHERE media_path = '".$this->path."' ". 
    505505          'AND media_id = '.(integer) $id.' '; 
    506            
     506 
    507507          if (!$this->core->auth->check('media_admin',$this->core->blog->id)) 
    508508          { 
    509509               $strReq .= 'AND (media_private <> 1 '; 
    510                 
     510 
    511511               if ($this->core->auth->userID()) { 
    512512                    $strReq .= "OR user_id = '".$this->con->escape($this->core->auth->userID())."'"; 
     
    514514               $strReq .= ') '; 
    515515          } 
    516            
     516 
    517517          $rs = $this->con->select($strReq); 
    518518          return $this->fileRecord($rs); 
    519519     } 
    520       
     520 
    521521     /** 
    522522     Returns media items attached to a blog post. Result is an array containing 
    523523     fileItems objects. 
    524       
     524 
    525525     @param    post_id   <b>integer</b>      Post ID 
    526526     @param    media_id  <b>integer</b>      Optionnal media ID 
     
    537537          } 
    538538          $rs = $this->postmedia->getPostMedia($params); 
    539            
     539 
    540540          $res = array(); 
    541            
     541 
    542542          while ($rs->fetch()) { 
    543543               $f = $this->fileRecord($rs); 
     
    546546               } 
    547547          } 
    548            
     548 
    549549          return $res; 
    550550     } 
    551       
     551 
    552552     /** 
    553553     @deprecated since version 2.4 
     
    558558          $this->postmedia->addPostMedia($post_id,$media_id); 
    559559     } 
    560       
     560 
    561561     /** 
    562562     @deprecated since version 2.4 
     
    567567          $this->postmedia->removePostMedia($post_id,$media_id,"attachment"); 
    568568     } 
    569       
     569 
    570570     /** 
    571571     Rebuilds database items collection. Optional <var>$pwd</var> parameter is 
    572572     the path where to start rebuild. 
    573       
     573 
    574574     @param    pwd       <b>string</b>       Directory to rebuild 
    575575     */ 
     
    579579               throw new Exception(__('You are not a super administrator.')); 
    580580          } 
    581            
     581 
    582582          $this->chdir($pwd); 
    583583          parent::getDir(); 
    584            
     584 
    585585          $dir = $this->dir; 
    586            
     586 
    587587          foreach ($dir['dirs'] as $d) { 
    588588               if (!$d->parent) { 
     
    590590               } 
    591591          } 
    592            
     592 
    593593          foreach ($dir['files'] as $f) { 
    594594               $this->chdir(dirname($f->relname)); 
    595595               $this->createFile($f->basename); 
    596596          } 
    597            
     597 
    598598          $this->rebuildDB($pwd); 
    599599     } 
    600       
     600 
    601601     protected function rebuildDB($pwd) 
    602602     { 
    603603          $media_dir = $pwd ? $pwd : '.'; 
    604            
     604 
    605605          $strReq = 
    606606          'SELECT media_file, media_id '. 
     
    608608          "WHERE media_path = '".$this->path."' ". 
    609609          "AND media_dir = '".$this->con->escape($media_dir)."' "; 
    610            
     610 
    611611          $rs = $this->con->select($strReq); 
    612            
     612 
    613613          $delReq = 'DELETE FROM '.$this->table.' '. 
    614614                    'WHERE media_id IN (%s) '; 
    615615          $del_ids = array(); 
    616            
     616 
    617617          while ($rs->fetch()) 
    618618          { 
     
    621621               } 
    622622          } 
    623            
     623 
    624624          if (!empty($del_ids)) { 
    625625               $this->con->execute(sprintf($delReq,implode(',',$del_ids))); 
    626626          } 
    627627     } 
    628       
     628 
    629629     public function makeDir($d) 
    630630     { 
     
    632632          parent::makeDir($d); 
    633633     } 
    634       
     634 
    635635     /** 
    636636     Creates or updates a file in database. Returns new media ID or false if 
    637637     file does not exist. 
    638       
     638 
    639639     @param    name      <b>string</b>       File name (relative to working directory) 
    640640     @param    title     <b>string</b>       File title 
     
    648648               throw new Exception(__('Permission denied.')); 
    649649          } 
    650            
     650 
    651651          $file = $this->pwd.'/'.$name; 
    652652          if (!file_exists($file)) { 
    653653               return false; 
    654654          } 
    655            
     655 
    656656          $media_file = $this->relpwd ? path::clean($this->relpwd.'/'.$name) : path::clean($name); 
    657657          $media_type = files::getMimeType($name); 
    658            
     658 
    659659          $cur = $this->con->openCursor($this->table); 
    660            
     660 
    661661          $strReq = 'SELECT media_id '. 
    662662                    'FROM '.$this->table.' '. 
    663663                    "WHERE media_path = '".$this->con->escape($this->path)."' ". 
    664664                    "AND media_file = '".$this->con->escape($media_file)."' "; 
    665            
     665 
    666666          $rs = $this->con->select($strReq); 
    667            
     667 
    668668          if ($rs->isEmpty()) 
    669669          { 
     
    673673                    $rs = $this->con->select('SELECT MAX(media_id) FROM '.$this->table); 
    674674                    $media_id = (integer) $rs->f(0) + 1; 
    675                      
     675 
    676676                    $cur->media_id = $media_id; 
    677677                    $cur->user_id = (string) $this->core->auth->userID(); 
     
    681681                    $cur->media_creadt = date('Y-m-d H:i:s'); 
    682682                    $cur->media_upddt = date('Y-m-d H:i:s'); 
    683                      
     683 
    684684                    $cur->media_title = !$title ? (string) $name : (string) $title; 
    685685                    $cur->media_private = (integer) (boolean) $private; 
    686                      
     686 
    687687                    if ($dt) { 
    688688                         $cur->media_dt = (string) $dt; 
     
    690690                         $cur->media_dt = strftime('%Y-%m-%d %H:%M:%S',filemtime($file)); 
    691691                    } 
    692                      
     692 
    693693                    try { 
    694694                         $cur->insert(); 
     
    708708          { 
    709709               $media_id = (integer) $rs->media_id; 
    710                 
     710 
    711711               $cur->media_upddt = date('Y-m-d H:i:s'); 
    712                 
     712 
    713713               $cur->update('WHERE media_id = '.$media_id); 
    714714          } 
    715            
     715 
    716716          $this->callFileHandler($media_type,'create',$cur,$name,$media_id,$force); 
    717            
     717 
    718718          return $media_id; 
    719719     } 
    720       
     720 
    721721     /** 
    722722     Updates a file in database. 
    723       
     723 
    724724     @param    file      <b>fileItem</b>     Current fileItem object 
    725725     @param    newFile   <b>fileItem</b>     New fileItem object 
     
    730730               throw new Exception(__('Permission denied.')); 
    731731          } 
    732            
     732 
    733733          $id = (integer) $file->media_id; 
    734            
     734 
    735735          if (!$id) { 
    736736               throw new Exception('No file ID'); 
    737737          } 
    738            
     738 
    739739          if (!$this->core->auth->check('media_admin',$this->core->blog->id) 
    740740          && $this->core->auth->userID() != $file->media_user) { 
    741741               throw new Exception(__('You are not the file owner.')); 
    742742          } 
    743            
     743 
    744744          $cur = $this->con->openCursor($this->table); 
    745            
     745 
    746746          # We need to tidy newFile basename. If dir isn't empty, concat to basename 
    747747          $newFile->relname = files::tidyFileName($newFile->basename); 
     
    749749               $newFile->relname = $newFile->dir.'/'.$newFile->relname; 
    750750          } 
    751            
     751 
    752752          if ($file->relname != $newFile->relname) { 
    753753               $newFile->file = $this->root.'/'.$newFile->relname; 
    754                 
     754 
    755755               if ($this->isFileExclude($newFile->relname)) { 
    756756                    throw new Exception(__('This file is not allowed.')); 
    757757               } 
    758                 
     758 
    759759               if (file_exists($newFile->file)) { 
    760760                    throw new Exception(__('New file already exists.')); 
    761761               } 
    762                 
     762 
    763763               $this->moveFile($file->relname,$newFile->relname); 
    764                 
     764 
    765765               $cur->media_file = (string) $newFile->relname; 
    766766               $cur->media_dir = (string) dirname($newFile->relname); 
    767767          } 
    768            
     768 
    769769          $cur->media_title = (string) $newFile->media_title; 
    770770          $cur->media_dt = (string) $newFile->media_dtstr; 
    771771          $cur->media_upddt = date('Y-m-d H:i:s'); 
    772772          $cur->media_private = (integer) $newFile->media_priv; 
    773            
     773 
    774774          $cur->update('WHERE media_id = '.$id); 
    775            
     775 
    776776          $this->callFileHandler($file->type,'update',$file,$newFile); 
    777777     } 
    778       
     778 
    779779     /** 
    780780     Uploads a file. 
    781       
     781 
    782782     @param    tmp       <b>string</b>       Full path of temporary uploaded file 
    783783     @param    name      <b>string</b>       File name (relative to working directory) 
     
    790790               throw new Exception(__('Permission denied.')); 
    791791          } 
    792            
     792 
    793793          $name = files::tidyFileName($name); 
    794            
     794 
    795795          parent::uploadFile($tmp,$name,$overwrite); 
    796            
     796 
    797797          return $this->createFile($name,$title,$private); 
    798798     } 
    799       
     799 
    800800     /** 
    801801     Creates a file from binary content. 
    802       
     802 
    803803     @param    name      <b>string</b>       File name (relative to working directory) 
    804804     @param    bits      <b>string</b>       Binary file content 
     
    809809               throw new Exception(__('Permission denied.')); 
    810810          } 
    811            
     811 
    812812          $name = files::tidyFileName($name); 
    813            
     813 
    814814          parent::uploadBits($name,$bits); 
    815            
     815 
    816816          return $this->createFile($name,null,null); 
    817817     } 
    818       
     818 
    819819     /** 
    820820     Removes a file. 
    821       
     821 
    822822     @param    f         <b>fileItem</b>     fileItem object 
    823823     */ 
     
    827827               throw new Exception(__('Permission denied.')); 
    828828          } 
    829            
     829 
    830830          $media_file = $this->relpwd ? path::clean($this->relpwd.'/'.$f) : path::clean($f); 
    831            
     831 
    832832          $strReq = 'DELETE FROM '.$this->table.' '. 
    833833                    "WHERE media_path = '".$this->con->escape($this->path)."' ". 
    834834                    "AND media_file = '".$this->con->escape($media_file)."' "; 
    835            
     835 
    836836          if (!$this->core->auth->check('media_admin',$this->core->blog->id)) 
    837837          { 
    838838               $strReq .= "AND user_id = '".$this->con->escape($this->core->auth->userID())."'"; 
    839839          } 
    840            
     840 
    841841          $this->con->execute($strReq); 
    842            
     842 
    843843          if ($this->con->changes() == 0) { 
    844844               throw new Exception(__('File does not exist in the database.')); 
    845845          } 
    846            
     846 
    847847          parent::removeFile($f); 
    848            
     848 
    849849          $this->callFileHandler(files::getMimeType($media_file),'remove',$f); 
    850850     } 
     
    861861     { 
    862862          $media_dir = $this->relpwd ? $this->relpwd : '.'; 
    863            
     863 
    864864          $strReq = 
    865865          'SELECT distinct media_dir '. 
     
    871871                    $dir[] = ($rs->media_dir == '.' ? '' : $rs->media_dir); 
    872872          } 
    873            
     873 
    874874          return $dir; 
    875875     } 
    876       
     876 
    877877     /** 
    878878     Extract zip file in current location 
    879       
     879 
    880880     @param    f         <b>fileRecord</b>   fileRecord object 
    881881     */ 
     
    885885          $zip->setExcludePattern($this->exclude_pattern); 
    886886          $zip->getList(false,'#(^|/)(__MACOSX|\.svn|\.DS_Store|\.directory|Thumbs\.db)(/|$)#'); 
    887            
     887 
    888888          if ($create_dir) 
    889889          { 
     
    896896                    $target = $f->dir.'/'.$destination; 
    897897               } 
    898                 
     898 
    899899               if (is_dir($f->dir.'/'.$destination)) { 
    900                     throw new Exception(sprintf(__('Extract destination directory %s already exists.'),dirname($f->relname).'/'.$destination));  
     900                    throw new Exception(sprintf(__('Extract destination directory %s already exists.'),dirname($f->relname).'/'.$destination)); 
    901901               } 
    902902          } 
     
    906906               $destination = ''; 
    907907          } 
    908            
     908 
    909909          $zip->unzipAll($target); 
    910910          $zip->close(); 
    911911          return dirname($f->relname).'/'.$destination; 
    912912     } 
    913       
     913 
    914914     /** 
    915915     Returns zip file content 
    916       
     916 
    917917     @param    f         <b>fileRecord</b>   fileRecord object 
    918918     @return <b>array</b> 
     
    928928     /** 
    929929     Calls file handlers registered for recreate event 
    930       
     930 
    931931     @param    f    <b>fileItem</b>     fileItem object 
    932932     */ 
     
    936936          $this->callFileHandler($media_type,'recreate',null,$f->basename); // Args list to be completed as necessary (Franck) 
    937937     } 
    938       
     938 
    939939     /* Image handlers 
    940940     ------------------------------------------------------- */ 
     
    942942     { 
    943943          $file = $this->pwd.'/'.$f; 
    944            
     944 
    945945          if (!file_exists($file)) { 
    946946               return false; 
    947947          } 
    948            
     948 
    949949          $p = path::info($file); 
    950950          $alpha = ($p['extension'] == 'png') || ($p['extension'] == 'PNG'); 
    951951          $thumb = sprintf(($alpha ? $this->thumb_tp_alpha : $this->thumb_tp),$p['dirname'],$p['base'],'%s'); 
    952            
     952 
    953953          try 
    954954          { 
    955955               $img = new imageTools(); 
    956956               $img->loadImage($file); 
    957                 
     957 
    958958               $w = $img->getW(); 
    959959               $h = $img->getH(); 
    960                 
     960 
    961961               if ($force) $this->imageThumbRemove($f); 
    962                 
     962 
    963963               foreach ($this->thumb_sizes as $suffix => $s) { 
    964964                    $thumb_file = sprintf($thumb,$suffix); 
     
    981981          } 
    982982     } 
    983       
     983 
    984984     protected function imageThumbUpdate($file,$newFile) 
    985985     { 
     
    989989               $alpha = ($p['extension'] == 'png') || ($p['extension'] == 'PNG'); 
    990990               $thumb_old = sprintf(($alpha ? $this->thumb_tp_alpha : $this->thumb_tp),$p['dirname'],$p['base'],'%s'); 
    991                 
     991 
    992992               $p = path::info($newFile->relname); 
    993993               $alpha = ($p['extension'] == 'png') || ($p['extension'] == 'PNG'); 
    994994               $thumb_new = sprintf(($alpha ? $this->thumb_tp_alpha : $this->thumb_tp),$p['dirname'],$p['base'],'%s'); 
    995                 
     995 
    996996               foreach ($this->thumb_sizes as $suffix => $s) { 
    997997                    try { 
     
    10011001          } 
    10021002     } 
    1003       
     1003 
    10041004     protected function imageThumbRemove($f) 
    10051005     { 
     
    10071007          $alpha = ($p['extension'] == 'png') || ($p['extension'] == 'PNG'); 
    10081008          $thumb = sprintf(($alpha ? $this->thumb_tp_alpha : $this->thumb_tp),'',$p['base'],'%s'); 
    1009            
     1009 
    10101010          foreach ($this->thumb_sizes as $suffix => $s) { 
    10111011               try { 
     
    10141014          } 
    10151015     } 
    1016       
     1016 
    10171017     protected function imageMetaCreate($cur,$f,$id) 
    10181018     { 
    10191019          $file = $this->pwd.'/'.$f; 
    1020            
     1020 
    10211021          if (!file_exists($file)) { 
    10221022               return false; 
    10231023          } 
    1024            
     1024 
    10251025          $xml = new xmlTag('meta'); 
    10261026          $meta = imageMeta::readMeta($file); 
    10271027          $xml->insertNode($meta); 
    1028            
     1028 
    10291029          $c = $this->core->con->openCursor($this->table); 
    10301030          $c->media_meta = $xml->toXML(); 
    1031            
     1031 
    10321032          if ($cur->media_title !== null && $cur->media_title == basename($cur->media_file)) 
    10331033          { 
     
    10361036               } 
    10371037          } 
    1038            
     1038 
    10391039          if ($meta['DateTimeOriginal'] && $cur->media_dt === '') 
    10401040          { 
     
    10461046               } 
    10471047          } 
    1048            
     1048 
    10491049          $c->update('WHERE media_id = '.$id); 
    10501050     } 
    1051       
     1051 
    10521052     /** 
    10531053     Returns HTML code for MP3 player 
    1054       
     1054 
    10551055     @param    url       <b>string</b>       MP3 URL to play 
    10561056     @param    player    <b>string</b>       Player URL 
     
    10631063               $player = 'player_mp3.swf'; 
    10641064          } 
    1065            
     1065 
    10661066          if (!is_array($args)) 
    10671067          { 
     
    10781078               ); 
    10791079          } 
    1080            
     1080 
    10811081          $args['mp3'] = $url; 
    1082            
     1082 
    10831083          if (empty($args['width'])) { 
    10841084               $args['width'] = 200; 
     
    10871087               $args['height'] = 20; 
    10881088          } 
    1089            
     1089 
    10901090          $vars = array(); 
    10911091          foreach ($args as $k => $v) { 
    10921092               $vars[] = $k.'='.$v; 
    10931093          } 
    1094            
     1094 
    10951095          return 
    10961096          '<object type="application/x-shockwave-flash" '. 
     
    11031103          '</object>'; 
    11041104     } 
    1105       
     1105 
    11061106     public static function flvplayer($url,$player=null,$args=null) 
    11071107     { 
     
    11091109               $player = 'player_flv.swf'; 
    11101110          } 
    1111            
     1111 
    11121112          if (!is_array($args)) 
    11131113          { 
     
    11231123               ); 
    11241124          } 
    1125            
     1125 
    11261126          $args['flv'] = $url; 
    1127            
     1127 
    11281128          if (empty($args['width'])) { 
    11291129               $args['width'] = 400; 
     
    11321132               $args['height'] = 300; 
    11331133          } 
    1134            
     1134 
    11351135          $vars = array(); 
    11361136          foreach ($args as $k => $v) { 
    11371137               $vars[] = $k.'='.$v; 
    11381138          } 
    1139            
     1139 
    11401140          return 
    11411141          '<object type="application/x-shockwave-flash" '. 
     
    11501150     } 
    11511151} 
    1152 ?> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map