Ricordisamoa has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/216676

Change subject: Fix rel="copyright" for ApiHelp
......................................................................

Fix rel="copyright" for ApiHelp

Bug: T94038
Bug: T93995
Change-Id: I06e9bb6797c4e4ee00e5d72eda1e273800b2c7f4
---
M autoload.php
M includes/OutputPage.php
M includes/api/ApiHelp.php
A includes/api/ApiHelpOutputPage.php
4 files changed, 53 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/76/216676/1

diff --git a/autoload.php b/autoload.php
index 74c7efd..d204f1d 100644
--- a/autoload.php
+++ b/autoload.php
@@ -49,6 +49,7 @@
        'ApiFormatXmlRsd' => __DIR__ . '/includes/api/ApiRsd.php',
        'ApiFormatYaml' => __DIR__ . '/includes/api/ApiFormatYaml.php',
        'ApiHelp' => __DIR__ . '/includes/api/ApiHelp.php',
+       'ApiHelpOutputPage' => __DIR__ . '/includes/api/ApiHelpOutputPage.php',
        'ApiHelpParamValueMessage' => __DIR__ . 
'/includes/api/ApiHelpParamValueMessage.php',
        'ApiImageRotate' => __DIR__ . '/includes/api/ApiImageRotate.php',
        'ApiImport' => __DIR__ . '/includes/api/ApiImport.php',
diff --git a/includes/OutputPage.php b/includes/OutputPage.php
index a8fc01d..5b99280 100644
--- a/includes/OutputPage.php
+++ b/includes/OutputPage.php
@@ -3290,6 +3290,27 @@
        }
 
        /**
+        * @return string URL of a page specifying copyright conditions.
+        */
+       protected function getCopyrightUrl() {
+               $config = $this->getConfig();
+               $copyright = '';
+               if ( $config->get( 'RightsPage' ) ) {
+                       $copy = Title::newFromText( $config->get( 'RightsPage' 
) );
+
+                       if ( $copy ) {
+                               $copyright = $copy->getLocalURL();
+                       }
+               }
+
+               if ( !$copyright && $config->get( 'RightsUrl' ) ) {
+                       $copyright = $config->get( 'RightsUrl' );
+               }
+
+               return $copyright;
+       }
+
+       /**
         * @return array Array in format "link name or number => 'link html'".
         */
        public function getHeadLinksArray() {
@@ -3432,18 +3453,7 @@
                }
 
                # Copyright
-               $copyright = '';
-               if ( $config->get( 'RightsPage' ) ) {
-                       $copy = Title::newFromText( $config->get( 'RightsPage' 
) );
-
-                       if ( $copy ) {
-                               $copyright = $copy->getLocalURL();
-                       }
-               }
-
-               if ( !$copyright && $config->get( 'RightsUrl' ) ) {
-                       $copyright = $config->get( 'RightsUrl' );
-               }
+               $copyright = $this->getCopyrightUrl();
 
                if ( $copyright ) {
                        $tags['copyright'] = Html::element( 'link', array(
diff --git a/includes/api/ApiHelp.php b/includes/api/ApiHelp.php
index a81ae3f..1e94a2f 100644
--- a/includes/api/ApiHelp.php
+++ b/includes/api/ApiHelp.php
@@ -44,7 +44,7 @@
                $context->setSkin( SkinFactory::getDefaultInstance()->makeSkin( 
'apioutput' ) );
                $context->setLanguage( $this->getMain()->getLanguage() );
                $context->setTitle( SpecialPage::getTitleFor( 'ApiHelp' ) );
-               $out = new OutputPage( $context );
+               $out = new ApiHelpOutputPage( $context );
                $context->setOutput( $out );
 
                self::getHelp( $context, $modules, $params );
diff --git a/includes/api/ApiHelpOutputPage.php 
b/includes/api/ApiHelpOutputPage.php
new file mode 100644
index 0000000..68cf77f
--- /dev/null
+++ b/includes/api/ApiHelpOutputPage.php
@@ -0,0 +1,29 @@
+<?php
+/**
+ * Subclass of OutputPage for use by ApiHelp.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ */
+
+class ApiHelpOutputPage extends OutputPage {
+
+       protected function getCopyrightUrl() {
+               return 'https://www.mediawiki.org/wiki/Copyright';
+       }
+
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/216676
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I06e9bb6797c4e4ee00e5d72eda1e273800b2c7f4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Ricordisamoa <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to