permissionManager = $permissionManager; } public function doesWrites() { return true; } public function execute( $par ) { $this->checkPermissions(); $this->checkReadOnly(); $output = $this->getOutput(); $user = $this->getUser(); $request = $this->getRequest(); $this->setHeaders(); $this->outputHeader(); $output->addModules( [ 'mediawiki.special.edittags' ] ); $output->addModuleStyles( [ 'mediawiki.interface.helpers.styles', 'mediawiki.special' ] ); $this->submitClicked = $request->wasPosted() && $request->getBool( 'wpSubmit' ); // Handle our many different possible input types $ids = $request->getVal( 'ids' ); if ( $ids !== null ) { // Allow CSV from the form hidden field, or a single ID for show/hide links $this->ids = explode( ',', $ids ); } else { // Array input $this->ids = array_keys( $request->getArray( 'ids', [] ) ); } $this->ids = array_unique( array_filter( $this->ids ) ); // No targets? if ( count( $this->ids ) == 0 ) { throw new ErrorPageError( 'tags-edit-nooldid-title', 'tags-edit-nooldid-text' ); } $this->typeName = $request->getVal( 'type' ); $this->targetObj = Title::newFromText( $request->getText( 'target' ) ); // sanity check of parameter switch ( $this->typeName ) { case 'logentry': case 'logging': $this->typeName = 'logentry'; break; default: $this->typeName = 'revision'; break; } // Allow the list type to adjust the passed target // Yuck! Copied straight out of SpecialRevisiondelete, but it does exactly // what we want $this->targetObj = RevisionDeleter::suggestTarget( $this->typeName === 'revision' ? 'revision' : 'logging', $this->targetObj, $this->ids ); $this->isAllowed = $this->permissionManager->userHasRight( $user, 'changetags' ); $this->reason = $request->getVal( 'wpReason' ); // We need a target page! if ( $this->targetObj === null ) { $output->addWikiMsg( 'undelete-header' ); return; } // Check blocks if ( $this->permissionManager->isBlockedFrom( $user, $this->targetObj ) ) { throw new UserBlockedError( $user->getBlock(), $user, $this->getLanguage(), $request->getIP() ); } // Give a link to the logs/hist for this page $this->showConvenienceLinks(); // Either submit or create our form if ( $this->isAllowed && $this->submitClicked ) { $this->submit(); } else { $this->showForm(); } // Show relevant lines from the tag log $tagLogPage = new LogPage( 'tag' ); $output->addHTML( "
$1
', "tags-edit-{$this->typeName}-explanation" ); // Show form if the user can submit if ( $this->isAllowed ) { $form = Xml::openElement( 'form', [ 'method' => 'post', 'action' => $this->getPageTitle()->getLocalURL( [ 'action' => 'submit' ] ), 'id' => 'mw-revdel-form-revisions' ] ) . Xml::fieldset( $this->msg( "tags-edit-{$this->typeName}-legend", count( $this->ids ) )->text() ) . $this->buildCheckBoxes() . Xml::openElement( 'table' ) . "' . $this->msg( 'tags-edit-existing-tags' )->escaped() . ' | '; if ( $tags ) { $html .= $this->getLanguage()->commaList( array_map( 'htmlspecialchars', $tags ) ); } else { $html .= $this->msg( 'tags-edit-existing-tags-none' )->parse(); } $html .= ' | ||
' . $tagSelect[0] . ' | ' . $tagSelect[1];
} else {
// Otherwise, use a multi-select field for adding tags, and a list of
// checkboxes for removing them
for ( $list->reset(); $list->current(); $list->next() ) {
$currentTags = $list->current()->getTags();
if ( $currentTags ) {
$tags = array_merge( $tags, explode( ',', $currentTags ) );
}
}
$tags = array_unique( $tags );
$html = '
|