메뉴 건너뛰기

xe 멀티미디어 추가하기 및 youtube 풀사이즈 자동 재생하기 modules/editor/components/multimedia_link

Average Rating:
 0명 참여
Rate this page:
평점 한줄평 글쓴이 작성날짜

modules/editor/components/multimedia_link/mutimedia_link.class.php (xe 1.7.3.4 전문)


<?php
/**
 * @class  multimedia_link
 * @author NHN (developers@xpressengine.com)
 * @brief The components connected to the body of multimedia data
 */
class multimedia_link extends EditorHandler
{
 // editor_sequence from the editor must attend mandatory wearing ....
 var $editor_sequence = 0;
 var $component_path = '';

 /**
  * @brief editor_sequence and components out of the path
  */
 function multimedia_link($editor_sequence, $component_path)
 {
  $this->editor_sequence = $editor_sequence;
  $this->component_path = $component_path;
 }

 /**
  * @brief popup window to display in popup window request is to add content
  */
 function getPopupContent()
 {
  // Pre-compiled source code to compile template return to
  $tpl_path = $this->component_path.'tpl';
  $tpl_file = 'popup.html';

  Context::set("tpl_path", $tpl_path);

  $oTemplate = &TemplateHandler::getInstance();
  return $oTemplate->compile($tpl_path, $tpl_file);
 }

 /**
  * @brief Editor of the components separately if you use a unique code to the html code for a method to change
  *
  * Images and multimedia, seolmundeung unique code is required for the editor component added to its own code, and then
  * DocumentModule:: transContent() of its components transHtml() method call to change the html code for your own
  */
 function transHTML($xml_obj)
 {
  $src = $xml_obj->attrs->multimedia_src;
  $style = $xml_obj->attrs->style;

  preg_match_all('/(width|height)([^[:digit:]]+)([0-9]+)/i',$style,$matches);
  $width = trim($matches[3][0]);
  $height = trim($matches[3][1]);
  
  //높이와 너비를 지정해줌
  if(!$width) $width = 890;
  if(!$height) $height = 530;

  $auto_start = $xml_obj->attrs->auto_start;
  
  if($auto_start!="true")
  {
   $auto_start = "false";
   //youtube 자동재생 옵션
   $auto_option = "autoplay=0";
  }
  else
  {
   $auto_start = "true";
   $auto_option = "autoplay=1";
  }
   

  $wmode = $xml_obj->attrs->wmode;
  if($wmode == 'window') $wmode = 'window';
  else if($wmode == 'opaque') $wmode = 'opaque';
  else $wmode = 'transparent';


  $caption = $xml_obj->body;

  $src = str_replace(array('&','"'), array('&amp;','&qout;'), $src);
  $src = str_replace('&amp;amp;', '&amp;', $src);

  /*if(Context::getResponseMethod() != "XMLRPC") return sprintf("<script type=\"text/javascript\">displayMultimedia(\"%s\", \"%s\",\"%s\", { \"autostart\" : %s, \"wmode\" : \"%s\" });</script>", $src, $width, $height, $auto_start, $wmode);
  else return sprintf("<div style=\"width: %dpx; height: %dpx;\"><span style=\"position:relative; top:%dpx;left:%d\"><img src=\"%s\" /><br />Attached Multimedia</span></div>", $width, $height, ($height/2-16), ($width/2-31), Context::getRequestUri().'./modules/editor/components/multimedia_link/tpl/multimedia_link_component.gif');*/
  
  if(preg_match_all('/(youtube\.com\/watch\?v\=|youtube\.com\/v\/|youtu\.be\/|youtube\.com\/embed\/)(.*)/i',$src,$matches)) {
    $youtube_id = substr($matches[2][0], 0, 11);
    //유투브 주소 변경 youtube_id, youtube_srl
    //$youtube_id = str_replace("http://youtu.be/", "", $src);
    //$youtube_id = str_replace("http://www.youtube.com/watch?v=", "", $src);
    //$youtube_id = str_replace("http://www.youtube.com/embed/", "", $src);
    //$youtube_srl = "http://www.youtube.com/v/".$youtube_id;
    $youtube_srl = "http://www.youtube.com/embed/".$youtube_id;
    //http://www.youtube.com/embed/CpqBGbZDotw
       
    return sprintf("<center>
<iframe width=\"%s\" height=\"%s\" src=%s?rel=0&vq=hd1080&%s frameborder=\"0\" allowfullscreen></iframe>
</center>", $width, $height, $youtube_srl, $auto_option);
    
    //return sprintf("<center><object height=\"%s\" width=\"%s\"><param name=\"movie\" value=\"%s?version=3&amp;hl=ko_KR\" /><param name=\"allowFullScreen\" value=\"true\" /><param name=\"allowscriptaccess\" value=\"always\" /><embed allowfullscreen=\"true\" allowscriptaccess=\"always\" height=\"%s\" src=\"%s?version=3&amp;hl=ko_KR&amp;rel=0%s\" type=\"application/x-shockwave-flash\" width=\"%s\"></embed></object></center>", $height, $width,  $youtube_srl, $height, $youtube_srl, $auto_option,$width);
  }
   
   /*elseif(Context::getResponseMethod() != "XMLRPC"){
     return sprintf("zzzzzzz<script type=\"text/javascript\" src=\"%sjwplayer.js\"></script><div id=\"%s\">Loading the player ...</div><script type=\"text/javascript\">jwplayer(\"%s\").setup({flashplayer: \"%splayer.swf\",file: \"%s\", width: %s, height: %s, autostart: %s, plugins:{\"hd-2\":{state : \"true\"}}});</script>", $this->component_path, $src, $src, $this->component_path, $src, $width, $height, $auto_start, $this->component_path);
   }*/
  elseif(Context::getResponseMethod() != "XMLRPC"){
   return sprintf("<script type=\"text/javascript\">displayMultimedia(\"%s\", \"%s\",\"%s\", { \"autostart\" : %s, \"wmode\" : \"%s\" });</script>", $src, $width + 6 , $height + 8 , $auto_start, $wmode);
  }

  else return sprintf("<div style=\"width: %dpx; height: %dpx;\"><span style=\"position:relative; top:%dpx;left:%d\"><img src=\"%s\" /><br />Attached Multimedia</span></div>", $width, $height, ($height/2-16), ($width/2-31), Context::getRequestUri().'./modules/editor/components/multimedia_link/tpl/multimedia_link_component.gif');
  
 }
}
/* End of file multimedia_link.class.php */
/* Location: ./modules/editor/components/multimedia_link/multimedia_link.class.php */

 

 

modules/editor/components/multimedia_link/tpl/popup.html (xe 1.7.3.4 전문)

 

<!--%import("../lang")-->
<!--@if(__DEBUG__)-->
 <load target="popup.css" />
 <load target="popup.js" />
<!--@else-->
 <load target="popup.min.css" />
 <load target="popup.min.js" />
<!--@end-->
<section class="section">
 <h1>{$component_info->title} ver. {$component_info->version}</h1>
 <form action="./" method="get" onsubmit="return false" id="fo" class="x_form-horizontal">
  <div class="x_control-group">
   <label for="" class="x_control-label">{$lang->multimedia_url}</label>
   <div class="x_controls">
    <input type="text" id="multimedia_url" value="{$manual_url}" style="width:98%"/>
                 <div style="margin-top:5px;">예) http://www.youtube.com/embed/CpqBGbZDotw <br/>위와 같이 주소를 붙여넣기 하세요.</div>
   </div>
  </div>
  <div class="x_control-group">
   <label for="" class="x_control-label">{$lang->multimedia_caption}</label>
   <div class="x_controls">
    <input type="text" id="multimedia_caption" value="" />
   </div>
  </div>
  <div class="x_control-group">
   <label for="" class="x_control-label">{$lang->multimedia_width}</label>
   <div class="x_controls">
             <input type="text"  size="3" id="multimedia_width" value="890" />px<span class="btn" style="margin-left:20px;"><button type="button" onclick="multimedia_width.value='890', multimedia_height.value='530'">최적값 입력</button></span>
   </div>
  </div>
  <div class="x_control-group">
   <label for="" class="x_control-label">{$lang->multimedia_height}</label>
   <div class="x_controls">
    <input type="text"  size="3" id="multimedia_height" value="530" /> px
   </div>
  </div>
  <div class="x_control-group">
   <label for="" class="x_control-label">{$lang->multimedia_auto_start}</label>
   <div class="x_controls">
    <input type="checkbox" id="multimedia_auto_start" value="Y" checked="checked" />
   </div>
  </div>
  <div class="x_control-group">
   <label for="" class="x_control-label">{$lang->multimedia_wmode}</label>
   <div class="x_controls">
    <select id="multimedia_wmode">
     <option value="window">{$lang->multimedia_wmode_window}</option>
     <option value="opaque">{$lang->multimedia_wmode_opaque}</option>
     <option value="transparent" selected="selected">{$lang->multimedia_wmode_transparent}</option>
    </select>
    <p>{$lang->about_ccl_allow_modification}</p>
   </div>
  </div>
  <div class="x_clearfix btnArea">
   <div class="x_pull-right">
    <button type="button" id="btn_insert" class="x_btn x_btn-primary">{$lang->cmd_insert}</button>
    <a class="x_btn" href="{getUrl('','module','editor','act','dispEditorComponentInfo','component_name',$component_info->component_name)}" target="_blank" onclick="window.open(this.href,'ComponentInfo','width=10,height=10');return false;">{$lang->about_component}</a>
   </div>
  </div>
 </form>
</section>

 


modules/editor/components/multimedia_link/tpl/popup.js (xe 1.7.3.4 전문)

 

/**
 * popup으로 열렸을 경우 부모창의 위지윅에디터에 select된 멀티미디어 컴포넌트 코드를 체크하여
 * 있으면 가져와서 원하는 곳에 삽입
 **/
jQuery(function($){

(function(){
 if(!is_def(opener)) return;

 var $node = $(opener.editorPrevNode).filter('img'), attrs;
 if(!$node.length) return;

 attrs = {
  url     : $node.attr('multimedia_src') || null,
  caption : $node.attr('alt') || null,
  width   : $node.width() || 890,
  height  : $node.height() || 530,
  wmode   : $node.attr('wmode') || null
 };

 $.each(attrs, function(key, val) {
  get_by_id('multimedia_'+key).value = val;
 });

 // auto start?
 get_by_id('multimedia_auto_start').checked = ($node.attr('auto_start') == 'true');

})();

$('.btnArea button').click(function(){
 if(!is_def(opener)) return;

 var el_wmode = get_by_id('fo').elements['multimedia_wmode'];
 var attrs = {
  alt    : encodeURIComponent(get_by_id('multimedia_caption').value),
  width  : get_by_id('multimedia_width').value || 890,
  height : get_by_id('multimedia_height').value || 530,
  wmode  : el_wmode.value || el_wmode.options[0].value,
  auto_start : get_by_id('multimedia_auto_start').checked?'true':'false',
  multimedia_src : get_by_id('multimedia_url').value.replace(request_uri, '')
 };

 if(!attrs['multimedia_src']) {
   window.close();
   return;
 }

 var $selected_node = $(opener.editorPrevNode);
 if($selected_node.is('img') && $selected_node.attr('editor_component') == 'multimedia_link'){
  $selected_node
   .attr('multimedia_src', attrs.multimedia_src)
   .attr('width', attrs.width)
   .attr('height', attrs.height)
   .attr('wmode', attrs.wmode)
   .attr('auto_start', attrs.auto_start)
   .attr('alt', attrs.alt)
   .css('width', attrs.width + 'px')
   .css('height', attrs.height + 'px')
 }else{
  var html = '<img src="../../../../common/img/blank.gif" editor_component="multimedia_link" multimedia_src="" width="" height="" wmode="" style="display:block;width:'+attrs.width+'px;height:'+attrs.height+'px;border:2px dotted #4371B9;background:url(./modules/editor/components/multimedia_link/tpl/multimedia_link_component.gif) no-repeat center" auto_start="" alt="" />';

  html = html.replace(/(\w+)=""/g, function(m0,m1) {
   return attrs[m1] ? (m1+'="'+attrs[m1]+'"') : '';
  });

  opener.editorFocus(opener.editorPrevSrl);

  var iframe_obj = opener.editorGetIFrame(opener.editorPrevSrl)

  opener.editorReplaceHTML(iframe_obj, html);
 }
 opener.editorFocus(opener.editorPrevSrl);

 window.close();
});

});


제목 날짜
Star Rating 별점 위젯 업데이트 정보   2014.03.09
Bootstrap Menu templetes   file
    9
Font Awesome   file
    9
플레시 메뉴 layout 원본  
    8
태그 목록