55 if ( $text ===
null || $text ===
false ) {
56 wfWarn(
"TextContent constructed with \$text = " . var_export( $text,
true ) .
"! "
57 .
"This may indicate an error in the caller's scope.", 2 );
62 if ( !is_string( $text ) ) {
63 throw new MWException(
"TextContent expects a string in the constructor." );
75 return $this; # NOTE:
this is ok since
TextContent are immutable.
88 $truncatedtext = MediaWikiServices::getInstance()->getContentLanguage()->
89 truncateForDatabase( preg_replace(
"/[\n\r]/",
' ', $text ), max( 0, $maxlength ) );
91 return $truncatedtext;
104 return strlen( $text );
181 '@phan-var WikitextContent $wikitext';
184 return $wikitext->getText();
204 return str_replace( [
"\r\n",
"\r" ],
"\n", rtrim( $text ) );
223 '@phan-var self $that';
227 $lang = MediaWikiServices::getInstance()->getContentLanguage();
231 $ntext = $that->getText();
233 # Note: Use native PHP diff, external engines don't give us abstract output
234 $ota = explode(
"\n",
$lang->segmentForDiff( $otext ) );
235 $nta = explode(
"\n",
$lang->segmentForDiff( $ntext ) );
237 $diff =
new Diff( $ota, $nta );
268 $output = MediaWikiServices::getInstance()->getParser()
269 ->parse( $this->
getText(),
$title, $options,
true,
true, $revId );
272 if ( $generateHtml ) {
295 return htmlspecialchars( $this->
getText() );
314 public function convert( $toModel, $lossy =
'' ) {
315 $converted = parent::convert( $toModel, $lossy );
317 if ( $converted !==
false ) {
326 $converted = $toHandler->unserializeContent( $text );
$wgArticleCountMethod
Method used to determine if a page in a content namespace should be counted as a valid article.
$wgTextModelsToParse
Determines which types of text are parsed as wikitext.
const CONTENT_MODEL_WIKITEXT
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
Base implementation for content objects.
getContentHandlerFactory()
string $model_id
Name of the content model this Content object represents.
Class representing a 'diff' between two sequences of strings.
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
Set options of the Parser.
clearWrapperDivClass()
Clears the CSS class to use for the wrapping div, effectively disabling the wrapper div until addWrap...
Base content handler implementation for flat text contents.
Content object implementation for representing flat text.
fillParserOutput(Title $title, $revId, ParserOptions $options, $generateHtml, ParserOutput &$output)
Fills the provided ParserOutput object with information derived from the content.
isCountable( $hasLinks=null)
Returns true if this content is not a redirect, and $wgArticleCountMethod is "any".
getSize()
Returns the text's size in bytes.
__construct( $text, $model_id=CONTENT_MODEL_TEXT)
getWikitextForTransclusion()
Returns attempts to convert this content object to wikitext, and then returns the text string.
convert( $toModel, $lossy='')
This implementation provides lossless conversion between content models based on TextContent.
getText()
Returns the text represented by this Content object, as a string.
getHtml()
Generates an HTML version of the content, for display.
getNativeData()
Returns the text represented by this Content object, as a string.
diff(Content $that, Language $lang=null)
Diff this content object with another content object.
getTextForSearchIndex()
Returns the text represented by this Content object, as a string.
getTextForSummary( $maxlength=250)
static normalizeLineEndings( $text)
Do a "\\r\\n" -> "\\n" and "\\r" -> "\\n" transformation as well as trim trailing whitespace.
Represents a title within MediaWiki.
Base interface for content objects.
getModel()
Returns the ID of the content model used by this Content object.
if(!isset( $args[0])) $lang