mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-11-28 10:10:04 +00:00
1e02fad924
We had intended to use the constant CONTENT_FORMAT_TEXT, but accidentally used that as a string instead. Change-Id: I93a2c02d48d3fd7b73530562165d817965e272d1
47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* Scribunto Content Handler
|
|
*
|
|
* @file
|
|
* @ingroup Extensions
|
|
* @ingroup Scribunto
|
|
*
|
|
* @author Brad Jorsch <bjorsch@wikimedia.org>
|
|
*/
|
|
|
|
class ScribuntoContentHandler extends TextContentHandler {
|
|
|
|
public function __construct( $modelId = 'Scribunto', $formats = array( CONTENT_FORMAT_TEXT ) ) {
|
|
parent::__construct( $modelId, $formats );
|
|
}
|
|
|
|
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( '' );
|
|
}
|
|
}
|