* @return string
*/
public function getPageTitleActionText() {
- if ( isset( $this->mPageTitleActionText ) ) {
- return $this->mPageTitleActionText;
- }
- return '';
+ return $this->mPageTitleActionText;
}
/**
);
}
- /**
- * Return whether user JavaScript is allowed for this page
- * @deprecated since 1.18 Load modules with ResourceLoader, and origin and
- * trustworthiness is identified and enforced automagically.
- * @return bool
- */
- public function isUserJsAllowed() {
- wfDeprecated( __METHOD__, '1.18' );
- return $this->getAllowedModules( ResourceLoaderModule::TYPE_SCRIPTS ) >=
- ResourceLoaderModule::ORIGIN_USER_INDIVIDUAL;
- }
-
/**
* Show what level of JavaScript / CSS untrustworthiness is allowed on this page
* @see ResourceLoaderModule::$origin
$oldTidy = $popts->setTidy( $tidy );
$popts->setInterfaceMessage( (bool)$interface );
- $parserOutput = $wgParser->parse(
+ $parserOutput = $wgParser->getFreshParser()->parse(
$text, $title, $popts,
$linestart, true, $this->mRevisionId
);
}
/**
- * Add a ParserOutput object, but without Html
+ * Add a ParserOutput object, but without Html.
*
+ * @deprecated since 1.24, use addParserOutputMetadata() instead.
* @param ParserOutput $parserOutput
*/
public function addParserOutputNoText( &$parserOutput ) {
+ $this->addParserOutputMetadata( $parserOutput );
+ }
+
+ /**
+ * 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->mNewSectionLink = $parserOutput->getNewSection();
}
/**
- * Add a ParserOutput object
+ * Add the HTML and enhancements for it (like ResourceLoader modules) associated with a
+ * ParserOutput object, without any other metadata.
+ *
+ * @since 1.24
+ * @param ParserOutput $parserOutput
+ */
+ public function addParserOutputContent( &$parserOutput ) {
+ $this->addParserOutputText( $parserOutput );
+
+ $this->addModules( $parserOutput->getModules() );
+ $this->addModuleScripts( $parserOutput->getModuleScripts() );
+ $this->addModuleStyles( $parserOutput->getModuleStyles() );
+ $this->addModuleMessages( $parserOutput->getModuleMessages() );
+
+ $this->addJsConfigVars( $parserOutput->getJsConfigVars() );
+ }
+
+ /**
+ * Add the HTML associated with a ParserOutput object, without any metadata.
+ *
+ * @since 1.24
+ * @param ParserOutput $parserOutput
+ */
+ public function addParserOutputText( &$parserOutput ) {
+ $text = $parserOutput->getText();
+ wfRunHooks( 'OutputPageBeforeHTML', array( &$this, &$text ) );
+ $this->addHTML( $text );
+ }
+
+ /**
+ * Add everything from a ParserOutput object.
*
* @param ParserOutput $parserOutput
*/
function addParserOutput( &$parserOutput ) {
- $this->addParserOutputNoText( $parserOutput );
+ $this->addParserOutputMetadata( $parserOutput );
$parserOutput->setTOCEnabled( $this->mEnableTOC );
// Touch section edit links only if not previously disabled
if ( $parserOutput->getEditSectionTokens() ) {
$parserOutput->setEditSectionTokens( $this->mEnableSectionEditLinks );
}
- $text = $parserOutput->getText();
- wfRunHooks( 'OutputPageBeforeHTML', array( &$this, &$text ) );
- $this->addHTML( $text );
+
+ $this->addParserOutputText( $parserOutput );
}
/**
$oldLang = $popts->setTargetLanguage( $language );
}
- $parserOutput = $wgParser->parse(
+ $parserOutput = $wgParser->getFreshParser()->parse(
$text, $this->getTitle(), $popts,
$linestart, true, $this->mRevisionId
);
* /w/index.php?title=Main_page&variant=zh-cn should never be served.
*/
function addAcceptLanguage() {
- $lang = $this->getTitle()->getPageLanguage();
+ $title = $this->getTitle();
+ if ( !$title instanceof Title ) {
+ return;
+ }
+
+ $lang = $title->getPageLanguage();
if ( !$this->getRequest()->getCheck( 'variant' ) && $lang->hasVariants() ) {
$variants = $lang->getVariants();
$aloption = array();
}
}
- /**
- * Get the message associated with the HTTP response code $code
- *
- * @param int $code Status code
- * @return string|null Message or null if $code is not in the list of messages
- *
- * @deprecated since 1.18 Use HttpStatus::getMessage() instead.
- */
- public static function getStatusMessage( $code ) {
- wfDeprecated( __METHOD__, '1.18' );
- return HttpStatus::getMessage( $code );
- }
-
/**
* Finally, all the text has been munged and accumulated into
* the object, let's actually output it:
/**
* Get an array containing the variables to be set in mw.config in JavaScript.
*
- * DO NOT CALL THIS FROM OUTSIDE OF THIS CLASS OR Skin::makeGlobalVariablesScript().
- * This is only public until that function is removed. You have been warned.
- *
* Do not add things here which can be evaluated in ResourceLoaderStartUpModule
* - in other words, page-independent/site-wide variables (without state).
* You will only be adding bloat to the html page and causing page caches to
* have to be purged on configuration changes.
* @return array
*/
- public function getJSVars() {
+ private function getJSVars() {
global $wgContLang;
$curRevisionId = 0;