/** @var Article */
public $mArticle;
+ /** @var WikiPage */
+ private $page;
/** @var Title */
public $mTitle;
public $contentFormat = null;
/** @var null|array */
- public $changeTags = null;
+ private $changeTags = null;
# Placeholders for text injection by hooks (must be HTML)
# extensions should take care to _append_ to the present value
*/
public function __construct( Article $article ) {
$this->mArticle = $article;
+ $this->page = $article->getPage(); // model object
$this->mTitle = $article->getTitle();
$this->contentModel = $this->mTitle->getContentModel();
function edit() {
global $wgOut, $wgRequest, $wgUser;
// Allow extensions to modify/prevent this form or submission
- if ( !Hooks::run( 'AlternateEdit', array( $this ) ) ) {
+ if ( !Hooks::run( 'AlternateEdit', [ $this ] ) ) {
return;
}
return;
}
+ $revision = $this->mArticle->getRevisionFetched();
+ // Disallow editing revisions with content models different from the current one
+ if ( $revision && $revision->getContentModel() !== $this->contentModel ) {
+ $this->displayViewSourcePage(
+ $this->getContentObject(),
+ wfMessage(
+ 'contentmodelediterror',
+ $revision->getContentModel(),
+ $this->contentModel
+ )->plain()
+ );
+ return;
+ }
+
$this->isConflict = false;
// css / js subpages of user pages get a special treatment
$this->isCssJsSubpage = $this->mTitle->isCssJsSubpage();
}
if ( !$this->mTitle->getArticleID() ) {
- Hooks::run( 'EditFormPreloadText', array( &$this->textbox1, &$this->mTitle ) );
+ Hooks::run( 'EditFormPreloadText', [ &$this->textbox1, &$this->mTitle ] );
} else {
- Hooks::run( 'EditFormInitialText', array( $this ) );
+ Hooks::run( 'EditFormInitialText', [ $this ] );
}
}
);
}
# Ignore some permissions errors when a user is just previewing/viewing diffs
- $remove = array();
+ $remove = [];
foreach ( $permErrors as $error ) {
if ( ( $this->preview || $this->diff )
&& ( $error[0] == 'blockedtext' || $error[0] == 'autoblockedtext' )
throw new PermissionsError( $action, $permErrors );
}
- Hooks::run( 'EditPage::showReadOnlyForm:initial', array( $this, &$wgOut ) );
+ $this->displayViewSourcePage(
+ $content,
+ $wgOut->formatPermissionsErrorMessage( $permErrors, 'edit' )
+ );
+ }
+
+ /**
+ * Display a read-only View Source page
+ * @param Content $content content object
+ * @param string $errorMessage additional wikitext error message to display
+ */
+ protected function displayViewSourcePage( Content $content, $errorMessage = '' ) {
+ global $wgOut;
+
+ Hooks::run( 'EditPage::showReadOnlyForm:initial', [ $this, &$wgOut ] );
$wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->setPageTitle( wfMessage(
$wgOut->addHTML( $this->editFormPageTop );
$wgOut->addHTML( $this->editFormTextTop );
- $wgOut->addWikiText( $wgOut->formatPermissionsErrorMessage( $permErrors, 'edit' ) );
- $wgOut->addHTML( "<hr />\n" );
+ if ( $errorMessage !== '' ) {
+ $wgOut->addWikiText( $errorMessage );
+ $wgOut->addHTML( "<hr />\n" );
+ }
# If the user made changes, preserve them when showing the markup
# (This happens when a user is blocked during edit, for instance)
$text = $this->textbox1;
$wgOut->addWikiMsg( 'viewyourtext' );
} else {
- $text = $this->toEditText( $content );
+ try {
+ $text = $this->toEditText( $content );
+ } catch ( MWException $e ) {
+ # Serialize using the default format if the content model is not supported
+ # (e.g. for an old revision with a different model)
+ $text = $content->serialize();
+ }
$wgOut->addWikiMsg( 'viewsourcetext' );
}
$wgOut->addHTML( $this->editFormTextBeforeContent );
- $this->showTextbox( $text, 'wpTextbox1', array( 'readonly' ) );
+ $this->showTextbox( $text, 'wpTextbox1', [ 'readonly' ] );
$wgOut->addHTML( $this->editFormTextAfterContent );
- $wgOut->addHTML( Html::rawElement( 'div', array( 'class' => 'templatesUsed' ),
+ $wgOut->addHTML( Html::rawElement( 'div', [ 'class' => 'templatesUsed' ],
Linker::formatTemplates( $this->getTemplates() ) ) );
$wgOut->addModules( 'mediawiki.action.edit.collapsibleFooter' );
$name = $this->mTitle->getSkinFromCssJsSubpage();
$skins = array_merge(
array_keys( Skin::getSkinNames() ),
- array( 'common' )
+ [ 'common' ]
);
return !in_array( $name, $skins )
&& in_array( strtolower( $name ), $skins );
$changeTags = $request->getVal( 'wpChangeTags' );
if ( is_null( $changeTags ) || $changeTags === '' ) {
- $this->changeTags = array();
+ $this->changeTags = [];
} else {
$this->changeTags = array_filter( array_map( 'trim', explode( ',',
$changeTags ) ) );
throw new ErrorPageError(
'editpage-notsupportedcontentformat-title',
'editpage-notsupportedcontentformat-text',
- array( $this->contentFormat, ContentHandler::getLocalizedName( $this->contentModel ) )
+ [ $this->contentFormat, ContentHandler::getLocalizedName( $this->contentModel ) ]
);
}
$this->section === 'new' ? 'MediaWiki:addsection-editintro' : '' );
// Allow extensions to modify form data
- Hooks::run( 'EditPage::importFormData', array( $this, $request ) );
+ Hooks::run( 'EditPage::importFormData', [ $this, $request ] );
}
* for saving, preview parsing and so on...
*
* @param WebRequest $request
+ * @return string|null
*/
protected function importContentFormData( &$request ) {
return; // Don't do anything, EditPage already extracted wpTextbox1
*/
function initialiseForm() {
global $wgUser;
- $this->edittime = $this->mArticle->getTimestamp();
+ $this->edittime = $this->page->getTimestamp();
$content = $this->getContentObject( false ); # TODO: track content object?!
if ( $content === false ) {
$preload = $wgRequest->getVal( 'preload',
// Custom preload text for new sections
$this->section === 'new' ? 'MediaWiki:addsection-preload' : '' );
- $params = $wgRequest->getArray( 'preloadparams', array() );
+ $params = $wgRequest->getArray( 'preloadparams', [] );
$content = $this->getPreloadedContent( $preload, $params );
}
!$undorev->isDeleted( Revision::DELETED_TEXT ) &&
!$oldrev->isDeleted( Revision::DELETED_TEXT )
) {
- $content = $this->mArticle->getUndoContent( $undorev, $oldrev );
+ $content = $this->page->getUndoContent( $undorev, $oldrev );
if ( $content === false ) {
# Warn the user that something went wrong
$undoMsg = 'failure';
} else {
- $oldContent = $this->mArticle->getPage()->getContent( Revision::RAW );
+ $oldContent = $this->page->getContent( Revision::RAW );
$popts = ParserOptions::newFromUserAndLang( $wgUser, $wgContLang );
$newContent = $content->preSaveTransform( $this->mTitle, $wgUser, $popts );
return $content;
}
+ /**
+ * Get the edit's parent revision ID
+ *
+ * The "parent" revision is the ancestor that should be recorded in this
+ * page's revision history. It is either the revision ID of the in-memory
+ * article content, or in the case of a 3-way merge in order to rebase
+ * across a recoverable edit conflict, the ID of the newer revision to
+ * which we have rebased this page.
+ *
+ * @since 1.27
+ * @return int Revision ID
+ */
+ public function getParentRevId() {
+ if ( $this->parentRevId ) {
+ return $this->parentRevId;
+ } else {
+ return $this->mArticle->getRevIdFetched();
+ }
+ }
+
/**
* Get the current content of the page. This is basically similar to
* WikiPage::getContent( Revision::RAW ) except that when the page doesn't exist an empty
* @return Content
*/
protected function getCurrentContent() {
- $rev = $this->mArticle->getRevision();
+ $rev = $this->page->getRevision();
$content = $rev ? $rev->getContent( Revision::RAW ) : null;
if ( $content === false || $content === null ) {
*
* @since 1.21
*/
- protected function getPreloadedContent( $preload, $params = array() ) {
+ protected function getPreloadedContent( $preload, $params = [] ) {
global $wgUser;
if ( !empty( $this->mPreloadContent ) ) {
* @param int $statusValue The status value (to check for new article status)
*/
protected function setPostEditCookie( $statusValue ) {
- $revisionId = $this->mArticle->getLatest();
+ $revisionId = $this->page->getLatest();
$postEditKey = self::POST_EDIT_COOKIE_KEY_PREFIX . $revisionId;
$val = 'saved';
}
$response = RequestContext::getMain()->getRequest()->response();
- $response->setCookie( $postEditKey, $val, time() + self::POST_EDIT_COOKIE_DURATION, array(
+ $response->setCookie( $postEditKey, $val, time() + self::POST_EDIT_COOKIE_DURATION, [
'httpOnly' => false,
- ) );
+ ] );
}
/**
$bot = $wgUser->isAllowed( 'bot' ) && $this->bot;
$status = $this->internalAttemptSave( $resultDetails, $bot );
- Hooks::run( 'EditPage::attemptSave:after', array( $this, $status, $resultDetails ) );
+ Hooks::run( 'EditPage::attemptSave:after', [ $this, $status, $resultDetails ] );
return $status;
}
}
}
+ // "wpExtraQueryRedirect" is a hidden input to modify
+ // after save URL and is not used by actual edit form
+ $request = RequestContext::getMain()->getRequest();
+ $extraQueryRedirect = $request->getVal( 'wpExtraQueryRedirect' );
+
switch ( $status->value ) {
case self::AS_HOOK_ERROR_EXPECTED:
case self::AS_CONTENT_TOO_BIG:
case self::AS_SUCCESS_NEW_ARTICLE:
$query = $resultDetails['redirect'] ? 'redirect=no' : '';
+ if ( $extraQueryRedirect ) {
+ if ( $query === '' ) {
+ $query = $extraQueryRedirect;
+ } else {
+ $query = $query . '&' . $extraQueryRedirect;
+ }
+ }
$anchor = isset( $resultDetails['sectionanchor'] ) ? $resultDetails['sectionanchor'] : '';
$wgOut->redirect( $this->mTitle->getFullURL( $query ) . $anchor );
return false;
// Give extensions a chance to modify URL query on update
Hooks::run(
'ArticleUpdateBeforeRedirect',
- array( $this->mArticle, &$sectionanchor, &$extraQuery )
+ [ $this->mArticle, &$sectionanchor, &$extraQuery ]
);
if ( $resultDetails['redirect'] ) {
$extraQuery = 'redirect=no&' . $extraQuery;
}
}
+ if ( $extraQueryRedirect ) {
+ if ( $extraQuery === '' ) {
+ $extraQuery = $extraQueryRedirect;
+ } else {
+ $extraQuery = $extraQuery . '&' . $extraQueryRedirect;
+ }
+ }
+
$wgOut->redirect( $this->mTitle->getFullURL( $extraQuery ) . $sectionanchor );
return false;
protected function runPostMergeFilters( Content $content, Status $status, User $user ) {
// Run old style post-section-merge edit filter
if ( !ContentHandler::runLegacyHooks( 'EditFilterMerged',
- array( $this, $content, &$this->hookError, $this->summary ) )
+ [ $this, $content, &$this->hookError, $this->summary ] )
) {
# Error messages etc. could be handled within the hook...
$status->fatal( 'hookaborted' );
// Run new style post-section-merge edit filter
if ( !Hooks::run( 'EditFilterMergedContent',
- array( $this->mArticle->getContext(), $content, $status, $this->summary,
- $user, $this->minoredit ) )
+ [ $this->mArticle->getContext(), $content, $status, $this->summary,
+ $user, $this->minoredit ] )
) {
# Error messages etc. could be handled within the hook...
if ( $status->isGood() ) {
$status = Status::newGood();
- if ( !Hooks::run( 'EditPage::attemptSave', array( $this ) ) ) {
+ if ( !Hooks::run( 'EditPage::attemptSave', [ $this ] ) ) {
wfDebug( "Hook 'EditPage::attemptSave' aborted article saving\n" );
$status->fatal( 'hookaborted' );
$status->value = self::AS_HOOK_ERROR;
}
if ( !Hooks::run(
'EditFilter',
- array( $this, $this->textbox1, $this->section, &$this->hookError, $this->summary ) )
+ [ $this, $this->textbox1, $this->section, &$this->hookError, $this->summary ] )
) {
# Error messages etc. could be handled within the hook...
$status->fatal( 'hookaborted' );
# Load the page data from the master. If anything changes in the meantime,
# we detect it by using page_latest like a token in a 1 try compare-and-swap.
- $this->mArticle->loadPageData( 'fromdbmaster' );
- $new = !$this->mArticle->exists();
+ $this->page->loadPageData( 'fromdbmaster' );
+ $new = !$this->page->exists();
if ( $new ) {
// Late check for create permission, just in case *PARANOIA*
# Article exists. Check for edit conflict.
- $this->mArticle->clear(); # Force reload of dates, etc.
- $timestamp = $this->mArticle->getTimestamp();
+ $this->page->clear(); # Force reload of dates, etc.
+ $timestamp = $this->page->getTimestamp();
wfDebug( "timestamp: {$timestamp}, edittime: {$this->edittime}\n" );
if ( $timestamp != $this->edittime ) {
$this->isConflict = true;
if ( $this->section == 'new' ) {
- if ( $this->mArticle->getUserText() == $wgUser->getName() &&
- $this->mArticle->getComment() == $this->newSectionSummary()
+ if ( $this->page->getUserText() == $wgUser->getName() &&
+ $this->page->getComment() == $this->newSectionSummary()
) {
// Probably a duplicate submission of a new comment.
- // This can happen when squid resends a request after
+ // This can happen when CDN resends a request after
// a timeout but the first one actually went through.
wfDebug( __METHOD__
. ": duplicate new section submission; trigger edit conflict!\n" );
. ": conflict! getting section '{$this->section}' for time '{$this->edittime}'"
. " (article time '{$timestamp}')\n" );
- $content = $this->mArticle->replaceSectionContent(
+ $content = $this->page->replaceSectionContent(
$this->section,
$textbox_content,
$sectionTitle,
);
} else {
wfDebug( __METHOD__ . ": getting section '{$this->section}'\n" );
- $content = $this->mArticle->replaceSectionContent(
+ $content = $this->page->replaceSectionContent(
$this->section,
$textbox_content,
$sectionTitle
( ( $this->minoredit && !$this->isNew ) ? EDIT_MINOR : 0 ) |
( $bot ? EDIT_FORCE_BOT : 0 );
- $doEditStatus = $this->mArticle->doEditContent(
+ $doEditStatus = $this->page->doEditContent(
$content,
$this->summary,
$flags,
false,
$wgUser,
- $content->getDefaultFormat()
+ $content->getDefaultFormat(),
+ $this->changeTags
);
if ( !$doEditStatus->isOK() ) {
// but don't show it for errors from extension hooks
$errors = $doEditStatus->getErrorsArray();
if ( in_array( $errors[0][0],
- array( 'edit-gone-missing', 'edit-conflict', 'edit-already-exists' ) )
+ [ 'edit-gone-missing', 'edit-conflict', 'edit-already-exists' ] )
) {
$this->isConflict = true;
// Destroys data doEdit() put in $status->value but who cares
$this->updateWatchlist();
- if ( $this->changeTags && isset( $doEditStatus->value['revision'] ) ) {
- // If a revision was created, apply any change tags that were requested
- $addTags = $this->changeTags;
- $revId = $doEditStatus->value['revision']->getId();
- // Defer this both for performance and so that addTags() sees the rc_id
- // since the recentchange entry addition is deferred first (bug T100248)
- DeferredUpdates::addCallableUpdate( function() use ( $addTags, $revId ) {
- ChangeTags::addTags( $addTags, null, $revId );
- } );
- }
-
// If the content model changed, add a log entry
if ( $changingContentModel ) {
$this->addContentModelChangeLogEntry(
}
/**
- * @param Title $title
+ * @param User $user
* @param string $oldModel
* @param string $newModel
* @param string $reason
$log->setPerformer( $user );
$log->setTarget( $this->mTitle );
$log->setComment( $reason );
- $log->setParameters( array(
+ $log->setParameters( [
'4::oldmodel' => $oldModel,
'5::newmodel' => $newModel
- ) );
+ ] );
$logid = $log->insert();
$log->publish( $logid );
}
-
/**
* Register the change of watch status
*/
protected function updateWatchlist() {
global $wgUser;
- if ( $wgUser->isLoggedIn()
- && $this->watchthis != $wgUser->isWatched( $this->mTitle, WatchedItem::IGNORE_USER_RIGHTS )
- ) {
- $fname = __METHOD__;
- $title = $this->mTitle;
- $watch = $this->watchthis;
-
- // Do this in its own transaction to reduce contention...
- $dbw = wfGetDB( DB_MASTER );
- $dbw->onTransactionIdle( function () use ( $dbw, $title, $watch, $wgUser, $fname ) {
- WatchAction::doWatchOrUnwatch( $watch, $title, $wgUser );
- } );
+ if ( !$wgUser->isLoggedIn() ) {
+ return;
}
+
+ $user = $wgUser;
+ $title = $this->mTitle;
+ $watch = $this->watchthis;
+ // Do this in its own transaction to reduce contention...
+ DeferredUpdates::addCallableUpdate( function () use ( $user, $title, $watch ) {
+ if ( $watch == $user->isWatched( $title, WatchedItem::IGNORE_USER_RIGHTS ) ) {
+ return; // nothing to change
+ }
+ WatchAction::doWatchOrUnwatch( $watch, $title, $user );
+ } );
}
/**
if ( $result ) {
$editContent = $result;
+ // Update parentRevId to what we just merged.
+ $this->parentRevId = $currentRevision->getId();
return true;
}
}
/**
- * @return Revision
+ * @note: this method is very poorly named. If the user opened the form with ?oldid=X,
+ * one might think of X as the "base revision", which is NOT what this returns.
+ * @return Revision Current version when the edit was started
*/
function getBaseRevision() {
if ( !$this->mBaseRevision ) {
*/
protected static function matchSpamRegexInternal( $text, $regexes ) {
foreach ( $regexes as $regex ) {
- $matches = array();
+ $matches = [];
if ( preg_match( $regex, $text, $matches ) ) {
return $matches[0];
}
$wgOut->addModules( 'mediawiki.action.edit.stash' );
}
- $wgOut->setRobotPolicy( 'noindex,nofollow' );
-
# Enabled article-related sidebar, toplinks, etc.
$wgOut->setArticleRelated( true );
}
# Use the title defined by DISPLAYTITLE magic word when present
+ # NOTE: getDisplayTitle() returns HTML while getPrefixedText() returns plain text.
+ # setPageTitle() treats the input as wikitext, which should be safe in either case.
$displayTitle = isset( $this->mParserOutput ) ? $this->mParserOutput->getDisplayTitle() : false;
if ( $displayTitle === false ) {
$displayTitle = $contextTitle->getPrefixedText();
# there must be a description url to show a hint to shared repo
if ( $descUrl ) {
if ( !$this->mTitle->exists() ) {
- $wgOut->wrapWikiMsg( "<div class=\"mw-sharedupload-desc-create\">\n$1\n</div>", array(
+ $wgOut->wrapWikiMsg( "<div class=\"mw-sharedupload-desc-create\">\n$1\n</div>", [
'sharedupload-desc-create', $file->getRepo()->getDisplayName(), $descUrl
- ) );
+ ] );
} else {
- $wgOut->wrapWikiMsg( "<div class=\"mw-sharedupload-desc-edit\">\n$1\n</div>", array(
+ $wgOut->wrapWikiMsg( "<div class=\"mw-sharedupload-desc-edit\">\n$1\n</div>", [
'sharedupload-desc-edit', $file->getRepo()->getDisplayName(), $descUrl
- ) );
+ ] );
}
}
}
$block = Block::newFromTarget( $user, $user );
if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist
$wgOut->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n$1\n</div>",
- array( 'userpage-userdoesnotexist', wfEscapeWikiText( $username ) ) );
+ [ 'userpage-userdoesnotexist', wfEscapeWikiText( $username ) ] );
} elseif ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) {
# Show log extract if the user is currently blocked
LogEventsList::showLogExtract(
'block',
MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget(),
'',
- array(
+ [
'lim' => 1,
'showIfEmpty' => false,
- 'msgKey' => array(
+ 'msgKey' => [
'blocked-notice-logextract',
$user->getName() # Support GENDER in notice
- )
- )
+ ]
+ ]
);
}
}
$wgOut->wrapWikiMsg(
// Suppress the external link icon, consider the help url an internal one
"<div class=\"mw-newarticletext plainlinks\">\n$1\n</div>",
- array(
+ [
'newarticletext',
$helpLink
- )
+ ]
);
} else {
$wgOut->wrapWikiMsg(
// Suppress the external link icon, consider the help url an internal one
"<div class=\"mw-newarticletextanon plainlinks\">\n$1\n</div>",
- array(
+ [
'newarticletextanon',
$helpLink
- )
+ ]
);
}
}
# Give a notice if the user is editing a deleted/moved page...
if ( !$this->mTitle->exists() ) {
- LogEventsList::showLogExtract( $wgOut, array( 'delete', 'move' ), $this->mTitle,
+ LogEventsList::showLogExtract( $wgOut, [ 'delete', 'move' ], $this->mTitle,
'',
- array(
+ [
'lim' => 10,
- 'conds' => array( "log_action != 'revision'" ),
+ 'conds' => [ "log_action != 'revision'" ],
'showIfEmpty' => false,
- 'msgKey' => array( 'recreate-moveddeleted-warn' )
- )
+ 'msgKey' => [ 'recreate-moveddeleted-warn' ]
+ ]
);
}
}
$previewOutput = $this->getPreviewText();
}
- Hooks::run( 'EditPage::showEditForm:initial', array( &$this, &$wgOut ) );
+ Hooks::run( 'EditPage::showEditForm:initial', [ &$this, &$wgOut ] );
$this->setHeaders();
// search for textarea1 and textares2, and allow EditForm to override all uses.
$wgOut->addHTML( Html::openElement(
'form',
- array(
+ [
'id' => self::EDITFORM_ID,
'name' => self::EDITFORM_ID,
'method' => 'post',
'action' => $this->getActionURL( $this->getContextTitle() ),
'enctype' => 'multipart/form-data'
- )
+ ]
) );
if ( is_callable( $formCallback ) ) {
wfWarn( 'The $formCallback parameter to ' . __METHOD__ . 'is deprecated' );
- call_user_func_array( $formCallback, array( &$wgOut ) );
+ call_user_func_array( $formCallback, [ &$wgOut ] );
}
// Add an empty field to trip up spambots
$wgOut->addHTML(
- Xml::openElement( 'div', array( 'id' => 'antispam-container', 'style' => 'display: none;' ) )
+ Xml::openElement( 'div', [ 'id' => 'antispam-container', 'style' => 'display: none;' ] )
. Html::rawElement(
'label',
- array( 'for' => 'wpAntiSpam' ),
+ [ 'for' => 'wpAntiSpam' ],
wfMessage( 'simpleantispam-label' )->parse()
)
. Xml::element(
'input',
- array(
+ [
'type' => 'text',
'name' => 'wpAntispam',
'id' => 'wpAntispam',
'value' => ''
- )
+ ]
)
. Xml::closeElement( 'div' )
);
- Hooks::run( 'EditPage::showEditForm:fields', array( &$this, &$wgOut ) );
+ Hooks::run( 'EditPage::showEditForm:fields', [ &$this, &$wgOut ] );
// Put these up at the top to ensure they aren't lost on early form submission
$this->showFormBeforeText();
'<div class="mw-confirm-recreate">' .
wfMessage( $key, $username, "<nowiki>$comment</nowiki>" )->parse() .
Xml::checkLabel( wfMessage( 'recreate' )->text(), 'wpRecreate', 'wpRecreate', false,
- array( 'title' => Linker::titleAttrib( 'recreate' ), 'tabindex' => 1, 'id' => 'wpRecreate' )
+ [ 'title' => Linker::titleAttrib( 'recreate' ), 'tabindex' => 1, 'id' => 'wpRecreate' ]
) .
'</div>'
);
$wgOut->addHTML( Html::hidden( 'wpAutoSummary', $autosumm ) );
$wgOut->addHTML( Html::hidden( 'oldid', $this->oldid ) );
- $wgOut->addHTML( Html::hidden( 'parentRevId',
- $this->parentRevId ?: $this->mArticle->getRevIdFetched() ) );
+ $wgOut->addHTML( Html::hidden( 'parentRevId', $this->getParentRevId() ) );
$wgOut->addHTML( Html::hidden( 'format', $this->contentFormat ) );
$wgOut->addHTML( Html::hidden( 'model', $this->contentModel ) );
$wgOut->addHTML( $this->editFormTextAfterTools . "\n" );
- $wgOut->addHTML( Html::rawElement( 'div', array( 'class' => 'templatesUsed' ),
+ $wgOut->addHTML( Html::rawElement( 'div', [ 'class' => 'templatesUsed' ],
Linker::formatTemplates( $this->getTemplates(), $this->preview, $this->section != '' ) ) );
- $wgOut->addHTML( Html::rawElement( 'div', array( 'class' => 'hiddencats' ),
- Linker::formatHiddenCategories( $this->mArticle->getHiddenCategories() ) ) );
+ $wgOut->addHTML( Html::rawElement( 'div', [ 'class' => 'hiddencats' ],
+ Linker::formatHiddenCategories( $this->page->getHiddenCategories() ) ) );
- $wgOut->addHTML( Html::rawElement( 'div', array( 'class' => 'limitreport' ),
+ $wgOut->addHTML( Html::rawElement( 'div', [ 'class' => 'limitreport' ],
self::getPreviewLimitReport( $this->mParserOutput ) ) );
$wgOut->addModules( 'mediawiki.action.edit.collapsibleFooter' );
if ( $this->isConflict ) {
$wgOut->wrapWikiMsg( "<div class='mw-explainconflict'>\n$1\n</div>", 'explainconflict' );
- $this->edittime = $this->mArticle->getTimestamp();
+ $this->edittime = $this->page->getTimestamp();
} else {
if ( $this->section != '' && !$this->isSectionEditSupported() ) {
// We use $this->section to much before this and getVal('wgSection') directly in other places
// Something went wrong
$wgOut->wrapWikiMsg( "<div class='errorbox'>\n$1\n</div>\n",
- array( 'missing-revision', $this->oldid ) );
+ [ 'missing-revision', $this->oldid ] );
}
}
}
if ( wfReadOnly() ) {
$wgOut->wrapWikiMsg(
"<div id=\"mw-read-only-warning\">\n$1\n</div>",
- array( 'readonlywarning', wfReadOnlyReason() )
+ [ 'readonlywarning', wfReadOnlyReason() ]
);
} elseif ( $wgUser->isAnon() ) {
if ( $this->formtype != 'preview' ) {
$wgOut->wrapWikiMsg(
- "<div id='mw-anon-edit-warning'>\n$1\n</div>",
- array( 'anoneditwarning',
+ "<div id='mw-anon-edit-warning' class='warningbox'>\n$1\n</div>",
+ [ 'anoneditwarning',
// Log-in link
'{{fullurl:Special:UserLogin|returnto={{FULLPAGENAMEE}}}}',
// Sign-up link
- '{{fullurl:Special:UserLogin/signup|returnto={{FULLPAGENAMEE}}}}' )
+ '{{fullurl:Special:UserLogin/signup|returnto={{FULLPAGENAMEE}}}}' ]
);
} else {
$wgOut->wrapWikiMsg( "<div id=\"mw-anon-preview-warning\">\n$1</div>",
if ( $this->isWrongCaseCssJsPage ) {
$wgOut->wrapWikiMsg(
"<div class='error' id='mw-userinvalidcssjstitle'>\n$1\n</div>",
- array( 'userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage() )
+ [ 'userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage() ]
);
}
if ( $this->getTitle()->isSubpageOf( $wgUser->getUserPage() ) ) {
if ( $this->isCssSubpage && $wgAllowUserCss ) {
$wgOut->wrapWikiMsg(
"<div id='mw-usercssyoucanpreview'>\n$1\n</div>",
- array( 'usercssyoucanpreview' )
+ [ 'usercssyoucanpreview' ]
);
}
if ( $this->isJsSubpage && $wgAllowUserJs ) {
$wgOut->wrapWikiMsg(
"<div id='mw-userjsyoucanpreview'>\n$1\n</div>",
- array( 'userjsyoucanpreview' )
+ [ 'userjsyoucanpreview' ]
);
}
}
}
if ( $this->mTitle->isProtected( 'edit' ) &&
- MWNamespace::getRestrictionLevels( $this->mTitle->getNamespace() ) !== array( '' )
+ MWNamespace::getRestrictionLevels( $this->mTitle->getNamespace() ) !== [ '' ]
) {
# Is the title semi-protected?
if ( $this->mTitle->isSemiProtected() ) {
$noticeMsg = 'protectedpagewarning';
}
LogEventsList::showLogExtract( $wgOut, 'protect', $this->mTitle, '',
- array( 'lim' => 1, 'msgKey' => array( $noticeMsg ) ) );
+ [ 'lim' => 1, 'msgKey' => [ $noticeMsg ] ] );
}
if ( $this->mTitle->isCascadeProtected() ) {
# Is this page under cascading protection from some source pages?
+ /** @var Title[] $cascadeSources */
list( $cascadeSources, /* $restrictions */ ) = $this->mTitle->getCascadeProtectionSources();
$notice = "<div class='mw-cascadeprotectedwarning'>\n$1\n";
$cascadeSourcesCount = count( $cascadeSources );
}
}
$notice .= '</div>';
- $wgOut->wrapWikiMsg( $notice, array( 'cascadeprotectedwarning', $cascadeSourcesCount ) );
+ $wgOut->wrapWikiMsg( $notice, [ 'cascadeprotectedwarning', $cascadeSourcesCount ] );
}
if ( !$this->mTitle->exists() && $this->mTitle->getRestrictions( 'create' ) ) {
LogEventsList::showLogExtract( $wgOut, 'protect', $this->mTitle, '',
- array( 'lim' => 1,
+ [ 'lim' => 1,
'showIfEmpty' => false,
- 'msgKey' => array( 'titleprotectedwarning' ),
- 'wrap' => "<div class=\"mw-titleprotectedwarning\">\n$1</div>" ) );
+ 'msgKey' => [ 'titleprotectedwarning' ],
+ 'wrap' => "<div class=\"mw-titleprotectedwarning\">\n$1</div>" ] );
}
if ( $this->kblength === false ) {
if ( $this->tooBig || $this->kblength > $wgMaxArticleSize ) {
$wgOut->wrapWikiMsg( "<div class='error' id='mw-edit-longpageerror'>\n$1\n</div>",
- array(
+ [
'longpageerror',
$wgLang->formatNum( $this->kblength ),
$wgLang->formatNum( $wgMaxArticleSize )
- )
+ ]
);
} else {
if ( !wfMessage( 'longpage-hint' )->isDisabled() ) {
$wgOut->wrapWikiMsg( "<div id='mw-edit-longpage-hint'>\n$1\n</div>",
- array(
+ [
'longpage-hint',
$wgLang->formatSize( strlen( $this->textbox1 ) ),
strlen( $this->textbox1 )
- )
+ ]
);
}
}
$inputAttrs = null, $spanLabelAttrs = null
) {
// Note: the maxlength is overridden in JS to 255 and to make it use UTF-8 bytes, not characters.
- $inputAttrs = ( is_array( $inputAttrs ) ? $inputAttrs : array() ) + array(
+ $inputAttrs = ( is_array( $inputAttrs ) ? $inputAttrs : [] ) + [
'id' => 'wpSummary',
'maxlength' => '200',
'tabindex' => '1',
'size' => 60,
'spellcheck' => 'true',
- ) + Linker::tooltipAndAccesskeyAttribs( 'summary' );
+ ] + Linker::tooltipAndAccesskeyAttribs( 'summary' );
- $spanLabelAttrs = ( is_array( $spanLabelAttrs ) ? $spanLabelAttrs : array() ) + array(
+ $spanLabelAttrs = ( is_array( $spanLabelAttrs ) ? $spanLabelAttrs : [] ) + [
'class' => $this->missingSummary ? 'mw-summarymissed' : 'mw-summary',
'id' => "wpSummaryLabel"
- );
+ ];
$label = null;
if ( $labelText ) {
$label = Xml::tags(
'label',
- $inputAttrs['id'] ? array( 'for' => $inputAttrs['id'] ) : null,
+ $inputAttrs['id'] ? [ 'for' => $inputAttrs['id'] ] : null,
$labelText
);
$label = Xml::tags( 'span', $spanLabelAttrs, $label );
$input = Html::input( 'wpSummary', $summary, 'text', $inputAttrs );
- return array( $label, $input );
+ return [ $label, $input ];
}
/**
list( $label, $input ) = $this->getSummaryInput(
$summary,
$labelText,
- array( 'class' => $summaryClass ),
- array()
+ [ 'class' => $summaryClass ],
+ []
);
$wgOut->addHTML( "{$label} {$input}" );
}
$summary = wfMessage( $message )->parse()
. Linker::commentBlock( $summary, $this->mTitle, $isSubjectPreview );
- return Xml::tags( 'div', array( 'class' => 'mw-summary-preview' ), $summary );
+ return Xml::tags( 'div', [ 'class' => 'mw-summary-preview' ], $summary );
}
protected function showFormBeforeText() {
*/
protected function showTextbox1( $customAttribs = null, $textoverride = null ) {
if ( $this->wasDeletedSinceLastEdit() && $this->formtype == 'save' ) {
- $attribs = array( 'style' => 'display:none;' );
+ $attribs = [ 'style' => 'display:none;' ];
} else {
- $classes = array(); // Textarea CSS
+ $classes = []; // Textarea CSS
if ( $this->mTitle->isProtected( 'edit' ) &&
- MWNamespace::getRestrictionLevels( $this->mTitle->getNamespace() ) !== array( '' )
+ MWNamespace::getRestrictionLevels( $this->mTitle->getNamespace() ) !== [ '' ]
) {
# Is the title semi-protected?
if ( $this->mTitle->isSemiProtected() ) {
}
}
- $attribs = array( 'tabindex' => 1 );
+ $attribs = [ 'tabindex' => 1 ];
if ( is_array( $customAttribs ) ) {
$attribs += $customAttribs;
}
protected function showTextbox2() {
- $this->showTextbox( $this->textbox2, 'wpTextbox2', array( 'tabindex' => 6, 'readonly' ) );
+ $this->showTextbox( $this->textbox2, 'wpTextbox2', [ 'tabindex' => 6, 'readonly' ] );
}
- protected function showTextbox( $text, $name, $customAttribs = array() ) {
+ protected function showTextbox( $text, $name, $customAttribs = [] ) {
global $wgOut, $wgUser;
$wikitext = $this->safeUnicodeOutput( $text );
$wikitext .= "\n";
}
- $attribs = $customAttribs + array(
+ $attribs = $customAttribs + [
'accesskey' => ',',
'id' => $name,
'cols' => $wgUser->getIntOption( 'cols' ),
// Avoid PHP notices when appending preferences
// (appending allows customAttribs['style'] to still work).
'style' => ''
- );
+ ];
$pageLang = $this->mTitle->getPageLanguage();
$attribs['lang'] = $pageLang->getHtmlCode();
protected function displayPreviewArea( $previewOutput, $isOnTop = false ) {
global $wgOut;
- $classes = array();
+ $classes = [];
if ( $isOnTop ) {
$classes[] = 'ontop';
}
- $attribs = array( 'id' => 'wikiPreview', 'class' => implode( ' ', $classes ) );
+ $attribs = [ 'id' => 'wikiPreview', 'class' => implode( ' ', $classes ) ];
if ( $this->formtype != 'preview' ) {
$attribs['style'] = 'display: none;';
} else {
// Empty content container for LivePreview
$pageViewLang = $this->mTitle->getPageViewLanguage();
- $attribs = array( 'lang' => $pageViewLang->getHtmlCode(), 'dir' => $pageViewLang->getDir(),
- 'class' => 'mw-content-' . $pageViewLang->getDir() );
+ $attribs = [ 'lang' => $pageViewLang->getHtmlCode(), 'dir' => $pageViewLang->getDir(),
+ 'class' => 'mw-content-' . $pageViewLang->getDir() ];
$wgOut->addHTML( Html::rawElement( 'div', $attribs ) );
}
}
# This hook seems slightly odd here, but makes things more
# consistent for extensions.
- Hooks::run( 'OutputPageBeforeHTML', array( &$wgOut, &$text ) );
+ Hooks::run( 'OutputPageBeforeHTML', [ &$wgOut, &$text ] );
$wgOut->addHTML( $text );
if ( $this->mTitle->getNamespace() == NS_CATEGORY ) {
$this->mArticle->closeShowCategory();
$textboxContent = $this->toEditContent( $this->textbox1 );
- $newContent = $this->mArticle->replaceSectionContent(
+ $newContent = $this->page->replaceSectionContent(
$this->section, $textboxContent,
$this->summary, $this->edittime );
if ( $newContent ) {
- ContentHandler::runLegacyHooks( 'EditPageGetDiffText', array( $this, &$newContent ) );
- Hooks::run( 'EditPageGetDiffContent', array( $this, &$newContent ) );
+ ContentHandler::runLegacyHooks( 'EditPageGetDiffText', [ $this, &$newContent ] );
+ Hooks::run( 'EditPageGetDiffContent', [ $this, &$newContent ] );
$popts = ParserOptions::newFromUserAndLang( $wgUser, $wgContLang );
$newContent = $newContent->preSaveTransform( $this->mTitle, $wgUser, $popts );
*/
protected function showTosSummary() {
$msg = 'editpage-tos-summary';
- Hooks::run( 'EditPageTosSummary', array( $this->mTitle, &$msg ) );
+ Hooks::run( 'EditPageTosSummary', [ $this->mTitle, &$msg ] );
if ( !wfMessage( $msg )->isDisabled() ) {
global $wgOut;
$wgOut->addHTML( '<div class="mw-tos-summary">' );
public static function getCopyrightWarning( $title, $format = 'plain' ) {
global $wgRightsText;
if ( $wgRightsText ) {
- $copywarnMsg = array( 'copyrightwarning',
+ $copywarnMsg = [ 'copyrightwarning',
'[[' . wfMessage( 'copyrightpage' )->inContentLanguage()->text() . ']]',
- $wgRightsText );
+ $wgRightsText ];
} else {
- $copywarnMsg = array( 'copyrightwarning2',
- '[[' . wfMessage( 'copyrightpage' )->inContentLanguage()->text() . ']]' );
+ $copywarnMsg = [ 'copyrightwarning2',
+ '[[' . wfMessage( 'copyrightpage' )->inContentLanguage()->text() . ']]' ];
}
// Allow for site and per-namespace customization of contribution/copyright notice.
- Hooks::run( 'EditPageCopyrightWarning', array( $title, &$copywarnMsg ) );
+ Hooks::run( 'EditPageCopyrightWarning', [ $title, &$copywarnMsg ] );
return "<div id=\"editpage-copywarn\">\n" .
call_user_func_array( 'wfMessage', $copywarnMsg )->$format() . "\n</div>";
return '';
}
- $limitReport = Html::rawElement( 'div', array( 'class' => 'mw-limitReportExplanation' ),
+ $limitReport = Html::rawElement( 'div', [ 'class' => 'mw-limitReportExplanation' ],
wfMessage( 'limitreport-title' )->parseAsBlock()
);
// Show/hide animation doesn't work correctly on a table, so wrap it in a div.
- $limitReport .= Html::openElement( 'div', array( 'class' => 'preview-limit-report-wrapper' ) );
+ $limitReport .= Html::openElement( 'div', [ 'class' => 'preview-limit-report-wrapper' ] );
- $limitReport .= Html::openElement( 'table', array(
+ $limitReport .= Html::openElement( 'table', [
'class' => 'preview-limit-report wikitable'
- ) ) .
+ ] ) .
Html::openElement( 'tbody' );
foreach ( $output->getLimitReportData() as $key => $value ) {
if ( Hooks::run( 'ParserLimitReportFormat',
- array( $key, &$value, &$limitReport, true, true )
+ [ $key, &$value, &$limitReport, true, true ]
) ) {
$keyMsg = wfMessage( $key );
- $valueMsg = wfMessage( array( "$key-value-html", "$key-value" ) );
+ $valueMsg = wfMessage( [ "$key-value-html", "$key-value" ] );
if ( !$valueMsg->exists() ) {
$valueMsg = new RawMessage( '$1' );
}
}
$checkboxes = $this->getCheckboxes( $tabindex,
- array( 'minor' => $this->minoredit, 'watch' => $this->watchthis ) );
+ [ 'minor' => $this->minoredit, 'watch' => $this->watchthis ] );
$wgOut->addHTML( "<div class='editCheckboxes'>" . implode( $checkboxes, "\n" ) . "</div>\n" );
// Show copyright warning.
$cancel = $this->getCancelLink();
if ( $cancel !== '' ) {
$cancel .= Html::element( 'span',
- array( 'class' => 'mw-editButtons-pipe-separator' ),
+ [ 'class' => 'mw-editButtons-pipe-separator' ],
wfMessage( 'pipe-separator' )->text() );
}
$message = wfMessage( 'edithelppage' )->inContentLanguage()->text();
$edithelpurl = Skin::makeInternalOrExternalUrl( $message );
- $attrs = array(
+ $attrs = [
'target' => 'helpwindow',
'href' => $edithelpurl,
- );
+ ];
$edithelp = Html::linkButton( wfMessage( 'edithelp' )->text(),
- $attrs, array( 'mw-ui-quiet' ) ) .
+ $attrs, [ 'mw-ui-quiet' ] ) .
wfMessage( 'word-separator' )->escaped() .
wfMessage( 'newwindow' )->parse();
$wgOut->addHTML( " <span class='editHelp'>{$edithelp}</span>\n" );
$wgOut->addHTML( "</div><!-- editButtons -->\n" );
- Hooks::run( 'EditPage::showStandardInputs:options', array( $this, $wgOut, &$tabindex ) );
+ Hooks::run( 'EditPage::showStandardInputs:options', [ $this, $wgOut, &$tabindex ] );
$wgOut->addHTML( "</div><!-- editOptions -->\n" );
}
protected function showConflict() {
global $wgOut;
- if ( Hooks::run( 'EditPageBeforeConflictDiff', array( &$this, &$wgOut ) ) ) {
+ if ( Hooks::run( 'EditPageBeforeConflictDiff', [ &$this, &$wgOut ] ) ) {
+ $stats = $wgOut->getContext()->getStats();
+ $stats->increment( 'edit.failures.conflict' );
+
$wgOut->wrapWikiMsg( '<h2>$1</h2>', "yourdiff" );
$content1 = $this->toEditContent( $this->textbox1 );
* @return string
*/
public function getCancelLink() {
- $cancelParams = array();
+ $cancelParams = [];
if ( !$this->isConflict && $this->oldid > 0 ) {
$cancelParams['oldid'] = $this->oldid;
}
- $attrs = array( 'id' => 'mw-editform-cancel' );
+ $attrs = [ 'id' => 'mw-editform-cancel' ];
return Linker::linkKnown(
$this->getContextTitle(),
wfMessage( 'cancel' )->parse(),
- Html::buttonAttributes( $attrs, array( 'mw-ui-quiet' ) ),
+ Html::buttonAttributes( $attrs, [ 'mw-ui-quiet' ] ),
$cancelParams
);
}
* @return string
*/
protected function getActionURL( Title $title ) {
- return $title->getLocalURL( array( 'action' => $this->action ) );
+ return $title->getLocalURL( [ 'action' => $this->action ] );
}
/**
protected function getLastDelete() {
$dbr = wfGetDB( DB_SLAVE );
$data = $dbr->selectRow(
- array( 'logging', 'user' ),
- array(
+ [ 'logging', 'user' ],
+ [
'log_type',
'log_action',
'log_timestamp',
'log_params',
'log_deleted',
'user_name'
- ), array(
+ ], [
'log_namespace' => $this->mTitle->getNamespace(),
'log_title' => $this->mTitle->getDBkey(),
'log_type' => 'delete',
'log_action' => 'delete',
'user_id=log_user'
- ),
+ ],
__METHOD__,
- array( 'LIMIT' => 1, 'ORDER BY' => 'log_timestamp DESC' )
+ [ 'LIMIT' => 1, 'ORDER BY' => 'log_timestamp DESC' ]
);
// Quick paranoid permission checks...
if ( is_object( $data ) ) {
$previewHTML = '';
if ( !Hooks::run(
'AlternateEditPreview',
- array( $this, &$content, &$previewHTML, &$this->mParserOutput ) )
+ [ $this, &$content, &$previewHTML, &$this->mParserOutput ] )
) {
return $previewHTML;
}
$note = wfMessage( 'previewnote' )->plain() . ' ' . $continueEditing;
}
- $parserOptions = $this->mArticle->makeParserOptions( $this->mArticle->getContext() );
+ $parserOptions = $this->page->makeParserOptions( $this->mArticle->getContext() );
$parserOptions->setIsPreview( true );
$parserOptions->setIsSectionPreview( !is_null( $this->section ) && $this->section !== '' );
$content = $content->addSectionHeader( $this->summary );
}
- $hook_args = array( $this, &$content );
+ $hook_args = [ $this, &$content ];
ContentHandler::runLegacyHooks( 'EditPageGetPreviewText', $hook_args );
Hooks::run( 'EditPageGetPreviewContent', $hook_args );
if ( count( $parserOutput->getWarnings() ) ) {
$note .= "\n\n" . implode( "\n\n", $parserOutput->getWarnings() );
}
+
+ ScopedCallback::consume( $scopedCallback );
} catch ( MWContentSerializationException $ex ) {
$m = wfMessage(
'content-failed-to-parse',
$wgOut->parse( $note, true, /* interface */true ) . $conflict . "</div>\n";
$pageViewLang = $this->mTitle->getPageViewLanguage();
- $attribs = array( 'lang' => $pageViewLang->getHtmlCode(), 'dir' => $pageViewLang->getDir(),
- 'class' => 'mw-content-' . $pageViewLang->getDir() );
+ $attribs = [ 'lang' => $pageViewLang->getHtmlCode(), 'dir' => $pageViewLang->getDir(),
+ 'class' => 'mw-content-' . $pageViewLang->getDir() ];
$previewHTML = Html::rawElement( 'div', $attribs, $previewHTML );
return $previewhead . $previewHTML . $this->previewTextAfterContent;
*/
function getTemplates() {
if ( $this->preview || $this->section != '' ) {
- $templates = array();
+ $templates = [];
if ( !isset( $this->mParserOutput ) ) {
return $templates;
}
*
* Images are defined in ResourceLoaderEditToolbarModule.
*/
- $toolarray = array(
- array(
+ $toolarray = [
+ [
'id' => 'mw-editbutton-bold',
'open' => '\'\'\'',
'close' => '\'\'\'',
'sample' => wfMessage( 'bold_sample' )->text(),
'tip' => wfMessage( 'bold_tip' )->text(),
- ),
- array(
+ ],
+ [
'id' => 'mw-editbutton-italic',
'open' => '\'\'',
'close' => '\'\'',
'sample' => wfMessage( 'italic_sample' )->text(),
'tip' => wfMessage( 'italic_tip' )->text(),
- ),
- array(
+ ],
+ [
'id' => 'mw-editbutton-link',
'open' => '[[',
'close' => ']]',
'sample' => wfMessage( 'link_sample' )->text(),
'tip' => wfMessage( 'link_tip' )->text(),
- ),
- array(
+ ],
+ [
'id' => 'mw-editbutton-extlink',
'open' => '[',
'close' => ']',
'sample' => wfMessage( 'extlink_sample' )->text(),
'tip' => wfMessage( 'extlink_tip' )->text(),
- ),
- array(
+ ],
+ [
'id' => 'mw-editbutton-headline',
'open' => "\n== ",
'close' => " ==\n",
'sample' => wfMessage( 'headline_sample' )->text(),
'tip' => wfMessage( 'headline_tip' )->text(),
- ),
- $imagesAvailable ? array(
+ ],
+ $imagesAvailable ? [
'id' => 'mw-editbutton-image',
'open' => '[[' . $wgContLang->getNsText( NS_FILE ) . ':',
'close' => ']]',
'sample' => wfMessage( 'image_sample' )->text(),
'tip' => wfMessage( 'image_tip' )->text(),
- ) : false,
- $imagesAvailable ? array(
+ ] : false,
+ $imagesAvailable ? [
'id' => 'mw-editbutton-media',
'open' => '[[' . $wgContLang->getNsText( NS_MEDIA ) . ':',
'close' => ']]',
'sample' => wfMessage( 'media_sample' )->text(),
'tip' => wfMessage( 'media_tip' )->text(),
- ) : false,
- array(
+ ] : false,
+ [
'id' => 'mw-editbutton-nowiki',
'open' => "<nowiki>",
'close' => "</nowiki>",
'sample' => wfMessage( 'nowiki_sample' )->text(),
'tip' => wfMessage( 'nowiki_tip' )->text(),
- ),
- $showSignature ? array(
+ ],
+ $showSignature ? [
'id' => 'mw-editbutton-signature',
'open' => '--~~~~',
'close' => '',
'sample' => '',
'tip' => wfMessage( 'sig_tip' )->text(),
- ) : false,
- array(
+ ] : false,
+ [
'id' => 'mw-editbutton-hr',
'open' => "\n----\n",
'close' => '',
'sample' => '',
'tip' => wfMessage( 'hr_tip' )->text(),
- )
- );
+ ]
+ ];
$script = 'mw.loader.using("mediawiki.toolbar", function () {';
foreach ( $toolarray as $tool ) {
continue;
}
- $params = array(
+ $params = [
// Images are defined in ResourceLoaderEditToolbarModule
false,
// Note that we use the tip both for the ALT tag and the TITLE tag of the image.
$tool['close'],
$tool['sample'],
$tool['id'],
- );
+ ];
$script .= Xml::encodeJsCall(
'mw.toolbar.addButton',
$toolbar = '<div id="toolbar"></div>';
- Hooks::run( 'EditPageBeforeEditToolbar', array( &$toolbar ) );
+ Hooks::run( 'EditPageBeforeEditToolbar', [ &$toolbar ] );
return $toolbar;
}
public function getCheckboxes( &$tabindex, $checked ) {
global $wgUser, $wgUseMediaWikiUIEverywhere;
- $checkboxes = array();
+ $checkboxes = [];
// don't show the minor edit checkbox if it's a new page or section
if ( !$this->isNew ) {
$checkboxes['minor'] = '';
$minorLabel = wfMessage( 'minoredit' )->parse();
if ( $wgUser->isAllowed( 'minoredit' ) ) {
- $attribs = array(
+ $attribs = [
'tabindex' => ++$tabindex,
'accesskey' => wfMessage( 'accesskey-minoredit' )->text(),
'id' => 'wpMinoredit',
- );
+ ];
$minorEditHtml =
Xml::check( 'wpMinoredit', $checked['minor'], $attribs ) .
" <label for='wpMinoredit' id='mw-editpage-minoredit'" .
- Xml::expandAttributes( array( 'title' => Linker::titleAttrib( 'minoredit', 'withaccess' ) ) ) .
+ Xml::expandAttributes( [ 'title' => Linker::titleAttrib( 'minoredit', 'withaccess' ) ] ) .
">{$minorLabel}</label>";
if ( $wgUseMediaWikiUIEverywhere ) {
- $checkboxes['minor'] = Html::openElement( 'div', array( 'class' => 'mw-ui-checkbox' ) ) .
+ $checkboxes['minor'] = Html::openElement( 'div', [ 'class' => 'mw-ui-checkbox' ] ) .
$minorEditHtml .
Html::closeElement( 'div' );
} else {
$watchLabel = wfMessage( 'watchthis' )->parse();
$checkboxes['watch'] = '';
if ( $wgUser->isLoggedIn() ) {
- $attribs = array(
+ $attribs = [
'tabindex' => ++$tabindex,
'accesskey' => wfMessage( 'accesskey-watch' )->text(),
'id' => 'wpWatchthis',
- );
+ ];
$watchThisHtml =
Xml::check( 'wpWatchthis', $checked['watch'], $attribs ) .
" <label for='wpWatchthis' id='mw-editpage-watch'" .
- Xml::expandAttributes( array( 'title' => Linker::titleAttrib( 'watch', 'withaccess' ) ) ) .
+ Xml::expandAttributes( [ 'title' => Linker::titleAttrib( 'watch', 'withaccess' ) ] ) .
">{$watchLabel}</label>";
if ( $wgUseMediaWikiUIEverywhere ) {
- $checkboxes['watch'] = Html::openElement( 'div', array( 'class' => 'mw-ui-checkbox' ) ) .
+ $checkboxes['watch'] = Html::openElement( 'div', [ 'class' => 'mw-ui-checkbox' ] ) .
$watchThisHtml .
Html::closeElement( 'div' );
} else {
$checkboxes['watch'] = $watchThisHtml;
}
}
- Hooks::run( 'EditPageBeforeEditChecks', array( &$this, &$checkboxes, &$tabindex ) );
+ Hooks::run( 'EditPageBeforeEditChecks', [ &$this, &$checkboxes, &$tabindex ] );
return $checkboxes;
}
* @return array
*/
public function getEditButtons( &$tabindex ) {
- $buttons = array();
+ $buttons = [];
- $attribs = array(
+ $attribs = [
'id' => 'wpSave',
'name' => 'wpSave',
'tabindex' => ++$tabindex,
- ) + Linker::tooltipAndAccesskeyAttribs( 'save' );
+ ] + Linker::tooltipAndAccesskeyAttribs( 'save' );
$buttons['save'] = Html::submitButton( wfMessage( 'savearticle' )->text(),
- $attribs, array( 'mw-ui-constructive' ) );
+ $attribs, [ 'mw-ui-constructive' ] );
++$tabindex; // use the same for preview and live preview
- $attribs = array(
+ $attribs = [
'id' => 'wpPreview',
'name' => 'wpPreview',
'tabindex' => $tabindex,
- ) + Linker::tooltipAndAccesskeyAttribs( 'preview' );
+ ] + Linker::tooltipAndAccesskeyAttribs( 'preview' );
$buttons['preview'] = Html::submitButton( wfMessage( 'showpreview' )->text(),
$attribs );
$buttons['live'] = '';
- $attribs = array(
+ $attribs = [
'id' => 'wpDiff',
'name' => 'wpDiff',
'tabindex' => ++$tabindex,
- ) + Linker::tooltipAndAccesskeyAttribs( 'diff' );
+ ] + Linker::tooltipAndAccesskeyAttribs( 'diff' );
$buttons['diff'] = Html::submitButton( wfMessage( 'showdiff' )->text(),
$attribs );
- Hooks::run( 'EditPageBeforeEditButtons', array( &$this, &$buttons, &$tabindex ) );
+ Hooks::run( 'EditPageBeforeEditButtons', [ &$this, &$buttons, &$tabindex ] );
return $buttons;
}
$wgOut->prepareErrorPage( wfMessage( 'nosuchsectiontitle' ) );
$res = wfMessage( 'nosuchsectiontext', $this->section )->parseAsBlock();
- Hooks::run( 'EditPageNoSuchSection', array( &$this, &$res ) );
+ Hooks::run( 'EditPageNoSuchSection', [ &$this, &$res ] );
$wgOut->addHTML( $res );
$wgOut->returnToMain( false, $this->mTitle );
$wgOut->wrapWikiMsg( '<h2>$1</h2>', "yourtext" );
$this->showTextbox2();
- $wgOut->addReturnTo( $this->getContextTitle(), array( 'action' => 'edit' ) );
+ $wgOut->addReturnTo( $this->getContextTitle(), [ 'action' => 'edit' ] );
}
/**
*/
private function makeSafe( $invalue ) {
// Armor existing references for reversibility.
- $invalue = strtr( $invalue, array( "&#x" => "�" ) );
+ $invalue = strtr( $invalue, [ "&#x" => "�" ] );
$bytesleft = 0;
$result = "";
}
}
// reverse the transform that we made for reversibility reasons.
- return strtr( $result, array( "�" => "&#x" ) );
+ return strtr( $result, [ "�" => "&#x" ] );
}
}