Index: trunk/extensions/EmbedVideo/EmbedVideo.php |
— | — | @@ -9,12 +9,12 @@ |
10 | 10 | */ |
11 | 11 | |
12 | 12 | # Confirm MW environment |
13 | | -if ( !defined( 'MEDIAWIKI' ) ) { |
14 | | - echo <<<EOT |
| 13 | +if (!defined('MEDIAWIKI')) { |
| 14 | + echo <<<EOT |
15 | 15 | To install EmbedVideo, put the following line in LocalSettings.php: |
16 | | -require_once( "\$IP/extensions/EmbedVideo/EmbedVido.php" ); |
| 16 | +require_once( "\$IP/extensions/EmbedVideo/EmbedVideo.php" ); |
17 | 17 | EOT; |
18 | | - exit( 1 ); |
| 18 | + exit( 1 ); |
19 | 19 | } |
20 | 20 | |
21 | 21 | # Credits |
— | — | @@ -27,11 +27,20 @@ |
28 | 28 | 'version' => '1.0' |
29 | 29 | ); |
30 | 30 | |
31 | | -$dir = dirname( __FILE__ ) . '/'; |
32 | | -require_once( $dir . "EmbedVideo.hooks.php" ); |
33 | | -require_once( $dir . "EmbedVideo.Services.php" ); |
| 31 | +$dir = dirname(__FILE__) . '/'; |
| 32 | +require_once($dir . "EmbedVideo.hooks.php"); |
| 33 | +require_once($dir . "EmbedVideo.Services.php"); |
34 | 34 | $wgExtensionMessagesFiles['embedvideo'] = $dir . 'EmbedVideo.i18n.php'; |
35 | 35 | |
| 36 | + |
36 | 37 | $wgHooks['ParserFirstCallInit'][] = "EmbedVideo::setup"; |
37 | | -$wgHooks['LanguageGetMagic'][] = 'EmbedVideo::parserFunctionMagic'; |
38 | | - |
| 38 | +if (version_compare($wgVersion, '1.7', '<')) { |
| 39 | + # Hack solution to resolve 1.6 array parameter nullification for hook args |
| 40 | + function wfEmbedVideoLanguageGetMagic( &$magicWords ) { |
| 41 | + EmbedVideo::parserFunctionMagic( $magicWords ); |
| 42 | + return true; |
| 43 | + } |
| 44 | + $wgHooks['LanguageGetMagic'][] = 'wfEmbedVideoLanguageGetMagic'; |
| 45 | +} else { |
| 46 | + $wgHooks['LanguageGetMagic'][] = 'EmbedVideo::parserFunctionMagic'; |
| 47 | +} |
Index: trunk/extensions/EmbedVideo/EmbedVideo.Services.php |
— | — | @@ -7,57 +7,80 @@ |
8 | 8 | |
9 | 9 | # Build services list (may be augmented in LocalSettings.php) |
10 | 10 | $wgEmbedVideoServiceList = array( |
11 | | - 'dailymotion' => array( |
12 | | - 'url' => 'http://www.dailymotion.com/swf/$1' |
13 | | - ), |
14 | | - 'divshare' => array( |
15 | | - 'url' => 'http://www.divshare.com/flash/video2?myId=$1', |
16 | | - ), |
17 | | - 'funnyordie' => array( |
18 | | - 'url' => 'http://www.funnyordie.com/v1/flvideo/fodplayer.swf?file=' . |
19 | | - 'http://funnyordie.vo.llnwd.net/o16/$1.flv&autoStart=false' |
20 | | - ), |
21 | | - 'googlevideo' => array( |
22 | | - 'id_pattern' => '%[^0-9\\-]%', |
23 | | - 'url' => 'http://video.google.com/googleplayer.swf?docId=$1' |
24 | | - ), |
25 | | - 'interiavideo' => array( |
26 | | - 'url' => 'http://video.interia.pl/i/players/iVideoPlayer.05.swf?vid=$1', |
27 | | - ), |
28 | | - 'interia' => array( |
29 | | - 'url' => 'http://video.interia.pl/i/players/iVideoPlayer.05.swf?vid=$1', |
30 | | - ), |
31 | | - 'revver' => array( |
32 | | - 'url' => 'http://flash.revver.com/player/1.0/player.swf?mediaId=$1' |
33 | | - ), |
34 | | - 'sevenload' => array( |
35 | | - 'url' => 'http://page.sevenload.com/swf/en_GB/player.swf?id=$1' |
36 | | - ), |
37 | | - 'teachertube' => array( |
38 | | - 'extern' => '<embed src="http://www.teachertube.com/embed/player.swf" ' . |
39 | | - 'width="470" ' . |
40 | | - 'height="275" ' . |
41 | | - 'bgcolor="undefined" ' . |
42 | | - 'allowscriptaccess="always" ' . |
43 | | - 'allowfullscreen="true" ' . |
44 | | - 'flashvars="file=http://www.teachertube.com/embedFLV.php?pg=video_$2' . |
45 | | - '&menu=false' . |
46 | | - '&frontcolor=ffffff&lightcolor=FF0000' . |
47 | | - '&logo=http://www.teachertube.com/www3/images/greylogo.swf' . |
48 | | - '&skin=http://www.teachertube.com/embed/overlay.swf volume=80' . |
49 | | - '&controlbar=over&displayclick=link' . |
50 | | - '&viral.link=http://www.teachertube.com/viewVideo.php?video_id=$2' . |
51 | | - '&stretching=exactfit&plugins=viral-2' . |
52 | | - '&viral.callout=none&viral.onpause=false' . |
53 | | - '"' . |
54 | | - '/>', |
55 | | - ), |
56 | | - 'youtube' => array( |
57 | | - 'url' => 'http://www.youtube.com/v/$1' |
58 | | - ), |
59 | | - 'youtubehd' => array( |
60 | | - 'url' => 'http://www.youtube.com/v/$1&ap=%2526fmt%3D22', |
61 | | - 'default_width' => 720, |
62 | | - 'default_ratio' => 16 / 9 |
63 | | - ) |
| 11 | + 'dailymotion' => array( |
| 12 | + 'url' => 'http://www.dailymotion.com/swf/$1' |
| 13 | + ), |
| 14 | + 'divshare' => array( |
| 15 | + 'url' => 'http://www.divshare.com/flash/video2?myId=$1', |
| 16 | + ), |
| 17 | + 'edutopia' => array( |
| 18 | + 'extern' => |
| 19 | + '<object id="flashObj" width="$3" height="$4">' . |
| 20 | + '<param name="movie" value="http://c.brightcove.com/services/viewer/federated_f9?isVid=1&isUI=1" />' . |
| 21 | + '<param name="flashVars" value="videoId=$2&playerID=85476225001&domain=embed&dynamicStreaming=true" />' . |
| 22 | + '<param name="base" value="http://admin.brightcove.com" />' . |
| 23 | + '<param name="allowScriptAccess" value="always" />' . |
| 24 | + '<embed src="http://c.brightcove.com/services/viewer/federated_f9?isVid=1&isUI=1" ' . |
| 25 | + 'flashVars="videoId=$2&playerID=85476225001&domain=embed&dynamicStreaming=true" '. |
| 26 | + 'base="http://admin.brightcove.com" name="flashObj" width="$3" height="$4" '. |
| 27 | + 'seamlesstabbing="false" type="application/x-shockwave-flash" allowFullScreen="true" ' . |
| 28 | + 'allowScriptAccess="always" swLiveConnect="true" ' . |
| 29 | + 'pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">' . |
| 30 | + '</embed>' . |
| 31 | + '</object>', |
| 32 | + 'default_width' => 326, |
| 33 | + 'default_ratio' => 326/399, |
| 34 | + ), |
| 35 | + 'funnyordie' => array( |
| 36 | + 'url' => |
| 37 | + 'http://www.funnyordie.com/v1/flvideo/fodplayer.swf?file='. |
| 38 | + 'http://funnyordie.vo.llnwd.net/o16/$1.flv&autoStart=false' |
| 39 | + ), |
| 40 | + 'googlevideo' => array( |
| 41 | + 'id_pattern'=>'%[^0-9\\-]%', |
| 42 | + 'url' => 'http://video.google.com/googleplayer.swf?docId=$1' |
| 43 | + ), |
| 44 | + 'interiavideo' => array( |
| 45 | + 'url' => 'http://video.interia.pl/i/players/iVideoPlayer.05.swf?vid=$1', |
| 46 | + ), |
| 47 | + 'interia' => array( |
| 48 | + 'url' => 'http://video.interia.pl/i/players/iVideoPlayer.05.swf?vid=$1', |
| 49 | + ), |
| 50 | + 'revver' => array( |
| 51 | + 'url' => 'http://flash.revver.com/player/1.0/player.swf?mediaId=$1' |
| 52 | + ), |
| 53 | + 'sevenload' => array( |
| 54 | + 'url' => 'http://page.sevenload.com/swf/en_GB/player.swf?id=$1' |
| 55 | + ), |
| 56 | + 'teachertube' => array( |
| 57 | + 'extern' => |
| 58 | + '<embed src="http://www.teachertube.com/embed/player.swf" ' . |
| 59 | + 'width="$3" ' . |
| 60 | + 'height="$4" ' . |
| 61 | + 'bgcolor="undefined" ' . |
| 62 | + 'allowscriptaccess="always" ' . |
| 63 | + 'allowfullscreen="true" ' . |
| 64 | + 'flashvars="file=http://www.teachertube.com/embedFLV.php?pg=video_$2' . |
| 65 | + '&menu=false' . |
| 66 | + '&frontcolor=ffffff&lightcolor=FF0000' . |
| 67 | + '&logo=http://www.teachertube.com/www3/images/greylogo.swf' . |
| 68 | + '&skin=http://www.teachertube.com/embed/overlay.swf volume=80' . |
| 69 | + '&controlbar=over&displayclick=link' . |
| 70 | + '&viral.link=http://www.teachertube.com/viewVideo.php?video_id=$2' . |
| 71 | + '&stretching=exactfit&plugins=viral-2' . |
| 72 | + '&viral.callout=none&viral.onpause=false' . |
| 73 | + '"' . |
| 74 | + '/>', |
| 75 | + ), |
| 76 | + 'youtube' => array( |
| 77 | + 'url' => 'http://www.youtube.com/v/$1' |
| 78 | + ), |
| 79 | + 'youtubehd' => array( |
| 80 | + 'url' => 'http://www.youtube.com/v/$1&ap=%2526fmt%3D22', |
| 81 | + 'default_width' => 720, |
| 82 | + 'default_ratio' => 16/9 |
| 83 | + ), |
| 84 | + 'vimeo' => array( |
| 85 | + 'url'=>'http://vimeo.com/moogaloop.swf?clip_id=$1&;server=vimeo.com&fullscreen=0&show_title=1&show_byline=1&show_portrait=0' |
| 86 | + ) |
64 | 87 | ); |
Index: trunk/extensions/EmbedVideo/EmbedVideo.hooks.php |
— | — | @@ -15,22 +15,28 @@ |
16 | 16 | public static function setup( $parser ) { |
17 | 17 | # Setup parser hooks. ev is the primary hook, evp is supported for |
18 | 18 | # legacy purposes |
19 | | - $parser->setFunctionHook( 'ev', 'EmbedVideo::parserFunction_ev' ); |
20 | | - $parser->setFunctionHook( 'evp', 'EmbedVideo::parserFunction_evp' ); |
| 19 | + global $wgVersion; |
| 20 | + $prefix = version_compare($wgVersion, '1.7', '<') ? '#' : ''; |
| 21 | + EmbedVideo::addMagicWord($prefix, "ev", "EmbedVideo::parserFunction_ev"); |
| 22 | + EmbedVideo::addMagicWord($prefix, "evp", "EmbedVideo::parserFunction_evp"); |
21 | 23 | |
22 | 24 | return true; |
23 | 25 | } |
24 | 26 | |
| 27 | + private static function addMagicWord($prefix, $word, $function) { |
| 28 | + global $wgParser; |
| 29 | + $wgParser->setFunctionHook($prefix . $word, $function); |
| 30 | + } |
| 31 | + |
25 | 32 | /** |
26 | | - ** Adds magic words for parser functions. |
| 33 | + * Adds magic words for parser functions. |
27 | 34 | * @param Array $magicWords |
28 | 35 | * @param $langCode |
29 | 36 | * @return Boolean Always true |
30 | 37 | */ |
31 | | - public static function parserFunctionMagic( &$magicWords, $langCode = 'en' ) { |
32 | | - $magicWords['evp'] = array( 0, 'evp' ); |
33 | | - $magicWords['ev'] = array( 0, 'ev' ); |
34 | | - |
| 38 | + public static function parserFunctionMagic(&$magicWords, $langCode='en') { |
| 39 | + $magicWords['evp'] = array(0, 'evp'); |
| 40 | + $magicWords['ev'] = array(0, 'ev'); |
35 | 41 | return true; |
36 | 42 | } |
37 | 43 | |
— | — | @@ -43,8 +49,9 @@ |
44 | 50 | * @param String $width Width of video (optional) |
45 | 51 | * @return String Encoded representation of input params (to be processed later) |
46 | 52 | */ |
47 | | - public static function parserFunction_evp( $parser, $service = null, $id = null, $desc = null, $align = null, $width = null ) { |
48 | | - return EmbedVideo::parserFunction_ev( $parser, $service, $id, $width, $align, $desc ); |
| 53 | + public static function parserFunction_evp($parser, $service = null, $id = null, $desc = null, |
| 54 | + $align = null, $width = null) { |
| 55 | + return EmbedVideo::parserFunction_ev($parser, $service, $id, $width, $align, $desc); |
49 | 56 | } |
50 | 57 | |
51 | 58 | /** |
— | — | @@ -57,14 +64,15 @@ |
58 | 65 | * @param String $align alignment of the video (optional, unused) |
59 | 66 | * @return String Encoded representation of input params (to be processed later) |
60 | 67 | */ |
61 | | - public static function parserFunction_ev( $parser, $service = null, $id = null, $width = null, $align = null, $desc = null ) { |
| 68 | + public static function parserFunction_ev($parser, $service = null, $id = null, $width = null, |
| 69 | + $align = null, $desc = null) { |
62 | 70 | global $wgScriptPath; |
63 | 71 | |
64 | 72 | # Initialize things once |
65 | | - if ( !EmbedVideo::$initialized ) { |
| 73 | + if (!EmbedVideo::$initialized) { |
66 | 74 | EmbedVideo::VerifyWidthMinAndMax(); |
67 | 75 | # Add system messages |
68 | | - |
| 76 | + wfLoadExtensionMessages('embedvideo'); |
69 | 77 | $parser->disableCache(); |
70 | 78 | EmbedVideo::$initialized = true; |
71 | 79 | } |
— | — | @@ -74,8 +82,9 @@ |
75 | 83 | return EmbedVideo::errMissingParams( $service, $id ); |
76 | 84 | } |
77 | 85 | |
78 | | - $service = trim( $service ); |
79 | | - $id = trim( $id ); |
| 86 | + $service = trim($service); |
| 87 | + $id = trim($id); |
| 88 | + $desc = $parser->recursiveTagParse($desc); |
80 | 89 | |
81 | 90 | $entry = EmbedVideo::getServiceEntry( $service ); |
82 | 91 | if ( !$entry ) { |
— | — | @@ -98,8 +107,7 @@ |
99 | 108 | } |
100 | 109 | |
101 | 110 | # if the service has it's own custom extern declaration, use that instead |
102 | | - $clause = $entry['extern']; |
103 | | - if ( isset( $clause ) ) { |
| 111 | + if ( array_key_exists ( 'extern', $entry ) && ( $clause = $entry['extern'] ) != null ) { |
104 | 112 | $clause = wfMsgReplaceArgs( $clause, array( $wgScriptPath, $id, $width, $height ) ); |
105 | 113 | if ( $hasalign ) { |
106 | 114 | $clause = EmbedVideo::generateAlignExternClause( $clause, $align, $desc, $width, $height ); |
— | — | @@ -157,7 +165,7 @@ |
158 | 166 | " wmode=\"transparent\" width=\"{$width}\" height=\"{$height}\"></embed>" . |
159 | 167 | "</object>" . |
160 | 168 | "<div class=\"thumbcaption\">" . |
161 | | - $desc . |
| 169 | + $desc . |
162 | 170 | "</div></div></div>"; |
163 | 171 | |
164 | 172 | return $clause; |
— | — | @@ -178,8 +186,7 @@ |
179 | 187 | # the width is suitable, false otherwise. |
180 | 188 | private static function sanitizeWidth( $entry, &$width ) { |
181 | 189 | global $wgEmbedVideoMinWidth, $wgEmbedVideoMaxWidth; |
182 | | - |
183 | | - if ( $width === null ) { |
| 190 | + if ($width === null || $width == '*' || $width == '') { |
184 | 191 | if ( isset( $entry['default_width'] ) ) { |
185 | 192 | $width = $entry['default_width']; |
186 | 193 | } else { |