}
public function getTextForSummary( $maxlength = 250 ) {
- $text = $this->getNativeData();
+ $text = $this->getText();
$truncatedtext = MediaWikiServices::getInstance()->getContentLanguage()->
truncateForDatabase( preg_replace( "/[\n\r]/", ' ', $text ), max( 0, $maxlength ) );
* @return int
*/
public function getSize() {
- $text = $this->getNativeData();
+ $text = $this->getText();
return strlen( $text );
}
/**
* Returns the text represented by this Content object, as a string.
*
- * @return string The raw text.
+ * @deprecated since 1.33 use getText() instead.
+ *
+ * @return string The raw text. Subclasses may guarantee a specific syntax here.
*/
public function getNativeData() {
+ return $this->getText();
+ }
+
+ /**
+ * Returns the text represented by this Content object, as a string.
+ *
+ * @since 1.33
+ *
+ * @return string The raw text.
+ */
+ public function getText() {
return $this->mText;
}
* @return string The raw text.
*/
public function getTextForSearchIndex() {
- return $this->getNativeData();
+ return $this->getText();
}
/**
* @return string|bool The raw text, or false if the conversion failed.
*/
public function getWikitextForTransclusion() {
+ /** @var WikitextContent $wikitext */
$wikitext = $this->convert( CONTENT_MODEL_WIKITEXT, 'lossy' );
+ '@phan-var WikitextContent $wikitext';
if ( $wikitext ) {
- return $wikitext->getNativeData();
+ return $wikitext->getText();
} else {
return false;
}
* @return Content
*/
public function preSaveTransform( Title $title, User $user, ParserOptions $popts ) {
- $text = $this->getNativeData();
+ $text = $this->getText();
$pst = self::normalizeLineEndings( $text );
return ( $text === $pst ) ? $this : new static( $pst, $this->getModel() );
*/
public function diff( Content $that, Language $lang = null ) {
$this->checkModelID( $that->getModel() );
-
+ /** @var self $that */
+ '@phan-var self $that';
// @todo could implement this in DifferenceEngine and just delegate here?
if ( !$lang ) {
$lang = MediaWikiServices::getInstance()->getContentLanguage();
}
- $otext = $this->getNativeData();
- $ntext = $that->getNativeData();
+ $otext = $this->getText();
+ $ntext = $that->getText();
# Note: Use native PHP diff, external engines don't give us abstract output
$ota = explode( "\n", $lang->segmentForDiff( $otext ) );
protected function fillParserOutput( Title $title, $revId,
ParserOptions $options, $generateHtml, ParserOutput &$output
) {
- global $wgParser, $wgTextModelsToParse;
+ global $wgTextModelsToParse;
if ( in_array( $this->getModel(), $wgTextModelsToParse ) ) {
// parse just to get links etc into the database, HTML is replaced below.
- $output = $wgParser->parse( $this->getNativeData(), $title, $options, true, true, $revId );
+ $output = MediaWikiServices::getInstance()->getParser()
+ ->parse( $this->getText(), $title, $options, true, true, $revId );
}
if ( $generateHtml ) {
* @return string An HTML representation of the content
*/
protected function getHighlightHtml() {
- return htmlspecialchars( $this->getNativeData() );
+ return htmlspecialchars( $this->getText() );
}
/**
if ( $toHandler instanceof TextContentHandler ) {
// NOTE: ignore content serialization format - it's just text anyway.
- $text = $this->getNativeData();
+ $text = $this->getText();
$converted = $toHandler->unserializeContent( $text );
}