Index: trunk/phase3/includes/Linker.php |
— | — | @@ -234,16 +234,10 @@ |
235 | 235 | * the end of the link. |
236 | 236 | * @param $prefix String: optional prefix. As trail, only before instead of after. |
237 | 237 | */ |
238 | | - function makeLinkObj( $nt, $text= '', $query = '', $trail = '', $prefix = '' ) { |
| 238 | + function makeLinkObj( Title $nt, $text= '', $query = '', $trail = '', $prefix = '' ) { |
239 | 239 | global $wgUser; |
240 | 240 | wfProfileIn( __METHOD__ ); |
241 | 241 | |
242 | | - if ( !$nt instanceof Title ) { |
243 | | - # Fail gracefully |
244 | | - wfProfileOut( __METHOD__ ); |
245 | | - return "<!-- ERROR -->{$prefix}{$text}{$trail}"; |
246 | | - } |
247 | | - |
248 | 242 | if ( $nt->isExternal() ) { |
249 | 243 | $u = $nt->getFullURL(); |
250 | 244 | $link = $nt->getPrefixedURL(); |
— | — | @@ -308,19 +302,16 @@ |
309 | 303 | * @param $query String: link target |
310 | 304 | * @param $trail String: text after link |
311 | 305 | * @param $prefix String: text before link text |
312 | | - * @param $aprops String: extra attributes to the a-element |
| 306 | + * @param $aprops Mixed: extra attributes to the a-element. If a string, |
| 307 | + * inserted literally into the HTML, with a space prepended. It can also |
| 308 | + * be an associative array. In this case the keys are attributes, and |
| 309 | + * values are *unescaped* attribute values. |
313 | 310 | * @param $style String: style to apply - if empty, use getInternalLinkAttributesObj instead |
314 | 311 | * @return the a-element |
315 | 312 | */ |
316 | | - function makeKnownLinkObj( $title, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '', $style = '' ) { |
| 313 | + function makeKnownLinkObj( Title $title, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '', $style = '' ) { |
317 | 314 | wfProfileIn( __METHOD__ ); |
318 | 315 | |
319 | | - if ( !$title instanceof Title ) { |
320 | | - # Fail gracefully |
321 | | - wfProfileOut( __METHOD__ ); |
322 | | - return "<!-- ERROR -->{$prefix}{$text}{$trail}"; |
323 | | - } |
324 | | - |
325 | 316 | $nt = $this->normaliseSpecialPage( $title ); |
326 | 317 | |
327 | 318 | $u = $nt->escapeLocalURL( $query ); |
— | — | @@ -340,7 +331,16 @@ |
341 | 332 | $style = $this->getInternalLinkAttributesObj( $nt, $text ); |
342 | 333 | } |
343 | 334 | |
344 | | - if ( $aprops !== '' ) $aprops = ' ' . $aprops; |
| 335 | + if( is_string( $aprops ) && $aprops != '' ) { |
| 336 | + $aprops = " $aprops"; |
| 337 | + } elseif( is_array( $aprops ) ) { |
| 338 | + $attributes = $aprops; |
| 339 | + $aprops = ''; |
| 340 | + foreach( $attributes as $key => $value ) { |
| 341 | + $value = htmlspecialchars( $value ); |
| 342 | + $aprops .= " $key=\"$value\""; |
| 343 | + } |
| 344 | + } |
345 | 345 | |
346 | 346 | list( $inside, $trail ) = Linker::splitTrail( $trail ); |
347 | 347 | $r = "<a href=\"{$u}\"{$style}{$aprops}>{$prefix}{$text}{$inside}</a>{$trail}"; |
— | — | @@ -358,15 +358,9 @@ |
359 | 359 | * be included in the link text. Other characters will be appended after |
360 | 360 | * the end of the link. |
361 | 361 | */ |
362 | | - function makeBrokenLinkObj( $title, $text = '', $query = '', $trail = '', $prefix = '' ) { |
| 362 | + function makeBrokenLinkObj( Title $title, $text = '', $query = '', $trail = '', $prefix = '' ) { |
363 | 363 | wfProfileIn( __METHOD__ ); |
364 | 364 | |
365 | | - if ( !$title instanceof Title ) { |
366 | | - # Fail gracefully |
367 | | - wfProfileOut( __METHOD__ ); |
368 | | - return "<!-- ERROR -->{$prefix}{$text}{$trail}"; |
369 | | - } |
370 | | - |
371 | 365 | $nt = $this->normaliseSpecialPage( $title ); |
372 | 366 | |
373 | 367 | if( $nt->getNamespace() == NS_SPECIAL ) { |
— | — | @@ -406,6 +400,7 @@ |
407 | 401 | * the end of the link. |
408 | 402 | */ |
409 | 403 | function makeStubLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { |
| 404 | + wfDeprecated( __METHOD__ ); |
410 | 405 | return $this->makeColouredLinkObj( $nt, 'stub', $text, $query, $trail, $prefix ); |
411 | 406 | } |
412 | 407 | |
— | — | @@ -421,7 +416,6 @@ |
422 | 417 | * the end of the link. |
423 | 418 | */ |
424 | 419 | function makeColouredLinkObj( $nt, $colour, $text = '', $query = '', $trail = '', $prefix = '' ) { |
425 | | - |
426 | 420 | if($colour != ''){ |
427 | 421 | $style = $this->getInternalLinkAttributesObj( $nt, $text, $colour ); |
428 | 422 | } else $style = ''; |
— | — | @@ -1304,21 +1298,22 @@ |
1305 | 1299 | * @return string HTML to use for edit link |
1306 | 1300 | */ |
1307 | 1301 | public function doEditSectionLink( Title $nt, $section, $tooltip='' ) { |
1308 | | - $attribs = ''; |
1309 | | - if( $tooltip ) { |
1310 | | - $attribs = wfMsgHtml( 'editsectionhint', htmlspecialchars( $tooltip ) ); |
1311 | | - $attribs = " title=\"$attribs\""; |
1312 | | - } |
1313 | | - |
1314 | 1302 | $url = $this->makeKnownLinkObj( |
1315 | 1303 | $nt, |
1316 | 1304 | htmlspecialchars(wfMsg('editsection')), |
1317 | 1305 | "action=edit§ion=$section", |
1318 | | - '', '', '', $attribs |
| 1306 | + '', '', '', |
| 1307 | + array( 'title' => wfMsg( 'editsectionhint', $tooltip ) ) |
1319 | 1308 | ); |
1320 | 1309 | |
1321 | | - # Run the old hook |
| 1310 | + # Run the old hook. This takes up most of the function . . . hopefully |
| 1311 | + # we can rid of it someday. |
1322 | 1312 | $result = null; |
| 1313 | + $attribs = ''; |
| 1314 | + if( $tooltip ) { |
| 1315 | + $attribs = wfMsgHtml( 'editsectionhint', htmlspecialchars( $tooltip ) ); |
| 1316 | + $attribs = " title=\"$attribs\""; |
| 1317 | + } |
1323 | 1318 | wfRunHooks( 'EditSectionLink', array( &$this, $nt, $section, $attribs, $url, &$result ) ); |
1324 | 1319 | if( !is_null( $result ) ) { |
1325 | 1320 | # For reverse compatibility, add the brackets *after* the hook is |