9d001da1c8d90c19b402f351b2dcab2738940a2a
[lhc/web/wiklou.git] / includes / content / JSONContentHandler.php
1 <?php
2 /**
3 * JSON Schema Content Handler
4 *
5 * @file
6 *
7 * @author Ori Livneh <ori@wikimedia.org>
8 * @author Kunal Mehta <legoktm@gmail.com>
9 */
10
11 /**
12 * @since 1.24
13 */
14 class JSONContentHandler extends TextContentHandler {
15
16 /**
17 * The class name of objects that should be created
18 *
19 * @var string
20 */
21 protected $contentClass = 'JSONContent';
22
23 public function __construct( $modelId = CONTENT_MODEL_JSON ) {
24 parent::__construct( $modelId, array( CONTENT_FORMAT_JSON ) );
25 }
26
27 /**
28 * Unserializes a JSONContent object.
29 *
30 * @param string $text Serialized form of the content
31 * @param null|string $format The format used for serialization
32 *
33 * @return JSONContent
34 */
35 public function unserializeContent( $text, $format = null ) {
36 $this->checkFormat( $format );
37 return new $this->contentClass( $text );
38 }
39
40 /**
41 * Creates an empty JSONContent object.
42 *
43 * @return JSONContent
44 */
45 public function makeEmptyContent() {
46 return new $this->contentClass( '' );
47 }
48
49 /** JSON is English **/
50 public function getPageLanguage( Title $title, Content $content = null ) {
51 return wfGetLangObj( 'en' );
52 }
53
54 /** JSON is English **/
55 public function getPageViewLanguage( Title $title, Content $content = null ) {
56 return wfGetLangObj( 'en' );
57 }
58 }