Date: Wed, 1 Jul 2009 18:21:29 +0800 From: richard.philippines@gmail.com To: mediawiki-l@lists.wikimedia.org Subject: Re: [Mediawiki-l] How best to set up hooks in an extension function ?
Thanks Tim,
Your advice was exactly what I needed. I'm setting up my code like below. ABC's are replaced with real names and I've removed most of the code to just show the important parts. I took out the line: $wgExtensionFunctions[] = 'wfSetupCSS' and instead create a new class and then call a function in the class to register the hooks.
File: ABC_setup.php
$oABC = new ABC(); $oABC->registerHooks();
File: ABC.php
class ABC {
private $abcd;
public function registerHooks() { global $wgHooks, $wgExtensionFunctions, $wgVersion; $wgHooks['SkinTemplateOutputPageBeforeExec'][] = array($this, 'onSkinTemplateOutputPageBeforeExec'); $wgHooks['OutputPageBeforeHTML'][] = array($this, 'onOutputPageBeforeHTML'); $wgHooks['LanguageGetMagic'][] = array($this, 'onLanguageGetMagic'); $wgHooks['ParserFirstCallInit'][] = array($this, 'onParserFirstCallInit'); }
function onParserFirstCallInit( ) {
global $wgParser; $wgParser->setFunctionHook etc ...
Can you let me know if this is what you are suggesting assuming the code will run on say 1.14 MW where the parserfirstcallinit is implemented.
Also any suggestions you might have? I'd like to be sure the framework meets with the latest standards.
One last question. Is this the best place for me to be posting this kind of question?
Thanks,
Richard _______________________________________________ MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
_________________________________________________________________ Découvrez toutes les possibilités de communication avec vos proches http://www.microsoft.com/windows/windowslive/default.aspx