6 class TextContentHandler
extends ContentHandler
{
8 public function __construct( $modelId = CONTENT_MODEL_TEXT
, $formats = array( CONTENT_FORMAT_TEXT
) ) {
9 parent
::__construct( $modelId, $formats );
13 * Returns the content's text as-is.
15 * @param $content Content
16 * @param $format string|null
19 public function serializeContent( Content
$content, $format = null ) {
20 $this->checkFormat( $format );
21 return $content->getNativeData();
25 * Attempts to merge differences between three versions. Returns a new
26 * Content object for a clean merge and false for failure or a conflict.
28 * All three Content objects passed as parameters must have the same
31 * This text-based implementation uses wfMerge().
33 * @param $oldContent Content|string String
34 * @param $myContent Content|string String
35 * @param $yourContent Content|string String
37 * @return Content|Bool
39 public function merge3( Content
$oldContent, Content
$myContent, Content
$yourContent ) {
40 $this->checkModelID( $oldContent->getModel() );
41 $this->checkModelID( $myContent->getModel() );
42 $this->checkModelID( $yourContent->getModel() );
44 $format = $this->getDefaultFormat();
46 $old = $this->serializeContent( $oldContent, $format );
47 $mine = $this->serializeContent( $myContent, $format );
48 $yours = $this->serializeContent( $yourContent, $format );
50 $ok = wfMerge( $old, $mine, $yours, $result );
57 return $this->makeEmptyContent();
60 $mergedContent = $this->unserializeContent( $result, $format );
61 return $mergedContent;
65 * Unserializes a Content object of the type supported by this ContentHandler.
69 * @param $text string serialized form of the content
70 * @param $format null|String the format used for serialization
72 * @return Content the TextContent object wrapping $text
74 public function unserializeContent( $text, $format = null ) {
75 $this->checkFormat( $format );
77 return new TextContent( $text );
81 * Creates an empty TextContent object.
87 public function makeEmptyContent() {
88 return new TextContent( '' );