* @ingroup Content
*/
class TextContent extends AbstractContent {
-
public function __construct( $text, $model_id = CONTENT_MODEL_TEXT ) {
parent::__construct( $model_id );
if ( $text === null || $text === false ) {
wfWarn( "TextContent constructed with \$text = " . var_export( $text, true ) . "! "
- . "This may indicate an error in the caller's scope." );
+ . "This may indicate an error in the caller's scope.", 2 );
$text = '';
}
*/
public function getSize() {
$text = $this->getNativeData();
+
return strlen( $text );
}
*/
public function getNativeData() {
$text = $this->mText;
+
return $text;
}
$text = $this->getNativeData();
$pst = rtrim( $text );
- return ( $text === $pst ) ? $this : new WikitextContent( $pst );
+ return ( $text === $pst ) ? $this : new static( $pst );
}
/**
$nta = explode( "\n", $lang->segmentForDiff( $ntext ) );
$diff = new Diff( $ota, $nta );
+
return $diff;
}
}
$po->setText( $html );
+
return $po;
}
* 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
+ * @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.
*
* @return Content|bool A content object with the content model $toModel, or false if