jenkins-bot has submitted this change and it was merged. Change subject: Add title to list item of language link ......................................................................
Add title to list item of language link The key itemtitle can be used to set the title of the actual list item element. This is useful for article badges as it is already done by the js hack to add a title for the icon. Bug: 60717 Change-Id: Ic05c7535d7a35d9ee523373e1e3620e72887459d --- M includes/SkinTemplate.php A tests/phpunit/includes/SkinTemplateTest.php 2 files changed, 45 insertions(+), 3 deletions(-) Approvals: Daniel Kinzler: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 35183ce..e3e79e1 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -1838,7 +1838,7 @@ * * @param $key string, usually a key from the list you are generating this link from. * @param $item array, of list item data containing some of a specific set of keys. - * The "id" and "class" keys will be used as attributes for the list item, + * The "id", "class" and "itemtitle" keys will be used as attributes for the list item, * if "active" contains a value of true a "active" class will also be appended to class. * * @param $options array @@ -1855,7 +1855,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. + * array with just one link item inside of it. 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 * * @return string @@ -1869,7 +1870,7 @@ } else { $link = $item; // These keys are used by makeListItem and shouldn't be passed on to the link - foreach ( array( 'id', 'class', 'active', 'tag' ) as $k ) { + foreach ( array( 'id', 'class', 'active', 'tag', 'itemtitle' ) as $k ) { unset( $link[$k] ); } if ( isset( $item['id'] ) && !isset( $item['single-id'] ) ) { @@ -1894,6 +1895,9 @@ $attrs['class'] .= ' active'; $attrs['class'] = trim( $attrs['class'] ); } + if ( isset( $item['itemtitle'] ) ) { + $attrs['title'] = $item['itemtitle']; + } return Html::rawElement( isset( $options['tag'] ) ? $options['tag'] : 'li', $attrs, $html ); } diff --git a/tests/phpunit/includes/SkinTemplateTest.php b/tests/phpunit/includes/SkinTemplateTest.php new file mode 100644 index 0000000..8f54714 --- /dev/null +++ b/tests/phpunit/includes/SkinTemplateTest.php @@ -0,0 +1,38 @@ +<?php + +/** + * @covers SkinTemplate + * + * @group Output + * + * @licence GNU GPL v2+ + * @author Bene* < benestar.wikime...@gmail.com > + */ + +class SkinTemplateTest extends MediaWikiTestCase { + + /** + * @dataProvider makeListItemProvider + */ + public function testMakeListItem( $expected, $key, $item, $options, $message ) { + $template = $this->getMockForAbstractClass( 'BaseTemplate' ); + + $this->assertEquals( + $expected, + $template->makeListItem( $key, $item, $options ), + $message + ); + } + + public function makeListItemProvider() { + return array( + array( + '<li class="class" title="itemtitle"><a href="url" title="title">text</a></li>', + '', + array( 'class' => 'class', 'itemtitle' => 'itemtitle', 'href' => 'url', 'title' => 'title', 'text' => 'text' ), + array(), + 'Test makteListItem with normal values' + ) + ); + } +} -- To view, visit https://gerrit.wikimedia.org/r/111159 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic05c7535d7a35d9ee523373e1e3620e72887459d Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Bene <benestar.wikime...@googlemail.com> Gerrit-Reviewer: Aude <aude.w...@gmail.com> Gerrit-Reviewer: Bene <benestar.wikime...@googlemail.com> Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de> Gerrit-Reviewer: Hoo man <h...@online.de> Gerrit-Reviewer: Jack Phoenix <j...@countervandalism.net> Gerrit-Reviewer: Lydia Pintscher <lydia.pintsc...@wikimedia.de> Gerrit-Reviewer: Waldir <wal...@email.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits