int ] */ private $mCacheTTLs = [ 'currentmonth' => 86400, 'currentmonth1' => 86400, 'currentmonthname' => 86400, 'currentmonthnamegen' => 86400, 'currentmonthabbrev' => 86400, 'currentday' => 3600, 'currentday2' => 3600, 'currentdayname' => 3600, 'currentyear' => 86400, 'currenttime' => 3600, 'currenthour' => 3600, 'localmonth' => 86400, 'localmonth1' => 86400, 'localmonthname' => 86400, 'localmonthnamegen' => 86400, 'localmonthabbrev' => 86400, 'localday' => 3600, 'localday2' => 3600, 'localdayname' => 3600, 'localyear' => 86400, 'localtime' => 3600, 'localhour' => 3600, 'numberofarticles' => 3600, 'numberoffiles' => 3600, 'numberofedits' => 3600, 'currentweek' => 3600, 'currentdow' => 3600, 'localweek' => 3600, 'localdow' => 3600, 'numberofusers' => 3600, 'numberofactiveusers' => 3600, 'numberofpages' => 3600, 'currentversion' => 86400, 'currenttimestamp' => 3600, 'localtimestamp' => 3600, 'pagesinnamespace' => 3600, 'numberofadmins' => 3600, 'numberingroup' => 3600, ]; /** @var string[] */ private $mDoubleUnderscoreIDs = [ 'notoc', 'nogallery', 'forcetoc', 'toc', 'noeditsection', 'newsectionlink', 'nonewsectionlink', 'hiddencat', 'expectunusedcategory', 'index', 'noindex', 'staticredirect', 'notitleconvert', 'nocontentconvert', ]; /** @var string[] */ private $mSubstIDs = [ 'subst', 'safesubst', ]; /** @var array [ string => MagicWord ] */ private $mObjects = []; /** @var MagicWordArray */ private $mDoubleUnderscoreArray = null; /** @var Language */ private $contLang; /**#@-*/ /** * @param Language $contLang Content language */ public function __construct( Language $contLang ) { $this->contLang = $contLang; } public function getContentLanguage() { return $this->contLang; } /** * Factory: creates an object representing an ID * * @param string $id The internal name of the magic word * * @return MagicWord */ public function get( $id ) { if ( !isset( $this->mObjects[$id] ) ) { $mw = new MagicWord( null, [], false, $this->contLang ); $mw->load( $id ); $this->mObjects[$id] = $mw; } return $this->mObjects[$id]; } /** * Get an array of parser variable IDs * * @return string[] */ public function getVariableIDs() { if ( !$this->mVariableIDsInitialised ) { # Get variable IDs Hooks::run( 'MagicWordwgVariableIDs', [ &$this->mVariableIDs ] ); $this->mVariableIDsInitialised = true; } return $this->mVariableIDs; } /** * Get an array of parser substitution modifier IDs * @return string[] */ public function getSubstIDs() { return $this->mSubstIDs; } /** * Allow external reads of TTL array * * @param string $id * @return int */ public function getCacheTTL( $id ) { if ( array_key_exists( $id, $this->mCacheTTLs ) ) { return $this->mCacheTTLs[$id]; } else { return -1; } } /** * Get a MagicWordArray of double-underscore entities * * @return MagicWordArray */ public function getDoubleUnderscoreArray() { if ( is_null( $this->mDoubleUnderscoreArray ) ) { Hooks::run( 'GetDoubleUnderscoreIDs', [ &$this->mDoubleUnderscoreIDs ] ); $this->mDoubleUnderscoreArray = $this->newArray( $this->mDoubleUnderscoreIDs ); } return $this->mDoubleUnderscoreArray; } /** * Get a new MagicWordArray with provided $names * * @param array $names * @return MagicWordArray */ public function newArray( array $names = [] ) : MagicWordArray { return new MagicWordArray( $names, $this ); } }