45 return WikitextContent::class;
61 $services = MediaWikiServices::getInstance();
67 ->getLanguageNameUtils()
68 ->getLanguageName( $iw,
69 LanguageNameUtils::AUTONYMS,
70 LanguageNameUtils::DEFINED )
76 $mwRedir = $services->getMagicWordFactory()->get(
'redirect' );
77 $redirectText = $mwRedir->getSynonym( 0 ) .
78 ' [[' . $optionalColon . $destination->
getFullText() .
']]';
81 $redirectText .=
"\n" . $text;
85 return new $class( $redirectText );
132 $fields = parent::getFieldsForSearchIndex( $engine );
138 $fields[
'auxiliary_text'] =
141 $fields[
'opening_text'] =
143 $fields[
'opening_text']->setFlag(
157 $fields = parent::getDataForSearchIndex( $page, $parserOutput, $engine );
160 $fields[
'heading'] = $structure->headings();
162 $fields[
'opening_text'] = $structure->getOpeningText();
163 $fields[
'text'] = $structure->getMainText();
164 $fields[
'auxiliary_text'] = $structure->getAuxiliaryText();
165 $fields[
'defaultsort'] = $structure->getDefaultSort();
169 $fields = array_merge( $fields,
189 return $content->getMessage()->plain();
192 return parent::serializeContent(
$content, $format );
204 if ( $shouldCallDeprecatedMethod ) {
211 '@phan-var WikitextContent $content';
215 $parser = MediaWikiServices::getInstance()->getParser();
216 $pst = $parser->preSaveTransform(
223 if ( $text === $pst ) {
228 $ret =
new $contentClass( $pst );
229 $ret->setPreSaveTransformFlags( $parser->getOutput()->getAllFlags() );
246 $shouldCallDeprecatedMethod = $this->shouldCallDeprecatedContentTransformMethod(
251 if ( $shouldCallDeprecatedMethod ) {
252 return $this->callDeprecatedContentPLT(
258 '@phan-var WikitextContent $content';
261 $plt = MediaWikiServices::getInstance()->getParser()->getPreloadText(
268 $contentClass = $this->getContentClass();
269 return new $contentClass( $plt );
286 '@phan-var WikitextContent $content';
287 $services = MediaWikiServices::getInstance();
288 $title = $services->getTitleFactory()->castFromPageReference( $cpoParams->
getPage() );
292 list( $redir, $text ) =
$content->getRedirectTargetAndText();
293 $parserOutput = $services->getParser()->getFreshParser()
295 ->parse( $text,
$title, $parserOptions,
true,
true, $revId );
300 $parserOutput->
addLink( $redir );
302 $redirTarget =
$content->getRedirectTarget();
307 $parserOutput->
addModuleStyles( [
'mediawiki.action.view.redirectPage' ] );
309 $parserOutput->
setText(
null );
314 if ( in_array(
'user-signature',
$content->getPreSaveTransformFlags() ) ) {
315 $parserOutput->
setOutputFlag( ParserOutputFlags::USER_SIGNATURE );
const CONTENT_MODEL_WIKITEXT
const CONTENT_FORMAT_WIKITEXT
Wikitext.
static getRedirectHeaderHtml(Language $lang, $target, $forceKnown=false)
Return the HTML for the top of a redirect page.
checkFormat( $format)
Convenient for checking whether a format provided as a parameter is actually supported.
shouldCallDeprecatedContentTransformMethod(Content $content, $params)
Check if we need to provide content overrides deprecated Content method.
callDeprecatedContentPST(Content $content, PreSaveTransformParams $params)
Provided content overrides deprecated Content::preSaveTransform, call it and return.
Content handler for File: files TODO: this handler s not used directly now, but instead manually call...
Wrapper allowing us to handle a system message as a Content object.
addLink(LinkTarget $link, $id=null)
Record a local or interwiki inline link for saving in future link tables.
getRawText()
Get the cacheable text with <mw:editsection> markers still in it.
setText( $text)
Set the text of the ParserOutput.
setOutputFlag(string $name, bool $val=true)
Provides a uniform interface to various boolean flags stored in the ParserOutput.
addModuleStyles( $modules)
Contain a class for special pages.
makeSearchFieldMapping( $name, $type)
Create a search field definition.
Base content handler implementation for flat text contents.
Represents a title within MediaWiki.
getNamespace()
Get the namespace index, i.e.
getFullText()
Get the prefixed title with spaces, plus any fragment (part beginning with '#')
getInterwiki()
Get the interwiki prefix.
Base representation for an editable wiki page.
getTitle()
Get the title object of the article.
Class allowing to explore structure of parsed wikitext.
Content handler for wiki text pages.
preSaveTransform(Content $content, PreSaveTransformParams $pstParams)
Returns a $content object with pre-save transformations applied (or the same object if no transformat...
getContentClass()
Returns the name of the associated Content class, to be used when creating new objects.
supportsRedirects()
Returns true because wikitext supports redirects.
fillParserOutput(Content $content, ContentParseParams $cpoParams, ParserOutput &$parserOutput)
Returns a ParserOutput object resulting from parsing the content's text using the global Parser servi...
preloadTransform(Content $content, PreloadTransformParams $pltParams)
Returns a Content object with preload transformations applied (or this object if no transformations a...
getFieldsForSearchIndex(SearchEngine $engine)
Get fields definition for search index.
makeRedirectContent(Title $destination, $text='')
Returns a WikitextContent object representing a redirect to the given destination page.
isParserCacheSupported()
Returns true, because wikitext supports caching using the ParserCache mechanism.
__construct( $modelId=CONTENT_MODEL_WIKITEXT)
serializeContent(Content $content, $format=null)
Returns the content's text as-is.
supportsSections()
Returns true because wikitext supports sections.
getDataForSearchIndex(WikiPage $page, ParserOutput $parserOutput, SearchEngine $engine)
Return fields to be indexed by search engine as representation of this document.
Base interface for content objects.
const FLAG_SCORING
This field contains secondary information, which is already present in other fields,...
const INDEX_TYPE_TEXT
TEXT fields are suitable for natural language and may be subject to analysis such as stemming.
const FLAG_NO_HIGHLIGHT
This field does not need highlight handling.