Merge "Fix rel="copyright" for ApiHelp"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 13 Jun 2015 00:08:48 +0000 (00:08 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 13 Jun 2015 00:08:48 +0000 (00:08 +0000)
includes/OutputPage.php
includes/api/ApiHelp.php

index fd55379..b3720a4 100644 (file)
@@ -304,6 +304,11 @@ class OutputPage extends ContextSource {
         */
        private $mEnableSectionEditLinks = true;
 
+       /**
+        * @var string|null The URL to send in a <link> 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 ) {
index a81ae3f..f6d124f 100644 (file)
@@ -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 );