jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/356963 )

Change subject: Make warning on forced-globalnotice message feature configurable
......................................................................


Make warning on forced-globalnotice message feature configurable

This introduces $wgGlobalNoticeDisplayWarningOnEditPage, which is by
default equal to false. When set to true, a warning will show to the
editor who's editing MediaWiki:Forced-globalnotice for informing
the purpose of the message.

This change also makes the areas where the message is emphasized more
semantic, by using <strong> instead of the <b> and <u> element.

See also: https://writers.stackexchange.com/q/4674

Change-Id: I020cb5cde923937d33f2ba68488dc7b8109408d1
---
M GlobalNotice.class.php
M extension.json
2 files changed, 24 insertions(+), 17 deletions(-)

Approvals:
  Jack Phoenix: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/GlobalNotice.class.php b/GlobalNotice.class.php
index 12a58e9..20fedca 100644
--- a/GlobalNotice.class.php
+++ b/GlobalNotice.class.php
@@ -78,33 +78,39 @@
        }
 
        /**
-        * Show an annoying notice when editing MediaWiki:Forced-globalnotice 
because
+        * Show an annoying warning when editing MediaWiki:Forced-globalnotice 
because
         * that message is Serious Business™.
-        * Disabled for production, might be too annoying -- but I just wanted 
to code
-        * this feature. :)
         *
-        * Would be hooked into the 'EditPage::showEditForm:initial' hook.
+        * Disabled for production by default (but can be configured),
+        * might be too annoying -- but I just wanted to code this feature. :)
         *
         * @param EditPage $editPage Instance of EditPage class
         * @return bool
-       public static function displayNoticeOnEditPage( &$editPage ) {
+        */
+       public static function displayWarningOnEditPage( &$editPage ) {
+               global $wgGlobalNoticeDisplayWarningOnEditPage;
+
+               if ( !$wgGlobalNoticeDisplayWarningOnEditPage ) {
+                       return true;
+               }
+
                // only initialize this when editing pages in MediaWiki 
namespace
                if ( $editPage->mTitle->getNamespace() != 8 ) {
                        return true;
                }
 
-               // Show an annoying notice when editing 
MediaWiki:Forced-globalnotice
+               // Show an annoying warning when editing 
MediaWiki:Forced-globalnotice
                // I considered using confirm() JS but it doesn't allow CSS 
properties
                // AFAIK and no CSS properties = less obtrusive notice = bad, 
so I ditched
                // that idea.
                if ( $editPage->mTitle->getDBkey() == 'Forced-globalnotice' ) {
                        $editPage->editFormPageTop .= '<span style="color: 
red;">Hey, hold it right there!</span><br />
-The value of this message is shown to <b>all users</b>, no matter what is 
their language. This can be <u>extremely</u> annoying.<br />
-<span style="text-transform: uppercase; font-size: 20px;">Only use this for 
really important things, like server maintenance notices!</span><br />
-Understood?
-<br /><br />
+       The value of this message is shown to <strong>all users</strong>, no 
matter what is their language. This can be <strong>extremely</strong> 
annoying.<br />
+       <span style="text-transform: uppercase; font-size: 20px;">Only use this 
for really important things, like server maintenance notices!</span><br />
+       Understood?
+       <br /><br />
 
-<a href="#" onclick="document.getElementById( \'wpTextbox1\' ).style.display = 
\'block\'; return false;">Yes!</a>';
+       <a href="#" onclick="document.getElementById( \'wpTextbox1\' 
).style.display = \'block\'; return false;">Yes!</a>';
                        // JavaScript must be injected here, wpTextbox1 doesn't 
exist before...
                        $editPage->editFormTextAfterWarn .= '<script 
type="text/javascript">
                                document.getElementById( \'wpTextbox1\' 
).style.display = \'none\';
@@ -113,6 +119,5 @@
 
                return true;
        }
-       */
 
-}
\ No newline at end of file
+}
diff --git a/extension.json b/extension.json
index 60d06c4..2b7979c 100644
--- a/extension.json
+++ b/extension.json
@@ -1,6 +1,6 @@
 {
        "name": "GlobalNotice",
-       "version": "0.5",
+       "version": "0.6.0",
        "author": [
                "Misza",
                "Jack Phoenix"
@@ -18,9 +18,11 @@
                "GlobalNotice": "GlobalNotice.class.php"
        },
        "Hooks": {
-               "SiteNoticeAfter": [
-                       "GlobalNotice::onSiteNoticeAfter"
-               ]
+               "SiteNoticeAfter": "GlobalNotice::onSiteNoticeAfter",
+               "EditPage::showEditForm:initial": 
"GlobalNotice::displayWarningOnEditPage"
+       },
+       "config": {
+               "GlobalNoticeDisplayWarningOnEditPage": false
        },
        "manifest_version": 1
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I020cb5cde923937d33f2ba68488dc7b8109408d1
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/GlobalNotice
Gerrit-Branch: master
Gerrit-Owner: SamanthaNguyen <samanthanguyen1...@gmail.com>
Gerrit-Reviewer: Jack Phoenix <j...@countervandalism.net>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to