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
27 * Content handler for wiki text pages.
31 class WikitextContentHandler
extends TextContentHandler
{
32 public function __construct( $modelId = CONTENT_MODEL_WIKITEXT
) {
33 parent
::__construct( $modelId, array( CONTENT_FORMAT_WIKITEXT
) );
36 public function unserializeContent( $text, $format = null ) {
37 $this->checkFormat( $format );
39 return new WikitextContent( $text );
43 * @see ContentHandler::makeEmptyContent
47 public function makeEmptyContent() {
48 return new WikitextContent( '' );
52 * Returns a WikitextContent object representing a redirect to the given destination page.
54 * @see ContentHandler::makeRedirectContent
56 * @param Title $destination the page to redirect to.
57 * @param string $text text to include in the redirect, if possible.
61 public function makeRedirectContent( Title
$destination, $text = '' ) {
64 if ( $destination->getNamespace() == NS_CATEGORY
) {
67 $iw = $destination->getInterwiki();
68 if ( $iw && Language
::fetchLanguageName( $iw, null, 'mw' ) ) {
73 $mwRedir = MagicWord
::get( 'redirect' );
74 $redirectText = $mwRedir->getSynonym( 0 ) .
75 ' [[' . $optionalColon . $destination->getFullText() . ']]';
78 $redirectText .= "\n" . $text;
81 return new WikitextContent( $redirectText );
85 * Returns true because wikitext supports redirects.
87 * @see ContentHandler::supportsRedirects
89 * @return boolean whether redirects are supported.
91 public function supportsRedirects() {
96 * Returns true because wikitext supports sections.
98 * @return boolean whether sections are supported.
100 public function supportsSections() {
105 * Returns true, because wikitext supports caching using the
106 * ParserCache mechanism.
111 public function isParserCacheSupported() {