Phuedx has uploaded a new change for review.

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

Change subject: Promote "switch-language" page action to stable
......................................................................

Promote "switch-language" page action to stable

Changes:
* Extract SkinMinerva#createSwitchLanguagePageAction from
  SkinMinervaBeta#preparePageActions and remove
  SkinMinervaBeta#preparePageActions
* Feature flag the new page action using the existing mechanism:
  the wgMinervaPageActions configuration variable. Per T140260, don't
  allow the "switch-language" page action by default
* Update the documentation for the wgMinervaPageActions configuration
  variable

Bug: T140260
Change-Id: Ie11a32bb0a3203a105b9951c69aba3213d219335
---
M README.md
M includes/skins/SkinMinerva.php
M includes/skins/SkinMinervaBeta.php
3 files changed, 35 insertions(+), 44 deletions(-)


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

diff --git a/README.md b/README.md
index f359f85..3ecd383 100644
--- a/README.md
+++ b/README.md
@@ -354,7 +354,7 @@
 
 #### $wgMFPageActions
 
-Controls, which page action show and which not. Allowed: `edit`, `watch`
+Controls, which page action show and which not. Allowed: `edit`, `watch`, 
`talk`, and `switch-language`.
 
 * Type: `Array`
 * Default: `['edit', 'watch']`
diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php
index ee8a67c..f9ced48 100644
--- a/includes/skins/SkinMinerva.php
+++ b/includes/skins/SkinMinerva.php
@@ -895,6 +895,13 @@
                        $menu['watch'] = $this->createWatchPageAction( $actions 
);
                }
 
+               if (
+                       ( $this->isAllowedPageAction( 'switch-language' ) && 
$this->doesPageHaveLanguages )
+                       || $this->getMFConfig()->get( 
'MinervaAlwaysShowLanguageButton' )
+               ) {
+                       $menu['switch-language'] = 
$this->createSwitchLanguageAction();
+               }
+
                $tpl->set( 'page_actions', $menu );
        }
 
@@ -955,6 +962,33 @@
        }
 
        /**
+        * Creates the the "switch-language" action: the icon that, when 
tapped, opens the language
+        * switcher.
+        *
+        * @return array A map compatible with BaseTemplat#makeListItem
+        */
+       protected function createSwitchLanguageAction() {
+               $languageSwitcherLinks = [];
+               $languageSwitcherClasses = 'language-selector';
+
+               if ( $this->doesPageHaveLanguages ) {
+                       
$languageSwitcherLinks['mobile-frontend-language-article-heading'] = [
+                               'href' => SpecialPage::getTitleFor( 
'MobileLanguages', $this->getTitle() )->getLocalURL()
+                       ];
+               } else {
+                       $languageSwitcherClasses .= ' disabled';
+               }
+
+               return [
+                       'text' => '',
+                       'itemtitle' => $this->msg( 
'mobile-frontend-language-article-heading' ),
+                       'class' => MobileUI::iconClass( 'language-switcher', 
'element', $languageSwitcherClasses ),
+                       'links' => $languageSwitcherLinks,
+                       'is_js_only' => false
+               ];
+       }
+
+       /**
         * Checks to see if the current page is (probably) editable.
         *
         * This is the same check that sets wgIsProbablyEditable later in the 
page output
diff --git a/includes/skins/SkinMinervaBeta.php 
b/includes/skins/SkinMinervaBeta.php
index b5ef653..5ceddff 100644
--- a/includes/skins/SkinMinervaBeta.php
+++ b/includes/skins/SkinMinervaBeta.php
@@ -15,49 +15,6 @@
        protected $shouldSecondaryActionsIncludeLanguageBtn = true;
 
        /**
-        * Do not set page actions on the user page that hasn't been created 
yet.
-        * Also add the language switcher action.
-        *
-        * @inheritdoc
-        * @param BaseTemplate $tpl
-        */
-       protected function preparePageActions( BaseTemplate $tpl ) {
-               $setPageActions = true;
-
-               if ( $this->isUserPage ) {
-                       if ( !$this->getTitle()->exists() ) {
-                               $setPageActions = false;
-                       }
-               }
-               if ( $setPageActions ) {
-                       parent::preparePageActions( $tpl );
-                       $menu = $tpl->data[ 'page_actions' ];
-
-                       $languageSwitcherLinks = [];
-                       $languageSwitcherClasses = 'disabled';
-                       if ( $this->doesPageHaveLanguages ) {
-                               
$languageSwitcherLinks['mobile-frontend-language-article-heading'] = [
-                                       'href' => SpecialPage::getTitleFor( 
'MobileLanguages', $this->getTitle() )->getLocalURL()
-                               ];
-                               $languageSwitcherClasses = '';
-                       }
-                       $languageSwitcherClasses .= ' language-selector';
-                       if ( $this->getMFConfig()->get( 
'MinervaAlwaysShowLanguageButton' ) ||
-                               $this->doesPageHaveLanguages ) {
-                               $menu['language-switcher'] = [ 'text' => '',
-                                       'itemtitle' => $this->msg( 
'mobile-frontend-language-article-heading' ),
-                                       'class' => MobileUI::iconClass( 
'language-switcher', 'element', $languageSwitcherClasses ),
-                                       'links' => $languageSwitcherLinks,
-                                       'is_js_only' => false
-                               ];
-                               $tpl->set( 'page_actions', $menu );
-                       }
-               } else {
-                       $tpl->set( 'page_actions', [] );
-               }
-       }
-
-       /**
         * Do not return secondary actions on the user page.
         *
         * @inheritdoc

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie11a32bb0a3203a105b9951c69aba3213d219335
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Phuedx <[email protected]>

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

Reply via email to