mediawiki-extensions-Scribunto/common/ScribuntoContentHandler.php
Kunal Mehta 98436e2008 Have ScribuntoContentHandler extend CodeContentHandler
Change-Id: I8d99ba9db7f804e898a74a47d9e4e02cac45e945
2016-07-26 00:38:47 +00: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 = 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 );
}
}