r82623 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82622‎ | r82623 | r82624 >
Date:19:04, 22 February 2011
Author:yaron
Status:deferred
Tags:
Comment:
Changed code to use new linkToTitle() method, for backward compatibility for Linker::makeKnownLinkObj() method
Modified paths:
  • /trunk/extensions/ReplaceText/SpecialReplaceText.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ReplaceText/SpecialReplaceText.php
@@ -38,6 +38,18 @@
3939 return $selected_namespaces;
4040 }
4141
 42+ /**
 43+ * Helper function to generate a link.
 44+ */
 45+ static function linkToTitle( $skin, $title, $linkText ) {
 46+ // link() method was added in MW 1.16
 47+ if ( method_exists( $skin, 'link' ) ) {
 48+ return $skin->link( $title, $linkText );
 49+ } else {
 50+ return $skin->makeKnownLinkObj( $title, $linkText );
 51+ }
 52+ }
 53+
4254 function doSpecialReplaceText() {
4355 global $wgUser, $wgOut, $wgRequest, $wgLang;
4456
@@ -93,7 +105,7 @@
94106
95107 // Link back
96108 $sk = $this->user->getSkin();
97 - $wgOut->addHTML( $sk->makeKnownLinkObj( $this->getTitle(), wfMsgHtml( 'replacetext_return' ) ) );
 109+ $wgOut->addHTML( $this->linkToTitle( $sk, $this->getTitle(), wfMsgHtml( 'replacetext_return' ) ) );
98110 return;
99111 } elseif ( $wgRequest->getCheck( 'target' ) ) { // very long elseif, look for "end elseif"
100112 // first, check that at least one namespace has been
@@ -153,7 +165,7 @@
154166 }
155167 if ( $bad_cat_name ) {
156168 //FIXME: raw html message
157 - $wgOut->addHTML( wfMsg( 'replacetext_nosuchcategory', $sk->link( $category_title, ucfirst( $this->category ) ) ) );
 169+ $wgOut->addHTML( wfMsg( 'replacetext_nosuchcategory', $this->linkToTitle( $sk, $category_title, ucfirst( $this->category ) ) ) );
158170 } else {
159171 if ( $this->edit_pages )
160172 $wgOut->addWikiMsg( 'replacetext_noreplacement', "<tt><nowiki>{$this->target}</nowiki></tt>" );
@@ -162,7 +174,7 @@
163175 }
164176 // link back to starting form
165177 //FIXME: raw html message
166 - $wgOut->addHTML( '<p>' . $sk->makeKnownLinkObj( $this->getTitle(), wfMsg( 'replacetext_return' ) ) . '</p>' );
 178+ $wgOut->addHTML( '<p>' . $this->linkToTitle( $sk, $this->getTitle(), wfMsg( 'replacetext_return' ) ) . '</p>' );
167179 } else {
168180 // Show a warning message if the replacement
169181 // string is either blank or found elsewhere on
@@ -370,7 +382,7 @@
371383 list( $title, $context ) = $title_and_context;
372384 $wgOut->addHTML(
373385 Xml::check( $title->getArticleID(), true ) .
374 - $skin->makeKnownLinkObj( $title, $title->getPrefixedText() ) . " - <small>$context</small><br />\n"
 386+ $this->linkToTitle( $skin, $title, $title->getPrefixedText() ) . " - <small>$context</small><br />\n"
375387 );
376388 }
377389 $wgOut->addHTML( '<br />' );
@@ -419,7 +431,7 @@
420432 $wgOut->addWikiMsg( 'replacetext_cannotmove', $wgLang->formatNum( count( $unmoveable_titles ) ) );
421433 $text = "<ul>\n";
422434 foreach ( $unmoveable_titles as $title ) {
423 - $text .= "<li>{$skin->makeKnownLinkObj( $title, $title->getPrefixedText() )}<br />\n";
 435+ $text .= "<li>{$this->linkToTitle( $skin, $title, $title->getPrefixedText() )}<br />\n";
424436 }
425437 $text .= "</ul>\n";
426438 $wgOut->addHTML( $text );

Status & tagging log