r51586 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51585‎ | r51586 | r51587 >
Date:10:07, 8 June 2009
Author:siebrand
Status:ok
Tags:
Comment:
Replace a few remaining uses of deprecated makeKnownLinkObj() by link[Known]() in core. Only uses in core remaining are in includes/Linker.php (all related to deprecated methods) and includes/parser/Parser.php.

Linking this to r51559 for CodeReview as there is some discussion there, and these changes are very similar.
Modified paths:
  • /trunk/phase3/includes/LogEventsList.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialNewimages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/LogEventsList.php
@@ -108,11 +108,22 @@
109109 $links = array();
110110 $hiddens = ''; // keep track for "go" button
111111 foreach( $filter as $type => $val ) {
 112+ // Should the below assignment be outside the foreach?
 113+ // Then it would have to be copied. Not certain what is more expensive.
 114+ $query = $this->getDefaultQuery();
 115+ $queryKey = "hide_{$type}_log";
 116+ $query[$queryKey] = $hideVal;
 117+
112118 $hideVal = 1 - intval($val);
113 - // FIXME: use link() here. Needs changes in getDefaultQuery()
114 - $link = $this->skin->makeKnownLinkObj( $wgTitle, $messages[$hideVal],
115 - wfArrayToCGI( array( "hide_{$type}_log" => $hideVal ), $this->getDefaultQuery() )
 119+
 120+ $link = $this->skin->link(
 121+ $wgTitle,
 122+ $messages[$hideVal],
 123+ array(),
 124+ $query,
 125+ array( 'known', 'noclasses' )
116126 );
 127+
117128 $links[$type] = wfMsgHtml( "log-show-hide-{$type}", $link );
118129 $hiddens .= Xml::hidden( "hide_{$type}_log", $val ) . "\n";
119130 }
Index: trunk/phase3/includes/specials/SpecialNewimages.php
@@ -65,13 +65,13 @@
6666 }
6767
6868 $where = array();
69 - $searchpar = '';
 69+ $searchpar = array();
7070 if ( $wpIlMatch != '' && !$wgMiserMode) {
7171 $nt = Title::newFromUrl( $wpIlMatch );
7272 if( $nt ) {
7373 $m = $dbr->escapeLike( strtolower( $nt->getDBkey() ) );
7474 $where[] = "LOWER(img_name) LIKE '%{$m}%'";
75 - $searchpar = '&wpIlMatch=' . urlencode( $wpIlMatch );
 75+ $searchpar['wpIlMatch'] = $wpIlMatch;
7676 }
7777 }
7878
@@ -163,29 +163,75 @@
164164
165165 # If we change bot visibility, this needs to be carried along.
166166 if( !$hidebots ) {
167 - $botpar = '&hidebots=0';
 167+ $botpar = array( 'hidebots' => 0 );
168168 } else {
169 - $botpar = '';
 169+ $botpar = array();
170170 }
171171 $now = wfTimestampNow();
172172 $d = $wgLang->date( $now, true );
173173 $t = $wgLang->time( $now, true );
174 - $dateLink = $sk->makeKnownLinkObj( $titleObj, htmlspecialchars( wfMsg( 'sp-newimages-showfrom', $d, $t ) ),
175 - 'from='.$now.$botpar.$searchpar );
 174+ $query = array_merge(
 175+ array( 'from' => $now ),
 176+ $botpar,
 177+ $searchpar
 178+ );
176179
177 - $botLink = $sk->makeKnownLinkObj($titleObj, wfMsgHtml( 'showhidebots',
178 - ($hidebots ? wfMsgHtml('show') : wfMsgHtml('hide'))),'hidebots='.($hidebots ? '0' : '1').$searchpar);
 180+ $dateLink = $sk->linkKnown(
 181+ $titleObj,
 182+ htmlspecialchars( wfMsg( 'sp-newimages-showfrom', $d, $t ) ),
 183+ array(),
 184+ $query
 185+ );
179186
 187+ $query = array_merge(
 188+ array( 'hidebots' => ( $hidebots ? 0 : 1 ) ),
 189+ $searchpar
 190+ );
180191
 192+ $message = wfMsgHtml(
 193+ 'showhidebots',
 194+ ( $hidebots ? wfMsgHtml( 'show' ) : wfMsgHtml( 'hide' ) )
 195+ );
 196+
 197+ $botLink = $sk->linkKnown(
 198+ $titleObj,
 199+ $message,
 200+ array(),
 201+ $query
 202+ );
 203+
181204 $opts = array( 'parsemag', 'escapenoentities' );
182205 $prevLink = wfMsgExt( 'pager-newer-n', $opts, $wgLang->formatNum( $limit ) );
183206 if( $firstTimestamp && $firstTimestamp != $latestTimestamp ) {
184 - $prevLink = $sk->makeKnownLinkObj( $titleObj, $prevLink, 'from=' . $firstTimestamp . $botpar . $searchpar );
 207+ $query = array_merge(
 208+ array( 'from' => $firstTimestamp ),
 209+ $botpar,
 210+ $searchpar
 211+ );
 212+
 213+ $prevLink = $sk->linkKnown(
 214+ $titleObj,
 215+ $prevLink,
 216+ array(),
 217+ $query
 218+ );
185219 }
186220
187221 $nextLink = wfMsgExt( 'pager-older-n', $opts, $wgLang->formatNum( $limit ) );
188222 if( $shownImages > $limit && $lastTimestamp ) {
189 - $nextLink = $sk->makeKnownLinkObj( $titleObj, $nextLink, 'until=' . $lastTimestamp.$botpar.$searchpar );
 223+ $query = array_merge(
 224+ array( 'until' => $lastTimestamp ),
 225+ $botpar,
 226+ $searchpar
 227+ );
 228+
 229+ $nextLink = $sk->linkKnown(
 230+ $titleObj,
 231+ $nextLink,
 232+ array(),
 233+ $query
 234+ );
 235+
190236 }
191237
192238 $prevnext = '<p>' . $botLink . ' '. wfMsgHtml( 'viewprevnext', $prevLink, $nextLink, $dateLink ) .'</p>';

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r51559* replace some use of deprecated makeKnownLinkObj() by link() in core...siebrand22:42, 6 June 2009

Status & tagging log