text1 = $text1 ; $this->text2 = $text2 ; $left_lines = explode("\n", $this->text1); $right_lines = explode("\n", $this->text2); $this->text_diff = new Text_Diff($left_lines, $right_lines); } /**==================================================================================================================================================== * Displays a human readable HTML representation of ALL the text marked with differences . * * @return string HTML with differences. */ public function show_all_with_difference() { $renderer = new Text_Diff_Renderer_inline() ; $result = $renderer->render($this->text_diff) ; $lignes = explode("\n", $result) ; $del_continue = false ; $ins_continue = false ; $return = "
    \n" ; foreach ($lignes as $l) { $return .= "
  1.  " ; 
    				
    				if ($del_continue)
    					$return .= "" ; 
    				if ($ins_continue)
    					$return .= "" ; 
    				
    				if (substr_count($l, '')-substr_count($l, '') > 0)  
    					$del_continue = true ; 
    				if (substr_count($l, '')-substr_count($l, '') < 0)  
    					$del_continue = false ; 
    				if (substr_count($l, '')-substr_count($l, '') > 0)  
    					$ins_continue = true ; 
    				if (substr_count($l, '')-substr_count($l, '') < 0)  
    					$ins_continue = false ; 
    					
    				$l = str_replace("", "", $l) ; 
    				$l = str_replace("", "", $l) ; 
    				$l = str_replace("", "", $l) ; 
    				$l = str_replace("", "", $l) ; 
    				
    				$return .= $l ; 
    				
    				if ($del_continue)
    					$return .= "" ; 
    				if ($ins_continue)
    					$return .= "" ; 
    				
    				$return .= "
  2. \n" ; } $return .= "
\n" ; return $return ; } /**==================================================================================================================================================== * Displays a simple human readable HTML representation of ALL the text marked with differences . * * @return string HTML with differences. */ public function show_simple_difference() { $renderer = new Text_Diff_Renderer_inline() ; $result = $renderer->render($this->text_diff) ; $result = str_replace("", "", $result) ; $result = str_replace("", "", $result) ; $result = str_replace("", "", $result) ; $result = str_replace("", "", $result) ; return $result ; } /**==================================================================================================================================================== * Displays a human readable HTML representation of ONLY the difference between two texts. * * @return string HTML with differences. */ public function show_only_difference() { $renderer = new Text_Diff_Renderer_inline() ; $result = $renderer->render($this->text_diff) ; $lignes = explode("\n", $result) ; $del_continue = false ; $ins_continue = false ; $first_trois_points = true ; $next_points = "" ; $buffer = array() ; foreach ($lignes as $l) { $l_inti = $l ; $return = "" ; if ($del_continue) $return .= "" ; if ($ins_continue) $return .= "" ; if (substr_count($l, '')-substr_count($l, '') > 0) $del_continue = true ; if (substr_count($l, '')-substr_count($l, '') < 0) $del_continue = false ; if (substr_count($l, '')-substr_count($l, '') > 0) $ins_continue = true ; if (substr_count($l, '')-substr_count($l, '') < 0) $ins_continue = false ; $l = str_replace("", "", $l) ; $l = str_replace("", "", $l) ; $l = str_replace("", "", $l) ; $l = str_replace("", "", $l) ; $return .= $l ; if ($del_continue) $return .= "" ; if ($ins_continue) $return .= "" ; if ($l_inti != $return) { $buffer[] = array(true, $return) ; } else { $buffer[] = array(false, $return) ; } } $return = "
    \n" ; $troispoint = false ; for ($i=0; $i
     ".$buffer[$i][1]."
    \n" ; $troispoint = false ; } else { if (!$troispoint) { if ($first_trois_points) { $return .= "
 ...
\n" ; $next_points .="
    \n" ; $troispoint = true ; $first_trois_points = false ; } else { $return .= "
 ...
\n" ; $next_points .= "
\n" ; $next_points .= "
 ...
" ; $next_points .="
    \n" ; $troispoint = true ; } } } } if ($next_points=="") $return .= "
\n" ; else $return .="\n" ; return $return ; } } } ?>