Disable wikitext editor on non-wikitext content models
Do not allow editing via JavaScript on non-wikitext content models For these pages ?action=edit will be used Bug: T173800 Change-Id: Ic62a0c1397ab8a6a59e5382c2999b63b3c60a19f
This commit is contained in:
parent
cd22f736d7
commit
ac7fcfc9e1
|
@ -19,6 +19,9 @@ class SkinMinerva extends SkinTemplate implements ICustomizableSkin {
|
||||||
const OPTION_BACK_TO_TOP = 'backToTop';
|
const OPTION_BACK_TO_TOP = 'backToTop';
|
||||||
const OPTION_TOGGLING = 'toggling';
|
const OPTION_TOGGLING = 'toggling';
|
||||||
const OPTIONS_MOBILE_BETA = 'beta';
|
const OPTIONS_MOBILE_BETA = 'beta';
|
||||||
|
/** @const LEAD_SECTION_NUMBER integer which corresponds to the lead section
|
||||||
|
in editing mode */
|
||||||
|
const LEAD_SECTION_NUMBER = 0;
|
||||||
|
|
||||||
/** @var string $skinname Name of this skin */
|
/** @var string $skinname Name of this skin */
|
||||||
public $skinname = 'minerva';
|
public $skinname = 'minerva';
|
||||||
|
@ -1063,6 +1066,13 @@ class SkinMinerva extends SkinTemplate implements ICustomizableSkin {
|
||||||
* @return array A map compatible with BaseTemplate#makeListItem
|
* @return array A map compatible with BaseTemplate#makeListItem
|
||||||
*/
|
*/
|
||||||
protected function createEditPageAction() {
|
protected function createEditPageAction() {
|
||||||
|
$title = $this->getTitle();
|
||||||
|
$editArgs = [ 'action' => 'edit' ];
|
||||||
|
if ( $title->isWikitextPage() ) {
|
||||||
|
// If the content model is wikitext we'll default to editing the lead section.
|
||||||
|
// Full wikitext editing is not possible via the api and hard on mobile devices.
|
||||||
|
$editArgs['section'] = self::LEAD_SECTION_NUMBER;
|
||||||
|
}
|
||||||
return [
|
return [
|
||||||
'id' => 'ca-edit',
|
'id' => 'ca-edit',
|
||||||
'text' => '',
|
'text' => '',
|
||||||
|
@ -1070,7 +1080,7 @@ class SkinMinerva extends SkinTemplate implements ICustomizableSkin {
|
||||||
'class' => MobileUI::iconClass( 'edit-enabled', 'element' ),
|
'class' => MobileUI::iconClass( 'edit-enabled', 'element' ),
|
||||||
'links' => [
|
'links' => [
|
||||||
'edit' => [
|
'edit' => [
|
||||||
'href' => $this->getTitle()->getLocalURL( [ 'action' => 'edit', 'section' => 0 ] )
|
'href' => $title->getLocalURL( $editArgs )
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'is_js_only' => false
|
'is_js_only' => false
|
||||||
|
@ -1240,7 +1250,7 @@ class SkinMinerva extends SkinTemplate implements ICustomizableSkin {
|
||||||
if ( !$title->isTalkPage() ) {
|
if ( !$title->isTalkPage() ) {
|
||||||
$title = $title->getTalkPage();
|
$title = $title->getTalkPage();
|
||||||
}
|
}
|
||||||
return $title->getContentModel() === CONTENT_MODEL_WIKITEXT;
|
return $title->isWikitextPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
popup = M.require( 'mobile.startup/toast' ),
|
popup = M.require( 'mobile.startup/toast' ),
|
||||||
// FIXME: Disable on IE < 10 for time being
|
// FIXME: Disable on IE < 10 for time being
|
||||||
blacklisted = /MSIE \d\./.test( navigator.userAgent ),
|
blacklisted = /MSIE \d\./.test( navigator.userAgent ),
|
||||||
|
contentModel = mw.config.get( 'wgPageContentModel' ),
|
||||||
isEditingSupported = router.isSupported() && !blacklisted,
|
isEditingSupported = router.isSupported() && !blacklisted,
|
||||||
// FIXME: Use currentPage.getId()
|
// FIXME: Use currentPage.getId()
|
||||||
isNewPage = currentPage.options.id === 0,
|
isNewPage = currentPage.options.id === 0,
|
||||||
|
@ -345,7 +346,11 @@
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !isEditingSupported ) {
|
if ( contentModel !== 'wikitext' ) {
|
||||||
|
// Only load the wikitext editor on wikitext. Otherwise we'll rely on the fallback behaviour
|
||||||
|
// (You can test this on MediaWiki:Common.css) ?action=edit url (T173800)
|
||||||
|
return;
|
||||||
|
} else if ( !isEditingSupported ) {
|
||||||
// Editing is disabled (or browser is blacklisted)
|
// Editing is disabled (or browser is blacklisted)
|
||||||
$caEdit.removeClass( 'hidden' );
|
$caEdit.removeClass( 'hidden' );
|
||||||
showSorryToast( mw.msg( 'mobile-frontend-editor-unavailable' ) );
|
showSorryToast( mw.msg( 'mobile-frontend-editor-unavailable' ) );
|
||||||
|
|
Loading…
Reference in New Issue