r105136 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105135‎ | r105136 | r105137 >
Date:23:20, 4 December 2011
Author:danwe
Status:deferred
Tags:
Comment:
Tag for 'Parser Fun' 0.1
Modified paths:
  • /tags/extensions/ParserFun/REL_0_1 (added) (history)

Diff [purge]

Index: tags/extensions/ParserFun/REL_0_1/RELEASE-NOTES
@@ -0,0 +1,13 @@
 2+ 'Parser Fun' Changelog:
 3+ =======================
 4+
 5+ * December 2, 2011 -- Version 0.1 (initial release)
 6+ - Magic word prefix 'THIS:', which is working with basically all functions returning page related information:
 7+ 'FULLPAGENAME', 'PAGENAME', 'BASEPAGENAME', 'SUBPAGENAME', 'SUBJECTPAGENAME', 'TALKPAGENAME', 'NAMESPACE',
 8+ 'SUBJECTSPACE', 'ARTICLESPACE', 'TALKSPACE' and their URL-encoded equivalents ending with 'EE'.
 9+ - Hook 'GetThisVariableValueSwitch' allows to make other magic variables work with 'THIS:'.
 10+ - 'parse' parser function with following parameters:
 11+ + <1> - input text (required)
 12+ + unstrip - 'none', 'nowiki', 'general', 'all' to unstrip input first. Allows to parse text inside <nowiki>.
 13+ + parse - whether text should really be parsed (in case you want to unstrip only)
 14+ - Distributed under ISC license and put into mediawiki.org svn repository.
Property changes on: tags/extensions/ParserFun/REL_0_1/RELEASE-NOTES
___________________________________________________________________
Added: svn:eol-style
115 + native
Index: tags/extensions/ParserFun/REL_0_1/COPYING
@@ -0,0 +1,13 @@
 2+Copyright (c) 2011 by Daniel Werner < danweetz@web.de >
 3+
 4+Permission to use, copy, modify, and/or distribute this software for any
 5+purpose with or without fee is hereby granted, provided that the above
 6+copyright notice and this permission notice appear in all copies.
 7+
 8+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 9+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 10+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 11+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 12+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 13+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 14+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
\ No newline at end of file
Property changes on: tags/extensions/ParserFun/REL_0_1/COPYING
___________________________________________________________________
Added: svn:eol-style
115 + native
Index: tags/extensions/ParserFun/REL_0_1/PFun_Parse.php
@@ -0,0 +1,176 @@
 2+<?php
 3+
 4+/**
 5+ * Class for the '#parse' parser function.
 6+ *
 7+ * @since 0.1
 8+ *
 9+ * @file PFun_Parse.php
 10+ * @ingroup ParserFun
 11+ *
 12+ * @author Daniel Werner
 13+ */
 14+class ParserFunParse extends ParserHook {
 15+
 16+ /**
 17+ * Whether or not the input text should be parsed by Parser::braceSubstitution()
 18+ * after the function has returned its value (this is possible by returning function
 19+ * result as array with 'noparse' set to false).
 20+ * This is always set to 'true' for new MW versions which support object style parser
 21+ * function arguments sinc we call the parsing process manually in this case.
 22+ *
 23+ * @since 0.1
 24+ *
 25+ * @var boolean
 26+ */
 27+ protected $postParse_fallback;
 28+
 29+ public function __construct() {
 30+ // make this a parser function extension (no tag extension) only:
 31+ parent::__construct( false, true );
 32+ }
 33+
 34+ /**
 35+ * No LSB in pre-5.3 PHP, to be refactored later
 36+ */
 37+ public static function staticMagic( array &$magicWords, $langCode ) {
 38+ $instance = new self;
 39+ return $instance->magic( $magicWords, $langCode );
 40+ }
 41+
 42+ /**
 43+ * No LSB in pre-5.3 PHP, to be refactored later
 44+ */
 45+ public static function staticInit( Parser &$parser ) {
 46+ global $egParserFunEnabledFunctions;
 47+ if( in_array( 'parse', $egParserFunEnabledFunctions ) ) {
 48+ // only register function if not disabled by configuration
 49+ $instance = new self;
 50+ $instance->init( $parser );
 51+ }
 52+ return true;
 53+ }
 54+
 55+ /**
 56+ * Gets the name of the parser hook.
 57+ * @see ParserHook::getName
 58+ *
 59+ * @return string
 60+ */
 61+ protected function getName() {
 62+ return 'parse';
 63+ }
 64+
 65+ /**
 66+ * Returns an array containing the parameter info.
 67+ * @see ParserHook::getParameterInfo
 68+ *
 69+ * @return array
 70+ */
 71+ protected function getParameterInfo( $type ) {
 72+ $params = array();
 73+
 74+ # input text.
 75+ # since 0.1
 76+ $params['text'] = new Parameter( 'text' );
 77+
 78+ # if 'true', this will prevent parsing. Usful if something should be unstripped only.
 79+ # since 0.1
 80+ $params['parse'] = new Parameter( 'parse', Parameter::TYPE_BOOLEAN );
 81+ $params['parse']->setDefault( true );
 82+
 83+ # Whether the input text should be unstripped first.
 84+ # since 0.1
 85+ $params['unstrip'] = new Parameter( 'unstrip', Parameter::TYPE_STRING );
 86+ $params['unstrip']->addCriteria( new CriterionInArray( 'none', 'nowiki', 'general', 'all' ) );
 87+ $params['unstrip']->setDefault( 'none' );
 88+
 89+ /**
 90+ * @ToDo: Perhaps a 'context' parameter would be quite interesting.
 91+ */
 92+
 93+ return $params;
 94+ }
 95+
 96+ /**
 97+ * Returns the list of default parameters.
 98+ * @see ParserHook::getDefaultParameters
 99+ *
 100+ * @return array
 101+ */
 102+ protected function getDefaultParameters( $type ) {
 103+ return array(
 104+ array( 'text', Validator::PARAM_UNNAMED ),
 105+ );
 106+ }
 107+
 108+ /**
 109+ * Returns the parser function otpions.
 110+ * @see ParserHook::getFunctionOptions
 111+ *
 112+ * @return array
 113+ */
 114+ protected function getFunctionOptions() {
 115+ return array(
 116+ 'noparse' => !$this->postParse_fallback,
 117+ 'isHTML' => false
 118+ );
 119+ }
 120+
 121+ /**
 122+ * Renders and returns the output.
 123+ * @see ParserHook::renderTag
 124+ *
 125+ * @param array $parameters
 126+ *
 127+ * @return string
 128+ */
 129+ public function render( array $parameters ) {
 130+
 131+
 132+
 133+ $text = $parameters['text'];
 134+
 135+ // current parsers StripState object
 136+ $stripState = $this->parser->mStripState;
 137+
 138+ switch( $parameters['unstrip'] ) {
 139+
 140+ // case 'none': <do nothing>
 141+
 142+ case 'nowiki':
 143+ $text = $stripState->unstripNoWiki( $text );
 144+ break;
 145+
 146+ case 'general':
 147+ $text = $stripState->unstripGeneral( $text );
 148+ break;
 149+
 150+ case 'all':
 151+ $text = $stripState->unstripBoth( $text );
 152+ break;
 153+ }
 154+
 155+ // parse if $frame is set (new MW versions) and parsing is not disabled for this one:
 156+ if( $this->frame !== null && $parameters['parse'] === true ) {
 157+
 158+ // we don't need the fallback since $frame is given:
 159+ $this->postParse_fallback = false;
 160+
 161+ /**
 162+ * Doing the parsing here allows to parse <noinclude> / <includeonly> acording to the context
 163+ * of where the function is defined and called. IF we use the parser function 'noparse' return
 164+ * value, it would always be parsed like a page view meaning <includeonly> content would appear.
 165+ */
 166+ $text = $this->parser->preprocessToDom( $text, $this->frame->isTemplate() ? Parser::PTD_FOR_INCLUSION : 0 );
 167+ $text = trim( $this->frame->expand( $text ) );
 168+ }
 169+ else {
 170+ // fallback for old MW versions or in case the 'parse' #parse parameter is set to false
 171+ $this->postParse_fallback = $parameters['parse'];
 172+ }
 173+
 174+ return $text;
 175+ }
 176+
 177+}
Property changes on: tags/extensions/ParserFun/REL_0_1/PFun_Parse.php
___________________________________________________________________
Added: svn:eol-style
1178 + native
Index: tags/extensions/ParserFun/REL_0_1/ParserFun.i18n.magic.php
@@ -0,0 +1,37 @@
 2+<?php
 3+#coding: utf-8
 4+
 5+/**
 6+ * Internationalization file for magic words of the 'Parser Fun' extension.
 7+ *
 8+ * @since 0.1
 9+ *
 10+ * @file ParserFun.i18n.magic.php
 11+ * @ingroup ParserFun
 12+ * @author Daniel Werner < danweetz@web.de >
 13+ */
 14+
 15+$magicWords = array();
 16+
 17+/** English
 18+ * @author Daniel Werner
 19+ */
 20+$magicWords['en'] = array(
 21+ 'parse' => array( 0, 'parse' ),
 22+ ExtParserFun::MAG_THIS => array( 1, 'THIS' ),
 23+);
 24+
 25+/** Message documentation (Message documentation)
 26+ * @author Daniel Werner
 27+ */
 28+$messages['qqq'] = array(
 29+ 'parse' => array( 0, 'Do not translate this! This is the magic word for the "#parse" function' ),
 30+ ExtParserFun::MAG_THIS => array( 1, 'Keyword to put in front of a variable like "{{THIS:PAGENAME}}". This will output the pagename of the page where it is defined on instead of the page actually being parsed. "THIS" refers to that page.' ),
 31+);
 32+
 33+/** German (Deutsch)
 34+ * @author Daniel Werner
 35+ */
 36+$magicWords['de'] = array(
 37+ ExtParserFun::MAG_THIS => array( 1, 'DIESER', 'DIESE', 'DIESES' ),
 38+);
Property changes on: tags/extensions/ParserFun/REL_0_1/ParserFun.i18n.magic.php
___________________________________________________________________
Added: svn:eol-style
139 + native
Index: tags/extensions/ParserFun/REL_0_1/ParserFun.i18n.php
@@ -0,0 +1,92 @@
 2+<?php
 3+
 4+/**
 5+ * Internationalization file of the 'Parser Fun' extension.
 6+ *
 7+ * @since 0.1
 8+ *
 9+ * @file ParserFun.i18n.php
 10+ * @ingroup ParserFun
 11+ * @author Daniel Werner < danweetz@web.de >
 12+ */
 13+
 14+$messages = array();
 15+
 16+/** English
 17+ * @author Daniel Werner
 18+ */
 19+$messages['en'] = array(
 20+ 'parserfun-desc' => "Adds a parser function <code>#parse</code> for parsing wikitext and introduces <code>THIS:</code> prefix for page information related magic variables",
 21+);
 22+
 23+/** Message documentation (Message documentation)
 24+ * @author Fryed-peach
 25+ */
 26+$messages['qqq'] = array(
 27+ 'parserfun-desc' => '{{desc}}',
 28+);
 29+
 30+/** German (Deutsch)
 31+ * @author Daniel Werner
 32+ * @author Kghbln
 33+ */
 34+$messages['de'] = array(
 35+ 'parserfun-desc' => 'Ergänzt die Parserfunktion <code>#parse</code> zum Parsen von Wikitext, sowie das <code>THIS:</code>-Präfix für Variablen, die von Wikiseiten Informationen abrufen',
 36+);
 37+
 38+/** French (Français)
 39+ * @author Gomoko
 40+ */
 41+$messages['fr'] = array(
 42+ 'parserfun-desc' => "Ajoute une fonction de l'analyseur <code>#parse</code> pour analyser le wikitext et introduit le préfixe <code>THIS:</code> pour l'information sur la page liée aux variables magiques",
 43+);
 44+
 45+/** Galician (Galego)
 46+ * @author Toliño
 47+ */
 48+$messages['gl'] = array(
 49+ 'parserfun-desc' => 'Engade unha función analítica <code>#parse</code> para analizar texto wiki e introduce o prefixo <code>THIS:</code> para as páxinas de información relacionadas coas variables máxicas',
 50+);
 51+
 52+/** Upper Sorbian (Hornjoserbsce)
 53+ * @author Michawiki
 54+ */
 55+$messages['hsb'] = array(
 56+ 'parserfun-desc' => 'Přidawa parserowu funkciju <code>#parse</code> za parsowanje wikiteksta a zawjeduje prefiks <code>THIS:</code> za magiske wariable, kotrež informacije stronow wotwołuja',
 57+);
 58+
 59+/** Interlingua (Interlingua)
 60+ * @author McDutchie
 61+ */
 62+$messages['ia'] = array(
 63+ 'parserfun-desc' => 'Adde al analysator syntactic un function <code>#parse</code> pro interpretar wikitexto e introduce le prefixo <code>THIS:</code> pro variabiles magic connexe a information de paginas',
 64+);
 65+
 66+/** Japanese (日本語)
 67+ * @author Fryed-peach
 68+ */
 69+$messages['ja'] = array(
 70+ 'parserfun-desc' => 'ウィキテキストの構文解析を行うパーサー関数 <code>#parse</code> を追加し、ページ情報に関連するマジック変数のための接頭辞 <code>THIS:</code> を導入する',
 71+);
 72+
 73+/** Macedonian (Македонски)
 74+ * @author Bjankuloski06
 75+ */
 76+$messages['mk'] = array(
 77+ 'parserfun-desc' => 'Додава парсерска функција <code>#parse</code> за парсирање на викитекст и го воведува префиксот <code>THIS:</code> за волшебни променливи што се однесуваат на информации за страници',
 78+);
 79+
 80+/** Malay (Bahasa Melayu)
 81+ * @author Anakmalaysia
 82+ */
 83+$messages['ms'] = array(
 84+ 'parserfun-desc' => 'Menambahkan fungsi penghurai <code>#parse</code> untuk menghuraikan teks wiki serta memperkenalkan awalan <code>THIS:</code> untuk pembolehubah sakti berkenaan maklumat laman',
 85+);
 86+
 87+/** Dutch (Nederlands)
 88+ * @author Siebrand
 89+ */
 90+$messages['nl'] = array(
 91+ 'parserfun-desc' => 'Voegt een parserfunctie <code>#parse</code> toe voor het parsen van wikitekst, en introduceert het voorvoegsel <code>THIS:</code> voor aan magische variabelen gerelateerde paginagegevens',
 92+);
 93+
Property changes on: tags/extensions/ParserFun/REL_0_1/ParserFun.i18n.php
___________________________________________________________________
Added: svn:eol-style
194 + native
Index: tags/extensions/ParserFun/REL_0_1/ParserFun.php
@@ -0,0 +1,262 @@
 2+<?php
 3+
 4+/**
 5+ * 'Parser Fun' adds a parser function '#parse' for parsing wikitext and introduces the
 6+ * 'THIS:' prefix for page information related magic variables
 7+ *
 8+ * Documentation: http://www.mediawiki.org/wiki/Extension:Parser_Fun
 9+ * Support: http://www.mediawiki.org/wiki/Extension_talk:Parser_Fun
 10+ * Source code: http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/ParserFun
 11+ *
 12+ * @version: 0.1
 13+ * @license: ISC license
 14+ * @author: Daniel Werner < danweetz@web.de >
 15+ *
 16+ * @file ParserFun.php
 17+ * @ingroup Parse
 18+ */
 19+
 20+if( !defined( 'MEDIAWIKI' ) ) {
 21+ die( 'This file is a MediaWiki extension, it is not a valid entry point' );
 22+}
 23+
 24+// Include the Validator extension if not loaded already:
 25+if ( ! defined( 'Validator_VERSION' ) ) {
 26+ @include_once( dirname( __FILE__ ) . '/../Validator/Validator.php' );
 27+}
 28+
 29+// Only initialize the extension when Validator extension is present:
 30+if ( ! defined( 'Validator_VERSION' ) ) {
 31+ die( '<p><b>Error:</b> You need to have <a href="http://www.mediawiki.org/wiki/Extension:Validator">Validator</a> installed in order to use <a href="http://www.mediawiki.org/wiki/Extension:Parse">Parse</a>.</p>' );
 32+}
 33+
 34+
 35+// Extension info & credits:
 36+$wgExtensionCredits['parserhook'][] = array(
 37+ 'path' => __FILE__,
 38+ 'name' => 'Parser Fun',
 39+ 'descriptionmsg' => 'parserfun-desc',
 40+ 'version' => ExtParserFun::VERSION,
 41+ 'author' => '[http://www.mediawiki.org/wiki/User:Danwe Daniel Werner]',
 42+ 'url' => 'http://www.mediawiki.org/wiki/Extension:Parser_Fun',
 43+);
 44+
 45+
 46+// Include the settings file:
 47+require_once ExtParserFun::getDir() . '/ParserFun_Settings.php';
 48+
 49+
 50+// magic words and message files:
 51+$wgExtensionMessagesFiles['ParserFun' ] = ExtParserFun::getDir() . '/ParserFun.i18n.php';
 52+$wgExtensionMessagesFiles['ParserFunMagic'] = ExtParserFun::getDir() . '/ParserFun.i18n.magic.php';
 53+
 54+
 55+$wgHooks['ParserFirstCallInit' ][] = 'ExtParserFun::init';
 56+
 57+
 58+// for magic word 'THISPAGENAME':
 59+$wgHooks['MagicWordwgVariableIDs' ][] = 'ExtParserFun::onMagicWordwgVariableIDs';
 60+$wgHooks['ParserGetVariableValueSwitch'][] = 'ExtParserFun::onParserGetVariableValueSwitch';
 61+
 62+
 63+// 'parse' parser function initialization:
 64+$wgAutoloadClasses['ParserFunParse'] = ExtParserFun::getDir() . '/PFun_Parse.php';
 65+
 66+$wgHooks['ParserFirstCallInit'][] = 'ParserFunParse::staticInit';
 67+$wgHooks['LanguageGetMagic' ][] = 'ParserFunParse::staticMagic';
 68+
 69+
 70+/**
 71+ * Extension class of the 'Parser Fun' extension.
 72+ * Handling the functionality around the 'THIS' magic word feature.
 73+ */
 74+class ExtParserFun {
 75+
 76+ /**
 77+ * Version of the 'Parser Fun' extension.
 78+ *
 79+ * @since 0.1
 80+ *
 81+ * @var string
 82+ */
 83+ const VERSION = '0.1';
 84+
 85+ const MAG_THIS = 'this';
 86+
 87+ public static function init( Parser &$parser ) {
 88+ global $egParserFunEnabledFunctions;
 89+ if( in_array( self::MAG_THIS, $egParserFunEnabledFunctions ) ) {
 90+ // only register function if not disabled by configuration
 91+ $parser->setFunctionHook( self::MAG_THIS, array( __CLASS__, 'pfObj_this' ), SFH_NO_HASH | SFH_OBJECT_ARGS );
 92+ }
 93+ return true;
 94+ }
 95+
 96+ /**
 97+ * Returns the extensions base installation directory.
 98+ *
 99+ * @since 0.1
 100+ *
 101+ * @return boolean
 102+ */
 103+ public static function getDir() {
 104+ static $dir = null;
 105+
 106+ if( $dir === null ) {
 107+ $dir = dirname( __FILE__ );
 108+ }
 109+ return $dir;
 110+ }
 111+
 112+ /**
 113+ * Magic word 'THIS:' to return certain information about the page the word actually is defined on
 114+ */
 115+ static function pfObj_this( Parser &$parser, PPFrame $frame = null, $args = null ) {
 116+ // if MW version is too old or something is wrong:
 117+ if( $frame === null || $frame->title === null ) {
 118+ return '';
 119+ }
 120+
 121+ // get part behind 'THIS:' if only 'THIS', use 'FULLPAGENAME'
 122+ $index = isset( $args[0] ) ? trim( $frame->expand( $args[0] ) ) : '';
 123+
 124+ $newArgs = array();
 125+
 126+ if( $index !== '' ) {
 127+ // clean up arguments as if first argument never were set:
 128+ unset( $args[0] );
 129+ foreach( $args as $arg ) {
 130+ $newArgs[] = $arg;
 131+ }
 132+
 133+ // get magic word ID of the variable name:
 134+ $mwId = self::getVariablesMagicWordId( $parser, $index );
 135+ if( $mwId === null ) {
 136+ // requested variable doesn't exist, make the thing a template call
 137+ return array( null, 'found' => false );
 138+ }
 139+ }
 140+ else {
 141+ // if only '{{THIS}}', set magic word id to 'FULLPAGENAME'
 142+ $mwId = 'fullpagename';
 143+ }
 144+
 145+ // get value:
 146+ $out = self::getThisVariableValue( $mwId, $parser, $frame, $newArgs );
 147+ if( $out === null ) {
 148+ // requested variable doesn't support 'THIS:', make the thing a template call
 149+ return array( null, 'found' => false );
 150+ }
 151+
 152+ return $out;
 153+
 154+ }
 155+
 156+ /**
 157+ * Returns the magic word ID for a variable like the user would write it. Returns null in case there
 158+ * is no word for the given variables name.
 159+ *
 160+ * @param Parser $parser
 161+ * @param type $word
 162+ * @return string|null
 163+ */
 164+ static function getVariablesMagicWordId( Parser $parser, $word ) {
 165+ // get all local (including translated) magic words IDs (values) with their actual literals (keys)
 166+ // for case insensitive [0] and sensitive [1]
 167+ $magicWords = $parser->mVariables->getHash();
 168+
 169+ if( array_key_exists( strtolower( $word ), $magicWords[0] ) ) {
 170+ // case insensitive word match
 171+ $mwId = $magicWords[0][ strtolower( $word ) ];
 172+ }
 173+ elseif( array_key_exists( $word, $magicWords[1] ) ) {
 174+ // case sensitive word match
 175+ $mwId = $magicWords[1][ $word ];
 176+ }
 177+ else {
 178+ // requested magic word doesn't exist for variables
 179+
 180+ return null;
 181+ }
 182+ return $mwId;
 183+ }
 184+
 185+ /**
 186+ * Returns the value of a variable like '{{FULLPAGENAME}}' in the context of the given PPFrame objects
 187+ * $frame->$title instead of the Parser objects subject. Returns null in case the requested variable
 188+ * doesn't support {{THIS:}}.
 189+ *
 190+ * @param string $mwId magic word ID of the variable
 191+ * @param Parser $parser
 192+ * @param PPFrame $frame
 193+ * @param array $args
 194+ *
 195+ * @return string|null
 196+ */
 197+ static function getThisVariableValue( $mwId, Parser &$parser, $frame, $args = array() ) {
 198+ $ret = null;
 199+ $title = $frame->title;
 200+
 201+ if( $title === null ) {
 202+ return null;
 203+ }
 204+
 205+ // check whether info is available, e.g. 'THIS:FULLPAGENAME' requires 'FULLPAGENAME'
 206+ switch( $mwId ) {
 207+ case 'fullpagename':
 208+ case 'fullpagenamee':
 209+ case 'pagename':
 210+ case 'pagenamee':
 211+ case 'basepagename':
 212+ case 'basepagenamee':
 213+ case 'subpagename':
 214+ case 'subpagenamee':
 215+ case 'subjectpagename':
 216+ case 'subjectpagenamee':
 217+ case 'talkpagename':
 218+ case 'talkpagenamee':
 219+ case 'namespacee': // for 'namespace', see bottom
 220+ case 'subjectspace':
 221+ case 'subjectspacee':
 222+ case 'talkspace':
 223+ case 'talkspacee':
 224+ // core parser function information requested
 225+ $ret = CoreParserFunctions::$mwId( $parser, $title->getPrefixedText() );
 226+ break;
 227+
 228+ case 'namespace':
 229+ // 'namespace' function name was renamed as PHP 5.3 came along
 230+ if( is_callable( 'CoreParserFunctions::mwnamespace' ) ) {
 231+ $ret = CoreParserFunctions::mwnamespace( $parser, $title->getPrefixedText() );
 232+ } else {
 233+ $ret = CoreParserFunctions::$mwId( $parser, $title->getPrefixedText() );
 234+ }
 235+ break;
 236+
 237+ default:
 238+ // give other extensions a chance to hook up with this and return their own values:
 239+ wfRunHooks( 'GetThisVariableValueSwitch', array( &$parser, $title, &$mwId, &$ret, $frame, $args ) );
 240+ }
 241+ return $ret;
 242+ }
 243+
 244+ static function onParserGetVariableValueSwitch( Parser &$parser, &$cache, &$magicWordId, &$ret, $frame = null ) {
 245+ switch( $magicWordId ) {
 246+ /** THIS **/
 247+ case self::MAG_THIS:
 248+ $ret = self::pfObj_this( $parser, $frame, null );
 249+ break;
 250+ }
 251+ return true;
 252+ }
 253+
 254+ static function onMagicWordwgVariableIDs( &$variableIds ) {
 255+ global $egParserFunEnabledFunctions;
 256+ if( in_array( self::MAG_THIS, $egParserFunEnabledFunctions ) ) {
 257+ // only register variable if not disabled by configuration
 258+ $variableIds[] = self::MAG_THIS;
 259+ }
 260+ return true;
 261+ }
 262+
 263+}
Property changes on: tags/extensions/ParserFun/REL_0_1/ParserFun.php
___________________________________________________________________
Added: svn:eol-style
1264 + native
Index: tags/extensions/ParserFun/REL_0_1/ParserFun_Settings.php
@@ -0,0 +1,32 @@
 2+<?php
 3+
 4+/**
 5+ * File defining the settings for the 'Parser Fun' extension.
 6+ * More info can be found at http://www.mediawiki.org/wiki/Extension:Parser_Fun#Configuration
 7+ *
 8+ * NOTICE:
 9+ * =======
 10+ * Changing one of these settings can be done by copying and placing
 11+ * it in LocalSettings.php, AFTER the inclusion of 'Parser Fun'.
 12+ *
 13+ * @file ParserFun_Settings.php
 14+ * @ingroup ParserFun
 15+ * @since 0.1
 16+ *
 17+ * @author Daniel Werner
 18+ */
 19+
 20+/**
 21+ * Allows to define which functionalities provided by 'Parser Fun' should be enabled within the wiki.
 22+ * By default all functionality is enabled.
 23+ *
 24+ * @example
 25+ * # Only enable 'THIS' prefix functionality:
 26+ * $egParserFunEnabledFunctions = array( 'this' );
 27+ * # Only enable '#parse' parser function:
 28+ * $egParserFunEnabledFunctions = array( 'parse' );
 29+ *
 30+ * @since 0.1
 31+ * @var array
 32+ */
 33+$egParserFunEnabledFunctions = array( 'this', 'parse' );
Property changes on: tags/extensions/ParserFun/REL_0_1/ParserFun_Settings.php
___________________________________________________________________
Added: svn:eol-style
134 + native
Index: tags/extensions/ParserFun/REL_0_1/README
@@ -0,0 +1,47 @@
 2+== About ==
 3+
 4+The 'Parser Fun' extension Enhances MediaWiki with the following features:
 5+
 6+(1) A new parser function to do several parser tasks manually on wikitext.
 7+ The following can be achieved by the '#parse' parser function:
 8+ - Parsing wikitext
 9+ - Unstripping '<nowiki>' and general stripped text
 10+
 11+(2) Prefix 'THIS:' (available in some other languages) which can be put in front
 12+ of site information related magic words like '{{THIS:PAGENAME}}'. This
 13+ allows to get the information from the page the phrase actually is literally
 14+ defined on instead of the page which is being parsed and where the phrase was
 15+ expanded into. '{{THIS}}' simply is synonym for '{{THIS:FULLPAGENAME}}'.
 16+ If 'THIS:' is used with an unsupported variable it will be interpreted as
 17+ template call. Currently the following functions are supported:
 18+ 'FULLPAGENAME', 'PAGENAME', 'BASEPAGENAME', 'SUBPAGENAME', 'SUBJECTPAGENAME',
 19+ 'TALKPAGENAME', 'NAMESPACE', 'SUBJECTSPACE', 'ARTICLESPACE', 'TALKSPACE'
 20+ as well as their URL-encoded equivalents ending with 'EE'.
 21+ It is possible for other extensions to support the 'THIS:' prefix, currently:
 22+ - All 'Subpage Fun' extension variables:
 23+ http://www.mediawiki.org/wiki/Extension:Subpage_Fun
 24+
 25+* Website: http://www.mediawiki.org/wiki/Extension:Parser_Fun
 26+* Author: Daniel Werner < danweetz@web.de >
 27+
 28+
 29+== Installation ==
 30+
 31+Once you have downloaded the code, place the 'ParserFun' directory within your
 32+MediaWiki 'extensions' directory. Then add the following code to your
 33+[[Manual:LocalSettings.php|LocalSettings.php]] file:
 34+
 35+ # Parser Fun
 36+ require_once( "$IP/extensions/ParserFun/ParserFun.php" );
 37+
 38+This extension requires Jeroen De Dauws 'Validator' extension (version 0.4.13 or
 39+above). It must be included before the 'Parser Fun' extension.
 40+You can get it at: http://www.mediawiki.org/wiki/Extension:Validator
 41+
 42+
 43+== Contributing ==
 44+
 45+If you have bug reports or feature requests, please add them to the 'Parser Fun'
 46+Talk page [0]. You can also send them to Daniel Werner < danweetz@web.de >
 47+
 48+[0] http://www.mediawiki.org/w/index.php?title=Extension_talk:Parser_Fun
Property changes on: tags/extensions/ParserFun/REL_0_1/README
___________________________________________________________________
Added: svn:eol-style
149 + native

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r105135Tag for 'Parser Fun' 0.1danwe23:18, 4 December 2011

Status & tagging log