mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-23 03:23:09 +00:00
Merge "ApiVisualEditor: Return notices as an associative array"
This commit is contained in:
commit
1cc0eae940
|
@ -242,7 +242,7 @@ class ApiVisualEditor extends ApiBase {
|
||||||
$eiTitle->exists() &&
|
$eiTitle->exists() &&
|
||||||
$permissionManager->userCan( 'read', $user, $eiTitle )
|
$permissionManager->userCan( 'read', $user, $eiTitle )
|
||||||
) {
|
) {
|
||||||
$notices[] = MediaWikiServices::getInstance()->getParser()->parse(
|
$notices['editintro'] = MediaWikiServices::getInstance()->getParser()->parse(
|
||||||
'<div class="mw-editintro">{{:' . $eiTitle->getFullText() . '}}</div>',
|
'<div class="mw-editintro">{{:' . $eiTitle->getFullText() . '}}</div>',
|
||||||
$title,
|
$title,
|
||||||
new ParserOptions( $user )
|
new ParserOptions( $user )
|
||||||
|
@ -250,13 +250,12 @@ class ApiVisualEditor extends ApiBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add all page notices, but strip their keys to retain order
|
// Add all page notices
|
||||||
// (since Title returns message-keyed array)
|
$notices = array_merge( $notices, $title->getEditNotices() );
|
||||||
$notices = array_merge( $notices, array_values( $title->getEditNotices() ) );
|
|
||||||
|
|
||||||
// Anonymous user notice
|
// Anonymous user notice
|
||||||
if ( !$user->isRegistered() ) {
|
if ( !$user->isRegistered() ) {
|
||||||
$notices[] = $this->msg(
|
$notices['anoneditwarning'] = $this->msg(
|
||||||
'anoneditwarning',
|
'anoneditwarning',
|
||||||
// Log-in link
|
// Log-in link
|
||||||
'{{fullurl:Special:UserLogin|returnto={{FULLPAGENAMEE}}}}',
|
'{{fullurl:Special:UserLogin|returnto={{FULLPAGENAMEE}}}}',
|
||||||
|
@ -267,11 +266,11 @@ class ApiVisualEditor extends ApiBase {
|
||||||
|
|
||||||
// Old revision notice
|
// Old revision notice
|
||||||
if ( $restoring ) {
|
if ( $restoring ) {
|
||||||
$notices[] = $this->msg( 'editingold' )->parseAsBlock();
|
$notices['editingold'] = $this->msg( 'editingold' )->parseAsBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( wfReadOnly() ) {
|
if ( wfReadOnly() ) {
|
||||||
$notices[] = $this->msg( 'readonlywarning', wfReadOnlyReason() );
|
$notices['readonlywarning'] = $this->msg( 'readonlywarning', wfReadOnlyReason() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Edit notices about the page being protected (only used when we're allowed to edit it;
|
// Edit notices about the page being protected (only used when we're allowed to edit it;
|
||||||
|
@ -280,8 +279,9 @@ class ApiVisualEditor extends ApiBase {
|
||||||
|
|
||||||
// New page notices
|
// New page notices
|
||||||
if ( !$title->exists() ) {
|
if ( !$title->exists() ) {
|
||||||
$notices[] = $this->msg(
|
$newArticleKey = $user->isRegistered() ? 'newarticletext' : 'newarticletextanon';
|
||||||
$user->isRegistered() ? 'newarticletext' : 'newarticletextanon',
|
$notices[$newArticleKey] = $this->msg(
|
||||||
|
$newArticleKey,
|
||||||
wfExpandUrl( Skin::makeInternalOrExternalUrl(
|
wfExpandUrl( Skin::makeInternalOrExternalUrl(
|
||||||
$this->msg( 'helppage' )->inContentLanguage()->text()
|
$this->msg( 'helppage' )->inContentLanguage()->text()
|
||||||
) )
|
) )
|
||||||
|
@ -289,7 +289,8 @@ class ApiVisualEditor extends ApiBase {
|
||||||
|
|
||||||
// Page protected from creation
|
// Page protected from creation
|
||||||
if ( $title->getRestrictions( 'create' ) ) {
|
if ( $title->getRestrictions( 'create' ) ) {
|
||||||
$protectionNotices[] = $this->msg( 'titleprotectedwarning' )->parseAsBlock() .
|
$protectionNotices['titleprotectedwarning'] =
|
||||||
|
$this->msg( 'titleprotectedwarning' )->parseAsBlock() .
|
||||||
$this->getLastLogEntry( $title, 'protect' );
|
$this->getLastLogEntry( $title, 'protect' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,7 +306,7 @@ class ApiVisualEditor extends ApiBase {
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if ( $out ) {
|
if ( $out ) {
|
||||||
$notices[] = $out;
|
$notices['recreate-moveddeleted-warn'] = $out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,7 +328,7 @@ class ApiVisualEditor extends ApiBase {
|
||||||
// Then it must be protected based on static groups (regular)
|
// Then it must be protected based on static groups (regular)
|
||||||
$noticeMsg = 'protectedpagewarning';
|
$noticeMsg = 'protectedpagewarning';
|
||||||
}
|
}
|
||||||
$protectionNotices[] = $this->msg( $noticeMsg )->parseAsBlock() .
|
$protectionNotices[$noticeMsg] = $this->msg( $noticeMsg )->parseAsBlock() .
|
||||||
$this->getLastLogEntry( $title, 'protect' );
|
$this->getLastLogEntry( $title, 'protect' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,7 +346,7 @@ class ApiVisualEditor extends ApiBase {
|
||||||
"</li>";
|
"</li>";
|
||||||
}
|
}
|
||||||
$notice .= '</ul>';
|
$notice .= '</ul>';
|
||||||
$protectionNotices[] = $notice;
|
$protectionNotices['cascadeprotectedwarning'] = $notice;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,7 +367,8 @@ class ApiVisualEditor extends ApiBase {
|
||||||
$notice = $this->getOutput()->formatPermissionsErrorMessage( $permErrors, 'edit' );
|
$notice = $this->getOutput()->formatPermissionsErrorMessage( $permErrors, 'edit' );
|
||||||
// That method returns wikitext (eww), hack to get it parsed:
|
// That method returns wikitext (eww), hack to get it parsed:
|
||||||
$notice = ( new RawMessage( '$1', [ $notice ] ) )->parseAsBlock();
|
$notice = ( new RawMessage( '$1', [ $notice ] ) )->parseAsBlock();
|
||||||
$notices[] = $notice;
|
// Invent a message key 'permissions-error' to store in $notices
|
||||||
|
$notices['permissions-error'] = $notice;
|
||||||
} elseif ( $protectionNotices ) {
|
} elseif ( $protectionNotices ) {
|
||||||
// If we can edit, and the page is protected, then show the details about the protection
|
// If we can edit, and the page is protected, then show the details about the protection
|
||||||
$notices = array_merge( $notices, $protectionNotices );
|
$notices = array_merge( $notices, $protectionNotices );
|
||||||
|
@ -392,7 +394,7 @@ class ApiVisualEditor extends ApiBase {
|
||||||
!User::isIP( $targetUsername )
|
!User::isIP( $targetUsername )
|
||||||
) {
|
) {
|
||||||
// User does not exist
|
// User does not exist
|
||||||
$notices[] = "<div class=\"mw-userpage-userdoesnotexist error\">\n" .
|
$notices['userpage-userdoesnotexist'] = "<div class=\"mw-userpage-userdoesnotexist error\">\n" .
|
||||||
$this->msg( 'userpage-userdoesnotexist', wfEscapeWikiText( $targetUsername ) )
|
$this->msg( 'userpage-userdoesnotexist', wfEscapeWikiText( $targetUsername ) )
|
||||||
->parse() .
|
->parse() .
|
||||||
"\n</div>";
|
"\n</div>";
|
||||||
|
@ -403,7 +405,7 @@ class ApiVisualEditor extends ApiBase {
|
||||||
) {
|
) {
|
||||||
// Show log extract if the user is sitewide blocked or is partially
|
// Show log extract if the user is sitewide blocked or is partially
|
||||||
// blocked and not allowed to edit their user page or user talk page
|
// blocked and not allowed to edit their user page or user talk page
|
||||||
$notices[] = $this->msg(
|
$notices['blocked-notice-logextract'] = $this->msg(
|
||||||
'blocked-notice-logextract',
|
'blocked-notice-logextract',
|
||||||
// Support GENDER in notice
|
// Support GENDER in notice
|
||||||
$targetUser->getName()
|
$targetUser->getName()
|
||||||
|
|
Loading…
Reference in a new issue