2013-02-20 22:00:42 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Scribunto Content Handler
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @ingroup Extensions
|
|
|
|
* @ingroup Scribunto
|
|
|
|
*
|
|
|
|
* @author Brad Jorsch <bjorsch@wikimedia.org>
|
|
|
|
*/
|
|
|
|
|
2014-09-15 08:43:15 +00:00
|
|
|
class ScribuntoContentHandler extends CodeContentHandler {
|
2013-02-20 22:00:42 +00:00
|
|
|
|
2014-10-10 09:02:03 +00:00
|
|
|
/**
|
|
|
|
* @param string $modelId
|
|
|
|
* @param string[] $formats
|
|
|
|
*/
|
2016-05-17 14:52:05 +00:00
|
|
|
public function __construct(
|
2017-06-15 17:19:00 +00:00
|
|
|
$modelId = CONTENT_MODEL_SCRIBUNTO, $formats = [ CONTENT_FORMAT_TEXT ]
|
2016-05-17 14:52:05 +00:00
|
|
|
) {
|
2013-02-20 22:00:42 +00:00
|
|
|
parent::__construct( $modelId, $formats );
|
|
|
|
}
|
|
|
|
|
2014-09-15 08:43:15 +00:00
|
|
|
protected function getContentClass() {
|
|
|
|
return 'ScribuntoContent';
|
|
|
|
}
|
|
|
|
|
2014-10-10 09:02:03 +00:00
|
|
|
/**
|
|
|
|
* @param string $format
|
|
|
|
* @return bool
|
|
|
|
*/
|
2013-04-29 20:51:39 +00:00
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
2015-07-24 14:17:45 +00:00
|
|
|
/**
|
|
|
|
* 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 );
|
|
|
|
}
|
2013-02-20 22:00:42 +00:00
|
|
|
}
|