6 parent::__construct(
'Nuke',
'nuke' );
22 $currentUser = $this->
getUser();
23 if ( $currentUser->isBlocked() ) {
24 $block = $currentUser->getBlock();
29 $target = trim(
$req->getText(
'target', $par ) );
32 if ( $target !==
'' ) {
35 $target = $user->getName();
39 $msg = $target ===
'' ?
40 $this->
msg(
'nuke-multiplepeople' )->inContentLanguage()->text() :
41 $this->
msg(
'nuke-defaultreason', $target )->
42 inContentLanguage()->text();
43 $reason =
$req->getText(
'wpReason', $msg );
45 $limit =
$req->getInt(
'limit', 500 );
46 $namespace =
$req->getVal(
'namespace' );
47 $namespace = ctype_digit( $namespace ) ? (int)$namespace :
null;
49 if (
$req->wasPosted()
50 && $currentUser->matchEditToken(
$req->getVal(
'wpEditToken' ) )
52 if (
$req->getVal(
'action' ) ===
'delete' ) {
53 $pages =
$req->getArray(
'pages' );
60 } elseif (
$req->getVal(
'action' ) ===
'submit' ) {
61 $this->
listForm( $target, $reason, $limit, $namespace );
65 } elseif ( $target ===
'' ) {
68 $this->
listForm( $target, $reason, $limit, $namespace );
80 $out->addWikiMsg(
'nuke-tools' );
84 'id' =>
'nuke-target',
85 'default' => $userName,
86 'label' => $this->
msg(
'nuke-userorip' )->text(),
91 'id' =>
'nuke-pattern',
92 'label' => $this->
msg(
'nuke-pattern' )->text(),
98 'id' =>
'nuke-namespace',
99 'type' =>
'namespaceselect',
100 'label' => $this->
msg(
'nuke-namespace' )->text(),
102 'name' =>
'namespace'
105 'id' =>
'nuke-limit',
108 'label' => $this->
msg(
'nuke-maxpages' )->text(),
114 HTMLForm::factory(
'ooui', $formDescriptor, $this->
getContext() )
115 ->setName(
'massdelete' )
116 ->setFormIdentifier(
'massdelete' )
117 ->setWrapperLegendMsg(
'nuke' )
118 ->setSubmitTextMsg(
'nuke-submit-user' )
119 ->setSubmitName(
'nuke-submit-user' )
120 ->setAction( $this->
getPageTitle()->getLocalURL(
'action=submit' ) )
121 ->setMethod(
'post' )
122 ->addHiddenField(
'wpEditToken', $this->
getUser()->getEditToken() )
124 ->displayForm(
false );
140 if ( count( $pages ) === 0 ) {
142 $out->addWikiMsg(
'nuke-nopages-global' );
152 $out->addModules(
'ext.nuke.confirm' );
155 $out->addWikiMsg(
'nuke-list-multiple' );
163 Xml::openElement(
'form', [
164 'action' => $nuke->getLocalURL(
'action=delete' ),
166 'name' =>
'nukelist' ]
168 Html::hidden(
'wpEditToken', $this->getUser()->getEditToken() ) .
172 $this->msg(
'deletecomment' )->text(),
'wpReason',
'wpReason', 70, $reason
179 if ( class_exists(
'ListToggle' ) ) {
181 $selectLinks = $listToggle->getHTML();
183 $out->addModules(
'ext.nuke' );
186 $links[] =
'<a href="#" id="toggleall">' .
187 $this->
msg(
'powersearch-toggleall' )->escaped() .
'</a>';
188 $links[] =
'<a href="#" id="togglenone">' .
189 $this->
msg(
'powersearch-togglenone' )->escaped() .
'</a>';
190 $links[] =
'<a href="#" id="toggleinvert">' .
191 $this->
msg(
'nuke-toggleinvert' )->escaped() .
'</a>';
193 $selectLinks = Xml::tags(
'p',
195 $this->
msg(
'nuke-select' )
196 ->rawParams( $this->
getLanguage()->commaList( $links ) )->escaped()
205 $wordSeparator = $this->
msg(
'word-separator' )->escaped();
206 $commaSeparator = $this->
msg(
'comma-separator' )->escaped();
209 foreach ( $pages as $info ) {
213 list( $title, $userName ) = $info;
217 $image->transform( [
'width' => 120,
'height' => 120 ], 0 ) :
220 $userNameText = $userName ?
221 $this->
msg(
'nuke-editby', $userName )->parse() . $commaSeparator :
225 $this->
msg(
'nuke-viewchanges' )->
text(),
227 [
'action' =>
'history' ]
229 $out->addHTML(
'<li>' .
233 [
'value' => $title->getPrefixedDBkey() ]
235 ( $thumb ? $thumb->toHtml( [
'desc-link' =>
true ] ) :
'' ) .
237 $this->
msg(
'parentheses' )->rawParams( $userNameText . $changesLink )->escaped() .
243 Xml::submitButton( $this->
msg(
'nuke-submit-delete' )->
text() ) .
266 $where = [
"(rc_new = 1) OR (rc_log_type = 'upload' AND rc_log_action = 'upload')" ];
268 if ( class_exists(
'ActorMigration' ) ) {
270 $actorQuery = ActorMigration::newMigration()->getJoin(
'rc_user' );
271 $what[
'rc_user_text'] = $actorQuery[
'fields'][
'rc_user_text'];
273 $actorQuery = ActorMigration::newMigration()
275 $where[] = $actorQuery[
'conds'];
278 $actorQuery = [
'tables' => [],
'joins' => [] ];
280 $what[] =
'rc_user_text';
286 if ( $namespace !==
null ) {
287 $where[
'rc_namespace'] = $namespace;
290 $pattern = $this->
getRequest()->getText(
'pattern' );
291 if ( !is_null( $pattern ) && trim( $pattern ) !==
'' ) {
294 $where[] =
'rc_title LIKE ' .
$dbr->addQuotes( $pattern );
296 $group = implode(
', ', $what );
298 $result =
$dbr->select(
299 [
'recentchanges' ] + $actorQuery[
'tables'],
304 'ORDER BY' =>
'rc_timestamp DESC',
305 'GROUP BY' => $group,
313 foreach ( $result as $row ) {
315 Title::makeTitle( $row->rc_namespace, $row->rc_title ),
322 Hooks::run(
'NukeGetNewPages', [
$username, $pattern, $namespace, $limit, &$pages ] );
327 if ( count( $pages ) > $limit ) {
328 $pages = array_slice( $pages, 0, $limit );
341 protected function doDelete( array $pages, $reason ) {
344 foreach ( $pages as $page ) {
345 $title = Title::newFromText( $page );
347 $deletionResult =
false;
348 if ( !Hooks::run(
'NukeDeletePage', [ $title, $reason, &$deletionResult ] ) ) {
349 if ( $deletionResult ) {
350 $res[] = $this->
msg(
'nuke-deleted', $title->getPrefixedText() )->parse();
352 $res[] = $this->
msg(
'nuke-not-deleted', $title->getPrefixedText() )->parse();
358 $permission_errors = $title->getUserPermissionsErrors(
'delete', $this->
getUser() );
360 if ( $permission_errors !== [] ) {
368 $article =
new Article( $title, 0 );
369 $ok = $article->doDeleteArticle( $reason );
373 $res[] = $this->
msg(
'nuke-deleted', $title->getPrefixedText() )->parse();
375 $res[] = $this->
msg(
'nuke-not-deleted', $title->getPrefixedText() )->parse();
379 $this->
getOutput()->addHTML(
"<ul>\n<li>" . implode(
"</li>\n<li>",
$res ) .
"</li>\n</ul>\n" );
380 $this->
getOutput()->addWikiMsg(
'nuke-delete-more' );
392 if ( !class_exists(
'UserNamePrefixSearch' ) ) {
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfLocalFile( $title)
Get an object referring to a locally registered file.
Class for viewing MediaWiki article and history.
Class for generating clickable toggle links for a list of checkboxes.
Show an error when a user tries to do something they do not have the necessary permissions for.
doDelete(array $pages, $reason)
Does the actual deletion of the pages.
promptForm( $userName='')
Prompt for a username or IP address.
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
getNewPages( $username, $limit, $namespace=null)
Gets a list of new pages by the specified user or everyone when none is specified.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
listForm( $username, $reason, $limit, $namespace=null)
Display list of pages to delete.
doesWrites()
Indicates whether this special page may perform database writes.
Parent class for all special pages.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User executing this instance.
checkPermissions()
Checks if userCanExecute, and if not throws a PermissionsError.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key)
Wrapper around wfMessage that sets the current context.
getRequest()
Get the WebRequest being used for this instance.
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
getPageTitle( $subpage=false)
Get a self-referential title object.
getLanguage()
Shortcut to get user's language.
MediaWiki Linker LinkRenderer null $linkRenderer
Show an error when the user tries to do something whilst blocked.
static search( $audience, $search, $limit, $offset=0)
Do a prefix search of user names and return a list of matching user names.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
this hook is for auditing only $req
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check $image
namespace and then decline to actually register it file or subcat img or subcat $title
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
this hook is for auditing only or null if authentication failed before getting that far $username
processing should stop and the error should be shown to the user * false