Henning Snater has uploaded a new change for review.

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


Change subject: Optimized copyright warning message output
......................................................................

Optimized copyright warning message output

Change-Id: I94897c4f0d68e1c5dd40e0e9a2093c31444bcd7a
---
M lib/includes/Utils.php
M lib/includes/specials/SpecialWikibasePage.php
M repo/includes/EntityView.php
M repo/includes/specials/SpecialModifyEntity.php
M repo/includes/specials/SpecialNewEntity.php
M repo/includes/specials/SpecialSetEntity.php
M repo/includes/specials/SpecialSetSiteLink.php
7 files changed, 37 insertions(+), 31 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/61/80961/1

diff --git a/lib/includes/Utils.php b/lib/includes/Utils.php
index a78da7a..a9e943c 100644
--- a/lib/includes/Utils.php
+++ b/lib/includes/Utils.php
@@ -317,7 +317,7 @@
         *
         * @return \Message
         */
-       public static function getRightsWarningMessage() {
+       public static function getCopyrightMessage() {
                global $wgRightsUrl, $wgRightsText;
 
                if ( wfMessage( 'wikidata-shortcopyrightwarning' )->exists() ) {
@@ -334,14 +334,14 @@
        }
 
        /**
-        * Returns a string for indicating which version of the copyright 
message is being used when
-        * calling getRightsWarningMessage.
+        * Returns a string indicating which version of the copyright message 
is being used when
+        * calling getCopyrightMessage.
         *
         * @since 0.4
         *
         * @return string
         */
-       public static function getRightsWarningVersion() {
+       public static function getCopyrightMessageVersion() {
                return wfMessage( 'wikibase-shortcopyrightwarning-version' 
)->text();
        }
 
diff --git a/lib/includes/specials/SpecialWikibasePage.php 
b/lib/includes/specials/SpecialWikibasePage.php
index 9f9aa20..f203f7e 100644
--- a/lib/includes/specials/SpecialWikibasePage.php
+++ b/lib/includes/specials/SpecialWikibasePage.php
@@ -31,6 +31,7 @@
  */
 use Wikibase\Repo\WikibaseRepo;
 use Wikibase\StringNormalizer;
+use Wikibase\Utils;
 
 abstract class SpecialWikibasePage extends SpecialPage {
 
@@ -111,4 +112,19 @@
                return true;
        }
 
+       /**
+        * Adds the "copyright info message" to the HTML output.
+        *
+        * @since 0.4
+        */
+       public function showCopyrightMessage() {
+               $this->getOutput()->addHTML(
+                       Html::rawElement(
+                               'div',
+                               array(),
+                               Utils::getCopyrightMessage()->parse()
+                       )
+               );
+       }
+
 }
diff --git a/repo/includes/EntityView.php b/repo/includes/EntityView.php
index 714d7e3..6d1b11d 100644
--- a/repo/includes/EntityView.php
+++ b/repo/includes/EntityView.php
@@ -842,8 +842,8 @@
 
                // copyright warning message
                $out->addJsConfigVars( 'wbCopyright', array(
-                       'version' => Utils::getRightsWarningVersion(),
-                       'messageHtml' => 
Utils::getRightsWarningMessage()->parse(),
+                       'version' => Utils::getCopyrightMessageVersion(),
+                       'messageHtml' => Utils::getCopyrightMessage()->parse(),
                ) );
 
                // TODO: use injected id formatter
diff --git a/repo/includes/specials/SpecialModifyEntity.php 
b/repo/includes/specials/SpecialModifyEntity.php
index 8e97ea1..5703467 100644
--- a/repo/includes/specials/SpecialModifyEntity.php
+++ b/repo/includes/specials/SpecialModifyEntity.php
@@ -4,7 +4,7 @@
 use Wikibase\Utils;
 
 /**
- * Abstract special page for modifing Wikibase entity.
+ * Abstract special page for modifying Wikibase entity.
  *
  * 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
@@ -99,6 +99,8 @@
                                $this->getOutput()->redirect( $entityUrl );
                        }
                }
+
+               return true;
        }
 
        /**
@@ -157,6 +159,8 @@
        private function setForm() {
                $this->getOutput()->addModuleStyles( array( 'wikibase.special' 
) );
 
+               // FIXME: Edit warning should be displayed above the license 
note like on "New Entity" page.
+               // (Unfortunately, the license note is generated in 
SpecialSetEntity::modifyEntity.)
                if ( $this->getUser()->isAnon() ) {
                        $this->showErrorHTML(
                                $this->msg(
@@ -275,21 +279,5 @@
                if ( $this->getUser()->isBlocked() ) {
                        $this->displayBlockedError();
                }
-       }
-
-       /**
-        * Show the rights warning message
-        *
-        * @since 0.4
-        */
-       public function showRightsMessage() {
-               $this->showErrorHTML(
-                       Html::rawElement(
-                               'p',
-                               array(),
-                               Utils::getRightsWarningMessage()->parse()
-                       ),
-                       'warning'
-               );
        }
 }
diff --git a/repo/includes/specials/SpecialNewEntity.php 
b/repo/includes/specials/SpecialNewEntity.php
index a63ee4f..38f2043 100644
--- a/repo/includes/specials/SpecialNewEntity.php
+++ b/repo/includes/specials/SpecialNewEntity.php
@@ -246,13 +246,10 @@
         * @param string $additionalHtml initial value for the description 
input box
         */
        public function createForm( $legend = null, $additionalHtml = '' ) {
+               $this->showCopyrightMessage();
+
                $this->getOutput()->addHTML(
-                               Html::rawElement(
-                                       'div',
-                                       array(),
-                                       
Utils::getRightsWarningMessage()->parse()
-                               )
-                               . Html::openElement(
+                               Html::openElement(
                                        'form',
                                        array(
                                                'method' => 'post',
diff --git a/repo/includes/specials/SpecialSetEntity.php 
b/repo/includes/specials/SpecialSetEntity.php
index 8481f39..a11215a 100644
--- a/repo/includes/specials/SpecialSetEntity.php
+++ b/repo/includes/specials/SpecialSetEntity.php
@@ -102,8 +102,10 @@
        protected function modifyEntity() {
                $request = $this->getRequest();
 
+               // FIXME: This method is supposed to modify the entity and not 
alter the output. Do not
+               // paste message directly into the HTML output in this method.
                if ( $this->entityContent === null || 
!$this->isValidLanguageCode( $this->language ) || !$request->wasPosted() ) {
-                       $this->showRightsMessage();
+                       $this->showCopyrightMessage();
 
                        return false;
                }
diff --git a/repo/includes/specials/SpecialSetSiteLink.php 
b/repo/includes/specials/SpecialSetSiteLink.php
index 60478c2..46c9698 100644
--- a/repo/includes/specials/SpecialSetSiteLink.php
+++ b/repo/includes/specials/SpecialSetSiteLink.php
@@ -99,10 +99,13 @@
         * @return string|boolean The summary or false
         */
        protected function modifyEntity() {
+               // FIXME: This method is supposed to modify the entity and not 
alter the output. Do not
+               // paste message directly into the HTML output in this method.
+
                $request = $this->getRequest();
                // has to be checked before modifying but is no error
                if ( $this->entityContent === null || !$this->isValidSiteId( 
$this->site ) || !$request->wasPosted() ) {
-                       $this->showRightsMessage();
+                       $this->showCopyrightMessage();
 
                        return false;
                }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I94897c4f0d68e1c5dd40e0e9a2093c31444bcd7a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Henning Snater <[email protected]>

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

Reply via email to