2014-08-20 17:03:46 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Main entry point for the CodeMirror extension.
|
|
|
|
*
|
|
|
|
* @link https://www.mediawiki.org/wiki/Extension:CodeMirror Documentation
|
|
|
|
* @file CodeMirror.php
|
|
|
|
* @defgroup CodeMirror
|
|
|
|
* @ingroup Extensions
|
|
|
|
* @author Pavel Astakhov <pastakhov@yandex.ru>
|
|
|
|
* @licence GNU General Public Licence 2.0 or later
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Check to see if we are being called as an extension or directly
|
|
|
|
if ( !defined( 'MEDIAWIKI' ) ) {
|
|
|
|
die( 'This file is an extension to MediaWiki and thus not a valid entry point.' );
|
|
|
|
}
|
|
|
|
|
2015-03-16 05:00:43 +00:00
|
|
|
const EXT_CODEMIRROR_VERSION = '3.1.0';
|
2014-08-20 17:03:46 +00:00
|
|
|
|
|
|
|
// Register this extension on Special:Version
|
|
|
|
$wgExtensionCredits['parserhook'][] = array(
|
|
|
|
'path' => __FILE__,
|
|
|
|
'name' => 'CodeMirror',
|
2014-08-25 10:56:52 +00:00
|
|
|
'version' => EXT_CODEMIRROR_VERSION,
|
2014-08-20 17:03:46 +00:00
|
|
|
'url' => 'https://www.mediawiki.org/wiki/Extension:CodeMirror',
|
2015-03-16 05:00:43 +00:00
|
|
|
'author' => array( '[https://www.mediawiki.org/wiki/User:Pastakhov Pavel Astakhov]', 'Florian Schmidt' ),
|
2014-08-20 17:03:46 +00:00
|
|
|
'descriptionmsg' => 'codemirror-desc'
|
|
|
|
);
|
|
|
|
|
|
|
|
// Allow translations for this extension
|
|
|
|
$wgMessagesDirs['CodeMirror'] = __DIR__ . '/i18n';
|
|
|
|
$wgExtensionMessagesFiles['CodeMirror'] = __DIR__ . '/CodeMirror.i18n.php';
|
|
|
|
|
|
|
|
$wgAutoloadClasses['CodeMirrorHooks'] = __DIR__ . '/CodeMirror.hooks.php';
|
|
|
|
|
2014-08-29 04:05:50 +00:00
|
|
|
$wgHooks['MakeGlobalVariablesScript'][] = 'CodeMirrorHooks::onMakeGlobalVariablesScript';
|
2015-03-16 05:00:43 +00:00
|
|
|
$wgHooks['BeforePageDisplay'][] = 'CodeMirrorHooks::onBeforePageDisplay';
|
|
|
|
$wgHooks['GetPreferences'][] = 'CodeMirrorHooks::onGetPreferences';
|
|
|
|
$wgHooks['ResourceLoaderRegisterModules'][] = 'CodeMirrorHooks::onResourceLoaderRegisterModules';
|
2014-10-23 06:09:10 +00:00
|
|
|
|
2015-03-16 05:00:43 +00:00
|
|
|
$wgCodeMirrorResourceTemplate = array(
|
2014-08-20 17:03:46 +00:00
|
|
|
'localBasePath' => __DIR__ . '/resources',
|
|
|
|
'remoteExtPath' => 'CodeMirror/resources',
|
|
|
|
);
|
|
|
|
|
2015-03-16 05:00:43 +00:00
|
|
|
$wgResourceModules['ext.CodeMirror.init'] = $wgCodeMirrorResourceTemplate + array(
|
|
|
|
'dependencies' => array(
|
|
|
|
'ext.CodeMirror.lib',
|
|
|
|
'ext.CodeMirror.other',
|
|
|
|
'mediawiki.api',
|
|
|
|
'jquery.textSelection',
|
|
|
|
'user.options',
|
|
|
|
),
|
|
|
|
'scripts' => array(
|
|
|
|
'ext.CodeMirror.js'
|
|
|
|
),
|
2014-10-23 06:09:10 +00:00
|
|
|
'group' => 'ext.CodeMirror',
|
2015-03-16 05:00:43 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
$wgResourceModules['ext.CodeMirror.lib'] = $wgCodeMirrorResourceTemplate + array(
|
2014-08-20 17:03:46 +00:00
|
|
|
'scripts' => array(
|
|
|
|
'lib/codemirror/lib/codemirror.js',
|
2014-08-27 09:33:10 +00:00
|
|
|
'lib/codemirror/addon/selection/active-line.js',
|
2014-08-20 17:03:46 +00:00
|
|
|
'mode/mediawiki/mediawiki.js',
|
|
|
|
),
|
2014-08-26 07:00:52 +00:00
|
|
|
'styles' => array(
|
|
|
|
'lib/codemirror/lib/codemirror.css',
|
2014-10-23 06:09:10 +00:00
|
|
|
'lib/codemirror/addon/lint/lint.css',
|
2014-08-26 07:00:52 +00:00
|
|
|
'mode/mediawiki/mediawiki.css',
|
|
|
|
),
|
2014-10-23 06:09:10 +00:00
|
|
|
'group' => 'ext.CodeMirror',
|
2015-03-16 05:00:43 +00:00
|
|
|
'targets' => array( 'mobile', 'desktop' ),
|
|
|
|
);
|