Ejemplo n.º 1
0
 /**
  * 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);
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * 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));
     }
 }