Moved ContentHandler deriving classes into their own files for better discoverability...
[lhc/web/wiklou.git] / includes / content / JavaScriptContentHandler.php
1 <?php
2
3 # XXX: make ScriptContentHandler base class, do highlighting stuff there?
4
5 /**
6 * @since 1.21
7 */
8 class JavaScriptContentHandler extends TextContentHandler {
9
10 public function __construct( $modelId = CONTENT_MODEL_JAVASCRIPT ) {
11 parent::__construct( $modelId, array( CONTENT_FORMAT_JAVASCRIPT ) );
12 }
13
14 public function unserializeContent( $text, $format = null ) {
15 $this->checkFormat( $format );
16
17 return new JavaScriptContent( $text );
18 }
19
20 public function makeEmptyContent() {
21 return new JavaScriptContent( '' );
22 }
23
24 /**
25 * Returns the english language, because JS is english, and should be handled as such.
26 *
27 * @return Language wfGetLangObj( 'en' )
28 *
29 * @see ContentHandler::getPageLanguage()
30 */
31 public function getPageLanguage( Title $title, Content $content = null ) {
32 return wfGetLangObj( 'en' );
33 }
34
35 /**
36 * Returns the english language, because CSS is english, and should be handled as such.
37 *
38 * @return Language wfGetLangObj( 'en' )
39 *
40 * @see ContentHandler::getPageViewLanguage()
41 */
42 public function getPageViewLanguage( Title $title, Content $content = null ) {
43 return wfGetLangObj( 'en' );
44 }
45 }