SamanthaNguyen has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/356963 )

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

[WIP] 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.

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


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalNotice 
refs/changes/63/356963/1

diff --git a/GlobalNotice.class.php b/GlobalNotice.class.php
index 12a58e9..b8d6a9d 100644
--- a/GlobalNotice.class.php
+++ b/GlobalNotice.class.php
@@ -78,41 +78,44 @@
        }
 
        /**
-        * 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 ) {
-               // only initialize this when editing pages in MediaWiki 
namespace
-               if ( $editPage->mTitle->getNamespace() != 8 ) {
+        */
+       public static function displayWarningOnEditPage( &$editPage ) {
+               global $wgGlobalNoticeDisplayWarningOnEditPage;
+
+               if ( $wgGlobalNoticeDisplayWarningOnEditPage ) {
+                       // only initialize this when editing pages in MediaWiki 
namespace
+                       if ( $editPage->mTitle->getNamespace() != 8 ) {
+                               return true;
+                       }
+
+                       // 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 <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>';
+                               // JavaScript must be injected here, wpTextbox1 
doesn't exist before...
+                               $editPage->editFormTextAfterWarn .= '<script 
type="text/javascript">
+                                       document.getElementById( \'wpTextbox1\' 
).style.display = \'none\';
+                               </script>';
+                       }
+
                        return true;
                }
-
-               // Show an annoying notice 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 />
-
-<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\';
-                       </script>';
-               }
-
-               return true;
        }
-       */
 
-}
\ No newline at end of file
+}
diff --git a/extension.json b/extension.json
index 60d06c4..86e3283 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::displayNoticeOnEditPage"
+       },
+       "config": {
+               "GlobalNoticeDisplayNoticeOnEditPage": "false"
        },
        "manifest_version": 1
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I020cb5cde923937d33f2ba68488dc7b8109408d1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GlobalNotice
Gerrit-Branch: master
Gerrit-Owner: SamanthaNguyen <samanthanguyen1...@gmail.com>

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

Reply via email to