/**
* Conveniance method for serializing this Content object.
*
- * Shorthand for $this->getContentHandler()->serialize( $this, $format )
+ * Shorthand for $this->getContentHandler()->serializeContent( $this, $format )
*
* @param null|String $format the desired serialization format (or null for the default format).
* @return String serialized form of this Content object
*/
public function serialize( $format = null ) {
- return $this->getContentHandler()->serialize( $this, $format );
+ return $this->getContentHandler()->serializeContent( $this, $format );
}
/**
public abstract function isCountable( $hasLinks = null ) ;
/**
- * @param null|Title $title
+ * @param IContextSource $context
* @param null $revId
* @param null|ParserOptions $options
* @param Boolean $generateHtml whether to generate Html (default: true). If false,
*
* @return ParserOutput
*/
- public abstract function getParserOutput( Title $title = null, $revId = null, ParserOptions $options = NULL, $generateHtml = true );
+ public abstract function getParserOutput( IContextSource $context, $revId = null, ParserOptions $options = NULL, $generateHtml = true );
/**
* Construct the redirect destination from this content and return an
*
* @return ParserOutput representing the HTML form of the text
*/
- public function getParserOutput( Title $title = null, $revId = null, ParserOptions $options = null, $generateHtml = true ) {
+ public function getParserOutput( IContextSource $context, $revId = null, ParserOptions $options = null, $generateHtml = true ) {
# generic implementation, relying on $this->getHtml()
if ( $generateHtml ) $html = $this->getHtml( $options );
}
/**
- * Returns a ParserOutput object reesulting from parsing the content's text using $wgParser
- *
- * @return ParserOutput representing the HTML form of the text
- */
- public function getParserOutput( Title $title = null, $revId = null, ParserOptions $options = null, $generateHtml = true ) {
+ * Returns a ParserOutput object resulting from parsing the content's text using $wgParser.
+ *
+ * @since WikiData1
+ *
+ * @param IContextSource|null $context
+ * @param null $revId
+ * @param null|ParserOptions $options
+ * @param bool $generateHtml
+ *
+ * @return ParserOutput representing the HTML form of the text
+ */
+ public function getParserOutput( IContextSource $context = null, $revId = null, ParserOptions $options = null, $generateHtml = true ) {
global $wgParser;
if ( !$options ) {
$options = $this->getDefaultParserOptions();
}
- $po = $wgParser->parse( $this->mText, $title, $options, true, true, $revId );
+ $po = $wgParser->parse( $this->mText, $context->getTitle(), $options, true, true, $revId );
return $po;
}
}
$handler = ContentHandler::getForModelName( $modelName );
- return $handler->unserialize( $text, $format );
+ return $handler->unserializeContent( $text, $format );
}
/**
/**
* Serializes Content object of the type supported by this ContentHandler.
*
- * @FIXME: bad method name: suggests it serializes a ContentHandler, while in fact it serializes a Content object
- *
* @abstract
* @param Content $content the Content object to serialize
* @param null $format the desired serialization format
* @return String serialized form of the content
*/
- public abstract function serialize( Content $content, $format = null );
+ public abstract function serializeContent( Content $content, $format = null );
/**
* Unserializes a Content object of the type supported by this ContentHandler.
*
- * @FIXME: bad method name: suggests it unserializes a ContentHandler, while in fact it unserializes a Content object
- *
* @abstract
* @param $blob String serialized form of the content
* @param null $format the format used for serialization
* @return Content the Content object created by deserializing $blob
*/
- public abstract function unserialize( $blob, $format = null );
+ public abstract function unserializeContent( $blob, $format = null );
/**
* Creates an empty Content object of the type supported by this ContentHandler.
*
- * @FIXME: bad method name: suggests it empties the content of an instance rather then creating a new empty one
*/
- public abstract function emptyContent();
+ public abstract function makeEmptyContent();
/**
* Returns the model name that identifies the content model this ContentHandler can handle.
}
/**
- * Returns a list of serialization formats supported by the serialize() and unserialize() methods of
+ * Returns a list of serialization formats supported by the serializeContent() and unserializeContent() methods of
* this ContentHandler.
*
* @return array of serialization formats as MIME type like strings
* Returns overrides for action handlers.
* Classes listed here will be used instead of the default one when
* (and only when) $wgActions[$action] === true. This allows subclasses
- * to override the default actiuon handlers.
+ * to override the default action handlers.
*
* @return Array
*/
parent::__construct( $modelName, $formats );
}
- public function serialize( Content $content, $format = null ) {
+ public function serializeContent( Content $content, $format = null ) {
$this->checkFormat( $format );
return $content->getNativeData();
}
$format = $this->getDefaultFormat();
- $old = $this->serialize( $oldContent, $format );
- $mine = $this->serialize( $myContent, $format );
- $yours = $this->serialize( $yourContent, $format );
+ $old = $this->serializeContent( $oldContent, $format );
+ $mine = $this->serializeContent( $myContent, $format );
+ $yours = $this->serializeContent( $yourContent, $format );
$ok = wfMerge( $old, $mine, $yours, $result );
}
if ( !$result ) {
- return $this->emptyContent();
+ return $this->makeEmptyContent();
}
- $mergedContent = $this->unserialize( $result, $format );
+ $mergedContent = $this->unserializeContent( $result, $format );
return $mergedContent;
}
parent::__construct( $modelName, array( 'application/x-wikitext' ) ); #FIXME: mime
}
- public function unserialize( $text, $format = null ) {
+ public function unserializeContent( $text, $format = null ) {
$this->checkFormat( $format );
return new WikitextContent( $text );
}
- public function emptyContent() {
+ public function makeEmptyContent() {
return new WikitextContent( '' );
}
parent::__construct( $modelName, array( 'text/javascript' ) ); #XXX: or use $wgJsMimeType? this is for internal storage, not HTTP...
}
- public function unserialize( $text, $format = null ) {
+ public function unserializeContent( $text, $format = null ) {
return new JavaScriptContent( $text );
}
- public function emptyContent() {
+ public function makeEmptyContent() {
return new JavaScriptContent( '' );
}
}
parent::__construct( $modelName, array( 'text/css' ) );
}
- public function unserialize( $text, $format = null ) {
+ public function unserializeContent( $text, $format = null ) {
return new CssContent( $text );
}
- public function emptyContent() {
+ public function makeEmptyContent() {
return new CssContent( '' );
}
if ( !$this->content_model ) $this->content_model = $this->getTitle()->getContentModelName();
$handler = ContentHandler::getForModelName( $this->content_model );
- return $handler->emptyContent();
+ return $handler->makeEmptyContent();
}
$content = $revision->getContent();
return $content;
if ( !$this->content_model ) $this->content_model = $this->getTitle()->getContentModelName();
$handler = ContentHandler::getForModelName( $this->content_model );
- return $handler->emptyContent();
+ return $handler->makeEmptyContent();
} else {
#FIXME: nasty side-effect!
$this->content_model = $rev->getContentModelName();
$handler = ContentHandler::getForTitle( $this->getTitle() );
if ( $preload === '' ) {
- return $handler->emptyContent();
+ return $handler->makeEmptyContent();
}
$title = Title::newFromText( $preload );
# Check for existence to avoid getting MediaWiki:Noarticletext
if ( $title === null || !$title->exists() || !$title->userCan( 'read' ) ) {
- return $handler->emptyContent();
+ return $handler->makeEmptyContent();
}
$page = WikiPage::factory( $title );
$title = $page->getRedirectTarget();
# Same as before
if ( $title === null || !$title->exists() || !$title->userCan( 'read' ) ) {
- return $handler->emptyContent();
+ return $handler->makeEmptyContent();
}
$page = WikiPage::factory( $title );
}
#XXX: For CSS/JS pages, we should have called the ShowRawCssJs hook here. But it's now deprecated, so never mind
$content = $content->preSaveTransform( $this->mTitle, $wgUser, $parserOptions );
- $parserOutput = $content->getParserOutput( $this->mTitle, null, $parserOptions );
+
+ // TODO: might be a saner way to get a meaningfull context here?
+ $parserOutput = $content->getParserOutput( $this->getArticle()->getContext(), null, $parserOptions );
$previewHTML = $parserOutput->getText();
$this->mParserOutput = $parserOutput;
if ( $txt !== $content_text ) {
# if the text changed, unserialize the new version to create an updated Content object.
- $content = $content->getContentHandler()->unserialize( $txt );
+ $content = $content->getContentHandler()->unserializeContent( $txt );
}
}
$edit->format = $serialization_format;
$edit->popts = $this->makeParserOptions( 'canonical' );
- $edit->output = $edit->pstContent->getParserOutput( $this->mTitle, $revid, $edit->popts );
+
+ // TODO: is there no better way to obtain a context here?
+ $context = RequestContext::getMain();
+ $context->setTitle( $this->mTitle );
+ $edit->output = $edit->pstContent->getParserOutput( $context, $revid, $edit->popts );
$edit->newContent = $content;
$edit->oldContent = $this->getContent( Revision::RAW );
}
# Update the links tables and other secondary data
- $updates = $editInfo->output->getLinksUpdateAndOtherUpdates( $this->mTitle );
+ $updates = $editInfo->output->getSecondaryDataUpdates( $this->mTitle );
SecondaryDataUpdate::runUpdates( $updates );
wfRunHooks( 'ArticleEditUpdates', array( &$this, &$editInfo, $options['changed'] ) );
# NOTE: stub for backwards-compatibility. assumes the given text is wikitext. will break horribly if it isn't.
$handler = ContentHandler::getForModelName( CONTENT_MODEL_WIKITEXT );
- $oldContent = $oldtext ? $handler->unserialize( $oldtext ) : null;
- $newContent = $newtext ? $handler->unserialize( $newtext ) : null;
+ $oldContent = $oldtext ? $handler->unserializeContent( $oldtext ) : null;
+ $newContent = $newtext ? $handler->unserializeContent( $newtext ) : null;
return $handler->getAutosummary( $oldContent, $newContent, $flags );
}
}
$time = - microtime( true );
- $this->parserOutput = $content->getParserOutput( $this->page->getTitle(), $this->revid, $this->parserOptions );
+ // TODO: page might not have this method? Hard to tell what page is supposed to be here...
+ $this->parserOutput = $content->getParserOutput( $this->page->getContext(), $this->revid, $this->parserOptions );
$time += microtime( true );
# Timing hack