41 parent::__construct( $modelId, $formats );
56 return $content->getText();
76 if ( $myContent->
equals( $yourContent ) ) {
81 if ( $oldContent->
equals( $yourContent ) ) {
95 $ok =
wfMerge( $old, $mine, $yours, $result );
107 return $mergedContent;
120 return TextContent::class;
137 return new $class( $text );
149 return new $class(
'' );
162 $fields = parent::getFieldsForSearchIndex( $engine );
163 $fields[
'language'] =
175 $fields = parent::getDataForSearchIndex( $page, $output, $engine, $revision );
176 $fields[
'language'] =
185 '@phan-var TextContent $content';
187 $text = $content->getText();
189 $pst = TextContent::normalizeLineEndings( $text );
192 return ( $text === $pst ) ? $content :
new $contentClass( $pst, $content->
getModel() );
220 $textModelsToParse = MediaWikiServices::getInstance()->getMainConfig()->get(
221 MainConfigNames::TextModelsToParse );
222 '@phan-var TextContent $content';
223 if ( in_array( $content->
getModel(), $textModelsToParse ) ) {
225 $output = MediaWikiServices::getInstance()->getParserFactory()->getInstance()
238 if ( method_exists( $content,
'getHtml' ) ) {
239 $method =
new ReflectionMethod( $content,
'getHtml' );
240 $method->setAccessible(
true );
241 $html = $method->invoke( $content );
242 $html =
"<pre>$html</pre>";
245 $html = htmlspecialchars( $content->getText(), ENT_COMPAT );
246 $html =
"<pre>$html</pre>";
const CONTENT_FORMAT_TEXT
For future use, e.g.
wfMerge(string $old, string $mine, string $yours, ?string &$simplisticMergeAttempt, string &$mergeLeftovers=null)
wfMerge attempts to merge differences between three texts.
A content handler knows how do deal with a specific type of content on a wiki page.
checkFormat( $format)
Convenient for checking whether a format provided as a parameter is actually supported.
getPageLanguage(Title $title, Content $content=null)
Get the language in which the content of the given page is written.
getDefaultFormat()
The format used for serialization/deserialization by default by this ContentHandler.
A class containing constants representing the names of configuration variables.
Contain a class for special pages.
makeSearchFieldMapping( $name, $type)
Create a search field definition.
Base content handler implementation for flat text contents.
unserializeContent( $text, $format=null)
Unserializes a Content object of the type supported by this ContentHandler.
serializeContent(Content $content, $format=null)
Returns the content's text as-is.
getContentClass()
Returns the name of the associated Content class, to be used when creating new objects.
__construct( $modelId=CONTENT_MODEL_TEXT, $formats=[CONTENT_FORMAT_TEXT])
Constructor, initializing the ContentHandler instance with its model ID and a list of supported forma...
getFieldsForSearchIndex(SearchEngine $engine)
Get fields definition for search index.
makeEmptyContent()
Creates an empty TextContent object.
fillParserOutput(Content $content, ContentParseParams $cpoParams, ParserOutput &$output)
Fills the provided ParserOutput object with information derived from the content.
merge3(Content $oldContent, Content $myContent, Content $yourContent)
Attempts to merge differences between three versions.
preSaveTransform(Content $content, PreSaveTransformParams $pstParams)
Returns a $content object with pre-save transformations applied (or the same object if no transformat...
getDataForSearchIndex(WikiPage $page, ParserOutput $output, SearchEngine $engine, ?RevisionRecord $revision=null)
Base representation for an editable wiki page.
getContent( $audience=RevisionRecord::FOR_PUBLIC, Authority $performer=null)
Get the content of the current revision.
getTitle()
Get the title object of the article.
Base interface for representing page content.
getModel()
Returns the ID of the content model used by this Content object.
equals(Content $that=null)
Returns true if this Content objects is conceptually equivalent to the given Content object.