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

index 84cca5e..cd7a8ac 100644 (file)
@@ -866,7 +866,7 @@ class EditPage {
                }
 
         $content = $this->mArticle->getContentObject();
-               return $content->getNativeData(); # this editor is for editing the raw text. so use the raw text.
+               return ContentHandler::getContentText( $content ); # this editor is for editing the raw text. so use the raw text.
        }
 
        /**
index 4f7ba15..df81657 100644 (file)
@@ -911,7 +911,7 @@ class WikiPage extends Page {
 
                if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
                        if ( $this->mTitle->exists() ) {
-                               $text = $this->getNativeData();
+                               $text = $this->getNativeData(); #FIXME: may not be a string. check Content model!
                        } 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->getNativeData(); // current revision
+               $oldtext = $this->getNativeData(); // current revision #FIXME: may not be a string. check Content model!
                $oldsize = strlen( $oldtext );
                $oldid = $this->getLatest();
                $oldIsRedirect = $this->isRedirect();
index e3cc80e..e93b1a2 100644 (file)
@@ -112,13 +112,14 @@ class ApiEditPage extends ApiBase {
                 $text = '';
                        } else {
                 $content = $articleObj->getContentObject();
-                $text = $content->getNativeData();
+                $text = ContentHandler::getContentText( $content ); #FIXME: serialize?! get format from params?...
                        }
 
                        if ( !is_null( $params['section'] ) ) {
                                // Process the content for section edits
                                $section = intval( $params['section'] );
-                $text = $content->getSection( $section, false );
+                $sectionContent = $content->getSection( $section );
+                $text = ContentHandler::getContentText( $sectionContent ); #FIXME: serialize?! get format from params?...
                                if ( $text === false || $text === null ) {
                                        $this->dieUsage( "There is no section {$section}.", 'nosuchsection' );
                                }
index 070a43d..10f17a2 100644 (file)
@@ -318,7 +318,7 @@ class ApiParse extends ApiBase {
 
                $page = WikiPage::factory( $titleObj );
 
-               if ( $this->section !== false ) {
+               if ( $this->section !== false ) { #FIXME: get section Content, get parser output, ...
                        $this->text = $this->getSectionText( $page->getRawText(), !is_null( $pageId )
                                        ? 'page id ' . $pageId : $titleObj->getText() ); #FIXME: get section...
 
@@ -330,13 +330,13 @@ 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->getNativeData(); #FIXME: change $this->text to $this->data?!
+                               $this->text = ContentHandler::getContentText( $this->content ); #FIXME: serialize, get format from params; or use object structure in result?
                        }
                        return $pout;
                }
        }
 
-       private function getSectionText( $text, $what ) {
+       private function getSectionText( $text, $what ) { #FIXME: replace with Content::getSection
                global $wgParser;
                // Not cached (save or load)
                $text = $wgParser->getSection( $text, $this->section, false );