https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114258
Revision: 114258
Author: daniel
Date: 2012-03-20 12:12:55 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
fix JS/CSS view
Modified Paths:
--------------
branches/Wikidata/phase3/includes/Article.php
branches/Wikidata/phase3/includes/Content.php
branches/Wikidata/phase3/includes/EditPage.php
branches/Wikidata/phase3/includes/WikiPage.php
Modified: branches/Wikidata/phase3/includes/Article.php
===================================================================
--- branches/Wikidata/phase3/includes/Article.php 2012-03-20 12:00:18 UTC
(rev 114257)
+++ branches/Wikidata/phase3/includes/Article.php 2012-03-20 12:12:55 UTC
(rev 114258)
@@ -620,7 +620,7 @@
# Viewing a redirect
page (e.g. with parameter redirect=no)
$wgOut->addHTML(
$this->viewRedirect( $rt ) );
# Parse just to get
categories, displaytitle, etc.
- $this->mParserOutput =
$content->getParserOutput( $parserOptions );
+ $this->mParserOutput =
$content->getParserOutput( $this->getTitle(), $oldid, $parserOptions );
$wgOut->addParserOutputNoText( $this->mParserOutput );
$outputDone = true;
}
@@ -754,7 +754,8 @@
// Give hooks a chance to customise the output
if ( wfRunHooks( 'ShowRawCssJs', array( $this->mContent,
$this->getTitle(), $wgOut ) ) ) {
- $wgOut->addHTML( $this->mContentObject->getHTML() );
+ $po = $this->mContentObject->getParserOutput();
+ $wgOut->addHTML( $po->getText() );
}
}
Modified: branches/Wikidata/phase3/includes/Content.php
===================================================================
--- branches/Wikidata/phase3/includes/Content.php 2012-03-20 12:00:18 UTC
(rev 114257)
+++ branches/Wikidata/phase3/includes/Content.php 2012-03-20 12:12:55 UTC
(rev 114258)
@@ -8,7 +8,7 @@
*/
abstract class Content {
- public function __construct( $modelName = null ) { #FIXME: really need
revId? annoying! #FIXME: really $title? or just when parsing, every time?
+ public function __construct( $modelName = null ) {
$this->mModelName = $modelName;
}
@@ -100,8 +100,6 @@
# XXX: isCacheable( ) # can/should we do this here?
- # TODO: WikiPage::getUndoText( Revision $undo, Revision $undoafter = null )
-
# 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: tie into WikiPage, make it use Content-objects throughout,
especially in doEdit(), doDelete(), updateRevisionOn(), etc
@@ -205,10 +203,6 @@
$html = $this->getHtml( $options );
$po = new ParserOutput( $html );
- if ( $this->mTitle ) $po->setTitleText( $this->mTitle->getText() );
-
- #TODO: cache settings, etc?
-
return $po;
}
@@ -249,7 +243,7 @@
$options = $this->getDefaultParserOptions();
}
- $po = $wgParser->parse( $this->mText, $this->getTitle(), $options,
true, true, $this->mRevId );
+ $po = $wgParser->parse( $this->mText, $title, $options, true, true,
$revId );
return $po;
}
Modified: branches/Wikidata/phase3/includes/EditPage.php
===================================================================
--- branches/Wikidata/phase3/includes/EditPage.php 2012-03-20 12:00:18 UTC
(rev 114257)
+++ branches/Wikidata/phase3/includes/EditPage.php 2012-03-20 12:12:55 UTC
(rev 114258)
@@ -1299,17 +1299,15 @@
if ( $this->isConflict ) {
wfDebug( __METHOD__ . ": conflict! getting
section '$this->section' for time '$this->edittime' (article time
'{$timestamp}')\n" );
- $cnt = $this->mArticle->replaceSection(
$this->section, $this->textbox1, $sectionTitle, $this->edittime );
- $text = ContentHandler::getContentText($cnt); #FIXME: use
Content object throughout, make edit form aware of content model and
serialization format
+ $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
} else {
wfDebug( __METHOD__ . ": getting section
'$this->section'\n" );
- $cnt = $this->mArticle->replaceSection( $this->section,
$this->textbox1, $sectionTitle );
- $text = ContentHandler::getContentText($cnt); #FIXME: use
Content object throughout, make edit form aware of content model and
serialization format
+ $text = $this->mArticle->replaceSection( $this->section,
$this->textbox1, $sectionTitle ); #FIXME: use Content object throughout, make
edit form aware of content model and serialization format
}
if ( is_null( $text ) ) {
wfDebug( __METHOD__ . ": activating conflict;
section replace failed.\n" );
$this->isConflict = true;
- $text = $this->textbox1; // do not try to merge
here!
+ $text = $this->textbox1; // do not try to merge
here! #FIXME: unserialize Content
} elseif ( $this->isConflict ) {
# Attempt merge
if ( $this->mergeChangesInto( $text ) ) {
#FIXME: passe/receive Content object
@@ -2315,7 +2313,7 @@
$oldtext = $this->getOriginalContent();
$newtext = $this->mArticle->replaceSection(
- $this->section, $this->textbox1, $this->summary,
$this->edittime );
+ $this->section, $this->textbox1, $this->summary,
$this->edittime ); #FIXME: use Content::replaceSection
wfRunHooks( 'EditPageGetDiffText', array( $this, &$newtext ) );
Modified: branches/Wikidata/phase3/includes/WikiPage.php
===================================================================
--- branches/Wikidata/phase3/includes/WikiPage.php 2012-03-20 12:00:18 UTC
(rev 114257)
+++ branches/Wikidata/phase3/includes/WikiPage.php 2012-03-20 12:12:55 UTC
(rev 114258)
@@ -303,7 +303,9 @@
if ( $text === false ) $content = $this->getContent();
else $content = ContentHandler::makeContent( $text, $this->mTitle ); #
TODO: allow model and format to be provided; or better, expect a Content object
- return $content->isRedirect();
+
+ if ( empty( $content ) ) return false;
+ else return $content->isRedirect();
}
/**
@@ -429,7 +431,7 @@
*
* @return Contet|false The text of the current revision
*/
- protected function getNativeData() {
+ protected function getNativeData() { #FIXME: examine all uses carefully!
caller must be aware of content model!
$content = $this->getContent( Revision::RAW );
if ( !$content ) return null;
@@ -563,7 +565,7 @@
$content = $this->getContent();
}
- if ( $content->isRedirect( ) ) {
+ if ( !$content || $content->isRedirect( ) ) {
return false;
}
@@ -1111,7 +1113,11 @@
$handler = ContentHandler::getForTitle( $this->getTitle() );
$undone = $handler->getUndoContent( $this->mLastRevision, $undo,
$undoafter );
- return ContentHandler::getContentText( $undone );
+ if ( !$undone ) {
+ return false;
+ } else {
+ return ContentHandler::getContentText( $undone );
+ }
}
return false;
@@ -1123,8 +1129,9 @@
* @param $sectionTitle String: new section's subject, only if $section
is 'new'
* @param $edittime String: revision timestamp or null to use the
current revision
* @return Content new complete article content, or null if error
+ * @deprecated since 1.20: use Content::replaceSection () instead.
*/
- public function replaceSection( $section, $text, $sectionTitle = '',
$edittime = null ) {
+ public function replaceSection( $section, $text, $sectionTitle = '',
$edittime = null ) { #FIXME: create a Content-based version (take and return
Content object)
wfProfileIn( __METHOD__ );
$sectionContent = ContentHandler::makeContent( $text,
$this->getTitle() ); #XXX: could make section title, but that's not required.
@@ -1159,7 +1166,7 @@
}
wfProfileOut( __METHOD__ );
- return $newContent;
+ return ContentHandler::getContentText( $newContent ); #XXX:
unclear what will happen for non-wikitext!
}
/**
@@ -2762,7 +2769,7 @@
}
$time = - wfTime();
- $this->parserOutput = $content->getParserOutput(
$this->parserOptions );
+ $this->parserOutput = $content->getParserOutput(
$this->page->getTitle(), $this->revid, $this->parserOptions );
$time += wfTime();
# Timing hack
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs