Jump to content

Topic on Extension talk:VisualEditor

How does e.g. $wgVisualEditorAvailableNamespaces work?

4
Summary by Kghbln
Kghbln (talkcontribs)

I have set the following to my "LocalSettings.php"

$wgVisualEditorAvailableNamespaces = [
        NS_MAIN => true,
        NS_USER => true,
        NS_EXTRA => true
        ];

What I expected was that VisualEditor is only available for the namespaces MAIN, USER and EXTRA. What is happening is that also the namespaces CATEGORY and FILE are available for editing with VisualEditor.

Changing the setting to the following does not change the set of available namespaces:

$wgVisualEditorAvailableNamespaces = [
        NS_MAIN => true,
        NS_USER => true,
        NS_EXTRA => true,
        '_merge_strategy' => 'array_plus'
        ];

So my question is: Which values are available to "_merge_strategy"? or What do I have to add to get VisualEditor only for the namespaces MAIN, USER and EXTRA?

Thanks for some insights.

Kghbln (talkcontribs)

Doing something like the following does not change anything either:

$wgVisualEditorAvailableNamespaces = [
        NS_MAIN => true,
        NS_USER => true,
        NS_FILE => false,
        NS_CATEGORY => false,
        NS_EXTRA => true
        ];

Adding something like 'array_replace' to '_merge_strategy' does not work either. Currently I just do not get it.

Osnard (talkcontribs)

I believe the merge strategies are only available on extension.json. For the available values see Manual:Extension.json/Schema#Merge strategies.

Have you tried manipulating the value in an "extension function"? e.g.

$wgExtensionFunctions[] = function() {
  unset( $GLOBALS['wgVisualEditorAvailableNamespaces'][NS_CATEGORY] );
};


(Code not tested)

Kghbln (talkcontribs)

Thanks for you info. @Tgr: came up with the decisive hint for easy configuring. This was probably too obvious. Current docu is pretty bad so I will improve that. The info about the merge strategies was very interesting too. So this is nothing for use in "LocalSettings.php".

That's how to enable and disable namespaces:

$wgVisualEditorAvailableNamespaces = [
        "File" => false, 
        "Category" => false, 
        "Extra" => true
        ];