X-Git-Url: http://git.cyclocoop.org/ecrire?a=blobdiff_plain;f=includes%2FEditPage.php;h=c6636e4d196d861cf7ad6f796eebdedac3b11b88;hb=efd69e2e80446c005cd0ff6c36eaa3f24f51864c;hp=914bad47435a6916e6c2f6651a926dc00a161ff9;hpb=c774fb98685cf6dda2be00bf562e4bb701ae21fe;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/EditPage.php b/includes/EditPage.php
index 914bad4743..c6636e4d19 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];
}
@@ -2295,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
- ) );
+ ] );
}
}
}
@@ -2317,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(
@@ -2325,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
- )
- )
+ ]
+ ]
);
}
}
@@ -2345,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' ]
+ ]
);
}
}
@@ -2479,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();
@@ -2511,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();
@@ -2563,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' ]
) .
'
'
);
@@ -2651,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' );
@@ -2804,7 +2814,7 @@ class EditPage {
// Something went wrong
$wgOut->wrapWikiMsg( "\n$1\n
\n",
- array( 'missing-revision', $this->oldid ) );
+ [ 'missing-revision', $this->oldid ] );
}
}
}
@@ -2812,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
",
@@ -2835,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() ) ) {
@@ -2843,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' ]
);
}
}
@@ -2859,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() ) {
@@ -2869,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?
@@ -2884,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 ) {
@@ -2900,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 )
- )
+ ]
);
}
}
@@ -2941,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 );
@@ -2966,7 +2976,7 @@ class EditPage {
$input = Html::input( 'wpSummary', $summary, 'text', $inputAttrs );
- return array( $label, $input );
+ return [ $label, $input ];
}
/**
@@ -2993,8 +3003,8 @@ class EditPage {
list( $label, $input ) = $this->getSummaryInput(
$summary,
$labelText,
- array( 'class' => $summaryClass ),
- array()
+ [ 'class' => $summaryClass ],
+ []
);
$wgOut->addHTML( "{$label} {$input}" );
}
@@ -3024,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() {
@@ -3082,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() ) {
@@ -3101,7 +3111,7 @@ HTML
}
}
- $attribs = array( 'tabindex' => 1 );
+ $attribs = [ 'tabindex' => 1 ];
if ( is_array( $customAttribs ) ) {
$attribs += $customAttribs;
@@ -3123,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 );
@@ -3138,7 +3148,7 @@ HTML
$wikitext .= "\n";
}
- $attribs = $customAttribs + array(
+ $attribs = $customAttribs + [
'accesskey' => ',',
'id' => $name,
'cols' => $wgUser->getIntOption( 'cols' ),
@@ -3146,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();
@@ -3157,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;';
@@ -3175,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 ) );
}
@@ -3210,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();
@@ -3248,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 );
@@ -3301,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( '' );
@@ -3337,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
";
@@ -3363,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' );
}
@@ -3410,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.
@@ -3423,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();
@@ -3442,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" );
}
@@ -3454,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' );
@@ -3480,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
);
}
@@ -3504,7 +3514,7 @@ HTML
* @return string
*/
protected function getActionURL( Title $title ) {
- return $title->getLocalURL( array( 'action' => $this->action ) );
+ return $title->getLocalURL( [ 'action' => $this->action ] );
}
/**
@@ -3540,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',
@@ -3552,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 ) ) {
@@ -3610,7 +3620,7 @@ HTML
$previewHTML = '';
if ( !Hooks::run(
'AlternateEditPreview',
- array( $this, &$content, &$previewHTML, &$this->mParserOutput ) )
+ [ $this, &$content, &$previewHTML, &$this->mParserOutput ] )
) {
return $previewHTML;
}
@@ -3679,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 );
@@ -3733,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;
@@ -3745,7 +3755,7 @@ HTML
*/
function getTemplates() {
if ( $this->preview || $this->section != '' ) {
- $templates = array();
+ $templates = [];
if ( !isset( $this->mParserOutput ) ) {
return $templates;
}
@@ -3786,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 ) {
@@ -3865,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.
@@ -3877,7 +3887,7 @@ HTML
$tool['close'],
$tool['sample'],
$tool['id'],
- );
+ ];
$script .= Xml::encodeJsCall(
'mw.toolbar.addButton',
@@ -3891,7 +3901,7 @@ HTML
$toolbar = '
';
- Hooks::run( 'EditPageBeforeEditToolbar', array( &$toolbar ) );
+ Hooks::run( 'EditPageBeforeEditToolbar', [ &$toolbar ] );
return $toolbar;
}
@@ -3909,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 {
@@ -3940,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;
}
@@ -3971,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;
}
@@ -4013,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 );
@@ -4046,7 +4056,7 @@ HTML
$wgOut->wrapWikiMsg( '$1 ', "yourtext" );
$this->showTextbox2();
- $wgOut->addReturnTo( $this->getContextTitle(), array( 'action' => 'edit' ) );
+ $wgOut->addReturnTo( $this->getContextTitle(), [ 'action' => 'edit' ] );
}
/**
@@ -4116,7 +4126,7 @@ HTML
*/
private function makeSafe( $invalue ) {
// Armor existing references for reversibility.
- $invalue = strtr( $invalue, array( "" => "" ) );
+ $invalue = strtr( $invalue, [ "" => "" ] );
$bytesleft = 0;
$result = "";
@@ -4182,6 +4192,6 @@ HTML
}
}
// reverse the transform that we made for reversibility reasons.
- return strtr( $result, array( "" => "" ) );
+ return strtr( $result, [ "" => "" ] );
}
}