mediawiki-extensions-Visual.../VisualEditor.hooks.php
Rob Moen 7d9e2d62a3 Restrict ext.visualEditor.core to the VisualEditor namespace in the hook
Change-Id: I169052bd9a1a38ab0352cca4bf8006a66db381f0
2012-05-25 16:34:25 -07:00

38 lines
820 B
PHP

<?php
class VisualEditorHooks {
/**
* Adds VisualEditor JS to the output if in the correct namespace
*
* @param $output OutputPage
* @param $skin Skin
*/
public static function onPageDisplay( &$output, &$skin ) {
if ( self::loadVisualEditor( $output, $skin ) ) {
$output->addModules( array( 'ext.visualEditor.core' ) );
}
return true;
}
/**
* Determines whether or not we should construct the loader.
*
* @param $output OutputPage
* @param $skin Skin
*/
public static function loadVisualEditor( &$output, &$skin ) {
global $wgTitle;
// Vector skin supported for now.
if ( $skin->getSkinName() !== 'vector' ) {
return false;
}
// Check Namespace
if ($wgTitle->getNamespace() !== NS_VISUALEDITOR) {
return false;
}
//TODO: user permissions...
return true;
}
}