00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 include_once( 'lib/ezutils/classes/ezdebug.php' );
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 class eZDiff
00046 {
00047
00048
00049
00050
00051 function eZDiff( $diffEngineType = false )
00052 {
00053 if ( $diffEngineType )
00054 {
00055 $this->DiffEngine = $diffEngineType;
00056 eZDebug::writeNotice( "Diff engine type: " . $diffEngineType, 'eZDiff' );
00057 }
00058 }
00059
00060
00061
00062
00063
00064
00065 function setDiffEngineType( $diffEngineType )
00066 {
00067 if ( isset( $diffEngineType ) )
00068 {
00069 $this->DiffEngine = $diffEngineType;
00070 eZDebug::writeNotice( "Changing diff engine to type: " . $diffEngineType, 'eZDiff' );
00071 }
00072 }
00073
00074
00075
00076
00077
00078 function getDiffEngineType()
00079 {
00080 return $this->DiffEngine;
00081 }
00082
00083
00084
00085
00086
00087 function engineType( $typeString )
00088 {
00089 switch ( $typeString )
00090 {
00091 case 'text':
00092 {
00093 return $this->DIFF_TYPE['text'];
00094 }break;
00095
00096 case 'xml':
00097 {
00098 return $this->DIFF_TYPE['xml'];
00099 }break;
00100
00101 case 'container':
00102 {
00103 return $this->DIFF_TYPE['container'];
00104 }break;
00105 }
00106 }
00107
00108
00109
00110
00111
00112 function initDiffEngine()
00113 {
00114 include_once( 'lib/ezdiff/classes/ezdiffengine.php' );
00115
00116 if ( !$diffEngine = $this->DiffEngineInstance )
00117 {
00118 switch( $this->DiffEngine )
00119 {
00120 case '0':
00121 {
00122 include_once( 'lib/ezdiff/classes/ezdifftextengine.php' );
00123 $this->DiffEngineInstance = new eZDiffTextEngine();
00124 }break;
00125
00126 case '1':
00127 {
00128 include_once( 'lib/ezdiff/classes/ezdiffxmltextengine.php' );
00129 $this->DiffEngineInstance = new eZDiffXMLTextEngine();
00130 }break;
00131
00132 case '2':
00133 {
00134 include_once( 'lib/ezdiff/classes/ezdiffcontainerobjectengine.php' );
00135 $this->DiffEngineInstance = new eZDiffContainerObjectEngine();
00136 }
00137 }
00138 }
00139 }
00140
00141
00142
00143
00144
00145
00146
00147
00148 function &diff( $fromData, $toData)
00149 {
00150 if ( !$this->DiffEngineInstance )
00151 return null;
00152
00153 $differ =& $this->DiffEngineInstance;
00154 $diffObject = $differ->createDifferenceObject( $fromData, $toData );
00155 return $diffObject;
00156 }
00157
00158
00159
00160 var $DiffEngine;
00161
00162
00163 var $DiffEngineInstance;
00164
00165
00166 var $DIFF_TYPE = array( 'text' => 0,
00167 'xml' => 1,
00168 'container' => 2 );
00169 }
00170
00171 ?>