From f3874a4a91b6667fd77d1f1443ec3f1d7f5f36c1 Mon Sep 17 00:00:00 2001 From: Ricordisamoa Date: Mon, 8 Jun 2015 15:39:06 +0200 Subject: [PATCH] Fix rel="copyright" for ApiHelp Bug: T94038 Bug: T93995 Change-Id: I06e9bb6797c4e4ee00e5d72eda1e273800b2c7f4 --- includes/OutputPage.php | 37 +++++++++++++++++++++++++++++-------- includes/api/ApiHelp.php | 1 + 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index a8fc01dd75..3b9da4081e 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -304,6 +304,11 @@ class OutputPage extends ContextSource { */ private $mEnableSectionEditLinks = true; + /** + * @var string|null The URL to send in a element with rel=copyright + */ + private $copyrightUrl; + /** * Constructor for OutputPage. This should not be called directly. * Instead a new RequestContext should be created and it will implicitly create @@ -340,6 +345,18 @@ class OutputPage extends ContextSource { return $this->mRedirect; } + /** + * Set the copyright URL to send with the output. + * Empty string to omit, null to reset. + * + * @since 1.26 + * + * @param string|null $url + */ + public function setCopyrightUrl( $url ) { + $this->copyrightUrl = $url; + } + /** * Set the HTTP status code to send with the output. * @@ -3432,17 +3449,21 @@ class OutputPage extends ContextSource { } # Copyright - $copyright = ''; - if ( $config->get( 'RightsPage' ) ) { - $copy = Title::newFromText( $config->get( 'RightsPage' ) ); + if ( $this->copyrightUrl !== null ) { + $copyright = $this->copyrightUrl; + } else { + $copyright = ''; + if ( $config->get( 'RightsPage' ) ) { + $copy = Title::newFromText( $config->get( 'RightsPage' ) ); - if ( $copy ) { - $copyright = $copy->getLocalURL(); + if ( $copy ) { + $copyright = $copy->getLocalURL(); + } } - } - if ( !$copyright && $config->get( 'RightsUrl' ) ) { - $copyright = $config->get( 'RightsUrl' ); + if ( !$copyright && $config->get( 'RightsUrl' ) ) { + $copyright = $config->get( 'RightsUrl' ); + } } if ( $copyright ) { diff --git a/includes/api/ApiHelp.php b/includes/api/ApiHelp.php index a81ae3f81f..f6d124f065 100644 --- a/includes/api/ApiHelp.php +++ b/includes/api/ApiHelp.php @@ -45,6 +45,7 @@ class ApiHelp extends ApiBase { $context->setLanguage( $this->getMain()->getLanguage() ); $context->setTitle( SpecialPage::getTitleFor( 'ApiHelp' ) ); $out = new OutputPage( $context ); + $out->setCopyrightUrl( 'https://www.mediawiki.org/wiki/Special:MyLanguage/Copyright' ); $context->setOutput( $out ); self::getHelp( $context, $modules, $params ); -- 2.20.1