2012-05-25 19:50:48 +00:00
|
|
|
<?php
|
2012-07-19 00:11:26 +00:00
|
|
|
/**
|
|
|
|
* VisualEditor extension hooks
|
2012-07-19 21:25:16 +00:00
|
|
|
*
|
2012-07-19 00:11:26 +00:00
|
|
|
* @file
|
|
|
|
* @ingroup Extensions
|
|
|
|
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
|
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
2012-05-25 19:50:48 +00:00
|
|
|
|
|
|
|
class VisualEditorHooks {
|
|
|
|
/**
|
2012-06-11 06:54:41 +00:00
|
|
|
* Adds VisualEditor JS to the output if in the correct namespace.
|
|
|
|
*
|
|
|
|
* This is attached to the MediaWiki 'BeforePageDisplay' hook.
|
2012-05-25 19:50:48 +00:00
|
|
|
*
|
|
|
|
* @param $output OutputPage
|
|
|
|
* @param $skin Skin
|
|
|
|
*/
|
2012-06-11 06:54:41 +00:00
|
|
|
public static function onBeforePageDisplay( &$output, &$skin ) {
|
|
|
|
global $wgTitle;
|
|
|
|
if (
|
|
|
|
// Vector skin supported for now.
|
|
|
|
$skin->getSkinName() === 'vector' &&
|
2012-06-18 21:13:26 +00:00
|
|
|
(
|
|
|
|
// Article in the VisualEditor namespace
|
|
|
|
$wgTitle->getNamespace() === NS_VISUALEDITOR ||
|
|
|
|
// Special page action for an article in the VisualEditor namespace
|
|
|
|
$skin->getRelevantTitle()->getNamespace() === NS_VISUALEDITOR
|
|
|
|
)
|
2012-06-11 06:54:41 +00:00
|
|
|
) {
|
2012-06-28 09:52:03 +00:00
|
|
|
$output->addModules( array( 'ext.visualEditor.viewPageTarget' ) );
|
2012-05-25 19:50:48 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-06-11 06:54:41 +00:00
|
|
|
* Adds extra variables to the page config.
|
2012-05-25 19:50:48 +00:00
|
|
|
*
|
2012-06-11 06:54:41 +00:00
|
|
|
* This is attached to the MediaWiki 'MakeGlobalVariablesScript' hook.
|
2012-05-25 19:50:48 +00:00
|
|
|
*/
|
2012-06-11 06:54:41 +00:00
|
|
|
public static function onMakeGlobalVariablesScript( &$vars ) {
|
2012-06-01 23:26:03 +00:00
|
|
|
global $wgUser, $wgTitle;
|
2012-06-11 06:54:41 +00:00
|
|
|
$vars['wgVisualEditor'] = array(
|
|
|
|
'isPageWatched' => $wgUser->isWatched( $wgTitle )
|
|
|
|
);
|
2012-06-01 23:26:03 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-07-27 23:43:27 +00:00
|
|
|
|
|
|
|
public static function onResourceLoaderTestModules( array &$testModules, ResourceLoader &$resourceLoader ) {
|
|
|
|
$testModules['qunit']['ext.visualEditor.test'] = array(
|
|
|
|
'scripts' => array(
|
|
|
|
// QUnit plugin
|
|
|
|
've.qunit.js',
|
|
|
|
// VisualEditor Tests
|
|
|
|
've.example.js',
|
|
|
|
've.Document.test.js',
|
|
|
|
've.Node.test.js',
|
|
|
|
've.BranchNode.test.js',
|
|
|
|
've.LeafNode.test.js',
|
|
|
|
've.Factory.test.js',
|
|
|
|
// VisualEditor DataModel Tests
|
|
|
|
'dm/ve.dm.example.js',
|
|
|
|
'dm/ve.dm.NodeFactory.test.js',
|
|
|
|
'dm/ve.dm.Node.test.js',
|
|
|
|
'dm/ve.dm.Converter.test.js',
|
|
|
|
'dm/ve.dm.BranchNode.test.js',
|
|
|
|
'dm/ve.dm.LeafNode.test.js',
|
|
|
|
'dm/nodes/ve.dm.TextNode.test.js',
|
|
|
|
'dm/ve.dm.Document.test.js',
|
|
|
|
'dm/ve.dm.DocumentSynchronizer.test.js',
|
|
|
|
'dm/ve.dm.Transaction.test.js',
|
|
|
|
'dm/ve.dm.TransactionProcessor.test.js',
|
|
|
|
'dm/ve.dm.Surface.test.js',
|
|
|
|
// VisualEditor ContentEditable Tests
|
|
|
|
'ce/ve.ce.test.js',
|
|
|
|
'ce/ve.ce.Document.test.js',
|
|
|
|
'ce/ve.ce.NodeFactory.test.js',
|
|
|
|
'ce/ve.ce.Node.test.js',
|
|
|
|
'ce/ve.ce.BranchNode.test.js',
|
|
|
|
'ce/ve.ce.LeafNode.test.js',
|
|
|
|
'ce/nodes/ve.ce.TextNode.test.js',
|
|
|
|
),
|
|
|
|
'dependencies' => array(
|
|
|
|
'ext.visualEditor.core',
|
|
|
|
'ext.visualEditor.viewPageTarget',
|
|
|
|
),
|
|
|
|
'localBasePath' => dirname( __FILE__ ) . '/modules/ve/test',
|
|
|
|
'remoteExtPath' => 'VisualEditor/modules/ve/test',
|
|
|
|
);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2012-05-25 19:50:48 +00:00
|
|
|
}
|