Dotclear


Ignore:
Timestamp:
11/19/11 14:44:40 (14 years ago)
Author:
xave
Branch:
default
Parents:
769:da721122beb5 (diff), 397:11252593aecf (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Branch 2.3 is now closed.

File:
1 edited

Legend:

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

    r397 r771  
    2323     protected $con;          ///< <b>connection</b> Database connection 
    2424     protected $table;        ///< <b>string</b> Media table name 
    25      protected $table_ref;    ///< <b>string</b> Post-media relation table name 
    2625     protected $type;         ///< <b>string</b> Media type filter 
     26     protected $postmedia; 
    2727     protected $file_sort = 'name-asc'; 
    2828      
     
    5757          $this->core =& $core; 
    5858          $this->con =& $core->con; 
     59          $this->postmedia = new dcPostMedia($core); 
    5960           
    6061          if ($this->core->blog == null) { 
     
    6364           
    6465          $this->table = $this->core->prefix.'media'; 
    65           $this->table_ref = $this->core->prefix.'post_media'; 
    6666          $root = $this->core->blog->public_path; 
    6767           
     
    175175      
    176176     @param    href      <b>string</b>       URL pattern 
     177     @param    last      <b>string</b>       Last item pattern 
    177178     @return   <b>string</b> HTML code 
    178179     */ 
    179      public function breadCrumb($href) 
     180     public function breadCrumb($href,$last='') 
    180181     { 
    181182          $res = ''; 
    182183          if ($this->relpwd && $this->relpwd != '.') { 
    183184               $pwd = ''; 
    184                foreach (explode('/',$this->relpwd) as $v) { 
    185                     $pwd .= rawurlencode($v).'/'; 
    186                     $res .= '<a href="'.sprintf($href,$pwd).'">'.$v.'</a> / '; 
     185               $arr = explode('/',$this->relpwd); 
     186               $count = count($arr); 
     187               foreach ($arr as $v) { 
     188                    if (($last != '') && (0 === --$count)) { 
     189                         $res .= sprintf($last,$v); 
     190                    } else { 
     191                         $pwd .= rawurlencode($v).'/'; 
     192                         $res .= '<a href="'.sprintf($href,$pwd).'">'.$v.'</a> / '; 
     193                    } 
    187194               } 
    188195          } 
     
    494501     public function getPostMedia($post_id,$media_id=null) 
    495502     { 
    496           $post_id = (integer) $post_id; 
    497            
    498           $strReq = 
    499           'SELECT media_file, M.media_id, media_path, media_title, media_meta, media_dt, '. 
    500           'media_creadt, media_upddt, media_private, user_id '. 
    501           'FROM '.$this->table.' M '. 
    502           'INNER JOIN '.$this->table_ref.' PM ON (M.media_id = PM.media_id) '. 
    503           "WHERE media_path = '".$this->path."' ". 
    504           'AND post_id = '.$post_id.' '; 
    505            
     503          $params = array( 
     504               'post_id' => $post_id, 
     505               'media_path' => $this->path 
     506          ); 
    506507          if ($media_id) { 
    507                $strReq .= 'AND M.media_id = '.(integer) $media_id.' '; 
    508           } 
    509            
    510           $rs = $this->con->select($strReq); 
     508               $params['media_id'] = (integer) $media_id; 
     509          } 
     510          $rs = $this->postmedia->getPostMedia($params); 
    511511           
    512512          $res = array(); 
     
    523523      
    524524     /** 
    525      Attaches a media to a post. 
    526       
    527      @param    post_id   <b>integer</b>      Post ID 
    528      @param    media_id  <b>integer</b>      Optionnal media ID 
     525     @deprecated since version 2.4 
     526     @see dcPostMedia::addPostMedia 
    529527     */ 
    530528     public function addPostMedia($post_id,$media_id) 
    531529     { 
    532           $post_id = (integer) $post_id; 
    533           $media_id = (integer) $media_id; 
    534            
    535           $f = $this->getPostMedia($post_id,$media_id); 
    536            
    537           if (!empty($f)) { 
    538                return; 
    539           } 
    540            
    541           $cur = $this->con->openCursor($this->table_ref); 
    542           $cur->post_id = $post_id; 
    543           $cur->media_id = $media_id; 
    544            
    545           $cur->insert(); 
    546           $this->core->blog->triggerBlog(); 
    547      } 
    548       
    549      /** 
    550      Detaches a media from a post. 
    551       
    552      @param    post_id   <b>integer</b>      Post ID 
    553      @param    media_id  <b>integer</b>      Optionnal media ID 
     530          $this->postmedia->addPostMedia($post_id,$media_id); 
     531     } 
     532      
     533     /** 
     534     @deprecated since version 2.4 
     535     @see dcPostMedia::removePostMedia 
    554536     */ 
    555537     public function removePostMedia($post_id,$media_id) 
    556538     { 
    557           $post_id = (integer) $post_id; 
    558           $media_id = (integer) $media_id; 
    559            
    560           $strReq = 'DELETE FROM '.$this->table_ref.' '. 
    561                     'WHERE post_id = '.$post_id.' '. 
    562                     'AND media_id = '.$media_id.' '; 
    563            
    564           $this->con->execute($strReq); 
    565           $this->core->blog->triggerBlog(); 
     539          $this->postmedia->removePostMedia($post_id,$media_id,"attachment"); 
    566540     } 
    567541      
     
    856830     { 
    857831          $zip = new fileUnzip($f->file); 
     832          $zip->setExcludePattern($this->exclude_pattern); 
    858833          $zip->getList(false,'#(^|/)(__MACOSX|\.svn|\.DS_Store|\.directory|Thumbs\.db)(/|$)#'); 
    859834           
Note: See TracChangeset for help on using the changeset viewer.

Sites map