MediaWiki  REL1_23
TextContentHandler.php
Go to the documentation of this file.
00001 <?php
00031 class TextContentHandler extends ContentHandler {
00032 
00033     // @codingStandardsIgnoreStart bug 57585
00034     public function __construct( $modelId = CONTENT_MODEL_TEXT,
00035         $formats = array( CONTENT_FORMAT_TEXT ) ) {
00036         parent::__construct( $modelId, $formats );
00037     }
00038     // @codingStandardsIgnoreEnd
00039 
00048     public function serializeContent( Content $content, $format = null ) {
00049         $this->checkFormat( $format );
00050 
00051         return $content->getNativeData();
00052     }
00053 
00069     public function merge3( Content $oldContent, Content $myContent, Content $yourContent ) {
00070         $this->checkModelID( $oldContent->getModel() );
00071         $this->checkModelID( $myContent->getModel() );
00072         $this->checkModelID( $yourContent->getModel() );
00073 
00074         $format = $this->getDefaultFormat();
00075 
00076         $old = $this->serializeContent( $oldContent, $format );
00077         $mine = $this->serializeContent( $myContent, $format );
00078         $yours = $this->serializeContent( $yourContent, $format );
00079 
00080         $ok = wfMerge( $old, $mine, $yours, $result );
00081 
00082         if ( !$ok ) {
00083             return false;
00084         }
00085 
00086         if ( !$result ) {
00087             return $this->makeEmptyContent();
00088         }
00089 
00090         $mergedContent = $this->unserializeContent( $result, $format );
00091 
00092         return $mergedContent;
00093     }
00094 
00105     public function unserializeContent( $text, $format = null ) {
00106         $this->checkFormat( $format );
00107 
00108         return new TextContent( $text );
00109     }
00110 
00118     public function makeEmptyContent() {
00119         return new TextContent( '' );
00120     }
00121 
00122 }