/** * Dump all variables stored in this object in their native types. * If you want a not yet set variable to be included in the results you can either set $compute to an array * with the name of the variable or set $compute to true to compute all not yet set variables. * * @param $compute array|bool Variables we should copute if not yet set * @param $includeUserVars bool Include user set variables * @return array */ public function dumpAllVars($compute = array(), $includeUserVars = false) { $allVarNames = array_keys($this->mVars); $exported = array(); $coreVariables = array(); if (!$includeUserVars) { // Compile a list of all variables set by the extension to be able to filter user set ones by name global $wgRestrictionTypes; $coreVariables = AbuseFilter::getBuilderValues(); $coreVariables = array_keys($coreVariables['vars']); // Title vars can have several prefixes $prefixes = array('ARTICLE', 'MOVED_FROM', 'MOVED_TO', 'FILE'); $titleVars = array('_ARTICLEID', '_NAMESPACE', '_TEXT', '_PREFIXEDTEXT', '_recent_contributors'); foreach ($wgRestrictionTypes as $action) { $titleVars[] = "_restrictions_{$action}"; } foreach ($titleVars as $var) { foreach ($prefixes as $prefix) { $coreVariables[] = $prefix . $var; } } $coreVariables = array_map('strtolower', $coreVariables); } foreach ($allVarNames as $varName) { if (($includeUserVars || in_array(strtolower($varName), $coreVariables)) && !in_array($varName, self::$varBlacklist) && ($compute === true || is_array($compute) && in_array($varName, $compute) || $this->mVars[$varName] instanceof AFPData)) { $exported[$varName] = $this->getVar($varName)->toNative(); } } return $exported; }
protected function setUserVariable($name, $value) { $builderValues = AbuseFilter::getBuilderValues(); if (array_key_exists($name, $builderValues['vars'])) { throw new AFPUserVisibleException('overridebuiltin', $this->mCur->pos, array($name)); } $this->mVars->setVar($name, $value); }