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

Change subject: Set tagline on Special:MobileOptions page
......................................................................


Set tagline on Special:MobileOptions page

Restrict the existing setting of wikidata descriptions to pages
in the main namespace. This will allow us to make the Minerva skin
dumber about when it should render and when it should not.

Also set a tagline for the special page MobileOptions

Given, we anticipate other special pages to also have taglines,
a configuration variable MFSpecialPageTaglines is added.

Bug: T180095
Change-Id: I3f5886715f0632e67e46e077d362a988a648a123
---
M README.md
M extension.json
M i18n/en.json
M i18n/qqq.json
M includes/MobileFrontend.hooks.php
5 files changed, 46 insertions(+), 4 deletions(-)

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



diff --git a/README.md b/README.md
index eab92f1..4522da1 100644
--- a/README.md
+++ b/README.md
@@ -581,6 +581,23 @@
     'tagline' => false,
   ]
 ```
+#### $wgMFSpecialPageTaglines
+Set taglines for special pages
+
+```php
+$wgMFSpecialPageTaglines = [
+  "SpecialPageName" => "valid-message-key",
+];
+```
+
+* Type: `Array`
+* Default:
+```php
+  [
+    "MobileOptions" => "mobile-frontend-settings-tagline"
+  ]
+```
+
 
 #### $wgMFStripResponsiveImages
 
diff --git a/extension.json b/extension.json
index 4a57570..8828a4a 100644
--- a/extension.json
+++ b/extension.json
@@ -1265,6 +1265,9 @@
                },
                "MFNoMobileCategory": false,
                "MFNoMobilePages": [],
+               "MFSpecialPageTaglines": {
+                       "MobileOptions": "mobile-frontend-settings-tagline"
+               },
                "MFNearbyRange": 10000,
                "MFNearby": false,
                "MFNearbyEndpoint": "",
diff --git a/i18n/en.json b/i18n/en.json
index 2798c97..d946136 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -198,6 +198,7 @@
        "mobile-frontend-search-content": "Search within pages",
        "mobile-frontend-search-content-no-results": 
"'''{{int:mobile-frontend-search-content}}''' to see if this phrase appears 
anywhere.",
        "mobile-frontend-search-no-results": "No page with this title.",
+       "mobile-frontend-settings-tagline": "Reading preferences",
        "mobile-frontend-settings-beta": "Beta",
        "mobile-frontend-settings-site-description": "{{SITENAME}} is available 
in $1 {{PLURAL:$1|language|languages}}. All available versions are listed 
below",
        "mobile-frontend-settings-site-header": "{{SITENAME}} Languages",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 68226a2..ab92dfc 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -199,6 +199,7 @@
        "mobile-frontend-search-content": "Caption for a button performing full 
text search of a given search query.\n\nUsed in 
{{msg-mw|Mobile-frontend-search-content-no-results}}.",
        "mobile-frontend-search-content-no-results": "Used when no pages with 
matching titles were found.\n\nRefers to 
{{msg-mw|Mobile-frontend-search-content}}.",
        "mobile-frontend-search-no-results": "Message informing user that no 
pages were found for a given query.",
+       "mobile-frontend-settings-tagline": "Tagline for Special:MobileOptions 
- will show under heading",
        "mobile-frontend-settings-beta": "Text for beta on settings 
page.\n{{Identical|Beta}}",
        "mobile-frontend-settings-site-description": "Shown on 
[[Special:MobileOptions]]. Parameters:\n* $1 - the number of other language 
versions for this wiki",
        "mobile-frontend-settings-site-header": "Heading for the 
Special:MobileOptions/Language page - only visible to non JavaScript users",
diff --git a/includes/MobileFrontend.hooks.php 
b/includes/MobileFrontend.hooks.php
index caa2491..ea88c97 100644
--- a/includes/MobileFrontend.hooks.php
+++ b/includes/MobileFrontend.hooks.php
@@ -571,7 +571,9 @@
         * @return bool
         */
        public static function onSpecialPageBeforeExecute( SpecialPage 
$special, $subpage ) {
-               $isMobileView = 
MobileContext::singleton()->shouldDisplayMobileView();
+               $context = MobileContext::singleton();
+               $isMobileView = $context->shouldDisplayMobileView();
+               $taglines = $context->getConfig()->get( 
'MFSpecialPageTaglines', [] );
                $name = $special->getName();
 
                if ( $isMobileView ) {
@@ -580,6 +582,10 @@
                        );
                        if ( $name === 'Userlogin' || $name === 'CreateAccount' 
) {
                                $special->getOutput()->addModules( 
'mobile.special.userlogin.scripts' );
+                       }
+                       if ( array_key_exists( $name, $taglines ) ) {
+                               self::setTagline( $special->getOutput(),
+                                       wfMessage( $taglines[$name] ) );
                        }
                }
 
@@ -1061,6 +1067,16 @@
        }
 
        /**
+        * Sets a tagline for a given page that can be displayed by the skin.
+        *
+        * @param OutputPage $outputPage
+        * @param string $desc
+        */
+       private static function setTagline( OutputPage $outputPage, $desc ) {
+               $outputPage->setProperty( 'wgMFDescription', $desc );
+       }
+
+       /**
         * OutputPageParserOutput hook handler
         * Disables TOC in output before it grabs HTML
         * @see 
https://www.mediawiki.org/wiki/Manual:Hooks/OutputPageParserOutput
@@ -1075,13 +1091,17 @@
                if ( $context->shouldDisplayMobileView() ) {
                        $po->setTOCEnabled( false );
                        $outputPage->setProperty( 'MFTOC', $po->getTOCHTML() 
!== '' );
-
-                       if ( $context->shouldShowWikibaseDescriptions( 
'tagline' ) ) {
+                       $title = $outputPage->getTitle();
+                       // Only set the tagline if the feature has been enabled 
and the article is in the main namespace
+                       if ( $context->shouldShowWikibaseDescriptions( 
'tagline' ) &&
+                               !$title->isMainPage() &&
+                               $title->getNamespace() === NS_MAIN
+                       ) {
                                $item = $po->getProperty( 'wikibase_item' );
                                if ( $item ) {
                                        $desc = 
ExtMobileFrontend::getWikibaseDescription( $item );
                                        if ( $desc ) {
-                                               $outputPage->setProperty( 
'wgMFDescription', $desc );
+                                               self::setTagline( $outputPage, 
$desc );
                                        }
                                }
                        }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I3f5886715f0632e67e46e077d362a988a648a123
Gerrit-PatchSet: 8
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: specialpages
Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org>
Gerrit-Reviewer: Bmansurov <bmansu...@wikimedia.org>
Gerrit-Reviewer: Jdlrobson <jrob...@wikimedia.org>
Gerrit-Reviewer: Pmiazga <pmia...@wikimedia.org>
Gerrit-Reviewer: Siebrand <siebr...@kitano.nl>
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