Index: branches/Wikidata/phase3/includes/Article.php |
— | — | @@ -620,7 +620,7 @@ |
621 | 621 | # Viewing a redirect page (e.g. with parameter redirect=no) |
622 | 622 | $wgOut->addHTML( $this->viewRedirect( $rt ) ); |
623 | 623 | # Parse just to get categories, displaytitle, etc. |
624 | | - $this->mParserOutput = $content->getParserOutput( $parserOptions ); |
| 624 | + $this->mParserOutput = $content->getParserOutput( $this->getTitle(), $oldid, $parserOptions ); |
625 | 625 | $wgOut->addParserOutputNoText( $this->mParserOutput ); |
626 | 626 | $outputDone = true; |
627 | 627 | } |
— | — | @@ -754,7 +754,8 @@ |
755 | 755 | |
756 | 756 | // Give hooks a chance to customise the output |
757 | 757 | if ( wfRunHooks( 'ShowRawCssJs', array( $this->mContent, $this->getTitle(), $wgOut ) ) ) { |
758 | | - $wgOut->addHTML( $this->mContentObject->getHTML() ); |
| 758 | + $po = $this->mContentObject->getParserOutput(); |
| 759 | + $wgOut->addHTML( $po->getText() ); |
759 | 760 | } |
760 | 761 | } |
761 | 762 | |
Index: branches/Wikidata/phase3/includes/Content.php |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | */ |
10 | 10 | abstract class Content { |
11 | 11 | |
12 | | - public function __construct( $modelName = null ) { #FIXME: really need revId? annoying! #FIXME: really $title? or just when parsing, every time? |
| 12 | + public function __construct( $modelName = null ) { |
13 | 13 | $this->mModelName = $modelName; |
14 | 14 | } |
15 | 15 | |
— | — | @@ -100,8 +100,6 @@ |
101 | 101 | |
102 | 102 | # XXX: isCacheable( ) # can/should we do this here? |
103 | 103 | |
104 | | - # TODO: WikiPage::getUndoText( Revision $undo, Revision $undoafter = null ) |
105 | | - |
106 | 104 | # TODO: EditPage::getPreloadedText( $preload ) // $wgParser->getPreloadText |
107 | 105 | # TODO: tie into EditPage, make it use Content-objects throughout, make edit form aware of content model and format |
108 | 106 | # TODO: tie into WikiPage, make it use Content-objects throughout, especially in doEdit(), doDelete(), updateRevisionOn(), etc |
— | — | @@ -205,10 +203,6 @@ |
206 | 204 | $html = $this->getHtml( $options ); |
207 | 205 | $po = new ParserOutput( $html ); |
208 | 206 | |
209 | | - if ( $this->mTitle ) $po->setTitleText( $this->mTitle->getText() ); |
210 | | - |
211 | | - #TODO: cache settings, etc? |
212 | | - |
213 | 207 | return $po; |
214 | 208 | } |
215 | 209 | |
— | — | @@ -249,7 +243,7 @@ |
250 | 244 | $options = $this->getDefaultParserOptions(); |
251 | 245 | } |
252 | 246 | |
253 | | - $po = $wgParser->parse( $this->mText, $this->getTitle(), $options, true, true, $this->mRevId ); |
| 247 | + $po = $wgParser->parse( $this->mText, $title, $options, true, true, $revId ); |
254 | 248 | |
255 | 249 | return $po; |
256 | 250 | } |
Index: branches/Wikidata/phase3/includes/EditPage.php |
— | — | @@ -1299,17 +1299,15 @@ |
1300 | 1300 | |
1301 | 1301 | if ( $this->isConflict ) { |
1302 | 1302 | wfDebug( __METHOD__ . ": conflict! getting section '$this->section' for time '$this->edittime' (article time '{$timestamp}')\n" ); |
1303 | | - $cnt = $this->mArticle->replaceSection( $this->section, $this->textbox1, $sectionTitle, $this->edittime ); |
1304 | | - $text = ContentHandler::getContentText($cnt); #FIXME: use Content object throughout, make edit form aware of content model and serialization format |
| 1303 | + $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $sectionTitle, $this->edittime ); #FIXME: use Content object throughout, make edit form aware of content model and serialization format |
1305 | 1304 | } else { |
1306 | 1305 | wfDebug( __METHOD__ . ": getting section '$this->section'\n" ); |
1307 | | - $cnt = $this->mArticle->replaceSection( $this->section, $this->textbox1, $sectionTitle ); |
1308 | | - $text = ContentHandler::getContentText($cnt); #FIXME: use Content object throughout, make edit form aware of content model and serialization format |
| 1306 | + $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $sectionTitle ); #FIXME: use Content object throughout, make edit form aware of content model and serialization format |
1309 | 1307 | } |
1310 | 1308 | if ( is_null( $text ) ) { |
1311 | 1309 | wfDebug( __METHOD__ . ": activating conflict; section replace failed.\n" ); |
1312 | 1310 | $this->isConflict = true; |
1313 | | - $text = $this->textbox1; // do not try to merge here! |
| 1311 | + $text = $this->textbox1; // do not try to merge here! #FIXME: unserialize Content |
1314 | 1312 | } elseif ( $this->isConflict ) { |
1315 | 1313 | # Attempt merge |
1316 | 1314 | if ( $this->mergeChangesInto( $text ) ) { #FIXME: passe/receive Content object |
— | — | @@ -2315,7 +2313,7 @@ |
2316 | 2314 | |
2317 | 2315 | $oldtext = $this->getOriginalContent(); |
2318 | 2316 | $newtext = $this->mArticle->replaceSection( |
2319 | | - $this->section, $this->textbox1, $this->summary, $this->edittime ); |
| 2317 | + $this->section, $this->textbox1, $this->summary, $this->edittime ); #FIXME: use Content::replaceSection |
2320 | 2318 | |
2321 | 2319 | wfRunHooks( 'EditPageGetDiffText', array( $this, &$newtext ) ); |
2322 | 2320 | |
Index: branches/Wikidata/phase3/includes/WikiPage.php |
— | — | @@ -303,7 +303,9 @@ |
304 | 304 | if ( $text === false ) $content = $this->getContent(); |
305 | 305 | else $content = ContentHandler::makeContent( $text, $this->mTitle ); # TODO: allow model and format to be provided; or better, expect a Content object |
306 | 306 | |
307 | | - return $content->isRedirect(); |
| 307 | + |
| 308 | + if ( empty( $content ) ) return false; |
| 309 | + else return $content->isRedirect(); |
308 | 310 | } |
309 | 311 | |
310 | 312 | /** |
— | — | @@ -429,7 +431,7 @@ |
430 | 432 | * |
431 | 433 | * @return Contet|false The text of the current revision |
432 | 434 | */ |
433 | | - protected function getNativeData() { |
| 435 | + protected function getNativeData() { #FIXME: examine all uses carefully! caller must be aware of content model! |
434 | 436 | $content = $this->getContent( Revision::RAW ); |
435 | 437 | if ( !$content ) return null; |
436 | 438 | |
— | — | @@ -563,7 +565,7 @@ |
564 | 566 | $content = $this->getContent(); |
565 | 567 | } |
566 | 568 | |
567 | | - if ( $content->isRedirect( ) ) { |
| 569 | + if ( !$content || $content->isRedirect( ) ) { |
568 | 570 | return false; |
569 | 571 | } |
570 | 572 | |
— | — | @@ -1111,7 +1113,11 @@ |
1112 | 1114 | $handler = ContentHandler::getForTitle( $this->getTitle() ); |
1113 | 1115 | $undone = $handler->getUndoContent( $this->mLastRevision, $undo, $undoafter ); |
1114 | 1116 | |
1115 | | - return ContentHandler::getContentText( $undone ); |
| 1117 | + if ( !$undone ) { |
| 1118 | + return false; |
| 1119 | + } else { |
| 1120 | + return ContentHandler::getContentText( $undone ); |
| 1121 | + } |
1116 | 1122 | } |
1117 | 1123 | |
1118 | 1124 | return false; |
— | — | @@ -1123,8 +1129,9 @@ |
1124 | 1130 | * @param $sectionTitle String: new section's subject, only if $section is 'new' |
1125 | 1131 | * @param $edittime String: revision timestamp or null to use the current revision |
1126 | 1132 | * @return Content new complete article content, or null if error |
| 1133 | + * @deprecated since 1.20: use Content::replaceSection () instead. |
1127 | 1134 | */ |
1128 | | - public function replaceSection( $section, $text, $sectionTitle = '', $edittime = null ) { |
| 1135 | + public function replaceSection( $section, $text, $sectionTitle = '', $edittime = null ) { #FIXME: create a Content-based version (take and return Content object) |
1129 | 1136 | wfProfileIn( __METHOD__ ); |
1130 | 1137 | |
1131 | 1138 | $sectionContent = ContentHandler::makeContent( $text, $this->getTitle() ); #XXX: could make section title, but that's not required. |
— | — | @@ -1159,7 +1166,7 @@ |
1160 | 1167 | } |
1161 | 1168 | |
1162 | 1169 | wfProfileOut( __METHOD__ ); |
1163 | | - return $newContent; |
| 1170 | + return ContentHandler::getContentText( $newContent ); #XXX: unclear what will happen for non-wikitext! |
1164 | 1171 | } |
1165 | 1172 | |
1166 | 1173 | /** |
— | — | @@ -2762,7 +2769,7 @@ |
2763 | 2770 | } |
2764 | 2771 | |
2765 | 2772 | $time = - wfTime(); |
2766 | | - $this->parserOutput = $content->getParserOutput( $this->parserOptions ); |
| 2773 | + $this->parserOutput = $content->getParserOutput( $this->page->getTitle(), $this->revid, $this->parserOptions ); |
2767 | 2774 | $time += wfTime(); |
2768 | 2775 | |
2769 | 2776 | # Timing hack |