Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/164409
Change subject: Hygiene: Cleanup PHP generation of icons for skins
......................................................................
Hygiene: Cleanup PHP generation of icons for skins
This will make transitioning to mw-ui-icon easier
Change-Id: I60b2e50525f694740c0ec43577c37d9441f8bfd5
---
M includes/skins/SkinMinerva.php
M includes/skins/SkinMinervaAlpha.php
2 files changed, 36 insertions(+), 20 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/09/164409/1
diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php
index 4265134..a95e73f 100644
--- a/includes/skins/SkinMinerva.php
+++ b/includes/skins/SkinMinerva.php
@@ -24,6 +24,20 @@
/**
* initialize various variables and generate the template
+ * @param string iconName
+ * @param string iconType element or before
+ * @param string additionalClassNames additional class names you want
to associate with the iconed element
+ * @return string class name for use with HTML element
+ */
+ protected static function iconClass( $iconName, $iconType = 'element',
$additionalClassNames = '' ) {
+ $modifiers = $iconType === 'before' ? 'icon-text' : '';
+ $modifiers .= ' icon-' . $iconName;
+
+ return 'icon ' . $modifiers . ' ' . $additionalClassNames;
+ }
+
+ /**
+ * initialize various variables and generate the template
* @return QuickTemplate
*/
protected function prepareQuickTemplate() {
@@ -152,7 +166,7 @@
'href' => '#/editor/' . $section,
'title' => wfMessage( 'editsectionhint',
$tooltip )->inLanguage( $lang ),
'data-section' => $section,
- 'class' => 'edit-page icon icon-32px icon-edit
enabled'
+ 'class' => self::iconClass( 'edit', 'element',
'edit-page enabled icon-32px' ),
), $message );
}
}
@@ -256,7 +270,7 @@
'title' => $notificationsMsg,
'href' =>
$notificationsTitle->getLocalURL(
array( 'returnto' =>
$currentTitle->getPrefixedText() ) ),
- 'class' => 'user-button icon icon-32px
main-header-button',
+ 'class' => self::iconClass(
'notifications', 'element', 'user-button main-header-button icon-32px' ),
'id'=> 'secondary-button',
) ) .
Html::element(
@@ -299,7 +313,7 @@
'href' =>
$this->getUser()->isLoggedIn() ?
$watchTitle->getLocalUrl( $watchlistQuery ) :
$this->getLoginUrl(
array( 'returnto' => $watchTitle ) ),
- 'class' => 'icon-watchlist icon
icon-text',
+ 'class' => self::iconClass(
'watchlist', 'before' ),
),
),
)
@@ -312,7 +326,7 @@
'text' => wfMessage(
'mobile-frontend-main-menu-upload' )->escaped(),
'href' =>
$this->getUser()->isLoggedIn() ? $donateTitle->getLocalUrl() :
$this->getLoginUrl( array( 'returnto' => $donateTitle ) ),
- 'class' =>
'icon-uploads icon icon-text',
+ 'class' =>
self::iconClass( 'uploads', 'before' ),
),
),
'class' => 'jsonly',
@@ -324,7 +338,7 @@
'text' => wfMessage(
'mobile-frontend-main-menu-settings' )->escaped(),
'href' =>
SpecialPage::getTitleFor( 'MobileOptions' )->
getLocalUrl( array(
'returnto' => $returnToTitle ) ),
- 'class' => 'icon-settings icon
icon-text',
+ 'class' => self::iconClass(
'settings', 'before' ),
),
),
);
@@ -337,7 +351,7 @@
'text' => wfMessage(
'preferences' )->escaped(),
'href' =>
$this->getUser()->isLoggedIn() ? $prefUrl :
$this->getLoginUrl(
array( 'returnto' => $prefUrl ) ),
- 'class' => 'icon-settings icon
icon-text',
+ 'class' => self::iconClass(
'settings', 'before' ),
),
),
);
@@ -380,7 +394,7 @@
array(
'text' => wfMessage(
'mobile-frontend-home-button' )->escaped(),
'href' =>
Title::newMainPage()->getLocalUrl(),
- 'class' => 'icon-home icon
icon-text',
+ 'class' => self::iconClass(
'home', 'before' ),
),
),
),
@@ -391,7 +405,7 @@
'href' =>
SpecialPage::getTitleFor( 'Randompage',
MWNamespace::getCanonicalName( $wgMFContentNamespace ) )->getLocalUrl() .
'#/random',
- 'class' => 'icon-random icon
icon-text',
+ 'class' => self::iconClass(
'random', 'before' ),
'id' => 'randomButton',
),
),
@@ -401,7 +415,7 @@
array(
'text' => wfMessage(
'mobile-frontend-main-menu-nearby' )->escaped(),
'href' =>
SpecialPage::getTitleFor( 'Nearby' )->getLocalURL(),
- 'class' => 'icon-nearby icon
icon-text',
+ 'class' => self::iconClass(
'nearby', 'before' ),
),
),
'class' => 'jsonly',
@@ -468,12 +482,12 @@
array(
'text' => $username,
'href' =>
SpecialPage::getTitleFor( 'UserProfile', $username )->getLocalUrl(),
- 'class' => 'icon icon-profile
truncated-text icon-text',
+ 'class' => self::iconClass(
'profile', 'before', 'truncated-text' ),
),
array(
'text' => wfMessage(
'mobile-frontend-main-menu-logout' )->escaped(),
'href' => $url,
- 'class' => 'icon icon-24px
icon-secondary icon-secondary-logout',
+ 'class' => self::iconClass(
'secondary-logout', 'element', 'icon-24px' ),
),
),
);
@@ -490,7 +504,7 @@
array(
'text' => wfMessage(
'mobile-frontend-main-menu-login' )->escaped(),
'href' => $url,
- 'class' => 'icon icon-anon
icon-text',
+ 'class' => self::iconClass(
'anon' ),
),
),
);
@@ -610,7 +624,7 @@
Html::element( 'a', array(
'title' => wfMessage(
'mobile-frontend-main-menu-button-tooltip' ),
'href' => $url,
- 'class' => 'main-header-button icon',
+ 'class' => self::iconClass( 'mainmenu' ),
'id'=> 'mw-mf-main-menu-button',
) )
);
@@ -700,7 +714,8 @@
if ( $this->isAllowedPageAction( 'edit' ) ) {
$menu['edit'] = array( 'id' => 'ca-edit', 'text' => '',
'itemtitle' => $this->msg(
'mobile-frontend-pageaction-edit-tooltip' ),
- 'class' => 'icon icon-32px icon-edit' );
+ 'class' => self::iconClass( 'edit', 'element',
'icon-32px' ),
+ );
}
if (
@@ -710,7 +725,8 @@
) {
$menu['photo'] = array( 'id' => 'ca-upload', 'text' =>
'',
'itemtitle' => $this->msg(
'mobile-frontend-pageaction-upload-tooltip' ),
- 'class' => 'icon icon-32px' );
+ 'class' => self::iconClass( 'addimage',
'element', 'icon-32px' ),
+ );
}
if ( $this->isAllowedPageAction( 'talk' ) ) {
@@ -726,9 +742,9 @@
// Javascript, so if the talk page hasn't been
created yet, add a 'hidden'
// CSS class which will be removed later via
Javascript.
if ( $menu['talk']['class'] === 'new' ) {
- $menu['talk']['class'] = 'hidden icon
icon-32px icon-talk';
+ $menu['talk']['class'] =
self::iconClass( 'talk', 'element', 'hidden icon-32px' );
} else {
- $menu['talk']['class'] = 'icon
icon-32px icon-talk';
+ $menu['talk']['class'] =
self::iconClass( 'talk', 'element', 'icon-32px' );
}
if ( isset( $tpl->data['_talkdata'] ) ) {
$menu['talk']['text'] =
$tpl->data['_talkdata']['text'];
@@ -743,7 +759,7 @@
if ( $this->isAllowedPageAction( 'watch' ) ) {
$watchTemplate = array(
'id' => 'ca-watch',
- 'class' => 'watch-this-article icon icon-32px',
+ 'class' => self::iconClass( 'watch', 'element',
'icon-32px watch-this-article' ),
);
// standardise watch article into one menu item
if ( isset( $actions['watch'] ) ) {
diff --git a/includes/skins/SkinMinervaAlpha.php
b/includes/skins/SkinMinervaAlpha.php
index 334e2c9..3da9178 100644
--- a/includes/skins/SkinMinervaAlpha.php
+++ b/includes/skins/SkinMinervaAlpha.php
@@ -68,12 +68,12 @@
}
if ( $numTopics ) {
$talkLabel = $this->getLanguage()->formatNum(
$numTopics );
- $class = 'count icon icon-32px icon-talk';
+ $class = self::iconClass( 'talk', 'element',
'count icon-32px' );
} else {
$talkLabel = wfMessage(
'mobile-frontend-talk-overlay-header' );
// add hidden css class to hide talk button,
when no content there. Adding content
// isn't possible without JS, so remove the
class in talk.js
- $class = 'hidden icon icon-32px icon-talk';
+ $class = self::iconClass( 'talk', 'element',
'hidden icon-32px' );
}
$menu = $tpl->data['page_actions'];
if ( isset( $menu['talk'] ) ) {
--
To view, visit https://gerrit.wikimedia.org/r/164409
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I60b2e50525f694740c0ec43577c37d9441f8bfd5
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