mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeEditor
synced 2024-11-24 07:13:27 +00:00
07b24bb9f0
This was an unfinished module to enable the CodeEditor to do inline editing of <syntaxhighlight> blocks. It was never finished and I think that with the VE and WE 2017 work, it likely will never be finished either. For that reason, it is better to remove it altogether. Change-Id: I83714188a53d2ca6bb7bf0dc6d0c89b7fb45a47a
48 lines
1.3 KiB
PHP
48 lines
1.3 KiB
PHP
<?php
|
|
|
|
class CodeEditorHooks {
|
|
static function getPageLanguage( Title $title, $model, $format ) {
|
|
global $wgCodeEditorEnableCore;
|
|
|
|
if ( $wgCodeEditorEnableCore ) {
|
|
if ( $model === CONTENT_MODEL_JAVASCRIPT ) {
|
|
return 'javascript';
|
|
} elseif ( $model === CONTENT_MODEL_CSS ) {
|
|
return 'css';
|
|
} elseif ( $model === CONTENT_MODEL_JSON ) {
|
|
return 'json';
|
|
}
|
|
}
|
|
|
|
// Give extensions a chance
|
|
// Note: $model and $format were added around the time of MediaWiki 1.28.
|
|
$lang = null;
|
|
Hooks::run( 'CodeEditorGetPageLanguage', [ $title, &$lang, $model, $format ] );
|
|
|
|
return $lang;
|
|
}
|
|
|
|
public static function getPreferences( $user, &$defaultPreferences ) {
|
|
$defaultPreferences['usecodeeditor'] = [
|
|
'type' => 'api',
|
|
'default' => '1',
|
|
];
|
|
return true;
|
|
}
|
|
|
|
public static function editPageShowEditFormInitial( $editpage, $output ) {
|
|
$output->addModuleStyles( 'ext.wikiEditor.toolbar.styles' );
|
|
|
|
$title = $editpage->getContextTitle();
|
|
$model = $editpage->contentModel;
|
|
$format = $editpage->contentFormat;
|
|
|
|
$lang = self::getPageLanguage( $title, $model, $format );
|
|
if ( $lang && $output->getUser()->getOption( 'usebetatoolbar' ) ) {
|
|
$output->addModules( 'ext.codeEditor' );
|
|
$output->addJsConfigVars( 'wgCodeEditorCurrentLanguage', $lang );
|
|
}
|
|
return true;
|
|
}
|
|
}
|