mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-12-22 12:52:52 +00:00
a00ce79826
This requires 1.41 for the interface (added in 4d6a470a) Bug: T271026 Change-Id: I393ba99b7265dac81c7fdaf3d21630386c7c53a9
35 lines
885 B
PHP
35 lines
885 B
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\Scribunto;
|
|
|
|
use MediaWiki\Extension\CodeEditor\Hooks\CodeEditorGetPageLanguageHook;
|
|
use MediaWiki\Title\Title;
|
|
|
|
/**
|
|
* Hooks from CodeEditor extension,
|
|
* which is optional to use with this extension.
|
|
*/
|
|
class CodeEditorHooks implements CodeEditorGetPageLanguageHook {
|
|
|
|
/**
|
|
* @param Title $title
|
|
* @param string|null &$languageCode
|
|
* @param string $model
|
|
* @param string $format
|
|
* @return bool
|
|
*/
|
|
public function onCodeEditorGetPageLanguage( Title $title, ?string &$languageCode, string $model, string $format ) {
|
|
global $wgScribuntoUseCodeEditor;
|
|
if ( $wgScribuntoUseCodeEditor && $title->hasContentModel( CONTENT_MODEL_SCRIBUNTO ) ) {
|
|
$engine = Scribunto::newDefaultEngine();
|
|
if ( $engine->getCodeEditorLanguage() ) {
|
|
$languageCode = $engine->getCodeEditorLanguage();
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
}
|