コード例 #1
0
ファイル: Loops.php プロジェクト: Tjorriemorrie/app
 /**
  * Connects to 'Variables' extension and sets a variable. Handles different versions of
  * 'Variables' extension since there have changed some things along the way.
  * 
  * @param Parser $parser
  * @param string $varName
  * @param string $varValue
  */
 private static function setVariable(Parser &$parser, $varName, $varValue)
 {
     global $wgExtVariables;
     static $newVersion = null;
     if ($newVersion === null) {
         // find out whether local wiki is using variables extension 2.0 or higher
         $newVersion = defined('ExtVariables::VERSION') && version_compare(ExtVariables::VERSION, '1.9999', '>');
     }
     if ($newVersion) {
         // clean way since Variables 2.0:
         ExtVariables::get($parser)->setVarValue($varName, $varValue);
     } else {
         // make sure to trim values and convert them to string since old versions of Variables extension won't do this.
         $wgExtVariables->vardefine($parser, trim($varName), trim($varValue));
     }
 }
コード例 #2
0
ファイル: Parse.php プロジェクト: hexmode/DynamicPageList
 /**
  * This function uses the Variables extension to provide navigation aids such as DPL_firstTitle, DPL_lastTitle, or DPL_findTitle.  These variables can be accessed as {{#var:DPL_firstTitle}} if Extension:Variables is installed.
  *
  * @access	public
  * @param	array	Array of scroll variables with the key as the variable name and the value as the value.  Non-arrays will be casted to arrays.
  * @return	void
  */
 private function defineScrollVariables($scrollVariables)
 {
     $scrollVariables = (array) $scrollVariables;
     foreach ($scrollVariables as $variable => $value) {
         Variables::setVar(['', '', $variable, $value]);
         if (defined('ExtVariables::VERSION')) {
             \ExtVariables::get($this->parser)->setVarValue($variable, $value);
         }
     }
 }
コード例 #3
0
ファイル: Variables.php プロジェクト: Tjorriemorrie/app
 * @file Variables.php
 * @ingroup Variables
 */
if (!defined('MEDIAWIKI')) {
    die;
}
$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');
// language files:
$wgExtensionMessagesFiles['Variables'] = ExtVariables::getDir() . '/Variables.i18n.php';
$wgExtensionMessagesFiles['VariablesMagic'] = ExtVariables::getDir() . '/Variables.i18n.magic.php';
// hooks registration:
$wgHooks['ParserFirstCallInit'][] = 'ExtVariables::init';
$wgHooks['ParserClearState'][] = 'ExtVariables::onParserClearState';
$wgHooks['InternalParseBeforeLinks'][] = 'ExtVariables::onInternalParseBeforeLinks';
// 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.0';