Merge "Fix RevisionStorageTest with non-wikitext NS_MAIN"
[lhc/web/wiklou.git] / includes / content / WikitextContentHandler.php
1 <?php
2
3 /**
4 * @since 1.21
5 */
6 class WikitextContentHandler extends TextContentHandler {
7
8 public function __construct( $modelId = CONTENT_MODEL_WIKITEXT ) {
9 parent::__construct( $modelId, array( CONTENT_FORMAT_WIKITEXT ) );
10 }
11
12 public function unserializeContent( $text, $format = null ) {
13 $this->checkFormat( $format );
14
15 return new WikitextContent( $text );
16 }
17
18 /**
19 * @see ContentHandler::makeEmptyContent
20 *
21 * @return Content
22 */
23 public function makeEmptyContent() {
24 return new WikitextContent( '' );
25 }
26
27
28 /**
29 * Returns a WikitextContent object representing a redirect to the given destination page.
30 *
31 * @see ContentHandler::makeRedirectContent
32 *
33 * @param Title $destination the page to redirect to.
34 *
35 * @return Content
36 */
37 public function makeRedirectContent( Title $destination ) {
38 $mwRedir = MagicWord::get( 'redirect' );
39 $redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $destination->getPrefixedText() . "]]\n";
40
41 return new WikitextContent( $redirectText );
42 }
43
44 /**
45 * Returns true because wikitext supports sections.
46 *
47 * @return boolean whether sections are supported.
48 */
49 public function supportsSections() {
50 return true;
51 }
52
53 /**
54 * Returns true, because wikitext supports caching using the
55 * ParserCache mechanism.
56 *
57 * @since 1.21
58 * @return bool
59 */
60 public function isParserCacheSupported() {
61 return true;
62 }
63 }