Implemented first version of <wrvideo> tag based on <wrmap> tag.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Tue, 2 Sep 2014 21:04:38 +0000 (21:04 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Tue, 2 Sep 2014 21:04:38 +0000 (21:04 +0000)
git-svn-id: http://www.winterrodeln.org/svn/servermediawiki/mediawiki_extensions/wrvideo/trunk@2119 7aebc617-e5e2-0310-91dc-80fb5f6d2477

i18n/de.json [new file with mode: 0644]
i18n/en.json [new file with mode: 0644]
i18n/qqq.json [new file with mode: 0644]
wrvideo.body.php [new file with mode: 0644]
wrvideo.php [new file with mode: 0644]

diff --git a/i18n/de.json b/i18n/de.json
new file mode 100644 (file)
index 0000000..5d5221b
--- /dev/null
@@ -0,0 +1,7 @@
+{
+       "@metadata": {
+               "authors": []
+       },
+       "wrvideo-error-msg": "Fehler beim Parsen von <wrvideo>: ",
+       "wrvideo-error-no-id": "Der Parameter 'id' fehlt."
+}
diff --git a/i18n/en.json b/i18n/en.json
new file mode 100644 (file)
index 0000000..12ae0f6
--- /dev/null
@@ -0,0 +1,7 @@
+{
+       "@metadata": {
+               "authors": []
+       },
+       "wrvideo-error-msg": "Error at parsing <wrvideo>: ",
+       "wrvideo-error-no-id": "Parameter 'id' is missing."
+}
diff --git a/i18n/qqq.json b/i18n/qqq.json
new file mode 100644 (file)
index 0000000..12ae0f6
--- /dev/null
@@ -0,0 +1,7 @@
+{
+       "@metadata": {
+               "authors": []
+       },
+       "wrvideo-error-msg": "Error at parsing <wrvideo>: ",
+       "wrvideo-error-no-id": "Parameter 'id' is missing."
+}
diff --git a/wrvideo.body.php b/wrvideo.body.php
new file mode 100644 (file)
index 0000000..9be74ab
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+
+// WrVideo
+// -------
+
+class WrVideo {
+       /// Renders the <video> tag.
+       /// @param $content string - the content of the <video> tag
+       /// @param $args array - the array of attribute name/value pairs for the tag
+       /// @param $parser Parser - the MW Parser object for the current page
+       ///
+       /// @return string - the html for rendering the map
+       public static function render($content, $args, $parser, $frame) {
+               $parserOutput = $parser->getOutput();
+               $parserOutput->addModules('ext.wrvideo');
+
+               try {
+                       // default properties
+                       $properties = array('width' => 500, 'height' => 281);
+
+                       // video properties
+                       if (isset($args['id'])) $properties['id'] = (int) $args['id']; // video ID
+                       if (isset($args['width'])) $properties['width'] = (int) $args['width']; // width as int value
+                       if (isset($args['height'])) $properties['height'] = (int) $args['height']; // height as int value
+
+                       // verify properties
+                       if (!isset($properties['id'])) throw new Exception(wfMessage('wrvideo-error-no-id')->text());
+
+                       // build iframe
+                       $doc = new DOMDocument();
+                       $child = $doc->appendChild($doc->createElement('iframe'));
+                       $child->setAttribute('src', '//player.vimeo.com/video/' . $properties['id'] . '?byline=0&amp;portrait=0&amp;color=014e9a');
+                       $child->setAttribute('width', $properties['width']);
+                       $child->setAttribute('height', $properties['height']);
+                       $child->setAttribute('frameborder', 0);
+                       $child->setAttribute('webkitallowfullscreen', '');
+                       $child->setAttribute('mozallowfullscreen', '');
+                       $child->setAttribute('allowfullscreen', '');
+               } catch (Exception $e) {
+                       $doc = new DOMDocument();
+                       $child = $doc->appendChild($doc->createElement('div'));
+                       $child->setAttribute('class', 'error');
+                       $child->appendChild($doc->createTextNode(wfMessage('wrvideo-error-msg')->text() . $e->getMessage()));
+               }
+               return array($doc->saveHTML($doc->firstChild), 'markerType' => 'nowiki');
+       }
+
+}
+
+?>
diff --git a/wrvideo.php b/wrvideo.php
new file mode 100644 (file)
index 0000000..4e03f9c
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+/* This extension embeds a video in a mediawiki page.
+Currently vimeo is supported.
+
+
+To embed the vimeo video
+https://vimeo.com/104778486
+
+the following HTML code has to be inserted into mediawiki:
+<iframe src="//player.vimeo.com/video/104778486?byline=0&amp;portrait=0&amp;color=51735d" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
+
+This extension allows this by the following tag:
+<wrvideo id="104778486" />
+<wrvideo id="104778486" width="500" height="281" />
+
+*/
+
+$wgExtensionCredits['parserhook'][] = array(
+       'name' => 'Winterrodeln Video',
+       'version' => '0.0.1',
+       'author' =>'Philipp Spitzer', 
+       'url' => 'http://www.winterrodeln.org/trac/wiki/WrVideo', 
+       'description' => 'This extension embeds a video in a mediawiki page. Currently vimeo is supported.'
+);
+
+
+
+$wgResourceModules['ext.wrvideo'] = array(
+       'localBasePath' => dirname( __FILE__ ),
+       'remoteExtPath' => 'wrvideo'
+);
+
+
+$wgAutoloadClasses['WrVideo'] = dirname(__FILE__) . '/wrvideo.body.php';
+$wgMessagesDirs['wrvideo'] = __DIR__ . '/i18n';
+$wgHooks['ParserFirstCallInit'][] = 'wrVideoParserFirstCallInit';
+
+
+function wrVideoParserFirstCallInit($parser) {
+       $parser->setHook('wrvideo', 'WrVideo::render');
+       return true;
+}
+
+
+?>