Changeset 415

Show
Ignore:
Timestamp:
08/20/08 05:45:56 (3 months ago)
Author:
082net
Message:

## media-filter ##

Applied JavaScript? replacer

Location:
media-filter/trunk
Files:
1 added
1 modified

Legend:

Unmodified
Added
Removed
  • media-filter/trunk/media-filter.php

    r94 r415  
    44Plugin URI: http://082net.com/tag/media-filter 
    55Description: 글 작성시 동영상 삽입을 쉽게 할 수있도록 도와주는 플러그인 입니다. GoogleVideo, YouTube, Mncast, Daum(tvpot) 등의 FLV 동영상을 지원하며, 일반적인 동영상(wmv, mov, swf 등)의 삽입도 지원합니다. 이 플러그인은 <a href="http://www.coolcode.cn/?p=100">coolplayer</a> v3.5 에 기반을 두고 있습니다. 자세한 사용법은 플러그인페이지를 참고하세요. 
    6 Version: 0.2 
     6Version: 0.3 
    77Author: Cheon, Yong-Min 
    88Author URI: http://082net.com/ 
     
    2020        // START Options 
    2121 
     22        var $version = '0.3'; 
     23        var $base, $baseurl; 
    2224        var $width = 320;        // 플레이어 너비 기본값 
    2325        var $height = 280;      // 플레이어 높이 기본값 
     
    2628 
    2729        // END Options 
    28         var $preset = array('d1', 'd2', 'd3', 'd4', 'gv', 'yt', 'yt2', 'mnc'); 
     30        var $preset = array('d1', 'd2', 'd3', 'd4', 'gv', 'yt', 'yt2', 'mnc', 'tagstory',); 
    2931        var $pre_url = array( 
    3032                'd1' => 'http://controller.tvpot.media.daum.net/mflvPlayer.swf?vid=', 
     
    3537                'yt' => 'http://www.youtube.com/v/', 
    3638                'yt2' => 'http://www.youtube.com/?v=', 
    37                 'mnc' =>'http://dory.mncast.com/mncHMovie.swf?movieID=' 
     39                'mnc' =>'http://dory.mncast.com/mncHMovie.swf?movieID=', 
     40                'tagstory' => 'http://play.tagstory.com/player/TS00@', 
    3841        ); 
    3942 
     
    4144                // change below line for default media URL (No trailing slash) 
    4245                $this->base = get_option('siteurl') . "/wp-content/uploads/media"; 
    43  
    44                 add_filter('the_content', array(&$this, '_filter'), 0); 
    45                 add_filter('the_excerpt', array(&$this, '_filter'), 0); 
     46                $this->baseurl = get_option('siteurl') . '/wp-content/plugins/'.dirname(plugin_basename(__FILE__)); 
     47                $this->preset = array_keys($this->pre_url); 
    4648        } 
    4749 
    4850        function _filter($content) { 
    4951                if($this->use_html_tag) 
    50                         $content = preg_replace('#<act(.*?)>(.*?)</act>#sie', '$this->get_script(\'$2\', \'$1\');', $content); 
    51                 $content = preg_replace('#\[act(.*?)\](.*?)\[/act\]#sie', '$this->get_script(\'$2\', \'$1\');', $content); 
     52                        $content = preg_replace('#(<p>)?\s*<act(.*?)>(.*?)</act>\s*(</p>)#sie', '$this->get_script(\'$3\', \'$2\');', $content); 
     53                $content = preg_replace('#(<p>)?\s*\[act(.*?)\](.*?)\[/act\]\s*(</p>)#sie', '$this->get_script(\'$3\', \'$2\');', $content); 
    5254                return $content; 
    5355        } 
     
    6567                $type = ''; 
    6668                $wh = false; 
    67                 $result = "<p class=\"mediafilter\">"; 
     69                $myid = 'wpmf_'.rand(); 
     70                $result = "<p class=\"mediafilter\" id=\"{$myid}\">"; 
    6871                if(preg_match('/type="([^"]*)"/i', $options, $match)) {  
    6972                        $type = trim($match[1]); 
     
    106109                         } else { $autostart = $this->autostart; } 
    107110                } 
    108                 $result .= $this->_replace_movie($type, $url, $width, $height, $autostart); 
     111                $result .= $this->_replace_movie($myid, $type, $url, $width, $height, $autostart); 
    109112                $result .= "</p>"; 
    110113                return $result; 
    111114        } 
    112115 
    113         function _replace_movie($type, $url, $width='', $height='', $autostart='') { 
     116        function _js() { 
     117                wp_enqueue_script('media-filter', $this->baseurl.'/media-filter.js', false, $this->version); 
     118        } 
     119 
     120        function _replace_movie($myid, $type, $url, $width='', $height='', $autostart=0) { 
     121                $result = "<script type=\"text/javascript\"><!--\n"; 
     122                $result .= "\tvar _{$myid} = media_filter_js(\"$myid\", \"$type\", \"$url\", \"$width\", \"$height\", \"$autostart\");\n"; 
     123                $result .= "--></script>"; 
     124                $result .= 'Hello, maybe you have JavaScript turned off'; 
     125                return $result; 
     126        } 
     127 
     128        // deprecated 
     129        function __replace_movie($myid, $type, $url, $width='', $height='', $autostart='') { 
    114130                $result = ''; 
    115131                switch($type) { 
     
    174190        } 
    175191 
     192        function options() { 
     193                if(isset($_POST['mediafilter_options'])) { 
     194 
     195                } 
     196?> 
     197 
     198<?php 
     199        } 
     200 
     201        function option_page() { 
     202 
     203        } 
     204 
    176205        function &get_instance() { 
    177206                static $instance = array(); 
     
    184213 
    185214$wpMediaFilter =& WpMediaFilter::get_instance(); 
     215 
     216add_filter('the_content', array(&$wpMediaFilter, '_filter'), 30); 
     217add_filter('the_excerpt', array(&$wpMediaFilter, '_filter'), 30); 
     218add_action('wp_head', array(&$wpMediaFilter, '_js'), 1); 
    186219?>