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;
}
}
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' )
protected function displayViewSourcePage( Content $content, $errorMessage = '' ) {
global $wgOut;
- Hooks::run( 'EditPage::showReadOnlyForm:initial', array( $this, &$wgOut ) );
+ Hooks::run( 'EditPage::showReadOnlyForm:initial', [ $this, &$wgOut ] );
$wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->setPageTitle( wfMessage(
}
$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 ] );
}
$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 );
}
*
* @since 1.21
*/
- protected function getPreloadedContent( $preload, $params = array() ) {
+ protected function getPreloadedContent( $preload, $params = [] ) {
global $wgUser;
if ( !empty( $this->mPreloadContent ) ) {
}
$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' );
// 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
if ( $changingContentModel ) {
$this->addContentModelChangeLogEntry(
$wgUser,
- $oldContentModel,
+ $new ? false : $oldContentModel,
$this->contentModel,
$this->summary
);
/**
* @param User $user
- * @param string $oldModel
+ * @param string|false $oldModel false if the page is being newly created
* @param string $newModel
* @param string $reason
*/
protected function addContentModelChangeLogEntry( User $user, $oldModel, $newModel, $reason ) {
- $log = new ManualLogEntry( 'contentmodel', 'change' );
+ $new = $oldModel === false;
+ $log = new ManualLogEntry( 'contentmodel', $new ? 'new' : 'change' );
$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 );
}
*/
protected static function matchSpamRegexInternal( $text, $regexes ) {
foreach ( $regexes as $regex ) {
- $matches = array();
+ $matches = [];
if ( preg_match( $regex, $text, $matches ) ) {
return $matches[0];
}
# 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
- ) );
+ ] );
}
}
}
# Show a warning message when someone creates/edits a user (talk) page but the user does not exist
# Show log extract when the user is currently blocked
if ( $namespace == NS_USER || $namespace == NS_USER_TALK ) {
- $parts = explode( '/', $this->mTitle->getText(), 2 );
- $username = $parts[0];
+ $username = explode( '/', $this->mTitle->getText(), 2 )[0];
$user = User::newFromName( $username, false /* allow IP users*/ );
$ip = User::isIP( $username );
$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( $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' ),
+ $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' );
// 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?
}
}
$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();
$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' );
* @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;
}
$content = $content->addSectionHeader( $this->summary );
}
- $hook_args = array( $this, &$content );
+ $hook_args = [ $this, &$content ];
ContentHandler::runLegacyHooks( 'EditPageGetPreviewText', $hook_args );
Hooks::run( 'EditPageGetPreviewContent', $hook_args );
$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" ] );
}
}