Deprecate Content::getNativeData, add TextContent::getText
[lhc/web/wiklou.git] / includes / content / TextContent.php
index 0198a0d..750b958 100644 (file)
@@ -73,7 +73,7 @@ class TextContent extends AbstractContent {
        }
 
        public function getTextForSummary( $maxlength = 250 ) {
-               $text = $this->getNativeData();
+               $text = $this->getText();
 
                $truncatedtext = MediaWikiServices::getInstance()->getContentLanguage()->
                        truncateForDatabase( preg_replace( "/[\n\r]/", ' ', $text ), max( 0, $maxlength ) );
@@ -87,7 +87,7 @@ class TextContent extends AbstractContent {
         * @return int
         */
        public function getSize() {
-               $text = $this->getNativeData();
+               $text = $this->getText();
 
                return strlen( $text );
        }
@@ -118,9 +118,22 @@ class TextContent extends AbstractContent {
        /**
         * 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;
        }
 
@@ -130,7 +143,7 @@ class TextContent extends AbstractContent {
         * @return string The raw text.
         */
        public function getTextForSearchIndex() {
-               return $this->getNativeData();
+               return $this->getText();
        }
 
        /**
@@ -145,7 +158,7 @@ class TextContent extends AbstractContent {
                $wikitext = $this->convert( CONTENT_MODEL_WIKITEXT, 'lossy' );
 
                if ( $wikitext ) {
-                       return $wikitext->getNativeData();
+                       return $wikitext->getText();
                } else {
                        return false;
                }
@@ -181,7 +194,7 @@ class TextContent extends AbstractContent {
         * @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() );
@@ -208,8 +221,8 @@ class TextContent extends AbstractContent {
                        $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 ) );
@@ -244,7 +257,7 @@ class TextContent extends AbstractContent {
 
                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 = $wgParser->parse( $this->getText(), $title, $options, true, true, $revId );
                }
 
                if ( $generateHtml ) {
@@ -291,7 +304,7 @@ class TextContent extends AbstractContent {
         * @return string An HTML representation of the content
         */
        protected function getHighlightHtml() {
-               return htmlspecialchars( $this->getNativeData() );
+               return htmlspecialchars( $this->getText() );
        }
 
        /**
@@ -318,7 +331,7 @@ class TextContent extends AbstractContent {
 
                if ( $toHandler instanceof TextContentHandler ) {
                        // NOTE: ignore content serialization format - it's just text anyway.
-                       $text = $this->getNativeData();
+                       $text = $this->getText();
                        $converted = $toHandler->unserializeContent( $text );
                }