*
* @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-
}
}
- 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
* @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 ) {
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];
}
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] );
}
}
if ( isset( $item['single-id'] ) ) {
+ $tooltipOption = isset( $item['exists'] ) && $item['exists'] === false ? 'nonexisting' : null;
+
if ( isset( $item['tooltiponly'] ) && $item['tooltiponly'] ) {
- $title = Linker::titleAttrib( $item['single-id'], null, $tooltipParams );
+ $title = Linker::titleAttrib( $item['single-id'], $tooltipOption, $tooltipParams );
if ( $title !== false ) {
$attrs['title'] = $title;
}
} else {
- $tip = Linker::tooltipAndAccesskeyAttribs( $item['single-id'], $tooltipParams );
+ $tip = Linker::tooltipAndAccesskeyAttribs(
+ $item['single-id'],
+ $tooltipParams,
+ $tooltipOption
+ );
if ( isset( $tip['title'] ) && $tip['title'] !== false ) {
$attrs['title'] = $tip['title'];
}
'text' => $this->username,
'href' => &$this->userpageUrlDetails['href'],
'class' => $this->userpageUrlDetails['exists'] ? false : 'new',
+ 'exists' => $this->userpageUrlDetails['exists'],
'active' => ( $this->userpageUrlDetails['href'] == $pageurl ),
'dir' => 'auto'
];
'text' => $this->msg( 'mytalk' )->text(),
'href' => &$usertalkUrlDetails['href'],
'class' => $usertalkUrlDetails['exists'] ? false : 'new',
+ 'exists' => $usertalkUrlDetails['exists'],
'active' => ( $usertalkUrlDetails['href'] == $pageurl )
];
$href = self::makeSpecialUrl( 'Preferences' );
if ( $selected ) {
$classes[] = 'selected';
}
+ $exists = true;
if ( $checkEdit && !$title->isKnown() ) {
$classes[] = 'new';
+ $exists = false;
if ( $query !== '' ) {
$query = 'action=edit&redlink=1&' . $query;
} else {
'class' => implode( ' ', $classes ),
'text' => $text,
'href' => $title->getLocalURL( $query ),
+ 'exists' => $exists,
'primary' => true ];
if ( $linkClass !== '' ) {
$result['link-class'] = $linkClass;