From 0d89bb4608d8db7f592291b4413d2a0c7711241d Mon Sep 17 00:00:00 2001 From: Daniel Kinzler Date: Mon, 19 Mar 2012 20:25:48 +0000 Subject: [PATCH] getNativeData() --- includes/Content.php | 32 ++++++++++++++++++-------------- includes/ContentHandler.php | 4 ++-- includes/EditPage.php | 2 +- includes/WikiPage.php | 8 ++++---- includes/api/ApiEditPage.php | 2 +- includes/api/ApiParse.php | 2 +- 6 files changed, 27 insertions(+), 23 deletions(-) diff --git a/includes/Content.php b/includes/Content.php index 859bb0c7c8..8280fc9178 100644 --- a/includes/Content.php +++ b/includes/Content.php @@ -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 .= "
\n";
-        $html .= htmlspecialchars( $this->getRawData() );
+        $html .= htmlspecialchars( $this->getNativeData() );
         $html .= "\n
\n"; return $html; @@ -303,7 +307,7 @@ class CssContent extends TextContent { protected function getHtml( ) { $html = ""; $html .= "
\n";
-        $html .= htmlspecialchars( $this->getRawData() );
+        $html .= htmlspecialchars( $this->getNativeData() );
         $html .= "\n
\n"; return $html; diff --git a/includes/ContentHandler.php b/includes/ContentHandler.php index 1a80b371f9..8a1badcaa8 100644 --- a/includes/ContentHandler.php +++ b/includes/ContentHandler.php @@ -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(); } /** diff --git a/includes/EditPage.php b/includes/EditPage.php index 91d2be4789..84cca5eb76 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -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. } /** diff --git a/includes/WikiPage.php b/includes/WikiPage.php index 749f19b62d..4f7ba15281 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -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(); diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index 3b74dac846..e3cc80e232 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -112,7 +112,7 @@ class ApiEditPage extends ApiBase { $text = ''; } else { $content = $articleObj->getContentObject(); - $text = $content->getRawData(); + $text = $content->getNativeData(); } if ( !is_null( $params['section'] ) ) { diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 7824c355e8..070a43d217 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -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; } -- 2.20.1