Hello,
Due to parser tags not being able to correctly handle variables such as {{{1}}} I created my own custom parser function that calls a parser tag I've installed so that I could use such variables with it. Unfortunately instead of outputting the actual image that it should do it outputs the code raw - I've verified this is something to do with the parser as I have done some testing and can confirm that before it is return-ed it is still HTML code, not escaped HTML code. Below is a copy of my custom code for anyone who is interested in helping. Any assistance would be greatly appreciated.
<?php
/* Parser Function style work around, calls above function. */
$wgExtensionFunctions[] = 'wfImageLinkWorkAroundParserFunction_Setup';
$wgHooks['LanguageGetMagic'][] = 'wfImageLinkWorkAroundParserFunction_Magic';
function wfImageLinkWorkAroundParserFunction_Setup() { global $wgParser; $wgParser->setFunctionHook( 'link', 'wfImageLinkWorkAroundParserFunction_Render' ); }
function wfImageLinkWorkAroundParserFunction_Magic( &$magicWords, $langCode ) { $magicWords[ 'link' ] = array( 0, 'link' ); return true; }
function wfImageLinkWorkAroundParserFunction_Render( &$parser, $target = '', $alt = "", $src = "", $height = "", $width = "" ) { $img = new LinkedImage; $img->wikipage = $target; $img->tooltip = $alt; $img->img_src = $src; $img->img_alt = $alt; $img->img_height = $height; $img->img_width = $width; $img->img_border = 0; #echo $img->render(); # Outputs actual HTML (e.g. <img src="foo" />) return $img->render(); #' Outputs escaped HTML (e.g. <img src="foo" />) }
?>
See here:
http://www.mediawiki.org/wiki/ Manual:Tag_extensions#How_can_I_avoid_modification_of_my_extension. 27s_HTML_output.3F
:-) Boris
On 30-Dec-07, at 1:45 PM, Minute Electron wrote:
Hello,
Due to parser tags not being able to correctly handle variables such as {{{1}}} I created my own custom parser function that calls a parser tag I've installed so that I could use such variables with it. Unfortunately instead of outputting the actual image that it should do it outputs the code raw - I've verified this is something to do with the parser as I have done some testing and can confirm that before it is return-ed it is still HTML code, not escaped HTML code. Below is a copy of my custom code for anyone who is interested in helping. Any assistance would be greatly appreciated.
<?php /* Parser Function style work around, calls above function. */ $wgExtensionFunctions[] = 'wfImageLinkWorkAroundParserFunction_Setup'; $wgHooks['LanguageGetMagic'][] = 'wfImageLinkWorkAroundParserFunction_Magic'; function wfImageLinkWorkAroundParserFunction_Setup() { global $wgParser; $wgParser->setFunctionHook( 'link', 'wfImageLinkWorkAroundParserFunction_Render' ); } function wfImageLinkWorkAroundParserFunction_Magic( &$magicWords, $langCode ) { $magicWords[ 'link' ] = array( 0, 'link' ); return true; } function wfImageLinkWorkAroundParserFunction_Render( &$parser, $target = '', $alt = "", $src = "", $height = "", $width = "" ) { $img = new LinkedImage; $img->wikipage = $target; $img->tooltip = $alt; $img->img_src = $src; $img->img_alt = $alt; $img->img_height = $height; $img->img_width = $width; $img->img_border = 0; #echo $img->render(); # Outputs actual HTML (e.g. <img src="foo" />) return $img->render(); #' Outputs escaped HTML (e.g. <img src="foo" />) } ?>
-- MinuteElectron. http://my.brlcad.org/~MinuteElectron/
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
On 12/30/07, Boris Steipe boris.steipe@utoronto.ca wrote:
See here:
http://www.mediawiki.org/wiki/ Manual:Tag_extensions#How_can_I_avoid_modification_of_my_extension. 27s_HTML_output.3F
:-) Boris
Thank you for the quick answer, while I am dealing with a parser function here (not a parser tag) this prompted me to further read the parser function documentation and find the relevant flag. Problem solved! :D
See this page for info: http://www.mediawiki.org/wiki/Manual:Parser_functions You can return an array as so to stop the output from parsing and have it treated as html.
return array($output, 'noparse' => true, 'isHTML' => true);
~Daniel Friesen(Dantman) of: -The Gaiapedia (http://gaia.wikia.com) -Wikia ACG on Wikia.com (http://wikia.com/wiki/Wikia_ACG) -and Wiki-Tools.com (http://wiki-tools.com)
Minute Electron wrote:
On 12/30/07, Boris Steipe boris.steipe@utoronto.ca wrote:
See here:
http://www.mediawiki.org/wiki/ Manual:Tag_extensions#How_can_I_avoid_modification_of_my_extension. 27s_HTML_output.3F
:-) Boris
Thank you for the quick answer, while I am dealing with a parser function here (not a parser tag) this prompted me to further read the parser function documentation and find the relevant flag. Problem solved! :D
mediawiki-l@lists.wikimedia.org