Jdlrobson has uploaded a new change for review.

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

Change subject: Hygiene: Refactor secondary actions generation
......................................................................

Hygiene: Refactor secondary actions generation

* No need for a separate nearby function
* Use attrs to allow buttons to have custom data attributes (see
following commit)

Change-Id: I0236b40a00ad43099172a0e4e88ce1810c1189e0
---
M includes/skins/MinervaTemplate.php
M includes/skins/MinervaTemplateAlpha.php
M includes/skins/MinervaTemplateBeta.php
3 files changed, 26 insertions(+), 27 deletions(-)


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

diff --git a/includes/skins/MinervaTemplate.php 
b/includes/skins/MinervaTemplate.php
index 83b5950..3e37947 100644
--- a/includes/skins/MinervaTemplate.php
+++ b/includes/skins/MinervaTemplate.php
@@ -192,8 +192,10 @@
                        )->getLocalURL();
 
                        $result['language'] = array(
-                               'class' => 'languageSelector',
-                               'url' => $languageUrl,
+                               'attributes' => array(
+                                       'class' => 'languageSelector',
+                                       'href' => $languageUrl,
+                               ),
                                'label' => wfMessage( 
'mobile-frontend-language-article-heading' )->text()
                        );
                }
@@ -208,10 +210,11 @@
                echo Html::openElement( 'div', array( 'id' => 
'page-secondary-actions' ) );
 
                foreach ( $this->getSecondaryActions() as $el ) {
-                       echo Html::element( 'a', array(
-                               'class' => 'mw-ui-button button ' . 
$el['class'],
-                               'href' => $el['url']
-                       ), $el['label'] );
+                       if ( !isset( $el['attributes']['class'] ) ) {
+                               $el['attributes']['class'] = '';
+                       }
+                       $el['attributes']['class'] .= ' mw-ui-button button';
+                       echo Html::element( 'a', $el['attributes'], 
$el['label'] );
                }
 
                echo Html::closeElement( 'div' );
diff --git a/includes/skins/MinervaTemplateAlpha.php 
b/includes/skins/MinervaTemplateAlpha.php
index c2fb95e..6df100c 100644
--- a/includes/skins/MinervaTemplateAlpha.php
+++ b/includes/skins/MinervaTemplateAlpha.php
@@ -16,42 +16,36 @@
        protected $searchPlaceHolderMsg = 'mobile-frontend-placeholder-alpha';
 
        /**
-        * Get button information to link to Special:Nearby to find articles
-        * (geographically) related to this
+        * Get page secondary actions
         */
-       public function getNearbyButton() {
+       protected function getSecondaryActions() {
                global $wgMFNearby;
+
+               $result = parent::getSecondaryActions();
                $title = $this->getSkin()->getTitle();
                $result = array();
 
                if ( $wgMFNearby && class_exists( 'GeoData' ) && 
GeoData::getPageCoordinates( $title ) ) {
                        $result['nearby'] = array(
-                               'url' => SpecialPage::getTitleFor( 'Nearby' 
)->getLocalUrl() . '#/page/' . $title->getText(),
-                               'class' => 'nearby-button',
+                               'attributes' => array(
+                                       'href' => SpecialPage::getTitleFor( 
'Nearby' )->getLocalUrl() . '#/page/' . $title->getText(),
+                                       'class' => 'nearby-button',
+                               ),
                                'label' => wfMessage( 
'mobile-frontend-nearby-sectiontext' )->text()
                        );
                }
-
-               return $result;
-       }
-
-       /**
-        * Get page secondary actions
-        */
-       protected function getSecondaryActions() {
-               $result = parent::getSecondaryActions();
-
-               $result += $this->getNearbyButton();
 
                // add categories button
                $skin = $this->getSkin();
                $categories = $skin->getCategoryLinks( false /* don't render 
the heading */ );
                if ( $categories ) {
                        $result['categories'] = array(
-                               'url' => '#/categories',
-                               // add hidden class (the overlay works only, 
when JS is enabled (class will
-                               // be removed in categories/init.js)
-                               'class' => 'category-button hidden',
+                               'attributes' => array(
+                                       'href' => '#/categories',
+                                       // add hidden class (the overlay works 
only, when JS is enabled (class will
+                                       // be removed in categories/init.js)
+                                       'class' => 'category-button hidden',
+                               ),
                                'label' => wfMessage( 'categories' )->text()
                        );
                }
diff --git a/includes/skins/MinervaTemplateBeta.php 
b/includes/skins/MinervaTemplateBeta.php
index d0988df..6941172 100644
--- a/includes/skins/MinervaTemplateBeta.php
+++ b/includes/skins/MinervaTemplateBeta.php
@@ -32,7 +32,9 @@
 
                if ( $wgMFDonationUrl ) {
                        $result['donation'] = array(
-                               'url' => $wgMFDonationUrl,
+                               'attributes' => array(
+                                       'href' => $wgMFDonationUrl,
+                               ),
                                'label' => wfMessage( 
'mobile-frontend-donate-button-label' )->text()
                        );
                }

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

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

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

Reply via email to