r99205 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99204‎ | r99205 | r99206 >
Date:10:56, 7 October 2011
Author:happy-melon
Status:deferred (Comments)
Tags:
Comment:
Update EmbedVideo to latest version from github (https://github.com/Whiteknight/mediawiki-embedvideo)
Modified paths:
  • /trunk/extensions/EmbedVideo/EmbedVideo.Services.php (modified) (history)
  • /trunk/extensions/EmbedVideo/EmbedVideo.hooks.php (modified) (history)
  • /trunk/extensions/EmbedVideo/EmbedVideo.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EmbedVideo/EmbedVideo.php
@@ -9,12 +9,12 @@
1010 */
1111
1212 # Confirm MW environment
13 -if ( !defined( 'MEDIAWIKI' ) ) {
14 - echo <<<EOT
 13+if (!defined('MEDIAWIKI')) {
 14+ echo <<<EOT
1515 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" );
1717 EOT;
18 - exit( 1 );
 18+ exit( 1 );
1919 }
2020
2121 # Credits
@@ -27,11 +27,20 @@
2828 'version' => '1.0'
2929 );
3030
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");
3434 $wgExtensionMessagesFiles['embedvideo'] = $dir . 'EmbedVideo.i18n.php';
3535
 36+
3637 $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 @@
88
99 # Build services list (may be augmented in LocalSettings.php)
1010 $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+ )
6487 );
Index: trunk/extensions/EmbedVideo/EmbedVideo.hooks.php
@@ -15,22 +15,28 @@
1616 public static function setup( $parser ) {
1717 # Setup parser hooks. ev is the primary hook, evp is supported for
1818 # 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");
2123
2224 return true;
2325 }
2426
 27+ private static function addMagicWord($prefix, $word, $function) {
 28+ global $wgParser;
 29+ $wgParser->setFunctionHook($prefix . $word, $function);
 30+ }
 31+
2532 /**
26 - ** Adds magic words for parser functions.
 33+ * Adds magic words for parser functions.
2734 * @param Array $magicWords
2835 * @param $langCode
2936 * @return Boolean Always true
3037 */
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');
3541 return true;
3642 }
3743
@@ -43,8 +49,9 @@
4450 * @param String $width Width of video (optional)
4551 * @return String Encoded representation of input params (to be processed later)
4652 */
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);
4956 }
5057
5158 /**
@@ -57,14 +64,15 @@
5865 * @param String $align alignment of the video (optional, unused)
5966 * @return String Encoded representation of input params (to be processed later)
6067 */
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) {
6270 global $wgScriptPath;
6371
6472 # Initialize things once
65 - if ( !EmbedVideo::$initialized ) {
 73+ if (!EmbedVideo::$initialized) {
6674 EmbedVideo::VerifyWidthMinAndMax();
6775 # Add system messages
68 -
 76+ wfLoadExtensionMessages('embedvideo');
6977 $parser->disableCache();
7078 EmbedVideo::$initialized = true;
7179 }
@@ -74,8 +82,9 @@
7583 return EmbedVideo::errMissingParams( $service, $id );
7684 }
7785
78 - $service = trim( $service );
79 - $id = trim( $id );
 86+ $service = trim($service);
 87+ $id = trim($id);
 88+ $desc = $parser->recursiveTagParse($desc);
8089
8190 $entry = EmbedVideo::getServiceEntry( $service );
8291 if ( !$entry ) {
@@ -98,8 +107,7 @@
99108 }
100109
101110 # 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 ) {
104112 $clause = wfMsgReplaceArgs( $clause, array( $wgScriptPath, $id, $width, $height ) );
105113 if ( $hasalign ) {
106114 $clause = EmbedVideo::generateAlignExternClause( $clause, $align, $desc, $width, $height );
@@ -157,7 +165,7 @@
158166 " wmode=\"transparent\" width=\"{$width}\" height=\"{$height}\"></embed>" .
159167 "</object>" .
160168 "<div class=\"thumbcaption\">" .
161 - $desc .
 169+ $desc .
162170 "</div></div></div>";
163171
164172 return $clause;
@@ -178,8 +186,7 @@
179187 # the width is suitable, false otherwise.
180188 private static function sanitizeWidth( $entry, &$width ) {
181189 global $wgEmbedVideoMinWidth, $wgEmbedVideoMaxWidth;
182 -
183 - if ( $width === null ) {
 190+ if ($width === null || $width == '*' || $width == '') {
184191 if ( isset( $entry['default_width'] ) ) {
185192 $width = $entry['default_width'];
186193 } else {

Comments

#Comment by Nikerabbit (talk | contribs)   17:51, 7 October 2011

Ewww! This is exactly what we don't want. Translators keep translating the extension, which is develop elsewhere and doesn't even use them.

Status & tagging log