diff --git a/i18n/en.json b/i18n/en.json index 7ff6548..7be02f4 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -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.
Don't be scared of markup.", diff --git a/i18n/qqq.json b/i18n/qqq.json index fe1a92f..ed18dd5 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -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}}", diff --git a/includes/MinervaHooks.php b/includes/MinervaHooks.php index 0a52ca4..424a3cc 100644 --- a/includes/MinervaHooks.php +++ b/includes/MinervaHooks.php @@ -168,4 +168,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 (