Merge "Restore formatting before split of RevisionDelete.php"
[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 class JSONContentHandler extends TextContentHandler {
12
13 public function __construct( $modelId = CONTENT_MODEL_JSON ) {
14 parent::__construct( $modelId, array( CONTENT_FORMAT_JSON ) );
15 }
16
17 /**
18 * Unserializes a JSONContent object.
19 *
20 * @param string $text Serialized form of the content
21 * @param null|string $format The format used for serialization
22 *
23 * @return JSONContent
24 */
25 public function unserializeContent( $text, $format = null ) {
26 $this->checkFormat( $format );
27 return new JSONContent( $text );
28 }
29
30 /**
31 * Creates an empty JSONContent object.
32 *
33 * @return JSONContent
34 */
35 public function makeEmptyContent() {
36 return new JSONContent( '' );
37 }
38
39 /** JSON is English **/
40 public function getPageLanguage( Title $title, Content $content = null ) {
41 return wfGetLangObj( 'en' );
42 }
43
44 /** JSON is English **/
45 public function getPageViewLanguage( Title $title, Content $content = null ) {
46 return wfGetLangObj( 'en' );
47 }
48 }