Go to the documentation of this file.
65 parent::__construct(
'EditTags',
'changetags' );
85 $output->addModules( [
'mediawiki.special.edittags' ] );
87 'mediawiki.interface.helpers.styles',
91 $this->submitClicked = $request->wasPosted() && $request->getBool(
'wpSubmit' );
94 $ids = $request->getVal(
'ids' );
95 if ( !is_null(
$ids ) ) {
97 $this->ids = explode(
',',
$ids );
100 $this->ids = array_keys( $request->getArray(
'ids', [] ) );
102 $this->ids = array_unique( array_filter( $this->ids ) );
105 if ( count( $this->ids ) == 0 ) {
106 throw new ErrorPageError(
'tags-edit-nooldid-title',
'tags-edit-nooldid-text' );
109 $this->typeName = $request->getVal(
'type' );
113 switch ( $this->typeName ) {
116 $this->typeName =
'logentry';
119 $this->typeName =
'revision';
127 $this->typeName ===
'revision' ?
'revision' :
'logging',
132 $this->isAllowed = $this->permissionManager->userHasRight( $user,
'changetags' );
134 $this->reason = $request->getVal(
'wpReason' );
136 if ( is_null( $this->targetObj ) ) {
137 $output->addWikiMsg(
'undelete-header' );
142 if ( $this->permissionManager->isBlockedFrom( $user, $this->targetObj ) ) {
150 if ( $this->isAllowed && $this->submitClicked ) {
157 $tagLogPage =
new LogPage(
'tag' );
158 $output->addHTML(
"<h2>" . $tagLogPage->getName()->escaped() .
"</h2>\n" );
164 [
'lim' => 25,
'conds' => [],
'useMaster' => $this->wasSaved ]
173 if ( $this->targetObj ) {
175 $this->
getSkin()->setRelevantTitle( $this->targetObj );
181 $this->
msg(
'viewpagelogs' )->text(),
184 'page' => $this->targetObj->getPrefixedText(),
185 'wpfilters' => [
'tag' ],
188 if ( !$this->targetObj->isSpecialPage() ) {
192 $this->
msg(
'pagehist' )->text(),
194 [
'action' =>
'history' ]
200 $this->
msg(
'tags-edit-manage-link' )->text()
212 if ( is_null( $this->revList ) ) {
214 $this->targetObj, $this->ids );
227 $out->wrapWikiMsg(
"<strong>$1</strong>", [
228 "tags-edit-{$this->typeName}-selected",
229 $this->
getLanguage()->formatNum( count( $this->ids ) ),
230 $this->targetObj->getPrefixedText()
234 $out->addHTML(
"<ul>" );
239 for ( $list->reset(); $list->current(); $list->next() ) {
240 $item = $list->current();
241 if ( !$item->canView() ) {
242 throw new ErrorPageError(
'permissionserrors',
'tags-update-no-permission' );
245 $out->addHTML( $item->getHTML() );
248 if ( !$numRevisions ) {
249 throw new ErrorPageError(
'tags-edit-nooldid-title',
'tags-edit-nooldid-text' );
252 $out->addHTML(
"</ul>" );
254 $out->wrapWikiMsg(
'<p>$1</p>',
"tags-edit-{$this->typeName}-explanation" );
257 if ( $this->isAllowed ) {
259 'action' => $this->
getPageTitle()->getLocalURL( [
'action' =>
'submit' ] ),
260 'id' =>
'mw-revdel-form-revisions' ] ) .
262 count( $this->ids ) )->text() ) .
266 '<td class="mw-label">' .
267 Xml::label( $this->
msg(
'tags-edit-reason' )->text(),
'wpReason' ) .
269 '<td class="mw-input">' .
280 '<td class="mw-submit">' .
282 $numRevisions )->text(), [
'name' =>
'wpSubmit' ] ) .
286 Html::hidden(
'wpEditToken', $this->
getUser()->getEditToken() ) .
287 Html::hidden(
'target', $this->targetObj->getPrefixedText() ) .
288 Html::hidden(
'type', $this->typeName ) .
289 Html::hidden(
'ids', implode(
',', $this->ids ) ) .
295 $out->addHTML( $form );
305 if ( $list->length() == 1 ) {
307 $tags = $list->current()->getTags();
309 $tags = explode(
',', $tags );
314 $html =
'<table id="mw-edittags-tags-selector">';
315 $html .=
'<tr><td>' . $this->
msg(
'tags-edit-existing-tags' )->escaped() .
318 $html .= $this->
getLanguage()->commaList( array_map(
'htmlspecialchars', $tags ) );
320 $html .= $this->
msg(
'tags-edit-existing-tags-none' )->parse();
322 $html .=
'</td></tr>';
323 $tagSelect = $this->
getTagSelect( $tags, $this->
msg(
'tags-edit-new-tags' )->plain() );
324 $html .=
'<tr><td>' . $tagSelect[0] .
'</td><td>' . $tagSelect[1];
329 for ( $list->reset(); $list->current(); $list->next() ) {
330 $currentTags = $list->current()->getTags();
331 if ( $currentTags ) {
332 $tags = array_merge( $tags, explode(
',', $currentTags ) );
335 $tags = array_unique( $tags );
337 $html =
'<table id="mw-edittags-tags-selector-multi"><tr><td>';
338 $tagSelect = $this->
getTagSelect( [], $this->
msg(
'tags-edit-add' )->plain() );
339 $html .=
'<p>' . $tagSelect[0] .
'</p>' . $tagSelect[1] .
'</td><td>';
340 $html .=
Xml::element(
'p',
null, $this->
msg(
'tags-edit-remove' )->plain() );
342 'wpRemoveAllTags',
'mw-edittags-remove-all' );
344 foreach ( $tags as $tag ) {
346 'wpTagsToRemove[]',
'mw-edittags-remove-' . $i++,
false, [
348 'class' =>
'mw-edittags-remove-checkbox',
355 $html .= Html::hidden(
'wpExistingTags', implode(
',', $tags ) );
356 $html .=
'</td></tr></table>';
375 $result[0] =
Xml::label( $label,
'mw-edittags-tag-list' );
377 $select =
new XmlSelect(
'wpTagList[]',
'mw-edittags-tag-list', $selectedTags );
378 $select->setAttribute(
'multiple',
'multiple' );
379 $select->setAttribute(
'size',
'8' );
382 $tags = array_unique( array_merge( $tags, $selectedTags ) );
385 $select->addOptions( array_combine( $tags, $tags ) );
387 $result[1] = $select->getHTML();
398 $token = $request->getVal(
'wpEditToken' );
399 if ( $this->submitClicked && !$this->
getUser()->matchEditToken( $token ) ) {
400 $this->
getOutput()->addWikiMsg(
'sessionfailure' );
405 $tagList = $request->getArray(
'wpTagList' );
406 if ( is_null( $tagList ) ) {
409 $existingTags = $request->getVal(
'wpExistingTags' );
410 if ( is_null( $existingTags ) || $existingTags ===
'' ) {
413 $existingTags = explode(
',', $existingTags );
416 if ( count( $this->ids ) > 1 ) {
418 $tagsToAdd = $tagList;
419 if ( $request->getBool(
'wpRemoveAllTags' ) ) {
420 $tagsToRemove = $existingTags;
422 $tagsToRemove = $request->getArray(
'wpTagsToRemove' );
428 $tagsToAdd = array_diff( $tagList, $existingTags );
429 $tagsToRemove = array_diff( $existingTags, $tagList );
432 if ( !$tagsToAdd && !$tagsToRemove ) {
436 $tagsToRemove,
null, $this->reason, $this->
getUser() );
452 $this->
getOutput()->setPageTitle( $this->
msg(
'actioncomplete' ) );
453 $this->
getOutput()->wrapWikiMsg(
"<div class=\"successbox\">\n$1\n</div>",
454 'tags-edit-success' );
455 $this->wasSaved =
true;
456 $this->revList->reloadFromMaster();
466 $this->
getOutput()->setPageTitle( $this->
msg(
'actionfailed' ) );
467 $this->
getOutput()->wrapWikiTextAsInterface(
468 'errorbox',
$status->getWikiText(
'tags-edit-failure',
false, $this->getLanguage() )
474 return $this->
msg(
'tags-edit-title' )->text();
getPageTitle( $subpage=false)
Get a self-referential title object.
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.
static newFatal( $message,... $parameters)
Factory function for fatal errors.
Show an error when the user tries to do something whilst blocked.
getOutput()
Get the OutputPage being used for this instance.
Shortcut to construct a special page which is unlisted by default.
static label( $label, $id, $attribs=[])
Convenience function to build an HTML form label.
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,...
getSkin()
Shortcut to get the skin being used for this instance.
getLanguage()
Shortcut to get user's language.
static openElement( $element, $attribs=null)
This opens an XML element.
Class for generating HTML <select> or <datalist> elements.
static fieldset( $legend=false, $content=false, $attribs=[])
Shortcut for creating fieldsets.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Class to simplify the use of log pages.
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getUser()
Shortcut to get the User executing this instance.
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
getContext()
Gets the context this SpecialPage is executed in.
getRequest()
Get the WebRequest being used for this instance.
Represents a title within MediaWiki.
static closeElement( $element)
Shortcut to close an XML element.
static input( $name, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML text input field.
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
MediaWiki Linker LinkRenderer null $linkRenderer
An error page which can definitely be safely rendered using the OutputPage.
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...
static submitButton( $value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
static checkLabel( $label, $name, $id, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox with a label.