[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Add text to tab links telling if they do exist
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/401733 ) Change subject: Add text to tab links telling if they do exist .. Add text to tab links telling if they do exist And changed a little bit signature of Linker::titleAttrib and Linker::tooltipAndAcceskeyAttribs. Added $options parameter to the second one and made $options parameter satisfied by passing an array with options, because there is one more now: 'nonexisting' which tells to add text about the thing that the page does not exist to its tooltip. Bug: T19099 Change-Id: Ia76dd6db363f6add5efb8955be9e23a1f8e8476f --- M includes/Linker.php M includes/skins/BaseTemplate.php M includes/skins/SkinTemplate.php 3 files changed, 36 insertions(+), 9 deletions(-) Approvals: Fz-29: Looks good to me, but someone else must approve Bartosz DziewoĆski: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/Linker.php b/includes/Linker.php index c0255ac..3b0e72d 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1968,8 +1968,9 @@ * * @since 1.16.3 $msgParams added in 1.27 * @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 string|array|null $options Null, string or array with some of the following options: +* - 'withaccess' to add an access-key hint +* - 'nonexisting' to add an accessibility hint that page does not exist * @param array $msgParams Parameters to pass to the message * * @return string Contents of the title attribute (which you must HTML- @@ -1989,7 +1990,12 @@ } } - if ( $options == 'withaccess' ) { + $options = (array)$options; + + if ( in_array( 'nonexisting', $options ) ) { + $tooltip = wfMessage( 'red-link-title', $tooltip ?: '' )->text(); + } + if ( in_array( 'withaccess', $options ) ) { $accesskey = self::accesskey( $name ); if ( $accesskey !== false ) { // Should be build the same as in jquery.accessKeyLabel.js @@ -2130,12 +2136,22 @@ * @since 1.16.3. $msgParams introduced in 1.27 * @param string $name * @param array $msgParams Params for constructing the message +* @param string|array|null $options Options to be passed to titleAttrib. +* +* @see Linker::titleAttrib for what options could be passed to $options. * * @return array */ - public static function tooltipAndAccesskeyAttribs( $name, array $msgParams = [] ) { + public static function tooltipAndAccesskeyAttribs( + $name, + array $msgParams = [], + $options = null + ) { + $options = (array)$options; + $options[] = 'withaccess'; + $attribs = [ - 'title' => self::titleAttrib( $name, 'withaccess', $msgParams ), + 'title' => self::titleAttrib( $name, $options, $msgParams ), 'accesskey' => self::accesskey( $name ) ]; if ( $attribs['title'] === false ) { diff --git a/includes/skins/BaseTemplate.php b/includes/skins/BaseTemplate.php index f0b336a..bb1d8d0 100644 --- a/includes/skins/BaseTemplate.php +++ b/includes/skins/BaseTemplate.php @@ -143,7 +143,7 @@ if ( isset( $plink['active'] ) ) { $ptool['active'] = $plink['active']; } - foreach ( [ 'href', 'class', 'text', 'dir', 'data' ] as $k ) { + foreach ( [ 'href', 'class', 'text', 'dir', 'data', 'exists' ] as $k ) { if ( isset( $plink[$k] ) ) { $ptool['links'][0][$k] = $plink[$k]; } @@ -391,7 +391,7 @@ if ( isset( $item['href'] ) || isset( $options['link-fallback'] ) ) { $attrs = $item; foreach ( [ 'single-id', 'text', 'msg', 'tooltiponly', 'context', 'primary', - 'tooltip-params' ] as $k ) { + 'tooltip-params', 'exists' ] as $k ) { unset( $attrs[$k] ); } @@ -412,13 +412,19 @@ } if ( isset( $item['single-id'] ) ) { + $tooltipOption = isset( $item['exists'] ) && $item['exists'] === false ? 'nonexisting' : null; + if ( isset( $item['tooltiponly'] ) && $item['tooltiponly'] ) { -
[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Add text to tab links telling if they do exist
Albert221 has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/401733 ) Change subject: Add text to tab links telling if they do exist .. Add text to tab links telling if they do exist And changed a little bit signature of Linker::titleAttrib and Linker::tooltipAndAcceskeyAttribs. Added $options parameter to the second one and made $options parameter satisfied by passing an array with options, because there is one more now: 'nonexisting' which tells to add text about the thing that the page does not exist to its tooltip. Bug: T19099 Change-Id: Ia76dd6db363f6add5efb8955be9e23a1f8e8476f --- M includes/Linker.php M includes/skins/BaseTemplate.php M includes/skins/SkinTemplate.php M languages/i18n/en.json M languages/i18n/qqq.json 5 files changed, 38 insertions(+), 11 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/33/401733/1 diff --git a/includes/Linker.php b/includes/Linker.php index 84e3103..8eb0b1a 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1968,8 +1968,9 @@ * * @since 1.16.3 $msgParams added in 1.27 * @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 string|array|null $options Null or the string or array containing some of the following options: +* - 'withaccess' to add an access-key hint +* - 'nonexisting' to add an accessibility hint that page does not exist * @param array $msgParams Parameters to pass to the message * * @return string Contents of the title attribute (which you must HTML- @@ -1989,7 +1990,17 @@ } } - if ( $options == 'withaccess' ) { + $options = (array)$options; + + if ( in_array( 'nonexisting', $options ) ) { + if ( $tooltip === false || $tooltip === '' ) { + $tooltip = wfMessage( 'nonexisting' )->text(); + } else { + $tooltip .= wfMessage( 'word-separator' )->text(); + $tooltip .= wfMessage( 'nonexisting' )->text(); + } + } + if ( in_array( 'withaccess', $options ) ) { $accesskey = self::accesskey( $name ); if ( $accesskey !== false ) { // Should be build the same as in jquery.accessKeyLabel.js @@ -2132,12 +2143,18 @@ * @since 1.16.3. $msgParams introduced in 1.27 * @param string $name * @param array $msgParams Params for constructing the message +* @param string|null $options Options to be passed to titleAttrib. +* +* @see Linker::titleAttrib * * @return array */ - public static function tooltipAndAccesskeyAttribs( $name, array $msgParams = [] ) { + public static function tooltipAndAccesskeyAttribs( $name, array $msgParams = [], $options = null ) { + $options = (array)$options; + $options[] = 'withaccess'; + $attribs = [ - 'title' => self::titleAttrib( $name, 'withaccess', $msgParams ), + 'title' => self::titleAttrib( $name, $options, $msgParams ), 'accesskey' => self::accesskey( $name ) ]; if ( $attribs['title'] === false ) { diff --git a/includes/skins/BaseTemplate.php b/includes/skins/BaseTemplate.php index f0b336a..1cff694 100644 --- a/includes/skins/BaseTemplate.php +++ b/includes/skins/BaseTemplate.php @@ -143,7 +143,7 @@ if ( isset( $plink['active'] ) ) { $ptool['active'] = $plink['active']; } - foreach ( [ 'href', 'class', 'text', 'dir', 'data' ] as $k ) { + foreach ( [ 'href', 'class', 'text', 'dir', 'data', 'exists' ] as $k ) { if ( isset( $plink[$k] ) ) { $ptool['links'][0][$k] = $plink[$k]; } @@ -391,7 +391,7 @@ if ( isset( $item['href'] ) || isset( $options['link-fallback'] ) ) { $attrs = $item; foreach ( [ 'single-id', 'text', 'msg', 'tooltiponly', 'context', 'primary', - 'tooltip-params' ] as $k ) { + 'tooltip-params', 'exists' ] as $k ) { unset( $attrs[$k] ); } @@ -412,13 +412,15 @@ } if ( isset( $item['single-id'] ) ) { + $tooltipOption = isset(