Florianschmidtwelzow has uploaded a new change for review.

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

Change subject: Add support for extensions to add custom login messages for 
mobile login page
......................................................................

Add support for extensions to add custom login messages for mobile login page

Reuses core hook.

Bug: T95903
Change-Id: I6143b4393946a2531b25d58b319f83483dcfb83e
---
M includes/skins/UserLoginAndCreateTemplate.php
1 file changed, 23 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/93/203893/1

diff --git a/includes/skins/UserLoginAndCreateTemplate.php 
b/includes/skins/UserLoginAndCreateTemplate.php
index f3674a1..ec804ad 100644
--- a/includes/skins/UserLoginAndCreateTemplate.php
+++ b/includes/skins/UserLoginAndCreateTemplate.php
@@ -15,7 +15,6 @@
        protected $pageMessageHeaders = array(
                'Uploads' => 'mobile-frontend-donate-image-login',
                'Watchlist' => 'mobile-frontend-watchlist-purpose',
-               'Gather' => 'gather-loginpage-desc',
        );
        /** @var array $actionMessages Message keys for site links */
        protected $pageMessages = array();
@@ -164,8 +163,9 @@
                $heading = '';
                $content = '';
 
-               if ( isset( $this->pageMessageHeaders[$returnto] ) ) {
-                       $heading = wfMessage( 
$this->pageMessageHeaders[$returnto] )->parse();
+               $pageMessageHeaders = $this->getPageMessageHeaders();
+               if ( isset( $pageMessageHeaders[$returnto] ) ) {
+                       $heading = wfMessage( $pageMessageHeaders[$returnto] 
)->parse();
                        if ( isset( $this->pageMessages[$returnto] ) ) {
                                $content = wfMessage( 
$this->pageMessages[$returnto] )->parse();
                        }
@@ -179,6 +179,26 @@
        }
 
        /**
+        * Returns an array of all valid login info messages.
+        *
+        * @return array
+        */
+       protected function getPageMessageHeaders() {
+               static $messages = null;
+               if ( !$messages ) {
+                       // default MobileFrontend messages
+                       $messages = $this->pageMessageHeaders;
+                       // reuse core hook to allow extensions to add their own 
messages
+                       // currently extensions needs to add two messages for 
full mobile support, one
+                       // withput a key and one with the returnto target as 
the key, example from Gather:
+                       // $messages['Gather'] = 'gather-loginpage-desc'; -> 
for mobile custom login page
+                       // $messages[] = 'gather-anon-view-lists'; -> // for 
core login page (and mobile alpha)
+                       Hooks::run( 'LoginFormValidErrorMessages', array( 
&$messages ) );
+               }
+               return $messages;
+       }
+
+       /**
         * Renders a prompt above the login or upload screen
         *
         */

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6143b4393946a2531b25d58b319f83483dcfb83e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <florian.schmidt.wel...@t-online.de>

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

Reply via email to