Index: trunk/phase3/includes/Linker.php |
— | — | @@ -198,7 +198,7 @@ |
199 | 199 | |
200 | 200 | $attribs = array_merge( |
201 | 201 | $attribs, |
202 | | - $this->linkAttribs( $target, $customAttribs, $options ) |
| 202 | + $this->linkAttribs( $target, $customAttribs, $options, $text ) |
203 | 203 | ); |
204 | 204 | if ( is_null( $text ) ) { |
205 | 205 | $text = $this->linkText( $target ); |
— | — | @@ -248,7 +248,7 @@ |
249 | 249 | /** |
250 | 250 | * Returns the array of attributes used when linking to the Title $target |
251 | 251 | */ |
252 | | - private function linkAttribs( $target, $attribs, $options ) { |
| 252 | + private function linkAttribs( $target, $attribs, $options, $linkText ) { |
253 | 253 | wfProfileIn( __METHOD__ ); |
254 | 254 | global $wgUser; |
255 | 255 | $defaults = array(); |
— | — | @@ -279,12 +279,13 @@ |
280 | 280 | } |
281 | 281 | |
282 | 282 | # Get a default title attribute. |
| 283 | + $known = in_array( 'known', $options ); |
283 | 284 | if ( $target->getPrefixedText() == '' ) { |
284 | 285 | # A link like [[#Foo]]. This used to mean an empty title |
285 | 286 | # attribute, but that's silly. Just don't output a title. |
286 | | - } elseif ( in_array( 'known', $options ) ) { |
| 287 | + } elseif ( $known && strtolower($linkText) !== strtolower($target->getPrefixedText() ) ) { |
287 | 288 | $defaults['title'] = $target->getPrefixedText(); |
288 | | - } else { |
| 289 | + } elseif ( !$known ) { |
289 | 290 | $defaults['title'] = wfMsg( 'red-link-title', $target->getPrefixedText() ); |
290 | 291 | } |
291 | 292 | |
— | — | @@ -312,7 +313,7 @@ |
313 | 314 | return ''; |
314 | 315 | } |
315 | 316 | |
316 | | - # If the target is just a fragment, with no title, we return the frag- |
| 317 | + # If the target is just a fragment, with no title, we return the frag- |
317 | 318 | # ment text. Otherwise, we return the title text itself. |
318 | 319 | if ( $target->getPrefixedText() === '' and $target->getFragment() !== '' ) { |
319 | 320 | return htmlspecialchars( $target->getFragment() ); |
— | — | @@ -324,14 +325,14 @@ |
325 | 326 | * Generate either a normal exists-style link or a stub link, depending |
326 | 327 | * on the given page size. |
327 | 328 | * |
328 | | - * @param $size Integer |
329 | | - * @param $nt Title object. |
330 | | - * @param $text String |
331 | | - * @param $query String |
332 | | - * @param $trail String |
333 | | - * @param $prefix String |
334 | | - * @return string HTML of link |
335 | | - * @deprecated |
| 329 | + * @param $size Integer |
| 330 | + * @param $nt Title object. |
| 331 | + * @param $text String |
| 332 | + * @param $query String |
| 333 | + * @param $trail String |
| 334 | + * @param $prefix String |
| 335 | + * @return string HTML of link |
| 336 | + * @deprecated |
336 | 337 | */ |
337 | 338 | function makeSizeLinkObj( $size, $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { |
338 | 339 | global $wgUser; |
— | — | @@ -1317,7 +1318,7 @@ |
1318 | 1319 | */ |
1319 | 1320 | function tocLineEnd() { |
1320 | 1321 | return "</li>\n"; |
1321 | | - } |
| 1322 | + } |
1322 | 1323 | |
1323 | 1324 | /** |
1324 | 1325 | * Wraps the TOC in a table and provides the hide/collapse javascript. |
— | — | @@ -1739,7 +1740,7 @@ |
1740 | 1741 | */ |
1741 | 1742 | function makeLink( $title, $text = '', $query = '', $trail = '' ) { |
1742 | 1743 | wfProfileIn( __METHOD__ ); |
1743 | | - $nt = Title::newFromText( $title ); |
| 1744 | + $nt = Title::newFromText( $title ); |
1744 | 1745 | if ( $nt instanceof Title ) { |
1745 | 1746 | $result = $this->makeLinkObj( $nt, $text, $query, $trail ); |
1746 | 1747 | } else { |