/** * @static * @return ResourceLoader */ protected static function getResourceLoaderInstance() { if (empty(self::$resourceLoaderInstance)) { self::$resourceLoaderInstance = new ResourceLoader(); } return self::$resourceLoaderInstance; }
/** * Get the last modified timestamp of this module. * * Last modified timestamps are calculated from the highest last modified * timestamp of this module's constituent files as well as the files it * depends on. This function is context-sensitive, only performing * calculations on files relevant to the given language, skin and debug * mode. * * @param $context ResourceLoaderContext: Context in which to calculate * the modified time * @return Integer: UNIX timestamp * @see ResourceLoaderModule::getFileDependencies */ public function getModifiedTime(ResourceLoaderContext $context) { if (isset($this->modifiedTime[$context->getHash()])) { return $this->modifiedTime[$context->getHash()]; } wfProfileIn(__METHOD__); $files = array(); // Flatten style files into $files $styles = self::collateFilePathListByOption($this->styles, 'media', 'all'); foreach ($styles as $styleFiles) { $files = array_merge($files, $styleFiles); } $skinFiles = self::tryForKey(self::collateFilePathListByOption($this->skinStyles, 'media', 'all'), $context->getSkin(), 'default'); foreach ($skinFiles as $styleFiles) { $files = array_merge($files, $styleFiles); } // Final merge, this should result in a master list of dependent files $files = array_merge($files, $this->scripts, $context->getDebug() ? $this->debugScripts : array(), self::tryForKey($this->languageScripts, $context->getLanguage()), self::tryForKey($this->skinScripts, $context->getSkin(), 'default'), $this->loaderScripts); $files = array_map(array($this, 'getLocalPath'), $files); // File deps need to be treated separately because they're already prefixed $files = array_merge($files, $this->getFileDependencies($context->getSkin())); // If a module is nothing but a list of dependencies, we need to avoid // giving max() an empty array if (count($files) === 0) { wfProfileOut(__METHOD__); return $this->modifiedTime[$context->getHash()] = 1; } wfProfileIn(__METHOD__ . '-filemtime'); $filesMtime = max(array_map(array(__CLASS__, 'safeFilemtime'), $files)); $filesMtime = ResourceLoaderHooks::normalizeTimestamp($filesMtime); // Wikia change - @macbre wfProfileOut(__METHOD__ . '-filemtime'); $this->modifiedTime[$context->getHash()] = max($filesMtime, $this->getMsgBlobMtime($context->getLanguage())); wfProfileOut(__METHOD__); return $this->modifiedTime[$context->getHash()]; }