3 * JSON Schema Content Handler
7 * @author Ori Livneh <ori@wikimedia.org>
8 * @author Kunal Mehta <legoktm@gmail.com>
14 class JSONContentHandler
extends TextContentHandler
{
17 * The class name of objects that should be created
21 protected $contentClass = 'JSONContent';
23 public function __construct( $modelId = CONTENT_MODEL_JSON
) {
24 parent
::__construct( $modelId, array( CONTENT_FORMAT_JSON
) );
28 * Unserializes a JSONContent object.
30 * @param string $text Serialized form of the content
31 * @param null|string $format The format used for serialization
35 public function unserializeContent( $text, $format = null ) {
36 $this->checkFormat( $format );
37 return new $this->contentClass( $text );
41 * Creates an empty JSONContent object.
45 public function makeEmptyContent() {
46 return new $this->contentClass( '' );
50 * Returns the english language, because JSON is english, and should be handled as such.
53 * @param Content|null $content
55 * @return Language Return of wfGetLangObj( 'en' )
57 * @see ContentHandler::getPageLanguage()
59 public function getPageLanguage( Title
$title, Content
$content = null ) {
60 return wfGetLangObj( 'en' );
64 * Returns the english language, because JSON is english, and should be handled as such.
67 * @param Content|null $content
69 * @return Language Return of wfGetLangObj( 'en' )
71 * @see ContentHandler::getPageLanguage()
73 public function getPageViewLanguage( Title
$title, Content
$content = null ) {
74 return wfGetLangObj( 'en' );