Beispiel #1
0
 /**
  * This function takes output requirements as can be found in a given ParserOutput
  * object and puts them back in to the internal temporal requirement list from
  * which they can be committed to some other output. It is needed when code that
  * would normally call SMWOutputs::requireHeadItem() has need to use a full
  * independent parser call (Parser::parse()) that produces its own parseroutput.
  * If omitted, all output items potentially committed to this parseroutput during
  * parsing will not be passed on to higher levels.
  *
  * Note that this is not required if the $parseroutput is further processed by
  * MediaWiki, but there are cases where the output is discarded and only its text
  * is used.
  *
  * @param ParserOutput $parserOutput
  */
 public static function requireFromParserOutput(ParserOutput $parserOutput)
 {
     // Note: we do not attempt to recover which head items where scripts here.
     $parserOutputHeadItems = $parserOutput->getHeadItems();
     self::$headItems = array_merge((array) self::$headItems, $parserOutputHeadItems);
     /// TODO Is the following needed?
     if (isset($parserOutput->mModules)) {
         foreach ($parserOutput->mModules as $module) {
             self::$resourceModules[$module] = $module;
         }
     }
 }
 /**
  * Add all metadata associated with a ParserOutput object, but without the actual HTML. This
  * includes categories, language links, ResourceLoader modules, effects of certain magic words,
  * and so on.
  *
  * @since 1.24
  * @param ParserOutput $parserOutput
  */
 public function addParserOutputMetadata($parserOutput)
 {
     $this->mLanguageLinks += $parserOutput->getLanguageLinks();
     $this->addCategoryLinks($parserOutput->getCategories());
     $this->setIndicators($parserOutput->getIndicators());
     $this->mNewSectionLink = $parserOutput->getNewSection();
     $this->mHideNewSectionLink = $parserOutput->getHideNewSection();
     $this->mParseWarnings = $parserOutput->getWarnings();
     if (!$parserOutput->isCacheable()) {
         $this->enableClientCache(false);
     }
     $this->mNoGallery = $parserOutput->getNoGallery();
     $this->mHeadItems = array_merge($this->mHeadItems, $parserOutput->getHeadItems());
     $this->addModules($parserOutput->getModules());
     $this->addModuleScripts($parserOutput->getModuleScripts());
     $this->addModuleStyles($parserOutput->getModuleStyles());
     $this->addJsConfigVars($parserOutput->getJsConfigVars());
     $this->mPreventClickjacking = $this->mPreventClickjacking || $parserOutput->preventClickjacking();
     // Template versioning...
     foreach ((array) $parserOutput->getTemplateIds() as $ns => $dbks) {
         if (isset($this->mTemplateIds[$ns])) {
             $this->mTemplateIds[$ns] = $dbks + $this->mTemplateIds[$ns];
         } else {
             $this->mTemplateIds[$ns] = $dbks;
         }
     }
     // File versioning...
     foreach ((array) $parserOutput->getFileSearchOptions() as $dbk => $data) {
         $this->mImageTimeKeys[$dbk] = $data;
     }
     // Hooks registered in the object
     $parserOutputHooks = $this->getConfig()->get('ParserOutputHooks');
     foreach ($parserOutput->getOutputHooks() as $hookInfo) {
         list($hookName, $data) = $hookInfo;
         if (isset($parserOutputHooks[$hookName])) {
             call_user_func($parserOutputHooks[$hookName], $this, $parserOutput, $data);
         }
     }
     // Link flags are ignored for now, but may in the future be
     // used to mark individual language links.
     $linkFlags = array();
     Hooks::run('LanguageLinks', array($this->getTitle(), &$this->mLanguageLinks, &$linkFlags));
     Hooks::run('OutputPageParserOutput', array(&$this, $parserOutput));
 }
Beispiel #3
0
 /**
  * This function takes output requirements as can be found in a given ParserOutput
  * object and puts them back in to the internal temporal requirement list from
  * which they can be committed to some other output. It is needed when code that
  * would normally call SMWOutputs::requireHeadItem() has need to use a full
  * independent parser call (Parser::parse()) that produces its own parseroutput.
  * If omitted, all output items potentially committed to this parseroutput during
  * parsing will not be passed on to higher levels.
  *
  * Note that this is not required if the $parseroutput is further processed by
  * MediaWiki, but there are cases where the output is discarded and only its text
  * is used.
  *
  * @param ParserOutput $parserOutput
  */
 public static function requireFromParserOutput(ParserOutput $parserOutput)
 {
     // Note: we do not attempt to recover which head items where scripts here.
     // ParserOutpt::getHeadItems() was added in MW 1.16
     if (is_callable(array($parserOutput, 'getHeadItems'))) {
         $parserOutputHeadItems = $parserOutput->getHeadItems();
     } else {
         $parserOutputHeadItems = (array) $parserOutput->headItems;
     }
     self::$headItems = array_merge((array) self::$headItems, $parserOutputHeadItems);
     /// TODO Is the following needed?
     if (isset($parserOutput->mModules)) {
         foreach ($parserOutput->mModules as $module) {
             self::$resourceModules[$module] = $module;
         }
     }
 }