36 private $submitClicked;
54 private $permissionManager;
62 parent::__construct(
'EditTags',
'changetags' );
64 $this->permissionManager = $permissionManager;
82 $output->addModules( [
'mediawiki.special.edittags' ] );
83 $output->addModuleStyles( [
84 'mediawiki.interface.helpers.styles',
88 $this->submitClicked = $request->wasPosted() && $request->getBool(
'wpSubmit' );
91 $ids = $request->getVal(
'ids' );
92 if ( $ids !==
null ) {
94 $this->ids = explode(
',', $ids );
97 $this->ids = array_keys( $request->getArray(
'ids', [] ) );
99 $this->ids = array_unique( array_filter( $this->ids ) );
102 if ( count( $this->ids ) == 0 ) {
103 throw new ErrorPageError(
'tags-edit-nooldid-title',
'tags-edit-nooldid-text' );
106 $this->typeName = $request->getVal(
'type' );
107 $this->targetObj = Title::newFromText( $request->getText(
'target' ) );
109 switch ( $this->typeName ) {
112 $this->typeName =
'logentry';
115 $this->typeName =
'revision';
123 $this->typeName ===
'revision' ?
'revision' :
'logging',
128 $this->reason = $request->getVal(
'wpReason',
'' );
130 if ( $this->targetObj ===
null ) {
131 $output->addWikiMsg(
'undelete-header' );
136 $checkReplica = !$this->submitClicked;
138 $this->permissionManager->isBlockedFrom(
148 $this->getLanguage(),
157 if ( $this->submitClicked ) {
164 $tagLogPage =
new LogPage(
'tag' );
165 $output->addHTML(
"<h2>" . $tagLogPage->getName()->escaped() .
"</h2>\n" );
166 LogEventsList::showLogExtract(
171 [
'lim' => 25,
'conds' => [],
'useMaster' => $this->wasSaved ]
180 if ( $this->targetObj ) {
182 $this->
getSkin()->setRelevantTitle( $this->targetObj );
186 $links[] = $linkRenderer->makeKnownLink(
188 $this->
msg(
'viewpagelogs' )->text(),
191 'page' => $this->targetObj->getPrefixedText(),
192 'wpfilters' => [
'tag' ],
195 if ( !$this->targetObj->isSpecialPage() ) {
197 $links[] = $linkRenderer->makeKnownLink(
199 $this->
msg(
'pagehist' )->text(),
201 [
'action' =>
'history' ]
205 $links[] = $linkRenderer->makeKnownLink(
207 $this->
msg(
'tags-edit-manage-link' )->text()
219 if ( $this->revList ===
null ) {
221 $this->targetObj, $this->ids );
224 return $this->revList;
234 $out->wrapWikiMsg(
"<strong>$1</strong>", [
235 "tags-edit-{$this->typeName}-selected",
236 $this->
getLanguage()->formatNum( count( $this->ids ) ),
237 $this->targetObj->getPrefixedText()
241 $out->addHTML(
"<ul>" );
246 for ( $list->reset(); $list->current(); $list->next() ) {
247 $item = $list->current();
248 if ( !$item->canView() ) {
249 throw new ErrorPageError(
'permissionserrors',
'tags-update-no-permission' );
252 $out->addHTML( $item->getHTML() );
255 if ( !$numRevisions ) {
256 throw new ErrorPageError(
'tags-edit-nooldid-title',
'tags-edit-nooldid-text' );
259 $out->addHTML(
"</ul>" );
261 $out->wrapWikiMsg(
'<p>$1</p>',
"tags-edit-{$this->typeName}-explanation" );
264 $form = Xml::openElement(
'form', [
'method' =>
'post',
265 'action' => $this->
getPageTitle()->getLocalURL( [
'action' =>
'submit' ] ),
266 'id' =>
'mw-revdel-form-revisions' ] ) .
267 Xml::fieldset( $this->
msg(
"tags-edit-{$this->typeName}-legend",
268 count( $this->ids ) )->text() ) .
270 Xml::openElement(
'table' ) .
272 '<td class="mw-label">' .
273 Xml::label( $this->
msg(
'tags-edit-reason' )->text(),
'wpReason' ) .
275 '<td class="mw-input">' .
276 Xml::input(
'wpReason', 60, $this->reason, [
281 'maxlength' => CommentStore::COMMENT_CHARACTER_LIMIT,
286 '<td class="mw-submit">' .
287 Xml::submitButton( $this->
msg(
"tags-edit-{$this->typeName}-submit",
288 $numRevisions )->text(), [
'name' =>
'wpSubmit' ] ) .
291 Xml::closeElement(
'table' ) .
292 Html::hidden(
'wpEditToken', $this->
getUser()->getEditToken() ) .
293 Html::hidden(
'target', $this->targetObj->getPrefixedText() ) .
294 Html::hidden(
'type', $this->typeName ) .
295 Html::hidden(
'ids', implode(
',', $this->ids ) ) .
296 Xml::closeElement(
'fieldset' ) .
"\n" .
297 Xml::closeElement(
'form' ) .
"\n";
299 $out->addHTML( $form );
309 if ( $list->length() == 1 ) {
311 $tags = $list->current()->getTags();
313 $tags = explode(
',', $tags );
318 $html =
'<table id="mw-edittags-tags-selector">';
319 $html .=
'<tr><td>' . $this->
msg(
'tags-edit-existing-tags' )->escaped() .
322 $html .= $this->
getLanguage()->commaList( array_map(
'htmlspecialchars', $tags ) );
324 $html .= $this->
msg(
'tags-edit-existing-tags-none' )->parse();
326 $html .=
'</td></tr>';
327 $tagSelect = $this->
getTagSelect( $tags, $this->
msg(
'tags-edit-new-tags' )->plain() );
328 $html .=
'<tr><td>' . $tagSelect[0] .
'</td><td>' . $tagSelect[1];
333 for ( $list->reset(); $list->current(); $list->next() ) {
334 $currentTags = $list->current()->getTags();
335 if ( $currentTags ) {
336 $tags = array_merge( $tags, explode(
',', $currentTags ) );
339 $tags = array_unique( $tags );
341 $html =
'<table id="mw-edittags-tags-selector-multi"><tr><td>';
342 $tagSelect = $this->
getTagSelect( [], $this->
msg(
'tags-edit-add' )->plain() );
343 $html .=
'<p>' . $tagSelect[0] .
'</p>' . $tagSelect[1] .
'</td><td>';
344 $html .= Xml::element(
'p',
null, $this->
msg(
'tags-edit-remove' )->plain() );
345 $html .= Xml::checkLabel( $this->
msg(
'tags-edit-remove-all-tags' )->plain(),
346 'wpRemoveAllTags',
'mw-edittags-remove-all' );
348 foreach ( $tags as $tag ) {
349 $html .= Xml::element(
'br' ) .
"\n" . Xml::checkLabel( $tag,
350 'wpTagsToRemove[]',
'mw-edittags-remove-' . $i++,
false, [
352 'class' =>
'mw-edittags-remove-checkbox',
359 $html .= Html::hidden(
'wpExistingTags', implode(
',', $tags ) );
360 $html .=
'</td></tr></table>';
379 $result[0] = Xml::label( $label,
'mw-edittags-tag-list' );
381 $select =
new XmlSelect(
'wpTagList[]',
'mw-edittags-tag-list', $selectedTags );
382 $select->setAttribute(
'multiple',
'multiple' );
383 $select->setAttribute(
'size',
'8' );
386 $tags = array_unique( array_merge( $tags, $selectedTags ) );
389 $select->addOptions( array_combine( $tags, $tags ) );
391 $result[1] = $select->getHTML();
402 $token = $request->getVal(
'wpEditToken' );
403 if ( $this->submitClicked && !$this->
getUser()->matchEditToken( $token ) ) {
404 $this->
getOutput()->addWikiMsg(
'sessionfailure' );
409 $tagList = $request->getArray(
'wpTagList' );
410 if ( $tagList ===
null ) {
413 $existingTags = $request->getVal(
'wpExistingTags' );
414 if ( $existingTags ===
null || $existingTags ===
'' ) {
417 $existingTags = explode(
',', $existingTags );
420 if ( count( $this->ids ) > 1 ) {
422 $tagsToAdd = $tagList;
423 if ( $request->getBool(
'wpRemoveAllTags' ) ) {
424 $tagsToRemove = $existingTags;
426 $tagsToRemove = $request->getArray(
'wpTagsToRemove' );
432 $tagsToAdd = array_diff( $tagList, $existingTags );
433 $tagsToRemove = array_diff( $existingTags, $tagList );
436 if ( !$tagsToAdd && !$tagsToRemove ) {
437 $status = Status::newFatal(
'tags-edit-none-selected' );
439 $status = $this->
getList()->updateChangeTagsOnAll( $tagsToAdd,
440 $tagsToRemove,
null, $this->reason, $this->
getAuthority() );
443 if ( $status->isGood() ) {
457 $out->setPageTitle( $this->
msg(
'actioncomplete' ) );
459 Html::successBox( $out->msg(
'tags-edit-success' )->parse() )
461 $this->wasSaved =
true;
462 $this->revList->reloadFromPrimary();
473 $out->setPageTitle( $this->
msg(
'actionfailed' ) );
476 $out->parseAsContent(
477 $status->getWikiText(
'tags-edit-failure',
false, $this->getLanguage() )
485 return $this->
msg(
'tags-edit-title' )->text();
An error page which can definitely be safely rendered using the OutputPage.
Class to simplify the use of log pages.
static suggestTarget( $typeName, $target, array $ids)
Suggest a target for the revision deletion.
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.
getSkin()
Shortcut to get the skin being used for this instance.
checkPermissions()
Checks if userCanExecute, and if not throws a PermissionsError.
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,...
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getAuthority()
Shortcut to get the Authority executing this instance.
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.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Represents a title within MediaWiki.
Shortcut to construct a special page which is unlisted by default.
Show an error when the user tries to do something whilst blocked.
Class for generating HTML <select> or <datalist> elements.