Merge "Use page ContentModel to choose editor language"

This commit is contained in:
jenkins-bot 2014-01-10 15:43:42 +00:00 committed by Gerrit Code Review
commit 9603214b8b

View file

@ -4,8 +4,14 @@ class CodeEditorHooks {
static function getPageLanguage( $title ) {
global $wgCodeEditorEnableCore;
// Try CSS/JS
if( $wgCodeEditorEnableCore && ( $title->isCssOrJsPage() || $title->isCssJsSubpage() ) ) {
if ( $wgCodeEditorEnableCore && method_exists( $title, "getContentModel" ) ) {
if ( $title->getContentModel() === CONTENT_MODEL_JAVASCRIPT ) {
return 'javascript';
} else if ( $title->getContentModel() === CONTENT_MODEL_CSS ) {
return 'css';
}
} elseif( $wgCodeEditorEnableCore && ( $title->isCssOrJsPage() || $title->isCssJsSubpage() ) ) {
// This block is deprecated. Remove after 1.23 release
if( preg_match( '/\.js$/', $title->getText() ) )
return 'javascript';
if( preg_match( '/\.css$/', $title->getText() ) )