Changeset 771:d6311bb1cfaa for inc/core/class.dc.media.php
- Timestamp:
- 11/19/11 14:44:40 (14 years ago)
- 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. - File:
-
- 1 edited
-
inc/core/class.dc.media.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
inc/core/class.dc.media.php
r397 r771 23 23 protected $con; ///< <b>connection</b> Database connection 24 24 protected $table; ///< <b>string</b> Media table name 25 protected $table_ref; ///< <b>string</b> Post-media relation table name26 25 protected $type; ///< <b>string</b> Media type filter 26 protected $postmedia; 27 27 protected $file_sort = 'name-asc'; 28 28 … … 57 57 $this->core =& $core; 58 58 $this->con =& $core->con; 59 $this->postmedia = new dcPostMedia($core); 59 60 60 61 if ($this->core->blog == null) { … … 63 64 64 65 $this->table = $this->core->prefix.'media'; 65 $this->table_ref = $this->core->prefix.'post_media';66 66 $root = $this->core->blog->public_path; 67 67 … … 175 175 176 176 @param href <b>string</b> URL pattern 177 @param last <b>string</b> Last item pattern 177 178 @return <b>string</b> HTML code 178 179 */ 179 public function breadCrumb($href )180 public function breadCrumb($href,$last='') 180 181 { 181 182 $res = ''; 182 183 if ($this->relpwd && $this->relpwd != '.') { 183 184 $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 } 187 194 } 188 195 } … … 494 501 public function getPostMedia($post_id,$media_id=null) 495 502 { 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 ); 506 507 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); 511 511 512 512 $res = array(); … … 523 523 524 524 /** 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 529 527 */ 530 528 public function addPostMedia($post_id,$media_id) 531 529 { 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 554 536 */ 555 537 public function removePostMedia($post_id,$media_id) 556 538 { 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"); 566 540 } 567 541 … … 856 830 { 857 831 $zip = new fileUnzip($f->file); 832 $zip->setExcludePattern($this->exclude_pattern); 858 833 $zip->getList(false,'#(^|/)(__MACOSX|\.svn|\.DS_Store|\.directory|Thumbs\.db)(/|$)#'); 859 834
Note: See TracChangeset
for help on using the changeset viewer.
