Victorbarbu has uploaded a new change for review. https://gerrit.wikimedia.org/r/263606
Change subject: Add custom attributes support to toolbox links' tooltips ...................................................................... Add custom attributes support to toolbox links' tooltips Added custom messages parameters support to toolbox links' tooltips, by setting 'tooltip-params' key in a $nav_urls item of SkinTemplate::buildNavUrls. Bug: T123365 Change-Id: I45577d54bd78ba1e2ba10fb8f04367244495bfea --- M includes/Linker.php M includes/skins/BaseTemplate.php M includes/skins/SkinTemplate.php M languages/i18n/en.json 4 files changed, 26 insertions(+), 14 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/06/263606/1 diff --git a/includes/Linker.php b/includes/Linker.php index 80e4c62..0dd4c47 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -2150,13 +2150,13 @@ * @param string $name Id of the element, minus prefixes. * @param string|null $options Null or the string 'withaccess' to add an access- * key hint + * @param array $msgParams Parameters to pass to the message + * * @return string Contents of the title attribute (which you must HTML- * escape), or false for no title attribute */ - public static function titleAttrib( $name, $options = null ) { - - $message = wfMessage( "tooltip-$name" ); - + public static function titleAttrib( $name, $options = null, array $msgParams = array() ) { + $message = wfMessage( "tooltip-$name", $msgParams ); if ( !$message->exists() ) { $tooltip = false; } else { @@ -2306,15 +2306,18 @@ /** * Returns the attributes for the tooltip and access key. + * * @param string $name + * @param array $msgParams Params for constructing the message + * * @return array */ - public static function tooltipAndAccesskeyAttribs( $name ) { + public static function tooltipAndAccesskeyAttribs( $name, array $msgParams = array() ) { # @todo FIXME: If Sanitizer::expandAttributes() treated "false" as "output # no attribute" instead of "output '' as value for attribute", this # would be three lines. $attribs = array( - 'title' => self::titleAttrib( $name, 'withaccess' ), + 'title' => self::titleAttrib( $name, 'withaccess', $msgParams ), 'accesskey' => self::accesskey( $name ) ); if ( $attribs['title'] === false ) { diff --git a/includes/skins/BaseTemplate.php b/includes/skins/BaseTemplate.php index 25df0f9..143b621 100644 --- a/includes/skins/BaseTemplate.php +++ b/includes/skins/BaseTemplate.php @@ -358,21 +358,28 @@ if ( isset( $item['href'] ) || isset( $options['link-fallback'] ) ) { $attrs = $item; - foreach ( array( 'single-id', 'text', 'msg', 'tooltiponly', 'context', 'primary' ) as $k ) { + foreach ( array( 'single-id', 'text', 'msg', 'tooltiponly', 'context', 'primary', + 'tooltip-params' ) as $k ) { unset( $attrs[$k] ); } if ( isset( $item['id'] ) && !isset( $item['single-id'] ) ) { $item['single-id'] = $item['id']; } + + $tooltipParams = array(); + if ( isset( $item['tooltip-params'] ) ) { + $tooltipParams = $item['tooltip-params']; + } + if ( isset( $item['single-id'] ) ) { if ( isset( $item['tooltiponly'] ) && $item['tooltiponly'] ) { - $title = Linker::titleAttrib( $item['single-id'] ); + $title = Linker::titleAttrib( $item['single-id'], null, $tooltipParams ); if ( $title !== false ) { $attrs['title'] = $title; } } else { - $tip = Linker::tooltipAndAccesskeyAttribs( $item['single-id'] ); + $tip = Linker::tooltipAndAccesskeyAttribs( $item['single-id'], $tooltipParams ); if ( isset( $tip['title'] ) && $tip['title'] !== false ) { $attrs['title'] = $tip['title']; } diff --git a/includes/skins/SkinTemplate.php b/includes/skins/SkinTemplate.php index 2ecbafb..f0ff727 100644 --- a/includes/skins/SkinTemplate.php +++ b/includes/skins/SkinTemplate.php @@ -1246,7 +1246,8 @@ $nav_urls['contributions'] = array( 'text' => $this->msg( 'contributions', $rootUser )->text(), - 'href' => self::makeSpecialUrlSubpage( 'Contributions', $rootUser ) + 'href' => self::makeSpecialUrlSubpage( 'Contributions', $rootUser ), + 'tooltip-params' => array( $rootUser ) ); $nav_urls['log'] = array( @@ -1262,7 +1263,8 @@ if ( $this->showEmailUser( $user ) ) { $nav_urls['emailuser'] = array( - 'href' => self::makeSpecialUrlSubpage( 'Emailuser', $rootUser ) + 'href' => self::makeSpecialUrlSubpage( 'Emailuser', $rootUser ), + 'tooltip-params' => array( $rootUser ) ); } diff --git a/languages/i18n/en.json b/languages/i18n/en.json index b436f90..dad304a 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -2558,7 +2558,7 @@ "accesskey-import": "s", "accesskey-watchlistedit-normal-submit": "s", "accesskey-watchlistedit-raw-submit": "s", - "tooltip-pt-userpage": "Your user page", + "tooltip-pt-userpage": "Your {{GENDER:|user}} page", "tooltip-pt-anonuserpage": "The user page for the IP address you are editing as", "tooltip-pt-mytalk": "Your talk page", "tooltip-pt-anontalk": "Discussion about edits from this IP address", @@ -2596,8 +2596,8 @@ "tooltip-t-recentchangeslinked": "Recent changes in pages linked from this page", "tooltip-feed-rss": "RSS feed for this page", "tooltip-feed-atom": "Atom feed for this page", - "tooltip-t-contributions": "A list of contributions by this user", - "tooltip-t-emailuser": "Send an email to this user", + "tooltip-t-contributions": "A list of contributions by {{GENDER:$1|this user}}", + "tooltip-t-emailuser": "Send an email to {{GENDER:$1|this user}}", "tooltip-t-info": "More information about this page", "tooltip-t-upload": "Upload files", "tooltip-t-specialpages": "A list of all special pages", -- To view, visit https://gerrit.wikimedia.org/r/263606 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I45577d54bd78ba1e2ba10fb8f04367244495bfea Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Victorbarbu <victorbarb...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits