Difference between revisions of "Extension:VideoSectionLink"
(also happy to return array) |
(more pseudocode and comments added) |
||
Line 37: | Line 37: | ||
# Add the parser-function | # Add the parser-function | ||
$wgParser->setFunctionHook($egVideoSectionLinkMagic, array($this, 'magicVideosectionlink')); | $wgParser->setFunctionHook($egVideoSectionLinkMagic, array($this, 'magicVideosectionlink')); | ||
− | + | #Add the Unknownaction hook | |
+ | $wgHooks['UnknownAction'][] = $this; | ||
+ | #need to set up the new action here | ||
} | } | ||
Line 46: | Line 48: | ||
global $egVideoSectionLinkMagic; | global $egVideoSectionLinkMagic; | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
+ | $text="{{SERVER}}/" . $param1 . "?action=videosection¶m2=" . $param2 . "¶m3=" .param3; | ||
# Return result with available parser flags | # Return result with available parser flags | ||
return array( | return array( | ||
Line 84: | Line 74: | ||
global $egVideoSectionLink; | global $egVideoSectionLink; | ||
$egVideoSectionLink = new VideoSectionLink(); | $egVideoSectionLink = new VideoSectionLink(); | ||
− | |||
− | |||
} | } | ||
Line 92: | Line 80: | ||
* Needed in MediaWiki >1.8.0 for magic word hooks to work properly | * Needed in MediaWiki >1.8.0 for magic word hooks to work properly | ||
*/ | */ | ||
+ | |||
function efVideoSectionLinkLanguageGetMagic(&$magicWords, $langCode = 0) { | function efVideoSectionLinkLanguageGetMagic(&$magicWords, $langCode = 0) { | ||
global $egVideoSectionLinkMagic; | global $egVideoSectionLinkMagic; | ||
$magicWords[$egVideoSectionLinkMagic] = array($langCode, $egVideoSectionLinkMagic); | $magicWords[$egVideoSectionLinkMagic] = array($langCode, $egVideoSectionLinkMagic); | ||
− | + | return true; | |
− | + | } | |
+ | |||
+ | function onUnknownAction($action, $article) { | ||
+ | |||
+ | #here we test for the action=videosection and extract the parameters from the query string | ||
+ | |||
+ | $movie = `ffmpeg -i $param1 -ss $param2 -t $param3 out1.mpg`; | ||
+ | $wgOut->disable(); | ||
+ | header("Content-Type: video/mpeg"); | ||
+ | header("Content-Disposition: attachment; filename=\"$movie.mpeg\""); | ||
+ | readfile($movie); | ||
return true; | return true; | ||
} | } |
Revision as of 09:13, 10 November 2008
<?php
Template:PhpCategory:Extensions created with Template:Extension
/**
* VideoSectionLink extension - An extension to enable users to link to defined sections of video. Made with Template:Extension * * See http://www.mediawiki.org/wiki/Extension:VideoSectionLink for installation and usage details * * @package MediaWiki * @subpackage Extensions * @author User:Jack * @copyright © 2008 User:Jack * @licence GNU General Public Licence 2.0 or later */
if (!defined('MEDIAWIKI')) die('Not an entry point.');
define('VIDEOSECTIONLINK_VERSION', '0.0.1, 2008-10-31');
$egVideoSectionLinkMagic = "videosection"; $wgExtensionFunctions[] = 'efSetupVideoSectionLink'; $wgHooks['LanguageGetMagic'][] = 'efVideoSectionLinkLanguageGetMagic';
$wgExtensionCredits['parserhook'][] = array( 'name' => 'VideoSectionLink', 'author' => 'User:Jack', 'description' => 'An extension to enable users to link to defined sections of video. Made with Template:Extension', 'url' => 'http://www.organicdesign.co.nz/Extension:VideoSectionLink', 'version' => VIDEOSECTIONLINK_VERSION );
class VideoSectionLink {
/** * Constructor */ function __construct() { global $wgHooks, $wgParser, $egVideoSectionLinkMagic;
# Add the parser-function $wgParser->setFunctionHook($egVideoSectionLinkMagic, array($this, 'magicVideosectionlink')); #Add the Unknownaction hook $wgHooks['UnknownAction'][] = $this; #need to set up the new action here }
/** * Expand the videosection-magic */ function magicVideosectionlink(&$parser, $param1 = , $param2 = ,$param3 = ) {
global $egVideoSectionLinkMagic;
$text="https://organicdesign.nz/" . $param1 . "?action=videosection¶m2=" . $param2 . "¶m3=" .param3;
# Return result with available parser flags return array( $text, 'found' => true, 'nowiki' => false, 'noparse' => false, 'noargs' => false, 'isHTML' => false );
}
/** * Needed in some versions to prevent Special:Version from breaking */ function __toString() { return __CLASS__; }
}
/**
* Called from $wgExtensionFunctions array when initialising extensions */
function efSetupVideoSectionLink() { global $egVideoSectionLink; $egVideoSectionLink = new VideoSectionLink();
}
/**
* Needed in MediaWiki >1.8.0 for magic word hooks to work properly */
function efVideoSectionLinkLanguageGetMagic(&$magicWords, $langCode = 0) { global $egVideoSectionLinkMagic; $magicWords[$egVideoSectionLinkMagic] = array($langCode, $egVideoSectionLinkMagic); return true; }
function onUnknownAction($action, $article) {
#here we test for the action=videosection and extract the parameters from the query string
$movie = `ffmpeg -i $param1 -ss $param2 -t $param3 out1.mpg`; $wgOut->disable(); header("Content-Type: video/mpeg"); header("Content-Disposition: attachment; filename=\"$movie.mpeg\""); readfile($movie); return true; }