Changeset 3167:9b0e5988c0eb
- Timestamp:
- 02/11/16 15:35:39 (9 years ago)
- Branch:
- default
- Files:
-
- 4 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/media.php
r3165 r3167 31 31 $dir = null; 32 32 33 // Attachement type if any 34 $link_type = !empty($_REQUEST['link_type']) ? $_REQUEST['link_type'] : null; 35 33 36 $page = !empty($_GET['page']) ? max(1,(integer) $_GET['page']) : 1; 34 37 $nb_per_page = ((integer) $core->auth->user_prefs->interface->media_by_page ? (integer) $core->auth->user_prefs->interface->media_by_page : 30); … … 85 88 $select = !empty($_REQUEST['select']) ? (integer)$_REQUEST['select'] : 0; // 0 : none, 1 : single media, >1 : multiple medias 86 89 87 $page_url_params = new ArrayObject(array('popup' => $popup,'select' => $select,'post_id' => $post_id ));90 $page_url_params = new ArrayObject(array('popup' => $popup,'select' => $select,'post_id' => $post_id,'link_type' => $link_type)); 88 91 if ($d) { 89 92 $page_url_params['d'] = $d; … … 774 777 function mediaItemLine($f,$i,$query,$table=false) 775 778 { 776 global $core, $page_url, $popup, $select, $post_id, $plugin_id, $page_url_params ;779 global $core, $page_url, $popup, $select, $post_id, $plugin_id, $page_url_params, $link_type; 777 780 778 781 $fname = $f->basename; … … 830 833 $act .= 831 834 '<a class="attach-media" title="'.__('Attach this file to entry').'" href="'. 832 $core->adminurl->get("admin.post.media", array('media_id' => $f->media_id, 'post_id' => $post_id,'attach' => 1)). 835 $core->adminurl->get("admin.post.media", 836 array('media_id' => $f->media_id, 'post_id' => $post_id,'attach' => 1,'link_type' => $link_type)). 833 837 '">'. 834 838 '<img src="images/plus.png" alt="'.__('Attach this file to entry').'"/>'. -
admin/media_item.php
r3154 r3167 27 27 } 28 28 29 // Attachement type if any 30 $link_type = !empty($_REQUEST['link_type']) ? $_REQUEST['link_type'] : null; 31 29 32 $file = null; 30 33 $popup = (integer) !empty($_REQUEST['popup']); … … 32 35 $plugin_id = isset($_REQUEST['plugin_id']) ? html::sanitizeURL($_REQUEST['plugin_id']) : ''; 33 36 $page_url_params = array('popup' => $popup,'select' => $select,'post_id' => $post_id); 34 $media_page_url_params = array('popup' => $popup,'select' => $select,'post_id' => $post_id );37 $media_page_url_params = array('popup' => $popup,'select' => $select,'post_id' => $post_id,'link_type' => $link_type); 35 38 36 39 if ($plugin_id != '') { -
admin/post_media.php
r2720 r3167 17 17 $post_id = !empty($_REQUEST['post_id']) ? (integer) $_REQUEST['post_id'] : null; 18 18 $media_id = !empty($_REQUEST['media_id']) ? (integer) $_REQUEST['media_id'] : null; 19 $link_type = !empty($_REQUEST['link_type']) ? $_REQUEST['link_type'] : null; 19 20 20 21 if (!$post_id) { … … 30 31 { 31 32 $core->media = new dcMedia($core); 32 $core->media->addPostMedia($post_id,$media_id );33 $core->media->addPostMedia($post_id,$media_id,$link_type); 33 34 if (!empty($_SERVER['HTTP_X_REQUESTED_WITH'])) { 34 35 header('Content-type: application/json'); … … 41 42 42 43 $core->media = new dcMedia($core); 43 $f = $core->media->getPostMedia($post_id,$media_id );44 $f = $core->media->getPostMedia($post_id,$media_id,$link_type); 44 45 if (empty($f)) { 45 46 $post_id = $media_id = null; … … 56 57 if (!empty($_POST['remove'])) 57 58 { 58 $core->media->removePostMedia($post_id,$media_id );59 $core->media->removePostMedia($post_id,$media_id,$link_type); 59 60 60 61 dcPage::addSuccessNotice(__('Attachment has been successfully removed.')); -
inc/core/class.dc.media.php
r3138 r3167 573 573 fileItems objects. 574 574 575 @param post_id <b>integer</b> Post ID575 @param post_id <b>integer</b> Post ID 576 576 @param media_id <b>integer</b> Optionnal media ID 577 @param link_type <b>string</b> Optionnal link type 577 578 @return <b>array</b> Array of fileItems 578 579 */ 579 public function getPostMedia($post_id,$media_id=null )580 public function getPostMedia($post_id,$media_id=null,$link_type=null) 580 581 { 581 582 $params = array( … … 586 587 $params['media_id'] = (integer) $media_id; 587 588 } 589 if ($link_type) { 590 $params['link_type'] = $link_type; 591 } 588 592 $rs = $this->postmedia->getPostMedia($params); 589 593 … … 604 608 @see dcPostMedia::addPostMedia 605 609 */ 606 public function addPostMedia($post_id,$media_id )607 { 608 $this->postmedia->addPostMedia($post_id,$media_id );610 public function addPostMedia($post_id,$media_id,$link_type='attachment') 611 { 612 $this->postmedia->addPostMedia($post_id,$media_id,$link_type); 609 613 } 610 614 … … 613 617 @see dcPostMedia::removePostMedia 614 618 */ 615 public function removePostMedia($post_id,$media_id )616 { 617 $this->postmedia->removePostMedia($post_id,$media_id, "attachment");619 public function removePostMedia($post_id,$media_id,$link_type='attachment') 620 { 621 $this->postmedia->removePostMedia($post_id,$media_id,$link_type); 618 622 } 619 623 -
inc/core/class.dc.postmedia.php
r2566 r3167 78 78 $strReq .= $params['sql']; 79 79 } 80 //echo $strReq; exit; 80 81 81 $rs = $this->con->select($strReq); 82 82 … … 87 87 Attaches a media to a post. 88 88 89 @param post_id <b>integer</b> Post ID89 @param post_id <b>integer</b> Post ID 90 90 @param media_id <b>integer</b> Optionnal media ID 91 @param link_type <b>string</b> Optionnal link type (default: attachment) 91 92 */ 92 93 public function addPostMedia($post_id,$media_id,$link_type='attachment') … … 113 114 Detaches a media from a post. 114 115 115 @param post_id <b>integer</b> Post ID116 @param post_id <b>integer</b> Post ID 116 117 @param media_id <b>integer</b> Optionnal media ID 118 @param link_type <b>string</b> Optionnal link type 117 119 */ 118 120 public function removePostMedia($post_id,$media_id,$link_type=null) -
inc/core/class.dc.rs.extensions.php
r3106 r3167 447 447 @return <b>integer</b> 448 448 */ 449 public static function countMedia($rs )449 public static function countMedia($rs,$link_type=null) 450 450 { 451 451 if (isset($rs->_nb_media[$rs->index()])) … … 459 459 'FROM '.$rs->core->prefix.'post_media '. 460 460 'WHERE post_id = '.(integer) $rs->post_id.' '; 461 if ($link_type != null) { 462 $strReq .= "AND link_type = '".$rs->core->con->escape($link_type)."'"; 463 } 461 464 462 465 $res = (integer) $rs->core->con->select($strReq)->f(0); -
inc/public/default-templates/currywurst/_entry-content.html
r2938 r3167 46 46 </tpl:AttachmentsHeader> 47 47 <li class="post-attachments-item {{tpl:AttachmentType}}"> 48 <tpl:AttachmentIf is_ mp3="1">49 {{tpl:include src="_ mp3_player.html"}} -48 <tpl:AttachmentIf is_audio="1"> 49 {{tpl:include src="_audio_player.html"}} 50 50 </tpl:AttachmentIf> 51 <tpl:AttachmentIf is_flv="1"> 52 {{tpl:include src="_flv_player.html"}} 51 <tpl:AttachmentIf is_video="1"> 52 <tpl:AttachmentIf is_flv="0"> 53 {{tpl:include src="_video_player.html"}} 54 {{tpl:else}} 55 {{tpl:include src="_flv_player.html"}} 56 </tpl:AttachmentIf> 53 57 </tpl:AttachmentIf> 54 <tpl:AttachmentIf is_ flv="0">58 <tpl:AttachmentIf is_video="0" is_audio="0"> 55 59 <a href="{{tpl:AttachmentURL}}" 56 60 title="{{tpl:AttachmentFileName}} ({{tpl:AttachmentSize}})">{{tpl:AttachmentTitle}}</a> -
inc/public/default-templates/mustek/post.html
r3017 r3167 100 100 </tpl:AttachmentsHeader> 101 101 <li class="{{tpl:AttachmentType}}"> 102 <tpl:AttachmentIf is_ mp3="1">103 {{tpl:include src="_ mp3_player.html"}} -102 <tpl:AttachmentIf is_audio="1"> 103 {{tpl:include src="_audio_player.html"}} 104 104 </tpl:AttachmentIf> 105 <tpl:AttachmentIf is_flv="1"> 106 {{tpl:include src="_flv_player.html"}} 107 </tpl:AttachmentIf> 108 <tpl:AttachmentIf is_flv="0"> 105 <tpl:AttachmentIf is_video="1"> 106 <tpl:AttachmentIf is_flv="0"> 107 {{tpl:include src="_video_player.html"}} 108 {{tpl:else}} 109 {{tpl:include src="_flv_player.html"}} 110 </tpl:AttachmentIf> 111 </tpl:AttachmentIf> 112 <tpl:AttachmentIf is_audio="0" is_video="0"> 109 113 <a href="{{tpl:AttachmentURL}}" 110 114 title="{{tpl:AttachmentFileName}} ({{tpl:AttachmentSize}})">{{tpl:AttachmentTitle}}</a> -
plugins/attachments/_admin.php
r3021 r3167 46 46 { 47 47 $core =& $GLOBALS['core']; 48 $post_media = $core->media->getPostMedia($post->post_id );48 $post_media = $core->media->getPostMedia($post->post_id,null,'attachment'); 49 49 $nb_media = count($post_media); 50 50 $title = !$nb_media ? __('Attachments') : sprintf(__('Attachments (%d)'),$nb_media); … … 71 71 'post_id' => $post->post_id, 72 72 'media_id' => $f->media_id, 73 'link_type' => 'attachment', 73 74 'remove' => '1' 74 75 )).'">'. … … 85 86 } 86 87 $item .= 87 '<p class="s-attachments"><a class="button" href="'.$core->adminurl->get('admin.media',array('post_id' => $post->post_id )).'">'.88 '<p class="s-attachments"><a class="button" href="'.$core->adminurl->get('admin.media',array('post_id' => $post->post_id, 'link_type' => 'attachment')).'">'. 88 89 __('Add files to this entry').'</a></p>'; 89 90 $sidebar['metas-box']['items']['attachments']= $item; … … 99 100 '<div>'.form::hidden(array('post_id'),$post->post_id). 100 101 form::hidden(array('media_id'),''). 102 form::hidden(array('link_type'),'attachment'). 101 103 form::hidden(array('remove'),1). 102 104 $core->formNonce().'</div></form>'; -
plugins/attachments/_public.php
r2832 r3167 40 40 "<?php\n". 41 41 'if ($_ctx->posts !== null && $core->media) {'."\n". 42 '$_ctx->attachments = new ArrayObject($core->media->getPostMedia($_ctx->posts->post_id ));'."\n".42 '$_ctx->attachments = new ArrayObject($core->media->getPostMedia($_ctx->posts->post_id,null,"attachment"));'."\n". 43 43 "?>\n". 44 44 … … 83 83 is_mp3 (0|1) #IMPLIED -- test if attachment is a mp3 file (value : 1) or not (value : 0) 84 84 is_flv (0|1) #IMPLIED -- test if attachment is a flv file (value : 1) or not (value : 0) 85 is_audio (0|1) #IMPLIED -- test if attachment is an audio file (value : 1) or not (value : 0) 86 is_video (0|1) #IMPLIED -- test if attachment is a video file (value : 1) or not (value : 0) 85 87 > 86 88 */ … … 107 109 108 110 if (isset($attr['is_flv'])) { 109 $sign = (boolean) $attr['is_flv'] ? '' : '!'; 110 $if[] = $sign. 111 '($attach_f->type == "video/x-flv" || '. 112 '$attach_f->type == "video/mp4" || '. 113 '$attach_f->type == "video/x-m4v")'; 111 $sign = (boolean) $attr['is_flv'] ? '==' : '!='; 112 $if[] = '$attach_f->type '.$sign.' "video/x-flv"'; 113 } 114 115 if (isset($attr['is_audio'])) { 116 $sign = (boolean) $attr['is_audio'] ? '==' : '!='; 117 $if[] = '$attach_f->type_prefix '.$sign.' "audio"'; 118 } 119 120 if (isset($attr['is_video'])) { 121 $sign = (boolean) $attr['is_video'] ? '==' : '!='; 122 $if[] = '$attach_f->type_prefix '.$sign.' "video"'; 114 123 } 115 124 … … 213 222 global $core; 214 223 return $core->tpl->displayCounter( 215 '$_ctx->posts->countMedia( )',224 '$_ctx->posts->countMedia(\'attachment\')', 216 225 array( 217 226 'none' => 'no attachments', … … 231 240 if ($tag == "EntryIf" && isset($attr['has_attachment'])) { 232 241 $sign = (boolean) $attr['has_attachment'] ? '' : '!'; 233 $if[] = $sign.'$_ctx->posts->countMedia( )';242 $if[] = $sign.'$_ctx->posts->countMedia(\'attachment\')'; 234 243 } 235 244 } -
plugins/pages/default-templates/mustek/page.html
r3017 r3167 37 37 </tpl:AttachmentsHeader> 38 38 <li class="{{tpl:AttachmentType}}"> 39 <tpl:AttachmentIf is_mp3="1"> 40 {{tpl:include src="_mp3_player.html"}} - 41 </tpl:AttachmentIf> 42 <tpl:AttachmentIf is_flv="1"> 43 {{tpl:include src="_flv_player.html"}} 44 </tpl:AttachmentIf> 45 <tpl:AttachmentIf is_flv="0"> 39 <tpl:AttachmentIf is_audio="1"> 40 {{tpl:include src="_audio_player.html"}} 41 </tpl:AttachmentIf> 42 <tpl:AttachmentIf is_video="1"> 43 <tpl:AttachmentIf is_flv="0"> 44 {{tpl:include src="_video_player.html"}} 45 {{tpl:else}} 46 {{tpl:include src="_flv_player.html"}} 47 </tpl:AttachmentIf> 48 </tpl:AttachmentIf> 49 <tpl:AttachmentIf is_audio="0" is_video="0"> 46 50 <a href="{{tpl:AttachmentURL}}" 47 title="{{tpl:AttachmentFileName}} ({{tpl:AttachmentSize}})">{{tpl:AttachmentTitle}}</a>48 </tpl:AttachmentIf>51 title="{{tpl:AttachmentFileName}} ({{tpl:AttachmentSize}})">{{tpl:AttachmentTitle}}</a> 52 </tpl:AttachmentIf> 49 53 </li> 50 54 <tpl:AttachmentsFooter>
Note: See TracChangeset
for help on using the changeset viewer.