Skip to content

Commit

Permalink
Added screen 9.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Jonsson committed Oct 19, 2012
1 parent dd4faf1 commit 276da52
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
4 changes: 4 additions & 0 deletions EmbedVideo.Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
'rutube' => array(
'url' => ''
),
'screen9' => array(
'extern' => 't',
'default_ratio' => 579 / 358
),
'sevenload' => array(
'url' => 'http://page.sevenload.com/swf/en_GB/player.swf?id=$1'
),
Expand Down
35 changes: 34 additions & 1 deletion EmbedVideo.hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,14 @@ public static function parserFunction_ev($parser, $service = null, $id = null, $
}
// if the service has it's own custom extern declaration, use that instead
if (array_key_exists ('extern', $entry) && ($clause = $entry['extern']) != NULL) {
$clause = wfMsgReplaceArgs($clause, array($wgScriptPath, $id, $width, $height, $url));
if ($service == 'screen9') {
$clause = self::parseScreen9Id( $id, $width, $height );
if ($clause == null) {
return self::errBadScreen9Id();
}
} else {
$clause = wfMsgReplaceArgs($clause, array($wgScriptPath, $id, $width, $height, $url));
}
if ($hasalign) {
$clause = self::generateAlignExternClause($clause, $align, $desc, $width, $height);
}
Expand Down Expand Up @@ -363,6 +370,16 @@ private static function errBadAlignment($align) {
return '<div class="errorbox">' . $msg . '</div>';
}

/**
* Get an error message for an invalid screen 9 id.
*
* @return string
*/
private static function errBadScreen9Id() {
$msg = wfMsg('embedvideo-illegal-screen9-id');
return '<div class="errorbox">' . $msg . '</div>';
}

/**
* Verify that the min and max values for width are sane.
*
Expand Down Expand Up @@ -411,4 +428,20 @@ private static function getYandex($id)
$url=substr($json, $start, $end-$start);
return $url;
}


private static function parseScreen9Id($id, $width, $height)
{
$parser = new Screen9IdParser();

if (! $parser->parse( $id ) ) {
return null;
}

$parser->setWidth( $width );

$parser->setHeight( $height );

return $parser->toString();
}
}
2 changes: 2 additions & 0 deletions EmbedVideo.i18n.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
'embedvideo-bad-id' => 'EmbedVideo received the bad id "$1" for the service "$2".',
'embedvideo-illegal-width' => 'EmbedVideo received the illegal width parameter "$1".',
'embedvideo-illegal-alignment' => 'EmbedVideo was given an illegal value for the alignment parameter "$1". Valid values are "right" or "left".',
'embedvideo-illegal-screen9-id' => 'EmbedVideo failed to interpret the screen9 id. Note that the id of a screen9 video is the full html-snippet obtained from the video for embedding.',
);
/** Russian (Русский)
* @author P@S@f
Expand Down Expand Up @@ -37,4 +38,5 @@
'embedvideo-bad-id' => 'EmbedVideo - Felaktig id "$1" för tjänsten "$2" har angivits.',
'embedvideo-illegal-width' => 'EmbedVideo - Felaktigt värde "$1" har angivits som bredd.',
'embedvideo-illegal-alignment' => 'EmbedVideo - Felaktigt värde har angivits som placering: "$1". Korrekta värden är "right" för högerställd och "left" för vänsterställd.',
'embedvideo-illegal-screen9-id' => 'EmbedVideo - Kunde inte tolka screen9 video-id. Observera att video-identiteten för en screen9-id är hela den html-kodsnutt som fås då man väljer "share -> embed" på screen9 videon.'
);
2 changes: 2 additions & 0 deletions EmbedVideo.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
require_once($dir . "EmbedVideo.hooks.php");
require_once($dir . "EmbedVideo.Services.php");

$wgAutoloadClasses['Screen9IdParser'] = dirname( __FILE__ ) . '/Screen9IdParser.php';

$wgHooks['ParserFirstCallInit'][] = "EmbedVideo::setup";
if (version_compare($wgVersion, '1.7', '<')) {
// Hack solution to resolve 1.6 array parameter nullification for hook args
Expand Down

0 comments on commit 276da52

Please sign in to comment.