mediawiki-extensions-Scribunto/common/ScribuntoContentHandler.php
Thiemo Mättig 93579c7363 Add more comments and type hints
Change-Id: I8c4b91d3a6695cc33c9c3d3fb427af5412323ff7
2014-12-19 19:25:53 +00:00

77 lines
1.8 KiB
PHP

<?php
/**
* Scribunto Content Handler
*
* @file
* @ingroup Extensions
* @ingroup Scribunto
*
* @author Brad Jorsch <bjorsch@wikimedia.org>
*/
class ScribuntoContentHandler extends TextContentHandler {
/**
* @param string $modelId
* @param string[] $formats
*/
public function __construct( $modelId = 'Scribunto', array $formats = array( CONTENT_FORMAT_TEXT ) ) {
parent::__construct( $modelId, $formats );
}
/**
* @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 );
}
/**
* Unserializes a ScribuntoContent object.
*
* @param $text string Serialized form of the content
* @param $format null|string The format used for serialization
* @return Content the ScribuntoContent object wrapping $text
*/
public function unserializeContent( $text, $format = null ) {
$this->checkFormat( $format );
return new ScribuntoContent( $text );
}
/**
* Creates an empty ScribuntoContent object.
*
* @return Content
*/
public function makeEmptyContent() {
return new ScribuntoContent( '' );
}
/**
* Scripts themselves should be in English.
*
* @param Title $title
* @param Content $content
* @return Language wfGetLangObj( 'en' )
*/
public function getPageLanguage( Title $title, Content $content = null ) {
return wfGetLangObj( 'en' );
}
/**
* Scripts themselves should be in English.
*
* @param Title $title
* @param Content $content
* @return Language wfGetLangObj( 'en' )
*/
public function getPageViewLanguage( Title $title, Content $content = null ) {
return wfGetLangObj( 'en' );
}
}