Dotclear


Ignore:
Timestamp:
06/23/11 13:00:59 (14 years ago)
Author:
Dsls <dsls@…>
Branch:
default
Message:
  • Re-enabled blank post_type required by media.php in class dcBlog
  • Attachments are now handled by a plugins/attachments/_admin.php
  • Added core dcPostMedia multi-purpose class, and 'link_type' in post_media table
  • Added new behavior : tplIfConditions, to enable to add new attributes to tpl:XXXIf tags
  • Moved tpl:SysIf has_tag attribute to Tags plugin
File:
1 edited

Legend:

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

    r270 r407  
    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           
     
    494494     public function getPostMedia($post_id,$media_id=null) 
    495495     { 
    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            
     496          $params = array( 
     497               'post_id' => $post_id, 
     498               'media_path' => $this->path 
     499          ); 
    506500          if ($media_id) { 
    507                $strReq .= 'AND M.media_id = '.(integer) $media_id.' '; 
    508           } 
    509            
    510           $rs = $this->con->select($strReq); 
     501               $params['media_id'] = (integer) $media_id; 
     502          } 
     503          $rs = $this->postmedia->getPostMedia($params); 
    511504           
    512505          $res = array(); 
     
    523516      
    524517     /** 
    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 
     518     @deprecated since version 2.4 
     519     @see dcPostMedia::addPostMedia 
    529520     */ 
    530521     public function addPostMedia($post_id,$media_id) 
    531522     { 
    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 
     523          $this->postmedia->addPostMedia($post_id,$media_id); 
     524     } 
     525      
     526     /** 
     527     @deprecated since version 2.4 
     528     @see dcPostMedia::removePostMedia 
    554529     */ 
    555530     public function removePostMedia($post_id,$media_id) 
    556531     { 
    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(); 
     532          $this->postmedia->removePostMedia($post_id,$media_id,"attachment"); 
    566533     } 
    567534      
Note: See TracChangeset for help on using the changeset viewer.

Sites map