Legoktm has uploaded a new change for review.

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

Change subject: SkinTemplate: Set link classes on content_navigation tabs
......................................................................

SkinTemplate: Set link classes on content_navigation tabs

Set link classes like 'mw-redirect' and 'stub' on the content_navigation
tabs.

Bug: T24976
Change-Id: I10b9b3f95a340ac028a53ea27ec857c12f8bef19
---
M includes/skins/BaseTemplate.php
M includes/skins/SkinTemplate.php
2 files changed, 18 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/62/292062/1

diff --git a/includes/skins/BaseTemplate.php b/includes/skins/BaseTemplate.php
index 3408db3..13db176 100644
--- a/includes/skins/BaseTemplate.php
+++ b/includes/skins/BaseTemplate.php
@@ -425,7 +425,8 @@
         * list item directly so they will not be passed to makeLink
         * (however the link will still support a tooltip and accesskey from it)
         * If you need an id or class on a single link you should include a 
"links"
-        * array with just one link item inside of it. If you want to add a 
title
+        * array with just one link item inside of it. You can also set 
"link-class" in
+        * $item to set a class on the link itself. If you want to add a title
         * to the list item itself, you can set "itemtitle" to the value.
         * $options is also passed on to makeLink calls
         *
@@ -450,6 +451,12 @@
                                // generating tooltips and accesskeys.
                                $link['single-id'] = $item['id'];
                        }
+                       if ( isset( $link['link-class'] ) ) {
+                               // link-class should be set on the <a> itself,
+                               // so pass it in as 'class'
+                               $link['class'] = $link['link-class'];
+                               unset( $link['link-class'] );
+                       }
                        $html = $this->makeLink( $key, $link, $options );
                }
 
diff --git a/includes/skins/SkinTemplate.php b/includes/skins/SkinTemplate.php
index cefc5bc..ec17c5a 100644
--- a/includes/skins/SkinTemplate.php
+++ b/includes/skins/SkinTemplate.php
@@ -17,6 +17,7 @@
  *
  * @file
  */
+use MediaWiki\MediaWikiServices;
 
 /**
  * Base class for template-based skins.
@@ -749,6 +750,9 @@
                        }
                }
 
+               $linkClass = 
MediaWikiServices::getInstance()->getLinkRenderer()->getLinkClasses( $title );
+
+
                // wfMessageFallback will nicely accept $message as an array of 
fallbacks
                // or just a single key
                $msg = wfMessageFallback( $message )->setContext( 
$this->getContext() );
@@ -771,11 +775,16 @@
                        return $result;
                }
 
-               return [
+               $result = [
                        'class' => implode( ' ', $classes ),
                        'text' => $text,
                        'href' => $title->getLocalURL( $query ),
                        'primary' => true ];
+               if ( $linkClass !== '' ) {
+                       $result['link-class'] = $linkClass;
+               }
+
+               return $result;
        }
 
        function makeTalkUrlDetails( $name, $urlaction = '' ) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I10b9b3f95a340ac028a53ea27ec857c12f8bef19
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>

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

Reply via email to