6 parent::__construct(
'Nuke',
'nuke' );
23 $currentUser = $this->
getUser();
24 if ( $currentUser->isBlocked() ) {
25 $block = $currentUser->getBlock();
30 $target = trim( $req->getText(
'target', $par ) );
33 if ( $target !==
'' ) {
34 $user = User::newFromName( $target );
36 $target = $user->getName();
40 $msg = $target ===
'' ?
41 $this->
msg(
'nuke-multiplepeople' )->inContentLanguage()->text() :
42 $this->
msg(
'nuke-defaultreason', $target )->
43 inContentLanguage()->text();
44 $reason = $req->getText(
'wpReason', $msg );
46 $limit = $req->getInt(
'limit', 500 );
47 $namespace = $req->getVal(
'namespace' );
48 $namespace = ctype_digit( $namespace ) ? (int)$namespace :
null;
50 if ( $req->wasPosted()
51 && $currentUser->matchEditToken( $req->getVal(
'wpEditToken' ) )
53 if ( $req->getVal(
'action' ) ===
'delete' ) {
54 $pages = $req->getArray(
'pages' );
61 } elseif ( $req->getVal(
'action' ) ===
'submit' ) {
62 $this->
listForm( $target, $reason, $limit, $namespace );
66 } elseif ( $target ===
'' ) {
69 $this->
listForm( $target, $reason, $limit, $namespace );
81 $out->addWikiMsg(
'nuke-tools' );
85 'id' =>
'nuke-target',
86 'default' => $userName,
87 'label' => $this->
msg(
'nuke-userorip' )->text(),
93 'id' =>
'nuke-pattern',
94 'label' => $this->
msg(
'nuke-pattern' )->text(),
100 'id' =>
'nuke-namespace',
101 'type' =>
'namespaceselect',
102 'label' => $this->
msg(
'nuke-namespace' )->text(),
104 'name' =>
'namespace'
107 'id' =>
'nuke-limit',
110 'label' => $this->
msg(
'nuke-maxpages' )->text(),
116 HTMLForm::factory(
'ooui', $formDescriptor, $this->
getContext() )
117 ->setName(
'massdelete' )
118 ->setFormIdentifier(
'massdelete' )
119 ->setWrapperLegendMsg(
'nuke' )
120 ->setSubmitTextMsg(
'nuke-submit-user' )
121 ->setSubmitName(
'nuke-submit-user' )
122 ->setAction( $this->
getPageTitle()->getLocalURL(
'action=submit' ) )
123 ->setMethod(
'post' )
124 ->addHiddenField(
'wpEditToken', $this->
getUser()->getEditToken() )
126 ->displayForm(
false );
137 protected function listForm( $username, $reason, $limit, $namespace =
null ) {
140 $pages = $this->
getNewPages( $username, $limit, $namespace );
142 if ( count( $pages ) === 0 ) {
143 if ( $username ===
'' ) {
144 $out->addWikiMsg(
'nuke-nopages-global' );
146 $out->addWikiMsg(
'nuke-nopages', $username );
154 $out->addModules(
'ext.nuke.confirm' );
156 if ( $username ===
'' ) {
157 $out->addWikiMsg(
'nuke-list-multiple' );
159 $out->addWikiMsg(
'nuke-list', $username );
165 Xml::openElement(
'form', [
166 'action' => $nuke->getLocalURL(
'action=delete' ),
168 'name' =>
'nukelist' ]
170 Html::hidden(
'wpEditToken', $this->getUser()->getEditToken() ) .
174 $this->msg(
'deletecomment' )->text(),
'wpReason',
'wpReason', 70, $reason
181 $selectLinks = $listToggle->getHTML();
188 $wordSeparator = $this->
msg(
'word-separator' )->escaped();
189 $commaSeparator = $this->
msg(
'comma-separator' )->escaped();
192 foreach ( $pages as $info ) {
196 list(
$title, $userName ) = $info;
199 $thumb = $image && $image->exists() ?
200 $image->transform( [
'width' => 120,
'height' => 120 ], 0 ) :
203 $userNameText = $userName ?
204 $this->
msg(
'nuke-editby', $userName )->parse() . $commaSeparator :
208 $this->
msg(
'nuke-viewchanges' )->text(),
210 [
'action' =>
'history' ]
212 $out->addHTML(
'<li>' .
216 [
'value' =>
$title->getPrefixedDBkey() ]
218 ( $thumb ? $thumb->toHtml( [
'desc-link' =>
true ] ) :
'' ) .
220 $this->
msg(
'parentheses' )->rawParams( $userNameText . $changesLink )->escaped() .
226 Xml::submitButton( $this->
msg(
'nuke-submit-delete' )->text() ) .
240 protected function getNewPages( $username, $limit, $namespace =
null ) {
249 $where = [
"(rc_new = 1) OR (rc_log_type = 'upload' AND rc_log_action = 'upload')" ];
251 if ( class_exists( ActorMigration::class ) ) {
252 if ( $username ===
'' ) {
253 $actorQuery = ActorMigration::newMigration()->getJoin(
'rc_user' );
254 $what[
'rc_user_text'] = $actorQuery[
'fields'][
'rc_user_text'];
256 $actorQuery = ActorMigration::newMigration()
257 ->getWhere(
$dbr,
'rc_user', User::newFromName( $username,
false ) );
258 $where[] = $actorQuery[
'conds'];
261 $actorQuery = [
'tables' => [],
'joins' => [] ];
262 if ( $username ===
'' ) {
263 $what[] =
'rc_user_text';
265 $where[
'rc_user_text'] = $username;
269 if ( $namespace !==
null ) {
270 $where[
'rc_namespace'] = $namespace;
273 $pattern = $this->
getRequest()->getText(
'pattern' );
274 if ( !is_null( $pattern ) && trim( $pattern ) !==
'' ) {
277 $where[] =
'rc_title LIKE ' .
$dbr->addQuotes( $pattern );
279 $group = implode(
', ', $what );
281 $result =
$dbr->select(
282 [
'recentchanges' ] + $actorQuery[
'tables'],
287 'ORDER BY' =>
'rc_timestamp DESC',
288 'GROUP BY' => $group,
296 foreach ( $result as $row ) {
298 Title::makeTitle( $row->rc_namespace, $row->rc_title ),
299 $username ===
'' ? $row->rc_user_text : false
305 Hooks::run(
'NukeGetNewPages', [ $username, $pattern, $namespace, $limit, &$pages ] );
310 if ( count( $pages ) > $limit ) {
311 $pages = array_slice( $pages, 0, $limit );
324 protected function doDelete( array $pages, $reason ) {
327 foreach ( $pages as $page ) {
328 $title = Title::newFromText( $page );
330 $deletionResult =
false;
331 if ( !Hooks::run(
'NukeDeletePage', [
$title, $reason, &$deletionResult ] ) ) {
332 if ( $deletionResult ) {
333 $res[] = $this->
msg(
'nuke-deleted',
$title->getPrefixedText() )->parse();
335 $res[] = $this->
msg(
'nuke-not-deleted',
$title->getPrefixedText() )->parse();
341 $permission_errors =
$title->getUserPermissionsErrors(
'delete', $this->
getUser() );
343 if ( $permission_errors !== [] ) {
352 $ok = $article->doDeleteArticle( $reason );
356 $res[] = $this->
msg(
'nuke-deleted',
$title->getPrefixedText() )->parse();
358 $res[] = $this->
msg(
'nuke-not-deleted',
$title->getPrefixedText() )->parse();
362 $this->
getOutput()->addHTML(
"<ul>\n<li>" . implode(
"</li>\n<li>",
$res ) .
"</li>\n</ul>\n" );
363 $this->
getOutput()->addWikiMsg(
'nuke-delete-more' );
375 $user = User::newFromName( $search );
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,... $params)
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.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
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.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.