$text = $this->getNativeData();
$pst = $wgParser->preSaveTransform( $text, $title, $user, $popts );
- return new CssContent( $pst );
+ return new static( $pst );
}
/**
parent::__construct( $modelId, array( CONTENT_FORMAT_CSS ) );
}
- /**
- * @param string $text
- * @param string $format
- *
- * @return CssContent
- *
- * @see ContentHandler::unserializeContent()
- */
- public function unserializeContent( $text, $format = null ) {
- $this->checkFormat( $format );
-
- return new CssContent( $text );
- }
-
- /**
- * @return CssContent A new CssContent object with empty text.
- *
- * @see ContentHandler::makeEmptyContent()
- */
- public function makeEmptyContent() {
- return new CssContent( '' );
+ protected function getContentClass() {
+ return 'CssContent';
}
/**
/**
* The class name of objects that should be created
*
+ * @deprecated override getContentClass instead
+ *
* @var string
*/
protected $contentClass = 'JSONContent';
}
/**
- * Unserializes a JSONContent object.
- *
- * @param string $text Serialized form of the content
- * @param null|string $format The format used for serialization
- *
- * @return JSONContent
- */
- public function unserializeContent( $text, $format = null ) {
- $this->checkFormat( $format );
- return new $this->contentClass( $text );
- }
-
- /**
- * Creates an empty JSONContent object.
+ * Temporary back-compat until extensions
+ * are updated to override this
*
- * @return JSONContent
+ * @return string
*/
- public function makeEmptyContent() {
- return new $this->contentClass( '' );
+ protected function getContentClass() {
+ return $this->contentClass;
}
/**
$text = $this->getNativeData();
$pst = $wgParser->preSaveTransform( $text, $title, $user, $popts );
- return new JavaScriptContent( $pst );
+ return new static( $pst );
}
/**
parent::__construct( $modelId, array( CONTENT_FORMAT_JAVASCRIPT ) );
}
- /**
- * @param string $text
- * @param string $format
- *
- * @return JavaScriptContent
- *
- * @see ContentHandler::unserializeContent()
- */
- public function unserializeContent( $text, $format = null ) {
- $this->checkFormat( $format );
-
- return new JavaScriptContent( $text );
- }
-
- /**
- * @return JavaScriptContent A new JavaScriptContent object with empty text.
- *
- * @see ContentHandler::makeEmptyContent()
- */
- public function makeEmptyContent() {
- return new JavaScriptContent( '' );
+ protected function getContentClass() {
+ return 'JavaScriptContent';
}
/**
return $mergedContent;
}
+ /**
+ * Returns the name of the associated Content class, to
+ * be used when creating new objects. Override expected
+ * by subclasses.
+ *
+ * @since 1.24
+ *
+ * @return string
+ */
+ protected function getContentClass() {
+ return 'TextContent';
+ }
+
/**
* Unserializes a Content object of the type supported by this ContentHandler.
*
public function unserializeContent( $text, $format = null ) {
$this->checkFormat( $format );
- return new TextContent( $text );
+ $class = $this->getContentClass();
+ return new $class( $text );
}
/**
* @return Content A new TextContent object with empty text.
*/
public function makeEmptyContent() {
- return new TextContent( '' );
+ $class = $this->getContentClass();
+ return new $class( '' );
}
}
if ( $sect === false ) {
return false;
} else {
- return new WikitextContent( $sect );
+ return new static( $sect );
}
}
$text = $wgParser->replaceSection( $oldtext, $sectionId, $text );
}
- $newContent = new WikitextContent( $text );
+ $newContent = new static( $text );
wfProfileOut( __METHOD__ );
$text .= "\n\n";
$text .= $this->getNativeData();
- return new WikitextContent( $text );
+ return new static( $text );
}
/**
$pst = $wgParser->preSaveTransform( $text, $title, $user, $popts );
rtrim( $pst );
- return ( $text === $pst ) ? $this : new WikitextContent( $pst );
+ return ( $text === $pst ) ? $this : new static( $pst );
}
/**
$text = $this->getNativeData();
$plt = $wgParser->getPreloadText( $text, $title, $popts, $params );
- return new WikitextContent( $plt );
+ return new static( $plt );
}
/**
'[[' . $target->getFullText() . ']]',
$this->getNativeData(), 1 );
- return new WikitextContent( $newText );
+ return new static( $newText );
}
/**
parent::__construct( $modelId, array( CONTENT_FORMAT_WIKITEXT ) );
}
- public function unserializeContent( $text, $format = null ) {
- $this->checkFormat( $format );
-
- return new WikitextContent( $text );
- }
-
- /**
- * @return Content A new WikitextContent object with empty text.
- *
- * @see ContentHandler::makeEmptyContent
- */
- public function makeEmptyContent() {
- return new WikitextContent( '' );
+ protected function getContentClass() {
+ return 'WikitextContent';
}
/**
$redirectText .= "\n" . $text;
}
- return new WikitextContent( $redirectText );
+ $class = $this->getContentClass();
+ return new $class( $redirectText );
}
/**