r102665 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102664‎ | r102665 | r102666 >
Date:17:04, 10 November 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
implemented sql like match feature as suggested in bug 5835 and fixed regression causing the list of pages to be not shown when not specifying a user
Modified paths:
  • /trunk/extensions/Nuke/Nuke.i18n.php (modified) (history)
  • /trunk/extensions/Nuke/Nuke_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Nuke/Nuke_body.php
@@ -34,14 +34,22 @@
3535 );
3636
3737 if( $wgRequest->wasPosted()
38 - && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) )
39 - && $wgRequest->getVal( 'action' ) == 'delete' ) {
 38+ && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
4039
41 - $pages = $wgRequest->getArray( 'pages' );
 40+
 41+ if ( $wgRequest->getVal( 'action' ) == 'delete' ) {
 42+ $pages = $wgRequest->getArray( 'pages' );
4243
43 - if( $pages ) {
44 - return $this->doDelete( $pages, $reason );
 44+ if( $pages ) {
 45+ return $this->doDelete( $pages, $reason );
 46+ }
4547 }
 48+ else if ( $wgRequest->getVal( 'action' ) == 'submit' ) {
 49+ $this->listForm( $target, $reason, $wgRequest->getInt( 'limit', 500 ) );
 50+ }
 51+ else {
 52+ $this->promptForm();
 53+ }
4654 }
4755 else if ( $target === '' ) {
4856 $this->promptForm();
@@ -71,6 +79,9 @@
7280 . '<td>' . htmlspecialchars( wfMsg( 'nuke-userorip' ) ) . '</td>'
7381 . '<td>' . Xml::input( 'target', 40, $userName ) . '</td>'
7482 . '</tr><tr>'
 83+ . '<td>' . htmlspecialchars( wfMsg( 'nuke-pattern' ) ) . '</td>'
 84+ . '<td>' . Xml::input( 'pattern', 40 ) . '</td>'
 85+ . '</tr><tr>'
7586 . '<td>' . htmlspecialchars( wfMsg( 'nuke-maxpages' ) ) . '</td>'
7687 . '<td>' . Xml::input( 'limit', 7, '500' ) . '</td>'
7788 . '</tr><tr>'
@@ -95,11 +106,17 @@
96107 $pages = $this->getNewPages( $username, $limit );
97108
98109 if( count( $pages ) == 0 ) {
99 - $wgOut->addWikiMsg( 'nuke-nopages', $username );
 110+ if ( $username === '' ) {
 111+ $wgOut->addWikiMsg( 'nuke-nopages-global' );
 112+ }
 113+ else {
 114+ $wgOut->addWikiMsg( 'nuke-nopages', $username );
 115+ }
 116+
100117 return $this->promptForm( $username );
101118 }
102119
103 - if ( $username == '' ) {
 120+ if ( $username === '' ) {
104121 $wgOut->addWikiMsg( 'nuke-list-multiple' );
105122 } else {
106123 $wgOut->addWikiMsg( 'nuke-list', $username );
@@ -156,7 +173,6 @@
157174
158175 $wgOut->addHTML( '<ul>' );
159176
160 - $sk = $wgUser->getSkin();
161177 foreach( $pages as $info ) {
162178 list( $title, $edits, $userName ) = $info;
163179 $image = $title->getNamespace() == NS_IMAGE ? wfLocalFile( $title ) : false;
@@ -170,10 +186,10 @@
171187 ) .
172188 '&#160;' .
173189 ( $thumb ? $thumb->toHtml( array( 'desc-link' => true ) ) : '' ) .
174 - $sk->makeKnownLinkObj( $title ) .
 190+ $this->getSkin()->makeKnownLinkObj( $title ) .
175191 '&#160;(' .
176192 ( $userName ? wfMsgExt( 'nuke-editby', 'parseinline', $userName ) . ',&#160;' : '' ) .
177 - $sk->makeKnownLinkObj( $title, $changes, 'action=history' ) .
 193+ $this->getSkin()->makeKnownLinkObj( $title, $changes, 'action=history' ) .
178194 ")</li>\n" );
179195 }
180196
@@ -204,11 +220,16 @@
205221
206222 $where = array( "(rc_new = 1) OR (rc_log_type = 'upload' AND rc_log_action = 'upload')" );
207223
208 - if ( $username == '' ) {
 224+ if ( $username === '' ) {
209225 $what[] = 'rc_user_text';
210226 } else {
211227 $where['rc_user_text'] = $username;
212228 }
 229+
 230+ $pattern = $this->getRequest()->getText( 'pattern' );
 231+ if ( !is_null( $pattern ) && trim( $pattern ) !== '' ) {
 232+ $where[] = 'rc_title LIKE ' . $dbr->addQuotes( $pattern );
 233+ }
213234
214235 $result = $dbr->select( 'recentchanges',
215236 $what,
Index: trunk/extensions/Nuke/Nuke.i18n.php
@@ -35,6 +35,8 @@
3636 'nuke-deleted' => "Page '''$1''' has been deleted.",
3737 'nuke-not-deleted' => "Page [[:$1]] '''could not''' be deleted.",
3838 'nuke-delete-more' => '[[Special:Nuke|Delete more pages]]',
 39+ 'nuke-pattern' => 'Pattern for the page name:',
 40+ 'nuke-nopages-global'=> 'There are no new pages in [[Special:RecentChanges|recent changes]].',
3941 );
4042
4143 /** Message documentation (Message documentation)

Status & tagging log