* @ingroup Content
*/
class TextContent extends AbstractContent {
+
+ /**
+ * @param string $text
+ * @param string $model_id
+ */
public function __construct( $text, $model_id = CONTENT_MODEL_TEXT ) {
parent::__construct( $model_id );
$this->mText = $text;
}
+ /**
+ * @note Mutable subclasses MUST override this to return a copy!
+ *
+ * @return Content $this
+ */
public function copy() {
return $this; # NOTE: this is ok since TextContent are immutable.
}
}
/**
- * returns the text's size in bytes.
+ * Returns the text's size in bytes.
*
- * @return int The size
+ * @return int
*/
public function getSize() {
$text = $this->getNativeData();
* Returns true if this content is not a redirect, and $wgArticleCountMethod
* is "any".
*
- * @param bool $hasLinks if it is known whether this content contains links,
+ * @param bool $hasLinks If it is known whether this content contains links,
* provide this information here, to avoid redundant parsing to find out.
*
- * @return bool True if the content is countable
+ * @return bool
*/
public function isCountable( $hasLinks = null ) {
global $wgArticleCountMethod;
/**
* Returns the text represented by this Content object, as a string.
*
- * @return string: the raw text
+ * @return string The raw text.
*/
public function getNativeData() {
$text = $this->mText;
/**
* Returns the text represented by this Content object, as a string.
*
- * @return string: the raw text
+ * @return string The raw text.
*/
public function getTextForSearchIndex() {
return $this->getNativeData();
*
* @note: this allows any text-based content to be transcluded as if it was wikitext.
*
- * @return string|false: the raw text, or null if the conversion failed
+ * @return string|bool The raw text, or false if the conversion failed.
*/
public function getWikitextForTransclusion() {
$wikitext = $this->convert( CONTENT_MODEL_WIKITEXT, 'lossy' );
* Returns a Content object with pre-save transformations applied.
* This implementation just trims trailing whitespace.
*
- * @param $title Title
- * @param $user User
- * @param $popts ParserOptions
+ * @param Title $title
+ * @param User $user
+ * @param ParserOptions $popts
+ *
* @return Content
*/
public function preSaveTransform( Title $title, User $user, ParserOptions $popts ) {
*
* @since 1.21
*
- * @param $that Content: The other content object to compare this content
+ * @param Content $that The other content object to compare this content
* object to.
- * @param $lang Language: The language object to use for text segmentation.
+ * @param Language $lang The language object to use for text segmentation.
* If not given, $wgContentLang is used.
*
* @return Diff A diff representing the changes that would have to be
* Returns a generic ParserOutput object, wrapping the HTML returned by
* getHtml().
*
- * @param $title Title Context title for parsing
- * @param int|null $revId Revision ID (for {{REVISIONID}})
- * @param $options ParserOptions|null Parser options
+ * @param Title $title Context title for parsing
+ * @param int $revId Revision ID (for {{REVISIONID}})
+ * @param ParserOptions $options Parser options
* @param bool $generateHtml Whether or not to generate HTML
*
- * @return ParserOutput representing the HTML form of the text
+ * @return ParserOutput Representing the HTML form of the text.
*/
- public function getParserOutput( Title $title,
- $revId = null,
- ParserOptions $options = null, $generateHtml = true
- ) {
+ public function getParserOutput( Title $title, $revId = null,
+ ParserOptions $options = null, $generateHtml = true ) {
global $wgParser, $wgTextModelsToParse;
if ( !$options ) {
* Generates a syntax-highlighted version of the content, as HTML.
* Used by the default implementation of getHtml().
*
- * @return string an HTML representation of the content's markup
+ * @return string A HTML representation of the content's markup
*/
protected function getHighlightHtml() {
# TODO: make Highlighter interface, use highlighter here, if available
}
/**
- * @see Content::convert()
- *
* This implementation provides lossless conversion between content models based
* on TextContent.
*
- * @param string $toModel the desired content model, use the CONTENT_MODEL_XXX flags.
- * @param string $lossy flag, set to "lossy" to allow lossy conversion. If lossy conversion is
- * not allowed, full round-trip conversion is expected to work without losing information.
+ * @param string $toModel
+ * @param string $lossy
*
- * @return Content|bool A content object with the content model $toModel, or false if
- * that conversion is not supported.
+ * @return Content|bool
+ *
+ * @see Content::convert()
*/
public function convert( $toModel, $lossy = '' ) {
$converted = parent::convert( $toModel, $lossy );
return $converted;
}
+
}