X-Git-Url: https://git.cyclocoop.org/%242?a=blobdiff_plain;f=includes%2FEditPage.php;h=b5d0a7b017fe82f490ef688ef904fee76edabcb6;hb=d9a3ae564cc835e3e23bab49d9515ee1e69bcaee;hp=277a6cc6d8bc2d3346a98c89b54ecc6a0ed18f54;hpb=74174fca253b9a759d7402f09b7fc37d5de0e9be;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/EditPage.php b/includes/EditPage.php
index 277a6cc6d8..b5d0a7b017 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -366,7 +366,7 @@ class EditPage {
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
@@ -490,7 +490,7 @@ class EditPage {
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;
}
@@ -589,9 +589,9 @@ class EditPage {
}
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 ] );
}
}
@@ -618,7 +618,7 @@ class EditPage {
);
}
# 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' )
@@ -678,7 +678,7 @@ class EditPage {
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(
@@ -711,10 +711,10 @@ class EditPage {
}
$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' );
@@ -768,7 +768,7 @@ class EditPage {
$name = $this->mTitle->getSkinFromCssJsSubpage();
$skins = array_merge(
array_keys( Skin::getSkinNames() ),
- array( 'common' )
+ [ 'common' ]
);
return !in_array( $name, $skins )
&& in_array( strtolower( $name ), $skins );
@@ -922,7 +922,7 @@ class EditPage {
$changeTags = $request->getVal( 'wpChangeTags' );
if ( is_null( $changeTags ) || $changeTags === '' ) {
- $this->changeTags = array();
+ $this->changeTags = [];
} else {
$this->changeTags = array_filter( array_map( 'trim', explode( ',',
$changeTags ) ) );
@@ -979,7 +979,7 @@ class EditPage {
throw new ErrorPageError(
'editpage-notsupportedcontentformat-title',
'editpage-notsupportedcontentformat-text',
- array( $this->contentFormat, ContentHandler::getLocalizedName( $this->contentModel ) )
+ [ $this->contentFormat, ContentHandler::getLocalizedName( $this->contentModel ) ]
);
}
@@ -994,7 +994,7 @@ class EditPage {
$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 ] );
}
@@ -1073,7 +1073,7 @@ class EditPage {
$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 );
}
@@ -1272,7 +1272,7 @@ class EditPage {
*
* @since 1.21
*/
- protected function getPreloadedContent( $preload, $params = array() ) {
+ protected function getPreloadedContent( $preload, $params = [] ) {
global $wgUser;
if ( !empty( $this->mPreloadContent ) ) {
@@ -1372,9 +1372,9 @@ class EditPage {
}
$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,
- ) );
+ ] );
}
/**
@@ -1390,7 +1390,7 @@ class EditPage {
$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;
}
@@ -1420,6 +1420,11 @@ class EditPage {
}
}
+ // "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:
@@ -1443,6 +1448,13 @@ class EditPage {
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;
@@ -1454,7 +1466,7 @@ class EditPage {
// 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'] ) {
@@ -1464,6 +1476,14 @@ class EditPage {
$extraQuery = 'redirect=no&' . $extraQuery;
}
}
+ if ( $extraQueryRedirect ) {
+ if ( $extraQuery === '' ) {
+ $extraQuery = $extraQueryRedirect;
+ } else {
+ $extraQuery = $extraQuery . '&' . $extraQueryRedirect;
+ }
+ }
+
$wgOut->redirect( $this->mTitle->getFullURL( $extraQuery ) . $sectionanchor );
return false;
@@ -1518,7 +1538,7 @@ class EditPage {
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' );
@@ -1533,8 +1553,8 @@ class EditPage {
// 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() ) {
@@ -1623,7 +1643,7 @@ class EditPage {
$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;
@@ -1700,7 +1720,7 @@ class EditPage {
}
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' );
@@ -2013,7 +2033,8 @@ class EditPage {
$flags,
false,
$wgUser,
- $content->getDefaultFormat()
+ $content->getDefaultFormat(),
+ $this->changeTags
);
if ( !$doEditStatus->isOK() ) {
@@ -2022,7 +2043,7 @@ class EditPage {
// 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
@@ -2040,17 +2061,6 @@ class EditPage {
$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(
@@ -2075,10 +2085,10 @@ class EditPage {
$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 );
}
@@ -2198,7 +2208,7 @@ class EditPage {
*/
protected static function matchSpamRegexInternal( $text, $regexes ) {
foreach ( $regexes as $regex ) {
- $matches = array();
+ $matches = [];
if ( preg_match( $regex, $text, $matches ) ) {
return $matches[0];
}
@@ -2232,8 +2242,6 @@ class EditPage {
$wgOut->addModules( 'mediawiki.action.edit.stash' );
}
- $wgOut->setRobotPolicy( 'noindex,nofollow' );
-
# Enabled article-related sidebar, toplinks, etc.
$wgOut->setArticleRelated( true );
@@ -2297,13 +2305,13 @@ class EditPage {
# there must be a description url to show a hint to shared repo
if ( $descUrl ) {
if ( !$this->mTitle->exists() ) {
- $wgOut->wrapWikiMsg( "
\n$1\n
", array(
+ $wgOut->wrapWikiMsg( "\n$1\n
", [
'sharedupload-desc-create', $file->getRepo()->getDisplayName(), $descUrl
- ) );
+ ] );
} else {
- $wgOut->wrapWikiMsg( "\n$1\n
", array(
+ $wgOut->wrapWikiMsg( "\n$1\n
", [
'sharedupload-desc-edit', $file->getRepo()->getDisplayName(), $descUrl
- ) );
+ ] );
}
}
}
@@ -2319,7 +2327,7 @@ class EditPage {
$block = Block::newFromTarget( $user, $user );
if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist
$wgOut->wrapWikiMsg( "\n$1\n
",
- 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(
@@ -2327,14 +2335,14 @@ class EditPage {
'block',
MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget(),
'',
- array(
+ [
'lim' => 1,
'showIfEmpty' => false,
- 'msgKey' => array(
+ 'msgKey' => [
'blocked-notice-logextract',
$user->getName() # Support GENDER in notice
- )
- )
+ ]
+ ]
);
}
}
@@ -2347,32 +2355,32 @@ class EditPage {
$wgOut->wrapWikiMsg(
// Suppress the external link icon, consider the help url an internal one
"\n$1\n
",
- array(
+ [
'newarticletext',
$helpLink
- )
+ ]
);
} else {
$wgOut->wrapWikiMsg(
// Suppress the external link icon, consider the help url an internal one
"\n$1\n
",
- 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' ]
+ ]
);
}
}
@@ -2481,7 +2489,7 @@ class EditPage {
$previewOutput = $this->getPreviewText();
}
- Hooks::run( 'EditPage::showEditForm:initial', array( &$this, &$wgOut ) );
+ Hooks::run( 'EditPage::showEditForm:initial', [ &$this, &$wgOut ] );
$this->setHeaders();
@@ -2513,41 +2521,41 @@ class EditPage {
// 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();
@@ -2565,7 +2573,7 @@ class EditPage {
'' .
wfMessage( $key, $username, "$comment " )->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' ]
) .
'
'
);
@@ -2653,13 +2661,13 @@ class EditPage {
$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' );
@@ -2806,7 +2814,7 @@ class EditPage {
// Something went wrong
$wgOut->wrapWikiMsg( "\n$1\n
\n",
- array( 'missing-revision', $this->oldid ) );
+ [ 'missing-revision', $this->oldid ] );
}
}
}
@@ -2814,17 +2822,17 @@ class EditPage {
if ( wfReadOnly() ) {
$wgOut->wrapWikiMsg(
"\n$1\n
",
- array( 'readonlywarning', wfReadOnlyReason() )
+ [ 'readonlywarning', wfReadOnlyReason() ]
);
} elseif ( $wgUser->isAnon() ) {
if ( $this->formtype != 'preview' ) {
$wgOut->wrapWikiMsg(
- "\n$1\n
",
- array( 'anoneditwarning',
+ "\n$1\n
",
+ [ '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( "\n$1
",
@@ -2837,7 +2845,7 @@ class EditPage {
if ( $this->isWrongCaseCssJsPage ) {
$wgOut->wrapWikiMsg(
"\n$1\n
",
- array( 'userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage() )
+ [ 'userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage() ]
);
}
if ( $this->getTitle()->isSubpageOf( $wgUser->getUserPage() ) ) {
@@ -2845,14 +2853,14 @@ class EditPage {
if ( $this->isCssSubpage && $wgAllowUserCss ) {
$wgOut->wrapWikiMsg(
"\n$1\n
",
- array( 'usercssyoucanpreview' )
+ [ 'usercssyoucanpreview' ]
);
}
if ( $this->isJsSubpage && $wgAllowUserJs ) {
$wgOut->wrapWikiMsg(
"\n$1\n
",
- array( 'userjsyoucanpreview' )
+ [ 'userjsyoucanpreview' ]
);
}
}
@@ -2861,7 +2869,7 @@ class EditPage {
}
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() ) {
@@ -2871,7 +2879,7 @@ class EditPage {
$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?
@@ -2886,14 +2894,14 @@ class EditPage {
}
}
$notice .= '';
- $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' => "\n$1
" ) );
+ 'msgKey' => [ 'titleprotectedwarning' ],
+ 'wrap' => "\n$1
" ] );
}
if ( $this->kblength === false ) {
@@ -2902,20 +2910,20 @@ class EditPage {
if ( $this->tooBig || $this->kblength > $wgMaxArticleSize ) {
$wgOut->wrapWikiMsg( "\n$1\n
",
- array(
+ [
'longpageerror',
$wgLang->formatNum( $this->kblength ),
$wgLang->formatNum( $wgMaxArticleSize )
- )
+ ]
);
} else {
if ( !wfMessage( 'longpage-hint' )->isDisabled() ) {
$wgOut->wrapWikiMsg( "\n$1\n
",
- array(
+ [
'longpage-hint',
$wgLang->formatSize( strlen( $this->textbox1 ) ),
strlen( $this->textbox1 )
- )
+ ]
);
}
}
@@ -2943,24 +2951,24 @@ class EditPage {
$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 );
@@ -2968,7 +2976,7 @@ class EditPage {
$input = Html::input( 'wpSummary', $summary, 'text', $inputAttrs );
- return array( $label, $input );
+ return [ $label, $input ];
}
/**
@@ -2995,8 +3003,8 @@ class EditPage {
list( $label, $input ) = $this->getSummaryInput(
$summary,
$labelText,
- array( 'class' => $summaryClass ),
- array()
+ [ 'class' => $summaryClass ],
+ []
);
$wgOut->addHTML( "{$label} {$input}" );
}
@@ -3026,7 +3034,7 @@ class EditPage {
$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() {
@@ -3084,11 +3092,11 @@ HTML
*/
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() ) {
@@ -3103,7 +3111,7 @@ HTML
}
}
- $attribs = array( 'tabindex' => 1 );
+ $attribs = [ 'tabindex' => 1 ];
if ( is_array( $customAttribs ) ) {
$attribs += $customAttribs;
@@ -3125,10 +3133,10 @@ HTML
}
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 );
@@ -3140,7 +3148,7 @@ HTML
$wikitext .= "\n";
}
- $attribs = $customAttribs + array(
+ $attribs = $customAttribs + [
'accesskey' => ',',
'id' => $name,
'cols' => $wgUser->getIntOption( 'cols' ),
@@ -3148,7 +3156,7 @@ HTML
// Avoid PHP notices when appending preferences
// (appending allows customAttribs['style'] to still work).
'style' => ''
- );
+ ];
$pageLang = $this->mTitle->getPageLanguage();
$attribs['lang'] = $pageLang->getHtmlCode();
@@ -3159,12 +3167,12 @@ HTML
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;';
@@ -3177,8 +3185,8 @@ HTML
} 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 ) );
}
@@ -3212,7 +3220,7 @@ HTML
}
# 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();
@@ -3250,8 +3258,8 @@ HTML
$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 );
@@ -3303,7 +3311,7 @@ HTML
*/
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( '' );
@@ -3339,15 +3347,15 @@ HTML
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 "
\n" .
call_user_func_array( 'wfMessage', $copywarnMsg )->$format() . "\n
";
@@ -3365,24 +3373,24 @@ HTML
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' );
}
@@ -3412,7 +3420,7 @@ HTML
}
$checkboxes = $this->getCheckboxes( $tabindex,
- array( 'minor' => $this->minoredit, 'watch' => $this->watchthis ) );
+ [ 'minor' => $this->minoredit, 'watch' => $this->watchthis ] );
$wgOut->addHTML( "
" . implode( $checkboxes, "\n" ) . "
\n" );
// Show copyright warning.
@@ -3425,18 +3433,18 @@ HTML
$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();
@@ -3444,7 +3452,7 @@ HTML
$wgOut->addHTML( "
{$edithelp} \n" );
$wgOut->addHTML( "
\n" );
- Hooks::run( 'EditPage::showStandardInputs:options', array( $this, $wgOut, &$tabindex ) );
+ Hooks::run( 'EditPage::showStandardInputs:options', [ $this, $wgOut, &$tabindex ] );
$wgOut->addHTML( "\n" );
}
@@ -3456,7 +3464,7 @@ HTML
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' );
@@ -3482,16 +3490,16 @@ HTML
* @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
);
}
@@ -3506,7 +3514,7 @@ HTML
* @return string
*/
protected function getActionURL( Title $title ) {
- return $title->getLocalURL( array( 'action' => $this->action ) );
+ return $title->getLocalURL( [ 'action' => $this->action ] );
}
/**
@@ -3542,8 +3550,8 @@ HTML
protected function getLastDelete() {
$dbr = wfGetDB( DB_SLAVE );
$data = $dbr->selectRow(
- array( 'logging', 'user' ),
- array(
+ [ 'logging', 'user' ],
+ [
'log_type',
'log_action',
'log_timestamp',
@@ -3554,15 +3562,15 @@ HTML
'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 ) ) {
@@ -3612,7 +3620,7 @@ HTML
$previewHTML = '';
if ( !Hooks::run(
'AlternateEditPreview',
- array( $this, &$content, &$previewHTML, &$this->mParserOutput ) )
+ [ $this, &$content, &$previewHTML, &$this->mParserOutput ] )
) {
return $previewHTML;
}
@@ -3681,7 +3689,7 @@ HTML
$content = $content->addSectionHeader( $this->summary );
}
- $hook_args = array( $this, &$content );
+ $hook_args = [ $this, &$content ];
ContentHandler::runLegacyHooks( 'EditPageGetPreviewText', $hook_args );
Hooks::run( 'EditPageGetPreviewContent', $hook_args );
@@ -3735,8 +3743,8 @@ HTML
$wgOut->parse( $note, true, /* interface */true ) . $conflict . "\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;
@@ -3747,7 +3755,7 @@ HTML
*/
function getTemplates() {
if ( $this->preview || $this->section != '' ) {
- $templates = array();
+ $templates = [];
if ( !isset( $this->mParserOutput ) ) {
return $templates;
}
@@ -3788,78 +3796,78 @@ HTML
*
* 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' => "",
'close' => " ",
'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 ) {
@@ -3867,7 +3875,7 @@ HTML
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.
@@ -3879,7 +3887,7 @@ HTML
$tool['close'],
$tool['sample'],
$tool['id'],
- );
+ ];
$script .= Xml::encodeJsCall(
'mw.toolbar.addButton',
@@ -3893,7 +3901,7 @@ HTML
$toolbar = '
';
- Hooks::run( 'EditPageBeforeEditToolbar', array( &$toolbar ) );
+ Hooks::run( 'EditPageBeforeEditToolbar', [ &$toolbar ] );
return $toolbar;
}
@@ -3911,26 +3919,26 @@ HTML
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 ) .
" Linker::titleAttrib( 'minoredit', 'withaccess' ) ) ) .
+ Xml::expandAttributes( [ 'title' => Linker::titleAttrib( 'minoredit', 'withaccess' ) ] ) .
">{$minorLabel} ";
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 {
@@ -3942,25 +3950,25 @@ HTML
$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 ) .
" Linker::titleAttrib( 'watch', 'withaccess' ) ) ) .
+ Xml::expandAttributes( [ 'title' => Linker::titleAttrib( 'watch', 'withaccess' ) ] ) .
">{$watchLabel} ";
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;
}
@@ -3973,35 +3981,35 @@ HTML
* @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;
}
@@ -4015,7 +4023,7 @@ HTML
$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 );
@@ -4048,7 +4056,7 @@ HTML
$wgOut->wrapWikiMsg( '$1 ', "yourtext" );
$this->showTextbox2();
- $wgOut->addReturnTo( $this->getContextTitle(), array( 'action' => 'edit' ) );
+ $wgOut->addReturnTo( $this->getContextTitle(), [ 'action' => 'edit' ] );
}
/**
@@ -4118,7 +4126,7 @@ HTML
*/
private function makeSafe( $invalue ) {
// Armor existing references for reversibility.
- $invalue = strtr( $invalue, array( "" => "" ) );
+ $invalue = strtr( $invalue, [ "" => "" ] );
$bytesleft = 0;
$result = "";
@@ -4184,6 +4192,6 @@ HTML
}
}
// reverse the transform that we made for reversibility reasons.
- return strtr( $result, array( "" => "" ) );
+ return strtr( $result, [ "" => "" ] );
}
}