Changeset 2566:9bf417837888 for inc/core/class.dc.postmedia.php
- Timestamp:
- 11/17/13 20:25:53 (12 years ago)
- Branch:
- 2.6
- Children:
- 2567:6c11245cbf04, 2568:61c67a7d17fa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/core/class.dc.postmedia.php
r1505 r2566 17 17 protected $con; ///< <b>connection</b> Database connection 18 18 protected $table; ///< <b>string</b> Post-Media table name 19 19 20 20 /** 21 21 Object constructor. 22 22 23 23 @param core <b>dcCore</b> dcCore instance 24 24 @param type <b>string</b> Media type filter … … 30 30 $this->table = $this->core->prefix.'post_media'; 31 31 } 32 32 33 33 /** 34 34 Returns media items attached to a blog post. Result is an array containing 35 35 fileItems objects. 36 36 37 37 @param post_id <b>integer</b> Post ID 38 38 @param media_id <b>integer</b> Optionnal media ID … … 44 44 'SELECT M.media_file, M.media_id, M.media_path, M.media_title, M.media_meta, M.media_dt, '. 45 45 'M.media_creadt, M.media_upddt, M.media_private, M.user_id, PM.post_id '; 46 46 47 47 if (!empty($params['columns']) && is_array($params['columns'])) { 48 48 $strReq .= implode(', ',$params['columns']).', '; 49 49 } 50 50 51 51 $strReq .= 52 52 'FROM '.$this->core->prefix.'media M '. 53 53 'INNER JOIN '.$this->table.' PM ON (M.media_id = PM.media_id) '; 54 54 55 55 if (!empty($params['from'])) { 56 56 $strReq .= $params['from'].' '; 57 57 } 58 58 59 59 $where=''; 60 60 if (isset($params['post_id'])) { … … 80 80 //echo $strReq; exit; 81 81 $rs = $this->con->select($strReq); 82 82 83 83 return $rs; 84 84 } … … 86 86 /** 87 87 Attaches a media to a post. 88 88 89 89 @param post_id <b>integer</b> Post ID 90 90 @param media_id <b>integer</b> Optionnal media ID … … 94 94 $post_id = (integer) $post_id; 95 95 $media_id = (integer) $media_id; 96 96 97 97 $f = $this->getPostMedia(array('post_id'=>$post_id,'media_id'=>$media_id,'link_type'=>$link_type)); 98 98 99 99 if (!$f->isEmpty()) { 100 100 return; 101 101 } 102 102 103 103 $cur = $this->con->openCursor($this->table); 104 104 $cur->post_id = $post_id; 105 105 $cur->media_id = $media_id; 106 106 $cur->link_type = $link_type; 107 107 108 108 $cur->insert(); 109 109 $this->core->blog->triggerBlog(); 110 110 } 111 111 112 112 /** 113 113 Detaches a media from a post. 114 114 115 115 @param post_id <b>integer</b> Post ID 116 116 @param media_id <b>integer</b> Optionnal media ID … … 120 120 $post_id = (integer) $post_id; 121 121 $media_id = (integer) $media_id; 122 122 123 123 $strReq = 'DELETE FROM '.$this->table.' '. 124 124 'WHERE post_id = '.$post_id.' '. … … 130 130 $this->core->blog->triggerBlog(); 131 131 } 132 132 133 133 /** 134 134 Returns media items attached to a blog post. Result is an array containing 135 135 fileItems objects. 136 136 137 137 @param post_id <b>integer</b> Post ID 138 138 @param media_id <b>integer</b> Optionnal media ID … … 142 142 { 143 143 $post_id = (integer) $post_id; 144 144 145 145 $strReq = 146 146 'SELECT media_file, M.media_id, media_path, media_title, media_meta, media_dt, '. … … 150 150 "WHERE media_path = '".$this->path."' ". 151 151 'AND post_id = '.$post_id.' '; 152 152 153 153 if ($media_id) { 154 154 $strReq .= 'AND M.media_id = '.(integer) $media_id.' '; 155 155 } 156 156 157 157 $rs = $this->con->select($strReq); 158 158 159 159 $res = array(); 160 160 161 161 while ($rs->fetch()) { 162 162 $f = $this->fileRecord($rs); … … 165 165 } 166 166 } 167 167 168 168 return $res; 169 169 } 170 170 171 171 } 172 ?>
Note: See TracChangeset
for help on using the changeset viewer.