mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 06:24:08 +00:00
f9f9328275
This hook tried to enforce $wgNamespaceProtection , but that's a core config variable that's already enforced by MediaWiki itself Change-Id: I15a40d92e0296eb60054d9845d5c42b880a8f278
42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php
|
|
|
|
class VisualEditorHooks {
|
|
/**
|
|
* Adds VisualEditor JS to the output if in the correct namespace.
|
|
*
|
|
* This is attached to the MediaWiki 'BeforePageDisplay' hook.
|
|
*
|
|
* @param $output OutputPage
|
|
* @param $skin Skin
|
|
*/
|
|
public static function onBeforePageDisplay( &$output, &$skin ) {
|
|
global $wgTitle;
|
|
if (
|
|
// Vector skin supported for now.
|
|
$skin->getSkinName() === 'vector' &&
|
|
(
|
|
// Article in the VisualEditor namespace
|
|
$wgTitle->getNamespace() === NS_VISUALEDITOR ||
|
|
// Special page action for an article in the VisualEditor namespace
|
|
$skin->getRelevantTitle()->getNamespace() === NS_VISUALEDITOR
|
|
)
|
|
) {
|
|
$output->addModules( array( 'ext.visualEditor.editPageInit' ) );
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Adds extra variables to the page config.
|
|
*
|
|
* This is attached to the MediaWiki 'MakeGlobalVariablesScript' hook.
|
|
*/
|
|
public static function onMakeGlobalVariablesScript( &$vars ) {
|
|
global $wgUser, $wgTitle;
|
|
$vars['wgVisualEditor'] = array(
|
|
'isPageWatched' => $wgUser->isWatched( $wgTitle )
|
|
);
|
|
return true;
|
|
}
|
|
}
|