From 08aa4418c30cfc18ccc69a0f0f9cb9e17be6c196 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Mon, 12 Aug 2013 09:28:15 +0200 Subject: Update to MediaWiki 1.21.1 --- includes/OutputPage.php | 390 ++++++++++++++++++++++++++++++------------------ 1 file changed, 244 insertions(+), 146 deletions(-) (limited to 'includes/OutputPage.php') diff --git a/includes/OutputPage.php b/includes/OutputPage.php index b4a81bb1..1e0c396a 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -43,6 +43,7 @@ class OutputPage extends ContextSource { var $mKeywords = array(); var $mLinktags = array(); + var $mCanonicalUrl = false; /// Additional stylesheets. Looks like this is for extensions. Might be replaced by resource loader. var $mExtStyles = array(); @@ -122,7 +123,7 @@ class OutputPage extends ContextSource { var $mScripts = ''; /** - * Inline CSS styles. Use addInlineStyle() sparsingly + * Inline CSS styles. Use addInlineStyle() sparingly */ var $mInlineStyles = ''; @@ -247,6 +248,11 @@ class OutputPage extends ContextSource { */ private $mRedirectedFrom = null; + /** + * Additional key => value data + */ + private $mProperties = array(); + /** * Constructor for OutputPage. This should not be called directly. * Instead a new RequestContext should be created and it will implicitly create @@ -255,7 +261,7 @@ class OutputPage extends ContextSource { function __construct( IContextSource $context = null ) { if ( $context === null ) { # Extensions should use `new RequestContext` instead of `new OutputPage` now. - wfDeprecated( __METHOD__ ); + wfDeprecated( __METHOD__, '1.18' ); } else { $this->setContext( $context ); } @@ -264,8 +270,8 @@ class OutputPage extends ContextSource { /** * Redirect to $url rather than displaying the normal page * - * @param $url String: URL - * @param $responsecode String: HTTP status code + * @param string $url URL + * @param string $responsecode HTTP status code */ public function redirect( $url, $responsecode = '302' ) { # Strip newlines as a paranoia check for header injection in PHP<5.1.2 @@ -295,8 +301,8 @@ class OutputPage extends ContextSource { * Add a new "" tag * To add an http-equiv meta tag, precede the name with "http:" * - * @param $name String tag name - * @param $val String tag value + * @param string $name tag name + * @param string $val tag value */ function addMeta( $name, $val ) { array_push( $this->mMetatags, array( $name, $val ) ); @@ -305,7 +311,7 @@ class OutputPage extends ContextSource { /** * Add a keyword or a list of keywords in the page header * - * @param $text String or array of strings + * @param string $text or array of strings */ function addKeyword( $text ) { if( is_array( $text ) ) { @@ -316,9 +322,11 @@ class OutputPage extends ContextSource { } /** - * Add a new \ tag to the page header + * Add a new \ tag to the page header. + * + * Note: use setCanonicalUrl() for rel=canonical. * - * @param $linkarr Array: associative array of attributes. + * @param array $linkarr associative array of attributes. */ function addLink( $linkarr ) { array_push( $this->mLinktags, $linkarr ); @@ -327,7 +335,7 @@ class OutputPage extends ContextSource { /** * Add a new \ with "rel" attribute set to "meta" * - * @param $linkarr Array: associative array mapping attribute names to their + * @param array $linkarr associative array mapping attribute names to their * values, both keys and values will be escaped, and the * "rel" attribute will be automatically added */ @@ -336,6 +344,14 @@ class OutputPage extends ContextSource { $this->addLink( $linkarr ); } + /** + * Set the URL to be used for the . This should be used + * in preference to addLink(), to avoid duplicate link tags. + */ + function setCanonicalUrl( $url ) { + $this->mCanonicalUrl = $url; + } + /** * Get the value of the "rel" attribute for metadata links * @@ -355,7 +371,7 @@ class OutputPage extends ContextSource { /** * Add raw HTML to the list of scripts (including \ tag, etc.) * - * @param $script String: raw HTML + * @param string $script raw HTML */ function addScript( $script ) { $this->mScripts .= $script . "\n"; @@ -364,7 +380,7 @@ class OutputPage extends ContextSource { /** * Register and add a stylesheet from an extension directory. * - * @param $url String path to sheet. Provide either a full url (beginning + * @param string $url path to sheet. Provide either a full url (beginning * with 'http', etc) or a relative path from the document root * (beginning with '/'). Otherwise it behaves identically to * addStyle() and draws from the /skins folder. @@ -385,9 +401,9 @@ class OutputPage extends ContextSource { /** * Add a JavaScript file out of skins/common, or a given relative path. * - * @param $file String: filename in skins/common or complete on-server path + * @param string $file filename in skins/common or complete on-server path * (/foo/bar.js) - * @param $version String: style version of the file. Defaults to $wgStyleVersion + * @param string $version style version of the file. Defaults to $wgStyleVersion */ public function addScriptFile( $file, $version = null ) { global $wgStylePath, $wgStyleVersion; @@ -405,7 +421,7 @@ class OutputPage extends ContextSource { /** * Add a self-contained script tag with the given contents * - * @param $script String: JavaScript text, no "