Text_MappedDiff

The WordPress Core Text MappedDiff class.

Defined (1)

The class is defined in the following location(s).

/wp-includes/Text/Diff.php  
  1. class Text_MappedDiff extends Text_Diff { 
  2.  
  3. /** 
  4. * Computes a diff between sequences of strings. 
  5. * This can be used to compute things like case-insensitve diffs, or diffs 
  6. * which ignore changes in white-space. 
  7. * @param array $from_lines An array of strings. 
  8. * @param array $to_lines An array of strings. 
  9. * @param array $mapped_from_lines This array should have the same size 
  10. * number of elements as $from_lines. The 
  11. * elements in $mapped_from_lines and 
  12. * $mapped_to_lines are what is actually 
  13. * compared when computing the diff. 
  14. * @param array $mapped_to_lines This array should have the same number 
  15. * of elements as $to_lines. 
  16. */ 
  17. function __construct($from_lines, $to_lines,  
  18. $mapped_from_lines, $mapped_to_lines) 
  19. assert(count($from_lines) == count($mapped_from_lines)); 
  20. assert(count($to_lines) == count($mapped_to_lines)); 
  21.  
  22. parent::Text_Diff($mapped_from_lines, $mapped_to_lines); 
  23.  
  24. $xi = $yi = 0; 
  25. for ($i = 0; $i < count($this->_edits); $i++) { 
  26. $orig = &$this->_edits[$i]->orig; 
  27. if (is_array($orig)) { 
  28. $orig = array_slice($from_lines, $xi, count($orig)); 
  29. $xi += count($orig); 
  30.  
  31. $final = &$this->_edits[$i]->final; 
  32. if (is_array($final)) { 
  33. $final = array_slice($to_lines, $yi, count($final)); 
  34. $yi += count($final); 
  35.  
  36. /** 
  37. * PHP4 constructor. 
  38. */ 
  39. public function Text_MappedDiff( $from_lines, $to_lines,  
  40. $mapped_from_lines, $mapped_to_lines ) { 
  41. self::__construct( $from_lines, $to_lines,  
  42. $mapped_from_lines, $mapped_to_lines ); 
  43.