mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 14:33:59 +00:00
7d9e2d62a3
Change-Id: I169052bd9a1a38ab0352cca4bf8006a66db381f0
38 lines
820 B
PHP
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;
|
|
}
|
|
|
|
}
|