mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-11-14 19:30:57 +00:00
1fad4da137
Change-Id: Ida2c9cac348fe31ecf8d8c0a352e899bcbff1ebf
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 = [ 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 );
|
|
}
|
|
}
|