Go to the documentation of this file.
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 !==
'' ) {
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(),
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 );
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() .
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 ===
'' ) {
254 $what[
'rc_user_text'] = $actorQuery[
'fields'][
'rc_user_text'];
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 ) {
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 ) {
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' );
getPageTitle( $subpage=false)
Get a self-referential title object.
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Show an error when the user tries to do something whilst blocked.
getOutput()
Get the OutputPage being used for this instance.
doDelete(array $pages, $reason)
Does the actual deletion of the pages.
static search( $audience, $search, $limit, $offset=0)
Do a prefix search of user names and return a list of matching user names.
checkPermissions()
Checks if userCanExecute, and if not throws a PermissionsError.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Show an error when a user tries to do something they do not have the necessary permissions for.
static openElement( $element, $attribs=null)
This opens an XML element.
static newMigration()
Static constructor.
listForm( $username, $reason, $limit, $namespace=null)
Display list of pages to delete.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Class for generating clickable toggle links for a list of checkboxes.
static check( $name, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getUser()
Shortcut to get the User executing this instance.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
getContext()
Gets the context this SpecialPage is executed in.
getNewPages( $username, $limit, $namespace=null)
Gets a list of new pages by the specified user or everyone when none is specified.
Parent class for all special pages.
static tags( $element, $attribs, $contents)
Same as Xml::element(), but does not escape contents.
getRequest()
Get the WebRequest being used for this instance.
doesWrites()
Indicates whether this special page may perform database writes.
promptForm( $userName='')
Prompt for a username or IP address.
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
Class for viewing MediaWiki article and history.
MediaWiki Linker LinkRenderer null $linkRenderer
wfLocalFile( $title)
Get an object referring to a locally registered file.
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
static inputLabel( $label, $name, $id, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML text input field with a label.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
static submitButton( $value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...