r21389 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r21388‎ | r21389 | r21390 >
Date:19:24, 19 April 2007
Author:midom
Status:old
Tags:
Comment:
revert back to 19xxx
Modified paths:
  • /trunk/phase3/includes/SpecialContributions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialContributions.php
@@ -48,7 +48,7 @@
4949 $res = $this->dbr->query( $sql, __METHOD__ );
5050 $row = $this->dbr->fetchObject( $res );
5151 if ( $row ) {
52 - return wfTimestamp( TS_MW, $row->rev_timestamp );
 52+ return $row->rev_timestamp;
5353 } else {
5454 return false;
5555 }
@@ -70,20 +70,14 @@
7171
7272 if ( $this->username == 'newbies' ) {
7373 $max = $this->dbr->selectField( 'user', 'max(user_id)', false, 'make_sql' );
74 - $condition = 'rev_user >' . (int)($max - $max / 100);
 74+ $condition = '>' . (int)($max - $max / 100);
7575 }
76 - /* WTF? -- disabling
77 - else if ( IP::isIPv6( $this->username ) ) {
78 - # All stored IPs should be sanitized from now on, check for exact matches for reverse compatibility
79 - $condition = '(rev_user_text=' . $this->dbr->addQuotes(IP::sanitizeIP($this->username)) . ' OR rev_user_text=' . $this->dbr->addQuotes($this->username) . ')';
80 - }
81 - */
8276
8377 if ( $condition == '' ) {
8478 $condition = ' rev_user_text=' . $this->dbr->addQuotes( $this->username );
8579 $index = 'usertext_timestamp';
8680 } else {
87 - #$condition = ' rev_user '.$condition ;
 81+ $condition = ' rev_user '.$condition ;
8882 $index = 'user_timestamp';
8983 }
9084 return array( $index, $condition );
@@ -106,7 +100,7 @@
107101 list( $page, $revision ) = $this->dbr->tableNamesN( 'page', 'revision' );
108102
109103 $sql = "SELECT rev_timestamp FROM $page, $revision $use_index " .
110 - "WHERE page_id = rev_page AND rev_timestamp > '" . $this->dbr->timestamp($this->offset) . "' AND " .
 104+ "WHERE page_id = rev_page AND rev_timestamp > '" . $this->offset . "' AND " .
111105 $usercond . $nscond;
112106 $sql .= " ORDER BY rev_timestamp ASC";
113107 $sql = $this->dbr->limitResult( $sql, $this->limit, 0 );
@@ -116,7 +110,7 @@
117111 if ( $numRows ) {
118112 $this->dbr->dataSeek( $res, $numRows - 1 );
119113 $row = $this->dbr->fetchObject( $res );
120 - $offset = wfTimestamp( TS_MW, $row->rev_timestamp );
 114+ $offset = $row->rev_timestamp;
121115 } else {
122116 $offset = false;
123117 }
@@ -143,7 +137,7 @@
144138 if ( $numRows ) {
145139 $this->dbr->dataSeek( $res, $numRows - 1 );
146140 $row = $this->dbr->fetchObject( $res );
147 - $offset = wfTimestamp( TS_MW, $row->rev_timestamp );
 141+ $offset = $row->rev_timestamp;
148142 } else {
149143 $offset = false;
150144 }
@@ -157,16 +151,16 @@
158152 list( $page, $revision ) = $this->dbr->tableNamesN( 'page', 'revision' );
159153 list( $index, $userCond ) = $this->getUserCond();
160154
161 - if ( $this->offset ) {
162 - $offsetQuery = "AND rev_timestamp < '" . $this->dbr->timestamp($this->offset) . "'";
163 - }
 155+ if ( $this->offset )
 156+ $offsetQuery = "AND rev_timestamp < '{$this->offset}'";
164157
165158 $nscond = $this->getNamespaceCond();
166159 $use_index = $this->dbr->useIndexClause( $index );
167160 $sql = 'SELECT ' .
168161 'page_namespace,page_title,page_is_new,page_latest,'.
169 - join(',', Revision::selectFields()).
170 - " FROM $page,$revision $use_index " .
 162+ 'rev_id,rev_page,rev_text_id,rev_timestamp,rev_comment,rev_minor_edit,rev_user,rev_user_text,'.
 163+ 'rev_deleted ' .
 164+ "FROM $page,$revision $use_index " .
171165 "WHERE page_id=rev_page AND $userCond $nscond $offsetQuery " .
172166 'ORDER BY rev_timestamp DESC';
173167 $sql = $this->dbr->limitResult( $sql, $this->limit, 0 );
@@ -199,19 +193,14 @@
200194 global $wgUser, $wgOut, $wgLang, $wgRequest;
201195
202196 $target = isset( $par ) ? $par : $wgRequest->getVal( 'target' );
203 - $radiobox = $wgRequest->getVal( 'newbie' );
204 -
205 - // check for radiobox
206 - if ( $radiobox == 'contribs-newbie' ) $target = 'newbies';
207 -
208197 if ( !strlen( $target ) ) {
209 - $wgOut->addHTML( contributionsForm( '' ) );
 198+ $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
210199 return;
211200 }
212201
213202 $nt = Title::newFromURL( $target );
214203 if ( !$nt ) {
215 - $wgOut->addHTML( contributionsForm( '' ) );
 204+ $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
216205 return;
217206 }
218207
@@ -219,15 +208,14 @@
220209
221210 list( $options['limit'], $options['offset']) = wfCheckLimits();
222211 $options['offset'] = $wgRequest->getVal( 'offset' );
 212+ /* Offset must be an integral. */
 213+ if ( !strlen( $options['offset'] ) || !preg_match( '/^[0-9]+$/', $options['offset'] ) )
 214+ $options['offset'] = '';
223215
224 - /* Offset must be numeric or an empty string */
225 - if ( !strlen( $options['offset'] ) || !preg_match( '/^[0-9]+$/', $options['offset'] ) )
226 - $options['offset'] = '';
227 -
228216 $title = SpecialPage::getTitleFor( 'Contributions' );
229217 $options['target'] = $target;
230218
231 - $nt = Title::makeTitle( NS_USER, $nt->getDBkey() );
 219+ $nt =& Title::makeTitle( NS_USER, $nt->getDBkey() );
232220 $finder = new ContribsFinder( ( $target == 'newbies' ) ? 'newbies' : $nt->getText() );
233221 $finder->setLimit( $options['limit'] );
234222 $finder->setOffset( $options['offset'] );
@@ -265,8 +253,6 @@
266254
267255 if ( $target == 'newbies' ) {
268256 $wgOut->setSubtitle( wfMsgHtml( 'sp-contributions-newbies-sub') );
269 - } else if ( preg_match( "/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\/(?:24|16)/", $target ) ) {
270 - $wgOut->setSubtitle( wfMsgHtml( 'contribsub', $target ) );
271257 } else {
272258 $wgOut->setSubtitle( wfMsgHtml( 'contribsub', contributionsSub( $nt ) ) );
273259 }
@@ -284,8 +270,8 @@
285271 }
286272
287273 list( $early, $late ) = $finder->getEditLimits();
288 - $lastts = count( $contribs ) ? wfTimestamp( TS_MW, $contribs[count( $contribs ) - 1]->rev_timestamp) : 0;
289 - $atstart = ( !count( $contribs ) || $late == (wfTimestamp( TS_MW, $contribs[0]->rev_timestamp ) ));
 274+ $lastts = count( $contribs ) ? $contribs[count( $contribs ) - 1]->rev_timestamp : 0;
 275+ $atstart = ( !count( $contribs ) || $late == $contribs[0]->rev_timestamp );
290276 $atend = ( !count( $contribs ) || $early == $lastts );
291277
292278 // These four are defaults
@@ -333,29 +319,14 @@
334320
335321 $wgOut->addHTML( "</ul>\n" );
336322 $wgOut->addHTML( "<p>{$prevnextbits}</p>\n" );
337 -
338 - # If there were contributions, and it was a valid user or IP, show
339 - # the appropriate "footer" message - WHOIS tools, etc.
340 - if( count( $contribs ) > 0 && $target != 'newbies' && $nt instanceof Title ) {
341 - $message = IP::isIPAddress( $target )
342 - ? 'sp-contributions-footer-anon'
343 - : 'sp-contributions-footer';
344 - $text = wfMsg( $message, $target );
345 - if( !wfEmptyMsg( $message, $text ) && $text != '-' ) {
346 - $wgOut->addHtml( '<div class="mw-contributions-footer">' );
347 - $wgOut->addWikiText( wfMsg( $message, $target ) );
348 - $wgOut->addHtml( '</div>' );
349 - }
350 - }
351 -
352323 }
353324
354325 /**
355326 * Generates the subheading with links
356 - * @param $nt see the Title object for the target
 327+ * @param $nt @see Title object for the target
357328 */
358329 function contributionsSub( $nt ) {
359 - global $wgSysopUserBans, $wgUser;
 330+ global $wgSysopUserBans, $wgLang, $wgUser;
360331
361332 $sk = $wgUser->getSkin();
362333 $id = User::idFromName( $nt->getText() );
@@ -368,7 +339,7 @@
369340 $talk = $nt->getTalkPage();
370341 if( $talk ) {
371342 # Talk page link
372 - $tools[] = $sk->makeLinkObj( $talk, wfMsgHtml( 'talkpagelinktext' ) );
 343+ $tools[] = $sk->makeLinkObj( $talk, $wgLang->getNsText( NS_TALK ) );
373344 if( ( $id != 0 && $wgSysopUserBans ) || ( $id == 0 && User::isIP( $nt->getText() ) ) ) {
374345 # Block link
375346 if( $wgUser->isAllowed( 'block' ) )
@@ -388,31 +359,27 @@
389360 * @param $options Array: the options to be included.
390361 */
391362 function contributionsForm( $options ) {
392 - global $wgScript, $wgTitle, $wgRequest;
 363+ global $wgScript, $wgTitle;
393364
394365 $options['title'] = $wgTitle->getPrefixedText();
395 - if (!isset($options['target']))
396 - $options['target'] = '';
397 - if (!isset($options['namespace']))
398 - $options['namespace'] = 0;
399366
400 - $f = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) );
401 -
 367+ $f = "<form method='get' action=\"$wgScript\">\n";
402368 foreach ( $options as $name => $value ) {
403369 if( $name === 'namespace') continue;
404 - $f .= "\t" . Xml::hidden( $name, $value ) . "\n";
 370+ $f .= "\t" . wfElement( 'input', array(
 371+ 'name' => $name,
 372+ 'type' => 'hidden',
 373+ 'value' => $value ) ) . "\n";
405374 }
406375
407 - $f .= '<fieldset>' .
408 - Xml::element( 'legend', array(), wfMsg( 'sp-contributions-search' ) ) .
409 - Xml::radioLabel( wfMsgExt( 'sp-contributions-newbies', array( 'parseinline' ) ), 'newbie' , 'contribs-newbie' , 'contribs-newbie', 'contribs-newbie' ) . '<br />' .
410 - Xml::radioLabel( wfMsgExt( 'sp-contributions-username', array( 'parseinline' ) ), 'newbie' , 'contribs-all', 'contribs-all', 'contribs-all' ) . ' ' .
411 - Xml::input( 'target', 30, $options['target']) . ' '.
412 - Xml::label( wfMsg( 'namespace' ), 'namespace' ) .
413 - Xml::namespaceSelector( $options['namespace'], '' ) .
414 - Xml::submitButton( wfMsg( 'sp-contributions-submit' ) ) .
415 - '</fieldset>' .
416 - Xml::closeElement( 'form' );
 376+ $f .= '<p>' . wfMsgHtml( 'namespace' ) . ' ' .
 377+ HTMLnamespaceselector( $options['namespace'], '' ) .
 378+ wfElement( 'input', array(
 379+ 'type' => 'submit',
 380+ 'value' => wfMsg( 'allpagessubmit' ) )
 381+ ) .
 382+ "</p></form>\n";
 383+
417384 return $f;
418385 }
419386