mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-12-01 19:36:15 +00:00
98436e2008
Change-Id: I8d99ba9db7f804e898a74a47d9e4e02cac45e945
53 lines
1.1 KiB
PHP
53 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* Scribunto Content Handler
|
|
*
|
|
* @file
|
|
* @ingroup Extensions
|
|
* @ingroup Scribunto
|
|
*
|
|
* @author Brad Jorsch <bjorsch@wikimedia.org>
|
|
*/
|
|
|
|
class ScribuntoContentHandler extends CodeContentHandler {
|
|
|
|
/**
|
|
* @param string $modelId
|
|
* @param string[] $formats
|
|
*/
|
|
public function __construct(
|
|
$modelId = CONTENT_MODEL_SCRIBUNTO, $formats = array( CONTENT_FORMAT_TEXT )
|
|
) {
|
|
parent::__construct( $modelId, $formats );
|
|
}
|
|
|
|
protected function getContentClass() {
|
|
return 'ScribuntoContent';
|
|
}
|
|
|
|
/**
|
|
* @param string $format
|
|
* @return bool
|
|
*/
|
|
public function isSupportedFormat( $format ) {
|
|
// An error in an earlier version of Scribunto means we might see this.
|
|
if ( $format === 'CONTENT_FORMAT_TEXT' ) {
|
|
$format = CONTENT_FORMAT_TEXT;
|
|
}
|
|
return parent::isSupportedFormat( $format );
|
|
}
|
|
|
|
/**
|
|
* Only allow this content handler to be used in the Module namespace
|
|
* @param Title $title
|
|
* @return bool
|
|
*/
|
|
public function canBeUsedOn( Title $title ) {
|
|
if ( $title->getNamespace() !== NS_MODULE ) {
|
|
return false;
|
|
}
|
|
|
|
return parent::canBeUsedOn( $title );
|
|
}
|
|
}
|