getNativeData()
authorDaniel Kinzler <daniel.kinzler@wikimedia.de>
Mon, 19 Mar 2012 20:25:48 +0000 (20:25 +0000)
committerDaniel Kinzler <daniel.kinzler@wikimedia.de>
Wed, 4 Apr 2012 17:56:12 +0000 (19:56 +0200)
includes/Content.php
includes/ContentHandler.php
includes/EditPage.php
includes/WikiPage.php
includes/api/ApiEditPage.php
includes/api/ApiParse.php

index 859bb0c..8280fc9 100644 (file)
@@ -25,7 +25,9 @@ abstract class Content {
      * as given by getDataModel().
      *
      */
-    public abstract function getRawData( );
+    public abstract function getNativeData( );
+
+    public abstract function getSize( );
 
     public abstract function getParserOutput( Title $title = null, $revId = null, ParserOptions $options = NULL );
 
@@ -58,11 +60,9 @@ abstract class Content {
     }
 
     #TODO: implement specialized ParserOutput for Wikidata model
-    #TODO: provide addToParserOutput fule Multipart... somehow.
+    #TODO: provide "combined" ParserOutput for Multipart... somehow.
 
-    # TODO: EditPage::mergeChanges( Content $a, Content $b )
     # TODO: Wikipage::isCountable(Content $a)
-    # TODO: Title::newFromRedirectRecurse( $this->getRawText() );
 
     # TODO: isCacheable( )
     # TODO: getSize( )
@@ -71,7 +71,11 @@ abstract class Content {
     # TODO: WikiPage::getAutosummary( $oldtext, $text, $flags )
 
     # TODO: EditPage::getPreloadedText( $preload ) // $wgParser->getPreloadText
+    # TODO: tie into EditPage, make it use Content-objects throughout, make edit form aware of content model and format
+    # TODO: make model-aware diff view!
+    # TODO: handle ImagePage and CategoryPage
 
+    # TODO: Title::newFromRedirectRecurse( $this->getRawText() );
 
     # TODO: tie into API to provide contentModel for Revisions
     # TODO: tie into API to provide serialized version and contentFormat for Revisions
@@ -94,7 +98,7 @@ abstract class TextContent extends Content {
      *
      * @return String the raw text
      */
-    public function getRawData( ) {
+    public function getNativeData( ) {
         $text = $this->mText;
         return $text;
     }
@@ -105,7 +109,7 @@ abstract class TextContent extends Content {
      * @return String the raw text
      */
     public function getSearchText( ) { #FIXME: use!
-        return $this->getRawData();
+        return $this->getNativeData();
     }
 
     /**
@@ -114,7 +118,7 @@ abstract class TextContent extends Content {
      * @return String the raw text
      */
     public function getWikitextForTransclusion( ) { #FIXME: use!
-        return $this->getRawData();
+        return $this->getNativeData();
     }
 
     /**
@@ -186,7 +190,7 @@ class WikitextContent extends TextContent {
     public function getSection( $section ) {
         global $wgParser;
 
-        $text = $this->getRawData();
+        $text = $this->getNativeData();
         $sect = $wgParser->getSection( $text, $section, false );
 
         return  new WikitextContent( $sect );
@@ -212,8 +216,8 @@ class WikitextContent extends TextContent {
             throw new MWException( "Incompatible content model for section: document uses $myModelName, section uses $sectionModelName." );
         }
 
-        $oldtext = $this->getRawData();
-        $text = $with->getRawData();
+        $oldtext = $this->getNativeData();
+        $text = $with->getNativeData();
 
         if ( $section == 'new' ) {
             # Inserting a new section
@@ -237,7 +241,7 @@ class WikitextContent extends TextContent {
     }
 
     public function getRedirectChain() {
-        $text = $this->getRawData();
+        $text = $this->getNativeData();
         return Title::newFromRedirectArray( $text );
     }
 
@@ -270,7 +274,7 @@ class MessageContent extends TextContent {
     /**
      * Returns the message as raw text, using the options supplied to the constructor minus "parse" and "parseinline".
      */
-    public function getRawData( ) {
+    public function getNativeData( ) {
         $opt = array_diff( $this->mOptions, array('parse', 'parseinline') );
 
         return wfMsgExt( $this->mMessageKey, $this->mParameters, $opt );
@@ -287,7 +291,7 @@ class JavaScriptContent extends TextContent {
     protected function getHtml( ) {
         $html = "";
         $html .= "<pre class=\"mw-code mw-js\" dir=\"ltr\">\n";
-        $html .= htmlspecialchars( $this->getRawData() );
+        $html .= htmlspecialchars( $this->getNativeData() );
         $html .= "\n</pre>\n";
 
         return $html;
@@ -303,7 +307,7 @@ class CssContent extends TextContent {
     protected function getHtml( ) {
         $html = "";
         $html .= "<pre class=\"mw-code mw-css\" dir=\"ltr\">\n";
-        $html .= htmlspecialchars( $this->getRawData() );
+        $html .= htmlspecialchars( $this->getNativeData() );
         $html .= "\n</pre>\n";
 
         return $html;
index 1a80b37..8a1badc 100644 (file)
@@ -20,7 +20,7 @@ abstract class ContentHandler {
             #XXX: or check by model name?
             #XXX: or define $content->allowRawData()?
             #XXX: or define $content->getDefaultWikiText()?
-            return $content->getRawData();
+            return $content->getNativeData();
         }
 
         #XXX: this must not be used for editing, otherwise we may loose data:
@@ -233,7 +233,7 @@ abstract class TextContentHandler extends ContentHandler {
 
     public function serialize( Content $content, $format = null ) {
         #FIXME: assert format
-        return $content->getRawData();
+        return $content->getNativeData();
     }
 
     /**
index 91d2be4..84cca5e 100644 (file)
@@ -866,7 +866,7 @@ class EditPage {
                }
 
         $content = $this->mArticle->getContentObject();
-               return $content->getRawData(); # this editor is for editing the raw text. so use the raw text.
+               return $content->getNativeData(); # this editor is for editing the raw text. so use the raw text.
        }
 
        /**
index 749f19b..4f7ba15 100644 (file)
@@ -429,11 +429,11 @@ class WikiPage extends Page {
                return $this->getText( Revision::RAW );
        }
 
-    protected function getRawData() {
+    protected function getNativeData() {
         $content = $this->getContent( Revision::RAW );
         if ( !$content ) return null;
 
-        return $content->getRawData();
+        return $content->getNativeData();
     }
 
        /**
@@ -911,7 +911,7 @@ class WikiPage extends Page {
 
                if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
                        if ( $this->mTitle->exists() ) {
-                               $text = $this->getRawData();
+                               $text = $this->getNativeData();
                        } else {
                                $text = false;
                        }
@@ -1265,7 +1265,7 @@ class WikiPage extends Page {
                $isminor = ( $flags & EDIT_MINOR ) && $user->isAllowed( 'minoredit' );
                $bot = $flags & EDIT_FORCE_BOT;
 
-               $oldtext = $this->getRawData(); // current revision
+               $oldtext = $this->getNativeData(); // current revision
                $oldsize = strlen( $oldtext );
                $oldid = $this->getLatest();
                $oldIsRedirect = $this->isRedirect();
index 3b74dac..e3cc80e 100644 (file)
@@ -112,7 +112,7 @@ class ApiEditPage extends ApiBase {
                 $text = '';
                        } else {
                 $content = $articleObj->getContentObject();
-                $text = $content->getRawData();
+                $text = $content->getNativeData();
                        }
 
                        if ( !is_null( $params['section'] ) ) {
index 7824c35..070a43d 100644 (file)
@@ -330,7 +330,7 @@ class ApiParse extends ApiBase {
                        $pout = $page->getParserOutput( $popts );
                        if ( $getWikitext ) {
                 $this->content = $page->getContent( Revision::RAW ); #FIXME: use $this->content everywhere
-                               $this->text = $this->content->getRawData(); #FIXME: change $this->text to $this->data?!
+                               $this->text = $this->content->getNativeData(); #FIXME: change $this->text to $this->data?!
                        }
                        return $pout;
                }