Merge "Suppress display of wikitext editor on action=edit"
This commit is contained in:
commit
d5cd6950b0
@ -14,6 +14,7 @@
|
||||
"mobile-frontend-editor-redlink-create": "Create page",
|
||||
"mobile-frontend-editor-redlink-explain": "This page has not yet been created.",
|
||||
"mobile-frontend-editor-redlink-leave": "No, thanks.",
|
||||
"mobile-frontend-editor-toload": "The editor will now load. If you still see this message after a few seconds, please [$1 reload the page].",
|
||||
"mobile-frontend-editor-tutorial-cancel": "No, thanks",
|
||||
"mobile-frontend-editor-tutorial-confirm": "Start editing",
|
||||
"mobile-frontend-editor-tutorial-summary": "Try improving the $1 page.<br />Don't be scared of markup.",
|
||||
|
@ -23,6 +23,7 @@
|
||||
"mobile-frontend-editor-redlink-create": "Label for a create page button.\n{{Identical|Create page}}",
|
||||
"mobile-frontend-editor-redlink-explain": "Question for the user, if he want to edit a page, which link he clicked and that does not exist yet, or not.",
|
||||
"mobile-frontend-editor-redlink-leave": "Used as a label for a button which the user can click to avoid editing a page which does not exist yet (red link): the question/alternative button is {{msg-mw|mobile-frontend-editor-redlink-create}}\n----\n{{Identical|No thanks}}",
|
||||
"mobile-frontend-editor-toload": "Text shown to the user in place of the wikitext editor on action=edit when the editing overlay is expected to load.\n\nParameters\n* $1 is the URL which points to a page with a fallback to the wikitext editor if necessary.",
|
||||
"mobile-frontend-editor-tutorial-cancel": "Label for button that user can click if they do not want to edit.\n{{Identical|No thanks}}",
|
||||
"mobile-frontend-editor-tutorial-confirm": "Text for the button a user clicks after they have read the editing tutorial and are ready to edit the page.\n\nSee also:\n* {{msg-mw|Mobile-frontend-editor-tutorial-summary}}",
|
||||
"mobile-frontend-editor-tutorial-summary": "Text for tutorial overlay presented to a user the first time they try to edit a page.\n\nParameters:\n* $1 - page title\nSee also:\n* {{msg-mw|Mobile-frontend-editor-tutorial-alt-summary}}",
|
||||
|
@ -172,4 +172,52 @@ class MinervaHooks {
|
||||
] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Suppress showing the wikitext editor on action=edit URLs
|
||||
*
|
||||
* @param Article $article The article being viewed.
|
||||
* @param User $user The user-specific settings.
|
||||
* @return bool Whether to show the wikitext editor or not.
|
||||
*/
|
||||
public static function onCustomEditor( Article $article, User $user ) {
|
||||
$out = $article->getContext()->getOutput();
|
||||
|
||||
if ( !( $out->getSkin() instanceof SkinMinerva ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$req = $article->getContext()->getRequest();
|
||||
|
||||
if ( $req->getVal( 'mobileeditorsuppress' ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$params = $req->getValues();
|
||||
$params['mobileeditorsuppress'] = '1';
|
||||
$url = wfScript() . '?' . wfArrayToCgi( $params );
|
||||
$escapedUrl = htmlspecialchars( $url );
|
||||
|
||||
$title = $article->getTitle();
|
||||
$titleMsg = $title->exists() ? 'editing' : 'creating';
|
||||
$out->setPageTitle( wfMessage( $titleMsg, $title->getPrefixedText() ) );
|
||||
$out->addWikiMsg( 'mobile-frontend-editor-toload', wfExpandUrl( $url ) );
|
||||
$out->setRevisionId( $req->getInt( 'oldid', $article->getRevIdFetched() ) );
|
||||
|
||||
// Redirect if the user has no JS (<noscript>)
|
||||
$out->addHeadItem(
|
||||
'mobileeditor-noscript-fallback',
|
||||
"<noscript><meta http-equiv=\"refresh\" content=\"0; url=$escapedUrl\"></noscript>"
|
||||
);
|
||||
// Redirect if the user has no ResourceLoader
|
||||
$out->addScript( Html::inlineScript(
|
||||
"(window.NORLQ=window.NORLQ||[]).push(" .
|
||||
"function(){" .
|
||||
"location.href=\"$url\";" .
|
||||
"}" .
|
||||
");"
|
||||
) );
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -312,7 +312,13 @@
|
||||
ev.stopPropagation();
|
||||
} );
|
||||
|
||||
if ( !router.getPath() && ( mw.util.getParamValue( 'veaction' ) || mw.util.getParamValue( 'action' ) === 'edit' ) ) {
|
||||
if ( !router.getPath() &&
|
||||
(
|
||||
mw.util.getParamValue( 'veaction' ) ||
|
||||
mw.util.getParamValue( 'action' ) === 'edit'
|
||||
) &&
|
||||
!mw.util.getParamValue( 'mobileeditorsuppress' )
|
||||
) {
|
||||
if ( mw.util.getParamValue( 'veaction' ) === 'edit' ) {
|
||||
editorOverride = 'VisualEditor';
|
||||
} else if ( mw.util.getParamValue( 'veaction' ) === 'editsource' ) {
|
||||
|
Loading…
Reference in New Issue
Block a user