53 private $submitClicked;
79 parent::__construct(
'EditTags',
'changetags' );
81 $this->permissionManager = $permissionManager;
82 $this->changeTagsStore = $changeTagsStore;
100 $output->addModules( [
'mediawiki.misc-authed-curate' ] );
101 $output->addModuleStyles( [
102 'mediawiki.interface.helpers.styles',
106 $this->submitClicked = $request->wasPosted() && $request->getBool(
'wpSubmit' );
109 $ids = $request->getVal(
'ids' );
110 if ( $ids !==
null ) {
112 $this->ids = explode(
',', $ids );
115 $this->ids = array_keys( $request->getArray(
'ids', [] ) );
117 $this->ids = array_unique( array_filter( $this->ids ) );
120 if ( count( $this->ids ) == 0 ) {
121 throw new ErrorPageError(
'tags-edit-nooldid-title',
'tags-edit-nooldid-text' );
124 $this->typeName = $request->getVal(
'type' );
125 $this->targetObj = Title::newFromText( $request->getText(
'target' ) );
127 switch ( $this->typeName ) {
130 $this->typeName =
'logentry';
133 $this->typeName =
'revision';
140 $this->targetObj = RevisionDeleter::suggestTarget(
141 $this->typeName ===
'revision' ?
'revision' :
'logging',
146 $this->reason = $request->getVal(
'wpReason',
'' );
148 if ( $this->targetObj ===
null ) {
149 $output->addWikiMsg(
'undelete-header' );
154 $checkReplica = !$this->submitClicked;
156 $this->permissionManager->isBlockedFrom(
166 $this->getLanguage(),
175 if ( $this->submitClicked ) {
182 $tagLogPage =
new LogPage(
'tag' );
183 $output->addHTML(
"<h2>" . $tagLogPage->getName()->escaped() .
"</h2>\n" );
184 LogEventsList::showLogExtract(
189 [
'lim' => 25,
'conds' => [],
'useMaster' => $this->wasSaved ]
198 if ( $this->targetObj ) {
200 $this->
getSkin()->setRelevantTitle( $this->targetObj );
204 $links[] = $linkRenderer->makeKnownLink(
206 $this->
msg(
'viewpagelogs' )->text(),
209 'page' => $this->targetObj->getPrefixedText(),
210 'wpfilters' => [
'tag' ],
213 if ( !$this->targetObj->isSpecialPage() ) {
215 $links[] = $linkRenderer->makeKnownLink(
217 $this->
msg(
'pagehist' )->text(),
219 [
'action' =>
'history' ]
223 $links[] = $linkRenderer->makeKnownLink(
225 $this->
msg(
'tags-edit-manage-link' )->text()
237 if ( $this->revList ===
null ) {
239 $this->targetObj, $this->ids );
242 return $this->revList;
252 $out->wrapWikiMsg(
"<strong>$1</strong>", [
253 "tags-edit-{$this->typeName}-selected",
254 $this->
getLanguage()->formatNum( count( $this->ids ) ),
255 $this->targetObj->getPrefixedText()
259 $out->addHTML(
"<ul>" );
264 for ( $list->reset(); $list->current(); $list->next() ) {
265 $item = $list->current();
266 if ( !$item->canView() ) {
267 throw new ErrorPageError(
'permissionserrors',
'tags-update-no-permission' );
270 $out->addHTML( $item->getHTML() );
273 if ( !$numRevisions ) {
274 throw new ErrorPageError(
'tags-edit-nooldid-title',
'tags-edit-nooldid-text' );
277 $out->addHTML(
"</ul>" );
279 $out->wrapWikiMsg(
'<p>$1</p>',
"tags-edit-{$this->typeName}-explanation" );
282 $form = Html::openElement(
'form', [
'method' =>
'post',
283 'action' => $this->
getPageTitle()->getLocalURL( [
'action' =>
'submit' ] ),
284 'id' =>
'mw-revdel-form-revisions' ] ) .
285 Xml::fieldset( $this->
msg(
"tags-edit-{$this->typeName}-legend",
286 count( $this->ids ) )->text() ) .
288 Html::openElement(
'table' ) .
290 '<td class="mw-label">' .
291 Html::label( $this->
msg(
'tags-edit-reason' )->text(),
'wpReason' ) .
293 '<td class="mw-input">' .
294 Html::element(
'input', [
'name' =>
'wpReason',
'size' => 60,
'value' => $this->reason,
299 'maxlength' => CommentStore::COMMENT_CHARACTER_LIMIT,
304 '<td class="mw-submit">' .
305 Html::submitButton( $this->
msg(
"tags-edit-{$this->typeName}-submit",
306 $numRevisions )->text(), [
'name' =>
'wpSubmit' ] ) .
309 Html::closeElement(
'table' ) .
310 Html::hidden(
'wpEditToken', $this->
getUser()->getEditToken() ) .
311 Html::hidden(
'target', $this->targetObj->getPrefixedText() ) .
312 Html::hidden(
'type', $this->typeName ) .
313 Html::hidden(
'ids', implode(
',', $this->ids ) ) .
314 Html::closeElement(
'fieldset' ) .
"\n" .
315 Html::closeElement(
'form' ) .
"\n";
317 $out->addHTML( $form );
327 if ( $list->length() == 1 ) {
329 $tags = $list->current()->getTags();
331 $tags = explode(
',', $tags );
336 $html =
'<table id="mw-edittags-tags-selector">';
337 $html .=
'<tr><td>' . $this->
msg(
'tags-edit-existing-tags' )->escaped() .
340 $html .= $this->
getLanguage()->commaList( array_map(
'htmlspecialchars', $tags ) );
342 $html .= $this->
msg(
'tags-edit-existing-tags-none' )->parse();
344 $html .=
'</td></tr>';
345 $tagSelect = $this->
getTagSelect( $tags, $this->
msg(
'tags-edit-new-tags' )->plain() );
346 $html .=
'<tr><td>' . $tagSelect[0] .
'</td><td>' . $tagSelect[1];
351 for ( $list->reset(); $list->current(); $list->next() ) {
352 $currentTags = $list->current()->getTags();
353 if ( $currentTags ) {
354 $tags = array_merge( $tags, explode(
',', $currentTags ) );
357 $tags = array_unique( $tags );
359 $html =
'<table id="mw-edittags-tags-selector-multi"><tr><td>';
360 $tagSelect = $this->
getTagSelect( [], $this->
msg(
'tags-edit-add' )->plain() );
361 $html .=
'<p>' . $tagSelect[0] .
'</p>' . $tagSelect[1] .
'</td><td>';
362 $html .=
Html::element(
'p', [], $this->
msg(
'tags-edit-remove' )->plain() );
364 'type' =>
'checkbox',
'name' =>
'wpRemoveAllTags',
'value' =>
'1',
365 'id' =>
'mw-edittags-remove-all'
367 . Html::label( $this->
msg(
'tags-edit-remove-all-tags' )->plain(),
'mw-edittags-remove-all' );
369 foreach ( $tags as $tag ) {
370 $id =
'mw-edittags-remove-' . $i++;
372 'type' =>
'checkbox',
'name' =>
'wpTagsToRemove[]',
'value' => $tag,
373 'class' =>
'mw-edittags-remove-checkbox',
'id' => $id,
374 ] ) .
' ' . Html::label( $tag, $id );
380 $html .= Html::hidden(
'wpExistingTags', implode(
',', $tags ) );
381 $html .=
'</td></tr></table>';
400 $result[0] = Html::label( $label,
'mw-edittags-tag-list' );
402 $select =
new XmlSelect(
'wpTagList[]',
'mw-edittags-tag-list', $selectedTags );
403 $select->setAttribute(
'multiple',
'multiple' );
404 $select->setAttribute(
'size',
'8' );
406 $tags = $this->changeTagsStore->listExplicitlyDefinedTags();
407 $tags = array_unique( array_merge( $tags, $selectedTags ) );
410 $select->addOptions( array_combine( $tags, $tags ) );
412 $result[1] = $select->getHTML();
423 $token = $request->getVal(
'wpEditToken' );
424 if ( $this->submitClicked && !$this->
getUser()->matchEditToken( $token ) ) {
425 $this->
getOutput()->addWikiMsg(
'sessionfailure' );
430 $tagList = $request->getArray(
'wpTagList' ) ?? [];
431 $existingTags = $request->getVal(
'wpExistingTags' );
432 if ( $existingTags ===
null || $existingTags ===
'' ) {
435 $existingTags = explode(
',', $existingTags );
438 if ( count( $this->ids ) > 1 ) {
440 $tagsToAdd = $tagList;
441 if ( $request->getBool(
'wpRemoveAllTags' ) ) {
442 $tagsToRemove = $existingTags;
444 $tagsToRemove = $request->getArray(
'wpTagsToRemove', [] );
450 $tagsToAdd = array_diff( $tagList, $existingTags );
451 $tagsToRemove = array_diff( $existingTags, $tagList );
454 if ( !$tagsToAdd && !$tagsToRemove ) {
455 $status = Status::newFatal(
'tags-edit-none-selected' );
457 $status = $this->
getList()->updateChangeTagsOnAll( $tagsToAdd,
458 $tagsToRemove,
null, $this->reason, $this->
getAuthority() );
461 if ( $status->isGood() ) {
475 $out->setPageTitleMsg( $this->
msg(
'actioncomplete' ) );
477 Html::successBox( $out->msg(
'tags-edit-success' )->parse() )
479 $this->wasSaved =
true;
480 $this->revList->reloadFromPrimary();
491 $out->setPageTitleMsg( $this->
msg(
'actionfailed' ) );
494 $out->parseAsContent(
495 $status->getWikiText(
'tags-edit-failure',
false, $this->getLanguage() )
503 return $this->
msg(
'tags-edit-title' );
512class_alias( SpecialEditTags::class,
'SpecialEditTags' );
An error page which can definitely be safely rendered using the OutputPage.
Class to simplify the use of log pages.
Parent class for all special pages.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getSkin()
Shortcut to get the skin being used for this instance.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
getUser()
Shortcut to get the User executing this instance.
getPageTitle( $subpage=false)
Get a self-referential title object.
checkPermissions()
Checks if userCanExecute, and if not throws a PermissionsError.
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
getContext()
Gets the context this SpecialPage is executed in.
getRequest()
Get the WebRequest being used for this instance.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
getAuthority()
Shortcut to get the Authority executing this instance.
getLanguage()
Shortcut to get user's language.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages By default the message key is the canonical name of...
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Shortcut to construct a special page which is unlisted by default.
General controller for RevDel, used by both SpecialRevisiondelete and ApiRevisionDelete.
Show an error when the user tries to do something whilst blocked.