Page MenuHomePhabricator

bug17099_2.patch

Authored By
bzimport
Nov 21 2014, 10:29 PM
Size
6 KB
Referenced Files
None
Subscribers
None

bug17099_2.patch

Index: skins/Vector.php
===================================================================
--- skins/Vector.php (revision 99200)
+++ skins/Vector.php (working copy)
@@ -96,12 +96,13 @@
' class="' . htmlspecialchars( $link['class'] ) . '"';
unset( $nav[$section][$key]['class'] );
}
+ $tooltipoption = ( isset( $link['exists'] ) && $link['exists'] == false ) ? 'redlink' : null;
if ( isset( $link['tooltiponly'] ) && $link['tooltiponly'] ) {
$nav[$section][$key]['key'] =
- Linker::tooltip( $xmlID );
+ Linker::tooltip( $xmlID, $tooltipoption );
} else {
$nav[$section][$key]['key'] =
- Xml::expandAttributes( Linker::tooltipAndAccesskeyAttribs( $xmlID ) );
+ Xml::expandAttributes( Linker::tooltipAndAccesskeyAttribs( $xmlID, $tooltipoption ) );
}
}
}
Index: includes/Linker.php
===================================================================
--- includes/Linker.php (revision 99200)
+++ includes/Linker.php (working copy)
@@ -1707,8 +1707,9 @@
* element than the id, for reverse-compatibility, etc.)
*
* @param $name String: id of the element, minus prefixes.
- * @param $options Mixed: null or the string 'withaccess' to add an access-
- * key hint
+ * @param $options Array: 'withaccess': add an access-key hint
+ * 'redlink': add (page does not exist)
+ *
* @return String: contents of the title attribute (which you must HTML-
* escape), or false for no title attribute
*/
@@ -1718,6 +1719,7 @@
return false;
wfProfileIn( __METHOD__ );
+ $options = (array)$options;
$message = wfMessage( "tooltip-$name" );
@@ -1733,7 +1735,16 @@
}
}
- if ( $options == 'withaccess' ) {
+ if ( in_array( 'redlink', $options, true) ) {
+ if ( $tooltip !== false || $tooltip !== '' ) {
+ $message = wfMessage( "red-link-title", $tooltip );
+ if ( !$message->isDisabled() ) {
+ $tooltip = $message->text();
+ }
+ }
+ }
+
+ if ( in_array( 'withaccess' , $options, true ) ) {
$accesskey = self::accesskey( $name );
if ( $accesskey !== false ) {
if ( $tooltip === false || $tooltip === '' ) {
@@ -2006,15 +2017,17 @@
/**
* Returns the attributes for the tooltip and access key.
*/
- public static function tooltipAndAccesskeyAttribs( $name ) {
+ public static function tooltipAndAccesskeyAttribs( $name, $options = null ) {
global $wgEnableTooltipsAndAccesskeys;
if ( !$wgEnableTooltipsAndAccesskeys )
return array();
# @todo FIXME: If Sanitizer::expandAttributes() treated "false" as "output
# no attribute" instead of "output '' as value for attribute", this
# would be three lines.
+ $options = (array)$options;
+ $options[] = 'withaccess';
$attribs = array(
- 'title' => self::titleAttrib( $name, 'withaccess' ),
+ 'title' => self::titleAttrib( $name, $options ),
'accesskey' => self::accesskey( $name )
);
if ( $attribs['title'] === false ) {
Index: includes/SkinTemplate.php
===================================================================
--- includes/SkinTemplate.php (revision 99200)
+++ includes/SkinTemplate.php (working copy)
@@ -562,6 +562,7 @@
'text' => $this->username,
'href' => &$this->userpageUrlDetails['href'],
'class' => $this->userpageUrlDetails['exists'] ? false : 'new',
+ 'exists' => $this->userpageUrlDetails['exists'],
'active' => ( $this->userpageUrlDetails['href'] == $pageurl )
);
$usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage );
@@ -569,6 +570,7 @@
'text' => wfMsg( 'mytalk' ),
'href' => &$usertalkUrlDetails['href'],
'class' => $usertalkUrlDetails['exists'] ? false : 'new',
+ 'exists' => $usertalkUrlDetails['exists'],
'active' => ( $usertalkUrlDetails['href'] == $pageurl )
);
$href = self::makeSpecialUrl( 'Preferences' );
@@ -657,6 +659,7 @@
'text' => $this->username,
'href' => $href,
'class' => $this->userpageUrlDetails['exists'] ? false : 'new',
+ 'exists' => $this->userpageUrlDetails['exists'],
'active' => ( $pageurl == $href )
);
$usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage );
@@ -665,6 +668,7 @@
'text' => wfMsg( 'anontalk' ),
'href' => $href,
'class' => $usertalkUrlDetails['exists'] ? false : 'new',
+ 'exists' => $usertalkUrlDetails['exists'],
'active' => ( $pageurl == $href )
);
$personal_urls['anonlogin'] = $login_url;
@@ -695,9 +699,11 @@
if( $selected ) {
$classes[] = 'selected';
}
+ $exists = true;
if( $checkEdit && !$title->isKnown() ) {
$classes[] = 'new';
$query = 'action=edit&redlink=1';
+ $exists = false;
}
// wfMessageFallback will nicely accept $message as an array of fallbacks
@@ -726,6 +732,7 @@
'class' => implode( ' ', $classes ),
'text' => $text,
'href' => $title->getLocalUrl( $query ),
+ 'exists' => $exists,
'primary' => true );
}
@@ -1493,7 +1500,7 @@
if ( isset($ptool["active"]) ) {
$personal_tools[$key]["active"] = $ptool["active"];
}
- foreach ( array("href", "class", "text") as $k ) {
+ foreach ( array("href", "class", "text", "exists") as $k ) {
if ( isset($ptool[$k]) )
$personal_tools[$key]["links"][0][$k] = $ptool[$k];
}
@@ -1666,15 +1673,16 @@
$item['single-id'] = $item['id'];
}
if ( isset( $item['single-id'] ) ) {
+ $tooltipoption = ( isset( $item['exists'] ) && $item['exists'] == false ) ? 'redlink' : null;
if ( isset( $item['tooltiponly'] ) && $item['tooltiponly'] ) {
- $attrs['title'] = Linker::titleAttrib( $item['single-id'] );
+ $attrs['title'] = Linker::titleAttrib( $item['single-id'], $tooltipoption );
if ( $attrs['title'] === false ) {
unset( $attrs['title'] );
}
} else {
$attrs = array_merge(
$attrs,
- Linker::tooltipAndAccesskeyAttribs( $item['single-id'] )
+ Linker::tooltipAndAccesskeyAttribs( $item['single-id'], $tooltipoption )
);
}
}
@@ -1709,7 +1717,7 @@
}
} else {
$link = array();
- foreach ( array( 'text', 'msg', 'href', 'rel', 'type', 'tooltiponly', 'target' ) as $k ) {
+ foreach ( array( 'text', 'msg', 'href', 'rel', 'type', 'tooltiponly', 'target', 'exists' ) as $k ) {
if ( isset( $item[$k] ) ) {
$link[$k] = $item[$k];
}

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4998
Default Alt Text
bug17099_2.patch (6 KB)

Event Timeline