summaryrefslogtreecommitdiff
path: root/extensions
diff options
context:
space:
mode:
Diffstat (limited to 'extensions')
m---------extensions/AbuseFilter0
m---------extensions/CheckUser0
-rw-r--r--extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php5
-rw-r--r--extensions/SyntaxHighlight_GeSHi/tests/parserTests.txt9
-rw-r--r--extensions/Variables/.gitignore7
-rw-r--r--extensions/Variables/.gitreview5
-rw-r--r--extensions/Variables/CODE_OF_CONDUCT.md1
-rw-r--r--extensions/Variables/COPYING16
-rw-r--r--extensions/Variables/Gruntfile.js29
-rw-r--r--extensions/Variables/README19
-rw-r--r--extensions/Variables/RELEASE-NOTES88
-rw-r--r--extensions/Variables/Variables.i18n.magic.php22
-rw-r--r--extensions/Variables/Variables.php375
-rw-r--r--extensions/Variables/Variables.settings.php29
-rw-r--r--extensions/Variables/gitinfo.json1
-rw-r--r--extensions/Variables/i18n/ast.json8
-rw-r--r--extensions/Variables/i18n/be-tarask.json9
-rw-r--r--extensions/Variables/i18n/de.json9
-rw-r--r--extensions/Variables/i18n/dsb.json8
-rw-r--r--extensions/Variables/i18n/el.json8
-rw-r--r--extensions/Variables/i18n/en.json8
-rw-r--r--extensions/Variables/i18n/es.json8
-rw-r--r--extensions/Variables/i18n/fa.json8
-rw-r--r--extensions/Variables/i18n/fr.json8
-rw-r--r--extensions/Variables/i18n/gl.json8
-rw-r--r--extensions/Variables/i18n/he.json8
-rw-r--r--extensions/Variables/i18n/hsb.json8
-rw-r--r--extensions/Variables/i18n/ia.json8
-rw-r--r--extensions/Variables/i18n/it.json8
-rw-r--r--extensions/Variables/i18n/ja.json8
-rw-r--r--extensions/Variables/i18n/ko.json8
-rw-r--r--extensions/Variables/i18n/ksh.json8
-rw-r--r--extensions/Variables/i18n/lb.json8
-rw-r--r--extensions/Variables/i18n/lij.json8
-rw-r--r--extensions/Variables/i18n/mk.json8
-rw-r--r--extensions/Variables/i18n/ms.json8
-rw-r--r--extensions/Variables/i18n/nl.json8
-rw-r--r--extensions/Variables/i18n/oc.json8
-rw-r--r--extensions/Variables/i18n/pl.json8
-rw-r--r--extensions/Variables/i18n/pms.json9
-rw-r--r--extensions/Variables/i18n/pt-br.json8
-rw-r--r--extensions/Variables/i18n/pt.json8
-rw-r--r--extensions/Variables/i18n/qqq.json10
-rw-r--r--extensions/Variables/i18n/roa-tara.json8
-rw-r--r--extensions/Variables/i18n/ru.json8
-rw-r--r--extensions/Variables/i18n/sv.json8
-rw-r--r--extensions/Variables/i18n/tl.json8
-rw-r--r--extensions/Variables/i18n/uk.json8
-rw-r--r--extensions/Variables/i18n/zh-hans.json8
-rw-r--r--extensions/Variables/i18n/zh-hant.json4
-rw-r--r--extensions/Variables/package.json12
-rw-r--r--extensions/Variables/tests/mwparsertests/Variables.txt49
-rw-r--r--extensions/Variables/version4
53 files changed, 951 insertions, 1 deletions
diff --git a/extensions/AbuseFilter b/extensions/AbuseFilter
new file mode 160000
+Subproject e4e82228a8af22fc423b282de36a970412e94a9
diff --git a/extensions/CheckUser b/extensions/CheckUser
new file mode 160000
+Subproject 710d30200318f1e8ec579bf0d07b07acbb105b5
diff --git a/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php b/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php
index 9eed2763..e2da350b 100644
--- a/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php
+++ b/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php
@@ -111,8 +111,11 @@ class SyntaxHighlight_GeSHi {
public static function parserHook( $text, $args = array(), $parser ) {
global $wgUseTidy;
+ // Replace strip markers (For e.g. {{#tag:syntaxhighlight|<nowiki>...}})
+ $out = $parser->mStripState->unstripNoWiki( $text );
+
// Don't trim leading spaces away, just the linefeeds
- $out = preg_replace( '/^\n+/', '', rtrim( $text ) );
+ $out = preg_replace( '/^\n+/', '', rtrim( $out ) );
// Convert deprecated attributes
if ( isset( $args['enclose'] ) ) {
diff --git a/extensions/SyntaxHighlight_GeSHi/tests/parserTests.txt b/extensions/SyntaxHighlight_GeSHi/tests/parserTests.txt
index c6aaa9a4..5d5038c9 100644
--- a/extensions/SyntaxHighlight_GeSHi/tests/parserTests.txt
+++ b/extensions/SyntaxHighlight_GeSHi/tests/parserTests.txt
@@ -154,3 +154,12 @@ Text <source lang="javascript" enclose="none">var a;</source>.
<p>Text <code class="mw-highlight" dir="ltr"><span class="kd">var</span> <span class="nx">a</span><span class="p">;</span></code>.
</p>
!! end
+
+!! test
+Enclose with nowiki
+!! input
+{{#tag:syntaxhighlight|<nowiki>foo</nowiki>|lang="text"|inline=none}}
+!! result
+<p><code class="mw-highlight" dir="ltr">foo</code>
+</p>
+!! end
diff --git a/extensions/Variables/.gitignore b/extensions/Variables/.gitignore
new file mode 100644
index 00000000..e62fc28b
--- /dev/null
+++ b/extensions/Variables/.gitignore
@@ -0,0 +1,7 @@
+node_modules/
+vendor/
+
+.svn
+*~
+*.kate-swp
+.*.swp
diff --git a/extensions/Variables/.gitreview b/extensions/Variables/.gitreview
new file mode 100644
index 00000000..70796b30
--- /dev/null
+++ b/extensions/Variables/.gitreview
@@ -0,0 +1,5 @@
+[gerrit]
+host=gerrit.wikimedia.org
+port=29418
+project=mediawiki/extensions/Variables.git
+track=1
diff --git a/extensions/Variables/CODE_OF_CONDUCT.md b/extensions/Variables/CODE_OF_CONDUCT.md
new file mode 100644
index 00000000..d8e5d087
--- /dev/null
+++ b/extensions/Variables/CODE_OF_CONDUCT.md
@@ -0,0 +1 @@
+The development of this software is covered by a [Code of Conduct](https://www.mediawiki.org/wiki/Code_of_Conduct).
diff --git a/extensions/Variables/COPYING b/extensions/Variables/COPYING
new file mode 100644
index 00000000..de01985a
--- /dev/null
+++ b/extensions/Variables/COPYING
@@ -0,0 +1,16 @@
+Copyright (c) 2006 - 2007 by Rob Adams
+Copyright (c) 2007 by Tom Hempel
+Copyright (c) 2008 by Xiloynaha
+Copyright (c) 2009 - 2012 by Daniel Werner < danweetz@web.de >
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/extensions/Variables/Gruntfile.js b/extensions/Variables/Gruntfile.js
new file mode 100644
index 00000000..2db815fa
--- /dev/null
+++ b/extensions/Variables/Gruntfile.js
@@ -0,0 +1,29 @@
+/*jshint node:true */
+module.exports = function ( grunt ) {
+ grunt.loadNpmTasks( 'grunt-jsonlint' );
+ grunt.loadNpmTasks( 'grunt-contrib-jshint' );
+ grunt.loadNpmTasks( 'grunt-banana-checker' );
+
+ grunt.initConfig( {
+ banana: {
+ all: 'i18n/'
+ },
+ jshint: {
+ all: [
+ '**/*.js',
+ '!node_modules/**',
+ '!vendor/**'
+ ]
+ },
+ jsonlint: {
+ all: [
+ '**/*.json',
+ '!node_modules/**',
+ '!vendor/**'
+ ]
+ }
+ } );
+
+ grunt.registerTask( 'test', [ 'jsonlint', 'banana', 'jshint' ] );
+ grunt.registerTask( 'default', 'test' );
+};
diff --git a/extensions/Variables/README b/extensions/Variables/README
new file mode 100644
index 00000000..9c5b7492
--- /dev/null
+++ b/extensions/Variables/README
@@ -0,0 +1,19 @@
+== About ==
+
+The 'Variables' extension for MediaWiki introduces parser functions for defining page-scoped
+variables within wiki pages.
+
+* Website: https://www.mediawiki.org/wiki/Extension:Variables
+* Authors: Rob Adams, Tom Hempel, Xiloynaha and Daniel Werner
+* License: Public domain
+
+
+== Installation ==
+
+Once you have downloaded the code, place the 'Variables' directory within your
+MediaWiki 'extensions' directory. Then add the following code to your
+[[Manual:LocalSettings.php|LocalSettings.php]] file:
+
+ # Variables
+ require_once( "$IP/extensions/Variables/Variables.php" );
+
diff --git a/extensions/Variables/RELEASE-NOTES b/extensions/Variables/RELEASE-NOTES
new file mode 100644
index 00000000..57ed6686
--- /dev/null
+++ b/extensions/Variables/RELEASE-NOTES
@@ -0,0 +1,88 @@
+ git era Changelog:
+ ==================
+
+ * (trunk) -- Version 2.0.1
+ - Using 'InternalParseBeforeSanitize' hook instead of 'InternalParseBeforeLinks' for MW 1.20
+ - Put into gerrit.wikimedia.org git repository.
+
+
+ svn era Changelog:
+ ==================
+
+ * (trunk) -- Version 2.0.1
+ - Localization added for various languages.
+
+ * November 16, 2010 -- Version 2.0 by Daniel Werner
+ Version 2.0 almost is a complete rewrite of the extension, just the idea remains the
+ same. It's the attempt to get rid of several bugs caused by the fact that MediaWiki
+ is using several Parser objects. Therefore in v2 each Parser has its own Variables
+ store, so nothing will get mixed up anymore. Full compatibility is given, except perhaps
+ in cases where bugs were used intentionally.
+
+ New features and bugfixes:
+ - Inclusion of special pages in the middle of the page won't reset all defined
+ variables anymore.
+ - Variables should now be compatible with all other extensions, except for those still
+ using Parser::parse() recursively in any way (which should never be done!).
+ - For MW 1.12 and later, '#var' default value no longer gets expanded when not needed.
+ - Experimental new function '#var_final' which allows to insert the variables final
+ (last) value after page processing is almost through.
+ - Global configuration variable '$egVariablesDisabledFunctions' added.
+
+ Internal changes:
+ - Parser class member $mExtVariables now contains an instance of ExtVariables where
+ only variables for that parser are getting stored. They won't be deleted by other
+ Parser actions anymore (e.g. special page inclusion doesn't reset variables anymore)
+ - ExtVariables class now has public functions which should be used by other extensions
+ for getting and setting variables information.
+ - Removed global '$wgExtVariables' variable.
+ - 'Variables_Settings.php' file for configuration settings added.
+
+ Others:
+ - Put under 'ISC License' (public domain before).
+ - In case you are using Extension:Loops, you should update it as well to remain compatibility.
+
+
+ * November 14, 2011 -- Version 1.3.1.1 (re-pack of 1.3.1 tagged version for svn)
+ - Although 1.4 is released already and 2.0 in the trunk, ensure one last version
+ compatible with MW < 1.12 still is available
+ - Some comments cleaned, 'RELEASE-NOTES' and 'README' files added.
+
+
+ * November 13, 2011 -- Version 1.4 by Daniel Werner
+ - Cleanup for use with more current MW versions:
+ + 'ParserFirstCallInit' hook in use and no more global extension functions.
+ + State of the Art internationalization files added.
+ - Dropped support for MW before 1.12
+ - 'ExtVariables::VARIABLES' constant with version info added.
+ - Put into mediawiki.org svn, 'RELEASE-NOTES' and 'README' files added.
+
+
+ Pre svn Changelog:
+ ==================
+
+ The following pre-svn changelog was composed by Daniel Werner in the hope it might
+ give an almost complete overview of all major releases of 'Variables' extension.
+ All changes can still be retrace at
+
+ https://www.mediawiki.org/w/index.php?title=Extension:VariablesExtension&action=history
+
+ * July 20, 2010 -- Version 1.3 by Daniel Werner
+ - Removed critical bug. Some kind of "Superglobal" variables. In some cases values
+ were passed from one page to another page during page imports and job queue jobs.
+
+ * March 28, 2009 -- Version 1.2 by Daniel Werner
+ - '#varexists' function introduced
+ - parameter for default value for '#var' function in case the variable doesn't exist
+ or its value is just an empty string.
+
+ * December 5, 2008 -- Version 1.1 by user 'Xiloynaha'
+ - '#vardefineecho' function introduced
+
+ * June 24, 2007 -- r3, Language file added by unknown contributor
+
+ * October 11, 2006 -- r2, Fixes for MediaWiki 1.8 compatibility by Tom Hempel
+ - '$wgExtensionCredits' and '$wgHooks' being used.
+
+ * October 11, 2006 -- r1, initial release by Rob Adams
+ - First version of 'Variables', introducing '#vardefine' and '#var'
diff --git a/extensions/Variables/Variables.i18n.magic.php b/extensions/Variables/Variables.i18n.magic.php
new file mode 100644
index 00000000..7d7292f0
--- /dev/null
+++ b/extensions/Variables/Variables.i18n.magic.php
@@ -0,0 +1,22 @@
+<?php
+#coding: utf-8
+
+/**
+ * Internationalization file for magic words of the 'Variables' extension.
+ *
+ * @since 1.4
+ *
+ * @file Variables.i18n.magic.php
+ * @ingroup Variables
+ * @author Daniel Werner < danweetz@web.de >
+ */
+
+$magicWords = array();
+
+$magicWords['en'] = array(
+ 'var' => array( 0, 'var' ),
+ 'var_final' => array( 0, 'var_final' ),
+ 'vardefine' => array( 0, 'vardefine' ),
+ 'vardefineecho' => array( 0, 'vardefineecho' ),
+ 'varexists' => array( 0, 'varexists' ),
+);
diff --git a/extensions/Variables/Variables.php b/extensions/Variables/Variables.php
new file mode 100644
index 00000000..84d6c90c
--- /dev/null
+++ b/extensions/Variables/Variables.php
@@ -0,0 +1,375 @@
+<?php
+
+/**
+ * 'Variables' introduces parser functions for defining page-scoped variables within
+ * wiki pages.
+ *
+ * Documentation: https://www.mediawiki.org/wiki/Extension:Variables
+ * Support: https://www.mediawiki.org/wiki/Extension_talk:Variables
+ * Source code: https://phabricator.wikimedia.org/diffusion/EVAR/
+ *
+ * @license: ISC License
+ * @author: Rob Adams
+ * @author: Tom Hempel
+ * @author: Xiloynaha
+ * @author: Daniel Werner < danweetz@web.de >
+ *
+ * @file Variables.php
+ * @ingroup Variables
+ */
+
+// Ensure that the script cannot be executed outside of MediaWiki.
+if ( !defined( 'MEDIAWIKI' ) ) {
+ die( 'This is an extension to MediaWiki and cannot be run standalone.' );
+}
+
+// Display extension properties on MediaWiki.
+$wgExtensionCredits['parserhook'][] = array(
+ 'path' => __FILE__,
+ 'name' => 'Variables',
+ 'descriptionmsg' => 'variables-desc',
+ 'version' => ExtVariables::VERSION,
+ 'author' => array(
+ 'Rob Adams',
+ 'Tom Hempel',
+ 'Xiloynaha',
+ '[https://www.mediawiki.org/wiki/User:Danwe Daniel Werner]',
+ '...'
+ ),
+ 'url' => 'https://www.mediawiki.org/wiki/Extension:Variables',
+ 'license-name' => 'ISC'
+);
+
+// language files:
+$wgMessagesDirs['Variables'] = __DIR__ . '/i18n';
+$wgExtensionMessagesFiles['VariablesMagic'] = ExtVariables::getDir() . '/Variables.i18n.magic.php';
+
+// hooks registration:
+$wgHooks['ParserFirstCallInit'][] = 'ExtVariables::init';
+$wgHooks['ParserClearState'][] = 'ExtVariables::onParserClearState';
+$wgHooks['InternalParseBeforeSanitize'][] = 'ExtVariables::onInternalParseBeforeSanitize';
+
+// parser tests registration:
+$wgParserTestFiles[] = ExtVariables::getDir() . '/tests/mwparsertests/Variables.txt';
+
+// Include the settings file:
+require_once ExtVariables::getDir() . '/Variables.settings.php';
+
+
+/**
+ * Extension class with basic extension information. This class serves as static
+ * class with the static parser functions but also als variables store instance
+ * as object assigned to a Parser object.
+ */
+class ExtVariables {
+
+ /**
+ * Version of the 'Variables' extension.
+ *
+ * @since 1.4
+ *
+ * @var string
+ */
+ const VERSION = '2.2.0';
+
+ /**
+ * Internal store for variable values
+ *
+ * @private
+ * @var array
+ */
+ public $mVariables = array();
+
+ /**
+ * Array with all names of variables requested by '#var_final'. Key of the values is the
+ * stripSateId of the strip-item placed where the final var should appear.
+ *
+ * @since 2.0
+ *
+ * @private
+ * @var array
+ */
+ public $mFinalizedVars = array();
+
+ /**
+ * Variables extensions own private StripState manager to manage '#final_var' placeholders
+ * and their replacement with the final var value or a defined default.
+ *
+ * @since 2.0
+ *
+ * @private
+ * @var StripState
+ */
+ public $mFinalizedVarsStripState;
+
+ /**
+ * Sets up parser functions
+ *
+ * @since 1.4
+ */
+ public static function init( Parser &$parser ) {
+
+ /*
+ * store for variables per parser object. This will solve several bugs related to
+ * 'ParserClearState' hook clearing all variables early in combination with certain
+ * other extensions. (since v2.0)
+ */
+ $parser->mExtVariables = new self();
+
+ // Parser::SFH_OBJECT_ARGS available since MW 1.12
+ self::initFunction( $parser, 'var', array( __CLASS__, 'pfObj_var' ), Parser::SFH_OBJECT_ARGS );
+ self::initFunction( $parser, 'var_final' );
+ self::initFunction( $parser, 'vardefine' );
+ self::initFunction( $parser, 'vardefineecho' );
+ self::initFunction( $parser, 'varexists' );
+
+ return true;
+ }
+ private static function initFunction( Parser &$parser, $name, $functionCallback = null, $flags = 0 ) {
+ if( $functionCallback === null ) {
+ // prefix parser functions with 'pf_'
+ $functionCallback = array( __CLASS__, 'pf_' . $name );
+ }
+ global $egVariablesDisabledFunctions;
+
+ // register function only if not disabled by configuration:
+ if( ! in_array( $name, $egVariablesDisabledFunctions ) ) {
+ $parser->setFunctionHook( $name, $functionCallback, $flags );
+ }
+ }
+
+ /**
+ * Returns the extensions base installation directory.
+ *
+ * @since 2.0
+ *
+ * @return string
+ */
+ public static function getDir() {
+ static $dir = null;
+
+ if( $dir === null ) {
+ $dir = dirname( __FILE__ );
+ }
+ return $dir;
+ }
+
+
+ ####################
+ # Parser Functions #
+ ####################
+
+ static function pf_varexists( Parser &$parser, $varName = '', $exists=true, $noexists=false ) {
+ if( self::get( $parser )->varExists( $varName ) ) {
+ return $exists;
+ } else {
+ return $noexists;
+ }
+ }
+
+ static function pf_vardefine( Parser &$parser, $varName = '', $value = '' ) {
+ self::get( $parser )->setVarValue( $varName, $value );
+ return '';
+ }
+
+ static function pf_vardefineecho( Parser &$parser, $varName = '', $value = '' ) {
+ self::get( $parser )->setVarValue( $varName, $value );
+ return $value;
+ }
+
+ static function pfObj_var( Parser &$parser, $frame, $args) {
+ $varName = trim( $frame->expand( $args[0] ) ); // first argument expanded already but lets do this anyway
+ $varVal = self::get( $parser )->getVarValue( $varName, null );
+
+ // default applies if var doesn't exist but also in case it is an empty string!
+ if( $varVal === null || $varVal === '' ) {
+ // only expand argument when needed:
+ $defaultVal = isset( $args[1] ) ? trim( $frame->expand( $args[1] ) ) : '';
+ return $defaultVal;
+ }
+ return $varVal;
+ }
+
+ static function pf_var_final( Parser &$parser, $varName, $defaultVal = '' ) {
+ return self::get( $parser )->requestFinalizedVar( $parser, $varName, $defaultVal );
+ }
+
+
+ ##############
+ # Used Hooks #
+ ##############
+
+ /**
+ * Used for '#var_final' parser function to insert the final variable values.
+ * @see http://www.mediawiki.org/wiki/Manual:Hooks/InternalParseBeforeSanitize
+ *
+ * @since 2.0.1
+ */
+ static function onInternalParseBeforeSanitize( Parser &$parser, &$text ) {
+ $varStore = self::get( $parser );
+
+ // only do this if '#var_final' was used
+ if( $varStore->mFinalizedVarsStripState === null ) {
+ return true;
+ }
+
+ /*
+ * all vars are final now, check whether requested vars can be inserted for '#final_var' or
+ * if the default has to be inserted. In any case, adjust the strip item value
+ */
+ foreach( $varStore->mFinalizedVars as $stripStateId => $varName ) {
+
+ $varVal = $varStore->getVarValue( $varName, '' );
+ if( $varVal !== '' ) {
+ // replace strip item value with final variables value or registered default:
+ $varStore->stripStatePair( $stripStateId, $varVal );
+ }
+ }
+
+ /**
+ * Unstrip all '#var_final' strip-markers with their final '#var' or default values.
+ * This HAS to be done here and can't be done through the normal unstrip process of MW.
+ * This because the default value as well as the variables value stil have to be rendered properly since they
+ * may contain links or even category links. On the other hand, they can't be parsed with Parser::recursiveTagParse()
+ * since this would parse wiki templates and functions which are intended as normal text, kind of similar to
+ * returning a parser functions value with 'noparse' => true.
+ * Also, there is no way to expand the '#var_final' default value here, just if needed, since the output could be an
+ * entirely different, e.g. if variables are used.
+ * This method also takes care of recursive '#var_final' calls (within the default value) quite well.
+ */
+ $text = $varStore->mFinalizedVarsStripState->unstripGeneral( $text );
+ return true;
+ }
+
+ /**
+ * This will clean up the variables store after parsing has finished. It will prevent strange things to happen
+ * for example during import of several pages or job queue is running for multiple pages. In these cases variables
+ * would become some kind of superglobals, being passed from one page to the other.
+ */
+ static function onParserClearState( Parser &$parser ) {
+ /**
+ * MessageCaches Parser clone will mess things up if we don't reset the entire object.
+ * Only resetting the array would unset it in the original object as well! This instead
+ * will break the entire reference to the object
+ */
+ $parser->mExtVariables = new self();
+ return true;
+ }
+
+
+ ##################
+ # Private Helper #
+ ##################
+
+ /**
+ * Takes care of setting a strip state pair
+ */
+ protected function stripStatePair( $marker, $value ) {
+ $this->mFinalizedVarsStripState->addGeneral( $marker, $value );
+ }
+
+
+ ####################################
+ # Public functions for interaction #
+ ####################################
+ #
+ # public non-parser functions, accessible for
+ # other extensions doing interactive stuff
+ # with 'Variables' (like Extension:Loops)
+ #
+
+ /**
+ * Convenience function to return the 'Variables' extensions variables store connected
+ * to a certain Parser object. Each parser has its own store which will be reset after
+ * a parsing process [Parser::parse()] has finished.
+ *
+ * @param Parser &$parser
+ *
+ * @return ExtVariables by reference so we still have the right object after 'ParserClearState'
+ */
+ public static function &get( Parser &$parser ) {
+ return $parser->mExtVariables;
+ }
+
+ /**
+ * Defines a variable, accessible by getVarValue() or '#var' parser function. Name and
+ * value will be trimmed and converted to string.
+ *
+ * @param string $varName
+ * @param string $value will be converted to string if no string is given
+ */
+ public function setVarValue( $varName, $value = '' ) {
+ $this->mVariables[ trim( $varName ) ] = trim( $value );
+ }
+
+ /**
+ * Returns a variables value or null if it doesn't exist.
+ *
+ * @param string $varName
+ * @param mixed $defaultVal
+ *
+ * @return string or mixed in case $defaultVal is being returned and not of type string
+ */
+ public function getVarValue( $varName, $defaultVal = null ) {
+ $varName = trim( $varName );
+ if ( $this->varExists( $varName ) ) {
+ return $this->mVariables[ $varName ];
+ } else {
+ return $defaultVal;
+ }
+ }
+
+ /**
+ * Checks whether a variable exists within the scope.
+ *
+ * @param string $varName
+ *
+ * @return boolean
+ */
+ public function varExists( $varName ) {
+ $varName = trim( $varName );
+ return array_key_exists( $varName, $this->mVariables );
+ }
+
+ /**
+ * Allows to unset a certain variable
+ *
+ * @param type $varName
+ */
+ public function unsetVar( $varName ) {
+ unset( $this->mVariables[ $varName ] );
+ }
+
+ /**
+ * Allows to register the usage of '#var_final'. Meaning a variable can be set as well
+ * as a default value. The return value, a strip-item then can be inserted into any
+ * wikitext processed by the same parser. Later that strip-item will be replaced with
+ * the final var text.
+ * Note: It's not possible to use the returned strip-item within other stripped text
+ * since 'Variables' unstripping will happen before the general unstripping!
+ *
+ * @param Parser $parser
+ * @param string $varName
+ * @param string $defaultVal
+ *
+ * @return string strip-item
+ */
+ function requestFinalizedVar( Parser &$parser, $varName, $defaultVal = '' ) {
+ if( $this->mFinalizedVarsStripState === null ) {
+ $this->mFinalizedVarsStripState = new StripState;
+ }
+ $id = count( $this->mFinalizedVars );
+ /*
+ * strip-item which will be unstripped in self::onInternalParseBeforeSanitize()
+ * In case the requested final variable has a value in the end, this strip-item
+ * value will be replaced with that value before unstripping.
+ */
+ $rnd = "{$parser->mUniqPrefix}-finalizedvar-{$id}-" . Parser::MARKER_SUFFIX;
+
+ $this->stripStatePair( $rnd, trim( $defaultVal ) );
+ $this->mFinalizedVars[ $rnd ] = trim( $varName );
+
+ return $rnd;
+ }
+
+}
diff --git a/extensions/Variables/Variables.settings.php b/extensions/Variables/Variables.settings.php
new file mode 100644
index 00000000..43b04cdf
--- /dev/null
+++ b/extensions/Variables/Variables.settings.php
@@ -0,0 +1,29 @@
+<?php
+
+/**
+ * File defining the settings for the 'Variables' extension.
+ * More info can be found at http://www.mediawiki.org/wiki/Extension:Variables#Configuration
+ *
+ * NOTICE:
+ * =======
+ * Changing one of these settings can be done by copying and placing
+ * it in LocalSettings.php, AFTER the inclusion of 'Variables'.
+ *
+ * @file Variables_Settings.php
+ * @ingroup Variables
+ * @since 2.0
+ *
+ * @author Daniel Werner
+ */
+
+/**
+ * Allows to define functions which should not be available within the wiki.
+ *
+ * @example
+ * # disable '#var_final' and '#vardefineecho' functions:
+ * $egVariablesDisabledFunctions = array( 'var_final', 'vardefineecho' );
+ *
+ * @since 2.0
+ * @var array
+ */
+$egVariablesDisabledFunctions = array();
diff --git a/extensions/Variables/gitinfo.json b/extensions/Variables/gitinfo.json
new file mode 100644
index 00000000..c972f07f
--- /dev/null
+++ b/extensions/Variables/gitinfo.json
@@ -0,0 +1 @@
+{"headSHA1": "c75b9d4669d15397ada8480d64cfe17dea798495\n", "head": "c75b9d4669d15397ada8480d64cfe17dea798495\n", "remoteURL": "https://gerrit.wikimedia.org/r/mediawiki/extensions/Variables", "branch": "c75b9d4669d15397ada8480d64cfe17dea798495\n", "headCommitDate": "1501149227"} \ No newline at end of file
diff --git a/extensions/Variables/i18n/ast.json b/extensions/Variables/i18n/ast.json
new file mode 100644
index 00000000..102fa51a
--- /dev/null
+++ b/extensions/Variables/i18n/ast.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Xuacu"
+ ]
+ },
+ "variables-desc": "Funciones analítiques que permiten trabayar con variables dinámiques nun contestu d'artículu"
+}
diff --git a/extensions/Variables/i18n/be-tarask.json b/extensions/Variables/i18n/be-tarask.json
new file mode 100644
index 00000000..2ed73e0b
--- /dev/null
+++ b/extensions/Variables/i18n/be-tarask.json
@@ -0,0 +1,9 @@
+{
+ "@metadata": {
+ "authors": [
+ "Jim-by",
+ "Wizardist"
+ ]
+ },
+ "variables-desc": "Функцыі парсэра для працы з дынамічнымі зьменнымі ў кантэксьце артыкулаў"
+}
diff --git a/extensions/Variables/i18n/de.json b/extensions/Variables/i18n/de.json
new file mode 100644
index 00000000..c234ec34
--- /dev/null
+++ b/extensions/Variables/i18n/de.json
@@ -0,0 +1,9 @@
+{
+ "@metadata": {
+ "authors": [
+ "Daniel Werner",
+ "Kghbln"
+ ]
+ },
+ "variables-desc": "Ergänzt Parserfunktionen die dynamische Variablen ermöglichen"
+}
diff --git a/extensions/Variables/i18n/dsb.json b/extensions/Variables/i18n/dsb.json
new file mode 100644
index 00000000..51809668
--- /dev/null
+++ b/extensions/Variables/i18n/dsb.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Michawiki"
+ ]
+ },
+ "variables-desc": "Parserowe funkcije, kótarež dowóluju źěłanje z dynamiskimi wariablami w nastawkach"
+}
diff --git a/extensions/Variables/i18n/el.json b/extensions/Variables/i18n/el.json
new file mode 100644
index 00000000..548f021d
--- /dev/null
+++ b/extensions/Variables/i18n/el.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Protnet"
+ ]
+ },
+ "variables-desc": "Συναρτήσεις συντακτικού αναλυτή που επιτρέπουν την εργασία με δυναμικές μεταβλητές σε πλαίσιο εύρους άρθρου"
+}
diff --git a/extensions/Variables/i18n/en.json b/extensions/Variables/i18n/en.json
new file mode 100644
index 00000000..b99b95f5
--- /dev/null
+++ b/extensions/Variables/i18n/en.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Daniel Werner"
+ ]
+ },
+ "variables-desc": "Parser functions allowing to work with dynamic variables in an article scoped context"
+}
diff --git a/extensions/Variables/i18n/es.json b/extensions/Variables/i18n/es.json
new file mode 100644
index 00000000..940100e4
--- /dev/null
+++ b/extensions/Variables/i18n/es.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Armando-Martin"
+ ]
+ },
+ "variables-desc": "Funciones de analizador (parser) que permiten trabajar con variables dinámicas en el contexto de un artículo"
+}
diff --git a/extensions/Variables/i18n/fa.json b/extensions/Variables/i18n/fa.json
new file mode 100644
index 00000000..3f8949ed
--- /dev/null
+++ b/extensions/Variables/i18n/fa.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Armin1392"
+ ]
+ },
+ "variables-desc": "عملیات تجزیه‌کننده برای کار کردن با متغیرهای پویا در یک مقاله بافت محدود شده، اجازه می‌دهد"
+}
diff --git a/extensions/Variables/i18n/fr.json b/extensions/Variables/i18n/fr.json
new file mode 100644
index 00000000..6cf721ab
--- /dev/null
+++ b/extensions/Variables/i18n/fr.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "DavidL"
+ ]
+ },
+ "variables-desc": "Fonctions de l'interpréteur permettant de travailler avec les variables dynamiques dans le contexte d'un article"
+}
diff --git a/extensions/Variables/i18n/gl.json b/extensions/Variables/i18n/gl.json
new file mode 100644
index 00000000..d75232cf
--- /dev/null
+++ b/extensions/Variables/i18n/gl.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Toliño"
+ ]
+ },
+ "variables-desc": "Funcións analíticas destinadas aos artigos que permiten traballar con variables dinámicas"
+}
diff --git a/extensions/Variables/i18n/he.json b/extensions/Variables/i18n/he.json
new file mode 100644
index 00000000..d593d459
--- /dev/null
+++ b/extensions/Variables/i18n/he.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Amire80"
+ ]
+ },
+ "variables-desc": "פונקציות מפענח שמאפשרות עבודה עם משתנים דינמיים בהקשר בתחום של ערך"
+}
diff --git a/extensions/Variables/i18n/hsb.json b/extensions/Variables/i18n/hsb.json
new file mode 100644
index 00000000..da4ed62c
--- /dev/null
+++ b/extensions/Variables/i18n/hsb.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Michawiki"
+ ]
+ },
+ "variables-desc": "Parserowe funkcije, kotre dźěłanje z dynamiskimi wariablemi w nastawkach dowoleja"
+}
diff --git a/extensions/Variables/i18n/ia.json b/extensions/Variables/i18n/ia.json
new file mode 100644
index 00000000..0af21568
--- /dev/null
+++ b/extensions/Variables/i18n/ia.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "McDutchie"
+ ]
+ },
+ "variables-desc": "Functiones del analysator syntactic que permitte laborar con variabiles dynamic in un \"article scoped context\""
+}
diff --git a/extensions/Variables/i18n/it.json b/extensions/Variables/i18n/it.json
new file mode 100644
index 00000000..f178cc94
--- /dev/null
+++ b/extensions/Variables/i18n/it.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Beta16"
+ ]
+ },
+ "variables-desc": "Funzioni parser che permettono di lavorare con variabili dinamiche in una pagina con ambito di contesto"
+}
diff --git a/extensions/Variables/i18n/ja.json b/extensions/Variables/i18n/ja.json
new file mode 100644
index 00000000..94f7e865
--- /dev/null
+++ b/extensions/Variables/i18n/ja.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Fryed-peach"
+ ]
+ },
+ "variables-desc": "記事をスコープとするコンテキストで動的変数を利用可能にするパーサー関数"
+}
diff --git a/extensions/Variables/i18n/ko.json b/extensions/Variables/i18n/ko.json
new file mode 100644
index 00000000..826facd5
--- /dev/null
+++ b/extensions/Variables/i18n/ko.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "아라"
+ ]
+ },
+ "variables-desc": "문서 범위 맥락에서 동적 변수와 함께 작동할 수 있도록 하는 파서 함수"
+}
diff --git a/extensions/Variables/i18n/ksh.json b/extensions/Variables/i18n/ksh.json
new file mode 100644
index 00000000..7eb61da1
--- /dev/null
+++ b/extensions/Variables/i18n/ksh.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Purodha"
+ ]
+ },
+ "variables-desc": "Paaser-Funxjuhne för dynaamesch Varijable em Zusammehang met Atikelle."
+}
diff --git a/extensions/Variables/i18n/lb.json b/extensions/Variables/i18n/lb.json
new file mode 100644
index 00000000..3c0e5dfc
--- /dev/null
+++ b/extensions/Variables/i18n/lb.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Robby"
+ ]
+ },
+ "variables-desc": "Parserfonktiounen déi et erlabe fir mat dynamesche Variabelen am Kontext vun engem Artikel ze schaffen"
+}
diff --git a/extensions/Variables/i18n/lij.json b/extensions/Variables/i18n/lij.json
new file mode 100644
index 00000000..2c870016
--- /dev/null
+++ b/extensions/Variables/i18n/lij.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Giromin Cangiaxo"
+ ]
+ },
+ "variables-desc": "Fonçioin parser che permettan de travagiâ con de variabbile dinammiche into contesto de 'n articcolo."
+}
diff --git a/extensions/Variables/i18n/mk.json b/extensions/Variables/i18n/mk.json
new file mode 100644
index 00000000..9b7b5c5e
--- /dev/null
+++ b/extensions/Variables/i18n/mk.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Bjankuloski06"
+ ]
+ },
+ "variables-desc": "Rасчленувачки функции што овозможуваат работа со динамични променливи во контекст со опфатност определена во страница"
+}
diff --git a/extensions/Variables/i18n/ms.json b/extensions/Variables/i18n/ms.json
new file mode 100644
index 00000000..8cf3cb8d
--- /dev/null
+++ b/extensions/Variables/i18n/ms.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Anakmalaysia"
+ ]
+ },
+ "variables-desc": "Fungsi-fungsi penghurai yang membenarkan kerja dengan pembolehubah dinamk dalam konteks berskop rencana"
+}
diff --git a/extensions/Variables/i18n/nl.json b/extensions/Variables/i18n/nl.json
new file mode 100644
index 00000000..48c18209
--- /dev/null
+++ b/extensions/Variables/i18n/nl.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Saruman"
+ ]
+ },
+ "variables-desc": "Parserfuncties die het mogelijk maken om met dynamische variabelen te werken in een paginacontext"
+}
diff --git a/extensions/Variables/i18n/oc.json b/extensions/Variables/i18n/oc.json
new file mode 100644
index 00000000..5f57be70
--- /dev/null
+++ b/extensions/Variables/i18n/oc.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Cedric31"
+ ]
+ },
+ "variables-desc": "Foncions de l'interpretador que permeton de trabalhar amb las variablas dinamicas dins lo contèxte d'un article"
+}
diff --git a/extensions/Variables/i18n/pl.json b/extensions/Variables/i18n/pl.json
new file mode 100644
index 00000000..0493a77b
--- /dev/null
+++ b/extensions/Variables/i18n/pl.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "BeginaFelicysym"
+ ]
+ },
+ "variables-desc": "Funkcje parsera umożliwiają pracę ze zmiennymi dynamicznymi w kontekście ograniczonym do artykułu"
+}
diff --git a/extensions/Variables/i18n/pms.json b/extensions/Variables/i18n/pms.json
new file mode 100644
index 00000000..9a77fa37
--- /dev/null
+++ b/extensions/Variables/i18n/pms.json
@@ -0,0 +1,9 @@
+{
+ "@metadata": {
+ "authors": [
+ "Borichèt",
+ "Dragonòt"
+ ]
+ },
+ "variables-desc": "Funsion ëd l'analisator ch'a përmëtto ëd travajé con le variàbij dinàmiche ant ël contest ëd n'artìcol"
+}
diff --git a/extensions/Variables/i18n/pt-br.json b/extensions/Variables/i18n/pt-br.json
new file mode 100644
index 00000000..4e1abf2a
--- /dev/null
+++ b/extensions/Variables/i18n/pt-br.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Cainamarques"
+ ]
+ },
+ "variables-desc": "Funções sintáticas que permitem trabalhar com variáveis dinâmicas no contexto de um artigo"
+}
diff --git a/extensions/Variables/i18n/pt.json b/extensions/Variables/i18n/pt.json
new file mode 100644
index 00000000..c907bfb6
--- /dev/null
+++ b/extensions/Variables/i18n/pt.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Hamilton Abreu"
+ ]
+ },
+ "variables-desc": "Funções do analisador sintático que permitem trabalhar com variáveis dinâmicas num contexto limitado ao âmbito de uma página"
+}
diff --git a/extensions/Variables/i18n/qqq.json b/extensions/Variables/i18n/qqq.json
new file mode 100644
index 00000000..7976e780
--- /dev/null
+++ b/extensions/Variables/i18n/qqq.json
@@ -0,0 +1,10 @@
+{
+ "@metadata": {
+ "authors": [
+ "Purodha",
+ "Shirayuki",
+ "Umherirrender"
+ ]
+ },
+ "variables-desc": "{{desc|name=Variables|url=https://www.mediawiki.org/wiki/Extension:Variables}}"
+}
diff --git a/extensions/Variables/i18n/roa-tara.json b/extensions/Variables/i18n/roa-tara.json
new file mode 100644
index 00000000..9fc0cf60
--- /dev/null
+++ b/extensions/Variables/i18n/roa-tara.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Joetaras"
+ ]
+ },
+ "variables-desc": "Le funziune analizzatrice permettene de fatià cu le variabbile dinameche jndr'à 'na vôsce jndr'à 'nu condeste"
+}
diff --git a/extensions/Variables/i18n/ru.json b/extensions/Variables/i18n/ru.json
new file mode 100644
index 00000000..c9fc605b
--- /dev/null
+++ b/extensions/Variables/i18n/ru.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Putnik"
+ ]
+ },
+ "variables-desc": "Функции парсера, позволяющие работать с динамическими переменными в контексте области статьи"
+}
diff --git a/extensions/Variables/i18n/sv.json b/extensions/Variables/i18n/sv.json
new file mode 100644
index 00000000..0c87d22c
--- /dev/null
+++ b/extensions/Variables/i18n/sv.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Lokal Profil"
+ ]
+ },
+ "variables-desc": "Parserfunktioner som gör det möjligt att arbeta med dynamiska variabler en artikelkontext"
+}
diff --git a/extensions/Variables/i18n/tl.json b/extensions/Variables/i18n/tl.json
new file mode 100644
index 00000000..c2407aff
--- /dev/null
+++ b/extensions/Variables/i18n/tl.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "AnakngAraw"
+ ]
+ },
+ "variables-desc": "Mga tungkulin ng pambanghay na nagpapahintulot na gumawa sa piling ng dinamikong mga bagay na nagpapabagu-bago sa loob ng isang diwang nasasaklawan ng artikulo"
+}
diff --git a/extensions/Variables/i18n/uk.json b/extensions/Variables/i18n/uk.json
new file mode 100644
index 00000000..93b661a5
--- /dev/null
+++ b/extensions/Variables/i18n/uk.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Base"
+ ]
+ },
+ "variables-desc": "Функції парсера, що дозволяють працювати із динамічними змінними у контексті статей"
+}
diff --git a/extensions/Variables/i18n/zh-hans.json b/extensions/Variables/i18n/zh-hans.json
new file mode 100644
index 00000000..92d560bc
--- /dev/null
+++ b/extensions/Variables/i18n/zh-hans.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Hzy980512"
+ ]
+ },
+ "variables-desc": "允许解析器函数在一个文章范围内使用动态变量"
+}
diff --git a/extensions/Variables/i18n/zh-hant.json b/extensions/Variables/i18n/zh-hant.json
new file mode 100644
index 00000000..d6733901
--- /dev/null
+++ b/extensions/Variables/i18n/zh-hant.json
@@ -0,0 +1,4 @@
+{
+ "@metadata": [],
+ "variables-desc": "允許解析器函數在一個文章範圍內使用動態變量"
+}
diff --git a/extensions/Variables/package.json b/extensions/Variables/package.json
new file mode 100644
index 00000000..e87548ca
--- /dev/null
+++ b/extensions/Variables/package.json
@@ -0,0 +1,12 @@
+{
+ "private": true,
+ "scripts": {
+ "test": "grunt test"
+ },
+ "devDependencies": {
+ "grunt": "1.0.1",
+ "grunt-banana-checker": "0.5.0",
+ "grunt-contrib-jshint": "1.1.0",
+ "grunt-jsonlint": "1.1.0"
+ }
+}
diff --git a/extensions/Variables/tests/mwparsertests/Variables.txt b/extensions/Variables/tests/mwparsertests/Variables.txt
new file mode 100644
index 00000000..d35578c4
--- /dev/null
+++ b/extensions/Variables/tests/mwparsertests/Variables.txt
@@ -0,0 +1,49 @@
+# @todo expand
+!! functionhooks
+var
+!! endfunctionhooks
+
+!! test
+#vardefine, #vardefineecho and #var
+!! input
+{{#vardefine: a | Test }}
+"{{#var: a }}"
+"{{#vardefineecho: a | Test 2 }}, {{#var: a }}"
+!!result
+<p>"Test"
+"Test 2, Test 2"
+</p>
+!! end
+
+!! test
+#varexists
+!! input
+{{#varexists: a }}{{#vardefine: a }}
+"{{#varexists: a }}"
+!!result
+<p>"1"
+</p>
+!! end
+
+!! test
+#var_final
+!! input
+"{{#var_final: a }}"
+{{#vardefine: a | something }}"{{#var: a }}"
+{{#vardefine: a | final }}"{{#var_final: a }}"
+!!result
+<p>"final"
+"something"
+"final"
+</p>
+!! end
+
+!! test
+Variables should not be reset on special page inclusion (old bug, solved in Variables 2.0)
+!! input
+{{#vardefine: a | 1 }}{{#vardefine: | {{Special:AllPages}} }}
+"{{#var: a }}"
+!!result
+<p>"1"
+</p>
+!! end
diff --git a/extensions/Variables/version b/extensions/Variables/version
new file mode 100644
index 00000000..a2d7d697
--- /dev/null
+++ b/extensions/Variables/version
@@ -0,0 +1,4 @@
+Variables: REL1_30
+2017-09-21T22:24:13
+
+c75b9d4