Difference between revisions of "Extension:VideoSectionLink"

From Organic Design wiki
(braces)
(hook not being called)
Line 18: Line 18:
 
$wgExtensionFunctions[]        = 'efSetupVideoSectionLink';
 
$wgExtensionFunctions[]        = 'efSetupVideoSectionLink';
 
$wgHooks['LanguageGetMagic'][] = 'efVideoSectionLinkLanguageGetMagic';
 
$wgHooks['LanguageGetMagic'][] = 'efVideoSectionLinkLanguageGetMagic';
 
+
 
+
 
$wgExtensionCredits['parserhook'][] = array(
 
$wgExtensionCredits['parserhook'][] = array(
 
'name'        => 'VideoSectionLink',
 
'name'        => 'VideoSectionLink',
Line 37: Line 37:
 
   
 
   
 
# Add the parser-function
 
# Add the parser-function
$wgParser->setFunctionHook($egVideoSectionLinkMagic, $this);
+
$wgParser->setFunctionHook($egVideoSectionLinkMagic, array($this,'magicVideosectionlink'));
 +
 
 +
 
 
#Add the Unknownaction hook
 
#Add the Unknownaction hook
$wgHooks['UnknownAction'][] = 'onUnknownAction';
+
$wgHooks['UnknownAction'][] = $this;
#need to set up the new action here
+
 
}
 
}
 
   
 
   
Line 46: Line 48:
 
* Expand the videosection-magic
 
* Expand the videosection-magic
 
*/
 
*/
function magicVideosectionlink(&$parser, $param1 = '', $param2 = '',$param3 = '') {
+
function magicVideosectionlink(&$parser, $vsUrl = '', $vsStart = '',$vsElapse = '') {
 +
 +
global $egVideoSectionLinkMagic,$wgScript;
  
global $egVideoSectionLinkMagic;
+
   $text= $wgScript . "?action=videosection" . "&vsUrl=" . $vsUrl . "&vsStart=" . $vsStart . "&vsElapse=" .$vsElapse;
 
 
   $text= $wgScript . "/" . $param1 . "?action=videosection&param2=" . $param2 . "&param3=" .$param3;
 
 
# Return result with available parser flags
 
# Return result with available parser flags
 
return array(
 
return array(
Line 60: Line 62:
 
'isHTML'  => false
 
'isHTML'  => false
 
);
 
);
+
 
}
 
}
+
 
/**
 
/**
 
* Callback method executes a shell command returning the section of the movie requested
 
* Callback method executes a shell command returning the section of the movie requested
Line 68: Line 70:
 
function onUnknownAction($action, $article) {
 
function onUnknownAction($action, $article) {
 
 
   
+
global $wgOut;
    # Hang on where are these parameters coming from?
+
print_r($action);
 +
print_r($article);
 +
 
 +
 +
/*    # Hang on where are these parameters coming from?
 
    # - from the request query-string, they were built into the URL by the parser-function
 
    # - from the request query-string, they were built into the URL by the parser-function
 
+
#$success = shellexec(fmpeg -i $param1 -ss $param2 -t $param3 out.mpg);
+
$success = shellexec(fmpeg -i $param1 -ss $param2 -t $param3 out.mpg);
+
 
$wgOut->disable();
 
$wgOut->disable();
 
header("Content-Type: video/mpeg");
 
header("Content-Type: video/mpeg");
 
header("Content-Disposition: attachment; filename=\"out.mpg\"");
 
header("Content-Disposition: attachment; filename=\"out.mpg\"");
+
 
#return the file as binary back to the client
 
#return the file as binary back to the client
+
readfile("out.mpg");
+
readfile("out.mpg");*/
 
return true;
 
return true;
 
}
 
}

Revision as of 02:12, 18 November 2008

<?php /**

Info.svg These are the MediaWiki extensions we're using and/or developing. Please refer to the information on the mediawiki.org wiki for installation and usage details. Extensions here which have no corresponding mediawiki article are either not ready for use or have been superseded. You can also browse our extension code in our local Subversion repository or our GitHub mirror.

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;

}

/** * Expand the videosection-magic */ function magicVideosectionlink(&$parser, $vsUrl = , $vsStart = ,$vsElapse = ) {

global $egVideoSectionLinkMagic,$wgScript;

  		$text= $wgScript . "?action=videosection" . "&vsUrl=" . $vsUrl . "&vsStart=" . $vsStart . "&vsElapse=" .$vsElapse;

# Return result with available parser flags return array( $text, 'found' => true, 'nowiki' => false, 'noparse' => false, 'noargs' => false, 'isHTML' => false );

}

/** * Callback method executes a shell command returning the section of the movie requested */ function onUnknownAction($action, $article) {

global $wgOut; print_r($action); print_r($article);


/* # Hang on where are these parameters coming from? # - from the request query-string, they were built into the URL by the parser-function

$success = shellexec(fmpeg -i $param1 -ss $param2 -t $param3 out.mpg);

$wgOut->disable(); header("Content-Type: video/mpeg"); header("Content-Disposition: attachment; filename=\"out.mpg\"");

#return the file as binary back to the client

readfile("out.mpg");*/ return true; }

/** * 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; }