mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-23 22:13:34 +00:00
Merge "Revert "Revert "Replace wgVisualEditorNamespaces with an associative array"""
This commit is contained in:
commit
44eeb5c8c1
|
@ -278,8 +278,11 @@ class ApiVisualEditor extends ApiBase {
|
|||
|
||||
$isSafeAction = in_array( $params['paction'], self::$SAFE_ACTIONS, true );
|
||||
|
||||
if ( !$isSafeAction &&
|
||||
!in_array( $title->getNamespace(), $this->veConfig->get( 'VisualEditorNamespaces' ) ) ) {
|
||||
$availableNamespaces = $this->veConfig->get( 'VisualEditorAvailableNamespaces' );
|
||||
if ( !$isSafeAction && (
|
||||
!isset( $availableNamespaces[$title->getNamespace()] ) ||
|
||||
!$availableNamespaces[$title->getNamespace()]
|
||||
) ) {
|
||||
|
||||
$this->dieUsage( "VisualEditor is not enabled in namespace " .
|
||||
$title->getNamespace(), 'novenamespace' );
|
||||
|
|
|
@ -121,7 +121,9 @@ class ApiVisualEditorEdit extends ApiVisualEditor {
|
|||
if ( !$page ) {
|
||||
$this->dieUsageMsg( 'invalidtitle', $params['page'] );
|
||||
}
|
||||
if ( !in_array( $page->getNamespace(), $this->veConfig->get( 'VisualEditorNamespaces' ) ) ) {
|
||||
$availableNamespaces = $this->veConfig->get( 'VisualEditorAvailableNamespaces' );
|
||||
if ( !isset( $availableNamespaces[$page->getNamespace()] ) ||
|
||||
!$availableNamespaces[$page->getNamespace()] ) {
|
||||
$this->dieUsage( "VisualEditor is not enabled in namespace " .
|
||||
$page->getNamespace(), 'novenamespace' );
|
||||
}
|
||||
|
|
|
@ -21,22 +21,18 @@ class VisualEditorHooks {
|
|||
}
|
||||
|
||||
/**
|
||||
* Initialise the 'VisualEditorNamespaces' setting, and add content namespaces
|
||||
* and NS_USER to it. This will run after LocalSettings.php is processed.
|
||||
* Initialise the 'VisualEditorAvailableNamespaces' setting, and add content
|
||||
* namespaces to it. This will run after LocalSettings.php is processed.
|
||||
*/
|
||||
public static function onRegistration() {
|
||||
global $wgVisualEditorNamespaces, $wgContentNamespaces;
|
||||
global $wgVisualEditorAvailableNamespaces, $wgContentNamespaces;
|
||||
|
||||
if ( !isset( $wgVisualEditorNamespaces ) ) {
|
||||
$wgVisualEditorNamespaces = array();
|
||||
foreach ( $wgContentNamespaces as $contentNamespace ) {
|
||||
if ( !isset( $wgVisualEditorAvailableNamespaces[$contentNamespace] ) ) {
|
||||
$wgVisualEditorAvailableNamespaces[$contentNamespace] = true;
|
||||
}
|
||||
}
|
||||
|
||||
$wgVisualEditorNamespaces = array_merge(
|
||||
$wgVisualEditorNamespaces,
|
||||
$wgContentNamespaces,
|
||||
array( NS_USER )
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public static function VisualEditorApiFactory( $main, $name ) {
|
||||
|
@ -297,7 +293,8 @@ class VisualEditorHooks {
|
|||
if ( !class_exists( 'BetaFeatures' ) ) {
|
||||
$namespaces = ConfigFactory::getDefaultInstance()
|
||||
->makeConfig( 'visualeditor' )
|
||||
->get( 'VisualEditorNamespaces' );
|
||||
->get( 'VisualEditorAvailableNamespaces' );
|
||||
$onNamespaces = array_keys( array_filter( $namespaces ) );
|
||||
|
||||
$preferences['visualeditor-enable'] = array(
|
||||
'type' => 'toggle',
|
||||
|
@ -305,9 +302,9 @@ class VisualEditorHooks {
|
|||
'visualeditor-preference-enable',
|
||||
$wgLang->commaList( array_map(
|
||||
array( 'self', 'convertNs' ),
|
||||
$namespaces
|
||||
$onNamespaces
|
||||
) ),
|
||||
count( $namespaces )
|
||||
count( $onNamespaces )
|
||||
),
|
||||
'section' => 'editing/editor'
|
||||
);
|
||||
|
@ -384,11 +381,13 @@ class VisualEditorHooks {
|
|||
$defaultUserOptions = $coreConfig->get( 'DefaultUserOptions' );
|
||||
$thumbLimits = $coreConfig->get( 'ThumbLimits' );
|
||||
$veConfig = ConfigFactory::getDefaultInstance()->makeConfig( 'visualeditor' );
|
||||
$availableNamespaces = $veConfig->get( 'VisualEditorAvailableNamespaces' );
|
||||
$onNamespaces = array_keys( array_filter( $availableNamespaces ) );
|
||||
|
||||
$vars['wgVisualEditorConfig'] = array(
|
||||
'disableForAnons' => $veConfig->get( 'VisualEditorDisableForAnons' ),
|
||||
'preferenceModules' => $veConfig->get( 'VisualEditorPreferenceModules' ),
|
||||
'namespaces' => $veConfig->get( 'VisualEditorNamespaces' ),
|
||||
'namespaces' => $onNamespaces,
|
||||
'pluginModules' => array_merge(
|
||||
ExtensionRegistry::getInstance()->getAttribute( 'VisualEditorPluginModules' ),
|
||||
$veConfig->get( 'VisualEditorPluginModules' ) // @todo deprecate the global setting
|
||||
|
|
|
@ -97,8 +97,11 @@
|
|||
"VisualEditorNewAccountEnableProportion": false,
|
||||
"VisualEditorEnableTocWidget": false,
|
||||
"VisualEditorAutoAccountEnable": false,
|
||||
"VisualEditorAvailableNamespaces": {
|
||||
"2": true,
|
||||
"_merge_strategy": "array_plus"
|
||||
},
|
||||
"VisualEditorSkinToolbarScrollOffset": [],
|
||||
"VisualEditorNamespaces": [],
|
||||
"VisualEditorParsoidTimeout": 100
|
||||
},
|
||||
"APIModules": {
|
||||
|
|
Loading…
Reference in a new issue