Index: trunk/phase3/includes/SpecialContributions.php |
— | — | @@ -48,7 +48,7 @@ |
49 | 49 | $res = $this->dbr->query( $sql, __METHOD__ ); |
50 | 50 | $row = $this->dbr->fetchObject( $res ); |
51 | 51 | if ( $row ) { |
52 | | - return wfTimestamp( TS_MW, $row->rev_timestamp ); |
| 52 | + return $row->rev_timestamp; |
53 | 53 | } else { |
54 | 54 | return false; |
55 | 55 | } |
— | — | @@ -70,20 +70,14 @@ |
71 | 71 | |
72 | 72 | if ( $this->username == 'newbies' ) { |
73 | 73 | $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); |
75 | 75 | } |
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 | | - */ |
82 | 76 | |
83 | 77 | if ( $condition == '' ) { |
84 | 78 | $condition = ' rev_user_text=' . $this->dbr->addQuotes( $this->username ); |
85 | 79 | $index = 'usertext_timestamp'; |
86 | 80 | } else { |
87 | | - #$condition = ' rev_user '.$condition ; |
| 81 | + $condition = ' rev_user '.$condition ; |
88 | 82 | $index = 'user_timestamp'; |
89 | 83 | } |
90 | 84 | return array( $index, $condition ); |
— | — | @@ -106,7 +100,7 @@ |
107 | 101 | list( $page, $revision ) = $this->dbr->tableNamesN( 'page', 'revision' ); |
108 | 102 | |
109 | 103 | $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 " . |
111 | 105 | $usercond . $nscond; |
112 | 106 | $sql .= " ORDER BY rev_timestamp ASC"; |
113 | 107 | $sql = $this->dbr->limitResult( $sql, $this->limit, 0 ); |
— | — | @@ -116,7 +110,7 @@ |
117 | 111 | if ( $numRows ) { |
118 | 112 | $this->dbr->dataSeek( $res, $numRows - 1 ); |
119 | 113 | $row = $this->dbr->fetchObject( $res ); |
120 | | - $offset = wfTimestamp( TS_MW, $row->rev_timestamp ); |
| 114 | + $offset = $row->rev_timestamp; |
121 | 115 | } else { |
122 | 116 | $offset = false; |
123 | 117 | } |
— | — | @@ -143,7 +137,7 @@ |
144 | 138 | if ( $numRows ) { |
145 | 139 | $this->dbr->dataSeek( $res, $numRows - 1 ); |
146 | 140 | $row = $this->dbr->fetchObject( $res ); |
147 | | - $offset = wfTimestamp( TS_MW, $row->rev_timestamp ); |
| 141 | + $offset = $row->rev_timestamp; |
148 | 142 | } else { |
149 | 143 | $offset = false; |
150 | 144 | } |
— | — | @@ -157,16 +151,16 @@ |
158 | 152 | list( $page, $revision ) = $this->dbr->tableNamesN( 'page', 'revision' ); |
159 | 153 | list( $index, $userCond ) = $this->getUserCond(); |
160 | 154 | |
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}'"; |
164 | 157 | |
165 | 158 | $nscond = $this->getNamespaceCond(); |
166 | 159 | $use_index = $this->dbr->useIndexClause( $index ); |
167 | 160 | $sql = 'SELECT ' . |
168 | 161 | '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 " . |
171 | 165 | "WHERE page_id=rev_page AND $userCond $nscond $offsetQuery " . |
172 | 166 | 'ORDER BY rev_timestamp DESC'; |
173 | 167 | $sql = $this->dbr->limitResult( $sql, $this->limit, 0 ); |
— | — | @@ -199,19 +193,14 @@ |
200 | 194 | global $wgUser, $wgOut, $wgLang, $wgRequest; |
201 | 195 | |
202 | 196 | $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 | | - |
208 | 197 | if ( !strlen( $target ) ) { |
209 | | - $wgOut->addHTML( contributionsForm( '' ) ); |
| 198 | + $wgOut->showErrorPage( 'notargettitle', 'notargettext' ); |
210 | 199 | return; |
211 | 200 | } |
212 | 201 | |
213 | 202 | $nt = Title::newFromURL( $target ); |
214 | 203 | if ( !$nt ) { |
215 | | - $wgOut->addHTML( contributionsForm( '' ) ); |
| 204 | + $wgOut->showErrorPage( 'notargettitle', 'notargettext' ); |
216 | 205 | return; |
217 | 206 | } |
218 | 207 | |
— | — | @@ -219,15 +208,14 @@ |
220 | 209 | |
221 | 210 | list( $options['limit'], $options['offset']) = wfCheckLimits(); |
222 | 211 | $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'] = ''; |
223 | 215 | |
224 | | - /* Offset must be numeric or an empty string */ |
225 | | - if ( !strlen( $options['offset'] ) || !preg_match( '/^[0-9]+$/', $options['offset'] ) ) |
226 | | - $options['offset'] = ''; |
227 | | - |
228 | 216 | $title = SpecialPage::getTitleFor( 'Contributions' ); |
229 | 217 | $options['target'] = $target; |
230 | 218 | |
231 | | - $nt = Title::makeTitle( NS_USER, $nt->getDBkey() ); |
| 219 | + $nt =& Title::makeTitle( NS_USER, $nt->getDBkey() ); |
232 | 220 | $finder = new ContribsFinder( ( $target == 'newbies' ) ? 'newbies' : $nt->getText() ); |
233 | 221 | $finder->setLimit( $options['limit'] ); |
234 | 222 | $finder->setOffset( $options['offset'] ); |
— | — | @@ -265,8 +253,6 @@ |
266 | 254 | |
267 | 255 | if ( $target == 'newbies' ) { |
268 | 256 | $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 ) ); |
271 | 257 | } else { |
272 | 258 | $wgOut->setSubtitle( wfMsgHtml( 'contribsub', contributionsSub( $nt ) ) ); |
273 | 259 | } |
— | — | @@ -284,8 +270,8 @@ |
285 | 271 | } |
286 | 272 | |
287 | 273 | 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 ); |
290 | 276 | $atend = ( !count( $contribs ) || $early == $lastts ); |
291 | 277 | |
292 | 278 | // These four are defaults |
— | — | @@ -333,29 +319,14 @@ |
334 | 320 | |
335 | 321 | $wgOut->addHTML( "</ul>\n" ); |
336 | 322 | $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 | | - |
352 | 323 | } |
353 | 324 | |
354 | 325 | /** |
355 | 326 | * Generates the subheading with links |
356 | | - * @param $nt see the Title object for the target |
| 327 | + * @param $nt @see Title object for the target |
357 | 328 | */ |
358 | 329 | function contributionsSub( $nt ) { |
359 | | - global $wgSysopUserBans, $wgUser; |
| 330 | + global $wgSysopUserBans, $wgLang, $wgUser; |
360 | 331 | |
361 | 332 | $sk = $wgUser->getSkin(); |
362 | 333 | $id = User::idFromName( $nt->getText() ); |
— | — | @@ -368,7 +339,7 @@ |
369 | 340 | $talk = $nt->getTalkPage(); |
370 | 341 | if( $talk ) { |
371 | 342 | # Talk page link |
372 | | - $tools[] = $sk->makeLinkObj( $talk, wfMsgHtml( 'talkpagelinktext' ) ); |
| 343 | + $tools[] = $sk->makeLinkObj( $talk, $wgLang->getNsText( NS_TALK ) ); |
373 | 344 | if( ( $id != 0 && $wgSysopUserBans ) || ( $id == 0 && User::isIP( $nt->getText() ) ) ) { |
374 | 345 | # Block link |
375 | 346 | if( $wgUser->isAllowed( 'block' ) ) |
— | — | @@ -388,31 +359,27 @@ |
389 | 360 | * @param $options Array: the options to be included. |
390 | 361 | */ |
391 | 362 | function contributionsForm( $options ) { |
392 | | - global $wgScript, $wgTitle, $wgRequest; |
| 363 | + global $wgScript, $wgTitle; |
393 | 364 | |
394 | 365 | $options['title'] = $wgTitle->getPrefixedText(); |
395 | | - if (!isset($options['target'])) |
396 | | - $options['target'] = ''; |
397 | | - if (!isset($options['namespace'])) |
398 | | - $options['namespace'] = 0; |
399 | 366 | |
400 | | - $f = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ); |
401 | | - |
| 367 | + $f = "<form method='get' action=\"$wgScript\">\n"; |
402 | 368 | foreach ( $options as $name => $value ) { |
403 | 369 | 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"; |
405 | 374 | } |
406 | 375 | |
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 | + |
417 | 384 | return $f; |
418 | 385 | } |
419 | 386 | |