improve explanations of email confirmations
[mediawiki.git] / includes / content / WikitextContentHandler.php
blob8be85bc7cb5454b79517a6f8ed7472b042745e71
1 <?php
2 /**
3 * Content handler for wiki text pages.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @since 1.21
22 * @file
23 * @ingroup Content
26 /**
27 * Content handler for wiki text pages.
29 * @ingroup Content
31 class WikitextContentHandler extends TextContentHandler {
33 public function __construct( $modelId = CONTENT_MODEL_WIKITEXT ) {
34 parent::__construct( $modelId, array( CONTENT_FORMAT_WIKITEXT ) );
37 public function unserializeContent( $text, $format = null ) {
38 $this->checkFormat( $format );
40 return new WikitextContent( $text );
43 /**
44 * @see ContentHandler::makeEmptyContent
46 * @return Content
48 public function makeEmptyContent() {
49 return new WikitextContent( '' );
52 /**
53 * Returns a WikitextContent object representing a redirect to the given destination page.
55 * @see ContentHandler::makeRedirectContent
57 * @param Title $destination the page to redirect to.
59 * @return Content
61 public function makeRedirectContent( Title $destination ) {
62 $optionalColon = '';
64 if ( $destination->getNamespace() == NS_CATEGORY ) {
65 $optionalColon = ':';
66 } else {
67 $iw = $destination->getInterwiki();
68 if ( $iw && Language::fetchLanguageName( $iw, null, 'mw' ) ) {
69 $optionalColon = ':';
73 $mwRedir = MagicWord::get( 'redirect' );
74 $redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $optionalColon . $destination->getFullText() . ']]';
76 return new WikitextContent( $redirectText );
79 /**
80 * Returns true because wikitext supports redirects.
82 * @see ContentHandler::supportsRedirects
84 * @return boolean whether redirects are supported.
86 public function supportsRedirects() {
87 return true;
90 /**
91 * Returns true because wikitext supports sections.
93 * @return boolean whether sections are supported.
95 public function supportsSections() {
96 return true;
99 /**
100 * Returns true, because wikitext supports caching using the
101 * ParserCache mechanism.
103 * @since 1.21
104 * @return bool
106 public function isParserCacheSupported() {
107 return true;