mediawiki-extensions-Scribunto/includes/common/ScribuntoContentHandler.php
Kunal Mehta 1fad4da137 Move classes into includes/
Change-Id: Ida2c9cac348fe31ecf8d8c0a352e899bcbff1ebf
2018-04-09 08:54:22 -07:00

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 );
}
}