MediaWiki
REL1_23
|
00001 <?php 00031 class WikitextContentHandler extends TextContentHandler { 00032 00033 public function __construct( $modelId = CONTENT_MODEL_WIKITEXT ) { 00034 parent::__construct( $modelId, array( CONTENT_FORMAT_WIKITEXT ) ); 00035 } 00036 00037 public function unserializeContent( $text, $format = null ) { 00038 $this->checkFormat( $format ); 00039 00040 return new WikitextContent( $text ); 00041 } 00042 00048 public function makeEmptyContent() { 00049 return new WikitextContent( '' ); 00050 } 00051 00062 public function makeRedirectContent( Title $destination, $text = '' ) { 00063 $optionalColon = ''; 00064 00065 if ( $destination->getNamespace() == NS_CATEGORY ) { 00066 $optionalColon = ':'; 00067 } else { 00068 $iw = $destination->getInterwiki(); 00069 if ( $iw && Language::fetchLanguageName( $iw, null, 'mw' ) ) { 00070 $optionalColon = ':'; 00071 } 00072 } 00073 00074 $mwRedir = MagicWord::get( 'redirect' ); 00075 $redirectText = $mwRedir->getSynonym( 0 ) . 00076 ' [[' . $optionalColon . $destination->getFullText() . ']]'; 00077 00078 if ( $text != '' ) { 00079 $redirectText .= "\n" . $text; 00080 } 00081 00082 return new WikitextContent( $redirectText ); 00083 } 00084 00092 public function supportsRedirects() { 00093 return true; 00094 } 00095 00103 public function supportsSections() { 00104 return true; 00105 } 00106 00117 public function isParserCacheSupported() { 00118 return true; 00119 } 00120 00121 }