MediaWiki
REL1_22
|
00001 <?php 00031 class TextContentHandler extends ContentHandler { 00032 00033 public function __construct( $modelId = CONTENT_MODEL_TEXT, $formats = array( CONTENT_FORMAT_TEXT ) ) { 00034 parent::__construct( $modelId, $formats ); 00035 } 00036 00044 public function serializeContent( Content $content, $format = null ) { 00045 $this->checkFormat( $format ); 00046 return $content->getNativeData(); 00047 } 00048 00064 public function merge3( Content $oldContent, Content $myContent, Content $yourContent ) { 00065 $this->checkModelID( $oldContent->getModel() ); 00066 $this->checkModelID( $myContent->getModel() ); 00067 $this->checkModelID( $yourContent->getModel() ); 00068 00069 $format = $this->getDefaultFormat(); 00070 00071 $old = $this->serializeContent( $oldContent, $format ); 00072 $mine = $this->serializeContent( $myContent, $format ); 00073 $yours = $this->serializeContent( $yourContent, $format ); 00074 00075 $ok = wfMerge( $old, $mine, $yours, $result ); 00076 00077 if ( !$ok ) { 00078 return false; 00079 } 00080 00081 if ( !$result ) { 00082 return $this->makeEmptyContent(); 00083 } 00084 00085 $mergedContent = $this->unserializeContent( $result, $format ); 00086 return $mergedContent; 00087 } 00088 00099 public function unserializeContent( $text, $format = null ) { 00100 $this->checkFormat( $format ); 00101 00102 return new TextContent( $text ); 00103 } 00104 00112 public function makeEmptyContent() { 00113 return new TextContent( '' ); 00114 } 00115 }