ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
DiffFormatter Class Reference
+ Collaboration diagram for DiffFormatter:

Public Member Functions

 format ($diff)
 Format a diff. More...
 
 _block ($xbeg, $xlen, $ybeg, $ylen, $edits)
 
 _start_diff ()
 
 _end_diff ()
 
 _block_header ($xbeg, $xlen, $ybeg, $ylen)
 
 _start_block ($header)
 
 _end_block ()
 
 _lines ($lines, $prefix=' ')
 
 _context ($lines)
 
 _added ($lines)
 
 _deleted ($lines)
 
 _changed ($orig, $closing)
 

Data Fields

 $leading_context_lines = 0
 Number of leading context "lines" to preserve. More...
 
 $trailing_context_lines = 0
 Number of trailing context "lines" to preserve. More...
 

Detailed Description

Definition at line 834 of file class.WordLevelDiff.php.

Member Function Documentation

◆ _added()

DiffFormatter::_added (   $lines)

Definition at line 996 of file class.WordLevelDiff.php.

997 {
998 $this->_lines($lines, '>');
999 }
_lines($lines, $prefix=' ')

References _lines().

Referenced by _block(), and _changed().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _block()

DiffFormatter::_block (   $xbeg,
  $xlen,
  $ybeg,
  $ylen,
  $edits 
)

Definition at line 929 of file class.WordLevelDiff.php.

930 {
931 $fname = 'DiffFormatter::_block';
932 //wfProfileIn( $fname );
933 $this->_start_block($this->_block_header($xbeg, $xlen, $ybeg, $ylen));
934 foreach ($edits as $edit) {
935 if ($edit->type == 'copy') {
936 $this->_context($edit->orig);
937 } elseif ($edit->type == 'add') {
938 $this->_added($edit->closing);
939 } elseif ($edit->type == 'delete') {
940 $this->_deleted($edit->orig);
941 } elseif ($edit->type == 'change') {
942 $this->_changed($edit->orig, $edit->closing);
943 } else {
944 trigger_error('Unknown edit type', E_USER_ERROR);
945 }
946 }
947 $this->_end_block();
948 //wfProfileOut( $fname );
949 }
_block_header($xbeg, $xlen, $ybeg, $ylen)
_changed($orig, $closing)

References _added(), _block_header(), _changed(), _context(), _deleted(), _end_block(), and _start_block().

Referenced by format().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _block_header()

DiffFormatter::_block_header (   $xbeg,
  $xlen,
  $ybeg,
  $ylen 
)

Definition at line 963 of file class.WordLevelDiff.php.

964 {
965 if ($xlen > 1) {
966 $xbeg .= "," . ($xbeg + $xlen - 1);
967 }
968 if ($ylen > 1) {
969 $ybeg .= "," . ($ybeg + $ylen - 1);
970 }
971
972 return $xbeg . ($xlen ? ($ylen ? 'c' : 'd') : 'a') . $ybeg;
973 }

Referenced by _block().

+ Here is the caller graph for this function:

◆ _changed()

DiffFormatter::_changed (   $orig,
  $closing 
)

Definition at line 1005 of file class.WordLevelDiff.php.

1006 {
1007 $this->_deleted($orig);
1008 echo "---\n";
1009 $this->_added($closing);
1010 }

References _added(), and _deleted().

Referenced by _block().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _context()

DiffFormatter::_context (   $lines)

Definition at line 991 of file class.WordLevelDiff.php.

992 {
993 $this->_lines($lines);
994 }

References _lines().

Referenced by _block().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _deleted()

DiffFormatter::_deleted (   $lines)

Definition at line 1000 of file class.WordLevelDiff.php.

1001 {
1002 $this->_lines($lines, '<');
1003 }

References _lines().

Referenced by _block(), and _changed().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _end_block()

DiffFormatter::_end_block ( )

Definition at line 980 of file class.WordLevelDiff.php.

981 {
982 }

Referenced by _block().

+ Here is the caller graph for this function:

◆ _end_diff()

DiffFormatter::_end_diff ( )

Definition at line 956 of file class.WordLevelDiff.php.

957 {
958 $val = ob_get_contents();
959 ob_end_clean();
960 return $val;
961 }

Referenced by format().

+ Here is the caller graph for this function:

◆ _lines()

DiffFormatter::_lines (   $lines,
  $prefix = ' ' 
)

Definition at line 984 of file class.WordLevelDiff.php.

985 {
986 foreach ($lines as $line) {
987 echo "$prefix $line\n";
988 }
989 }

Referenced by _added(), _context(), and _deleted().

+ Here is the caller graph for this function:

◆ _start_block()

DiffFormatter::_start_block (   $header)

Definition at line 975 of file class.WordLevelDiff.php.

976 {
977 echo $header;
978 }

Referenced by _block().

+ Here is the caller graph for this function:

◆ _start_diff()

DiffFormatter::_start_diff ( )

Definition at line 951 of file class.WordLevelDiff.php.

952 {
953 ob_start();
954 }

Referenced by format().

+ Here is the caller graph for this function:

◆ format()

DiffFormatter::format (   $diff)

Format a diff.

Parameters
$diffobject A Diff object.
Returns
string The formatted output.

Definition at line 858 of file class.WordLevelDiff.php.

859 {
860 $fname = 'DiffFormatter::format';
861 //wfProfileIn( $fname );
862
863 $xi = $yi = 1;
864 $block = false;
865 $context = array();
866
869
870 $this->_start_diff();
871
872 foreach ($diff->edits as $edit) {
873 if ($edit->type == 'copy') {
874 if (is_array($block)) {
875 if (sizeof($edit->orig) <= $nlead + $ntrail) {
876 $block[] = $edit;
877 } else {
878 if ($ntrail) {
879 $context = array_slice($edit->orig, 0, $ntrail);
880 $block[] = new _DiffOp_Copy($context);
881 }
882 $this->_block(
883 $x0,
884 $ntrail + $xi - $x0,
885 $y0,
886 $ntrail + $yi - $y0,
887 $block
888 );
889 $block = false;
890 }
891 }
892 $context = $edit->orig;
893 } else {
894 if (!is_array($block)) {
895 $context = array_slice($context, sizeof($context) - $nlead);
896 $x0 = $xi - sizeof($context);
897 $y0 = $yi - sizeof($context);
898 $block = array();
899 if ($context) {
900 $block[] = new _DiffOp_Copy($context);
901 }
902 }
903 $block[] = $edit;
904 }
905
906 if ($edit->orig) {
907 $xi += sizeof($edit->orig);
908 }
909 if ($edit->closing) {
910 $yi += sizeof($edit->closing);
911 }
912 }
913
914 if (is_array($block)) {
915 $this->_block(
916 $x0,
917 $xi - $x0,
918 $y0,
919 $yi - $y0,
920 $block
921 );
922 }
923
924 $end = $this->_end_diff();
925 //wfProfileOut( $fname );
926 return $end;
927 }
_block($xbeg, $xlen, $ybeg, $ylen, $edits)
$leading_context_lines
Number of leading context "lines" to preserve.
$trailing_context_lines
Number of trailing context "lines" to preserve.
$context
Definition: webdav.php:31

References $context, $leading_context_lines, $trailing_context_lines, _block(), _end_diff(), and _start_diff().

+ Here is the call graph for this function:

Field Documentation

◆ $leading_context_lines

DiffFormatter::$leading_context_lines = 0

Number of leading context "lines" to preserve.

This should be left at zero for this class, but subclasses may want to set this to other values.

Definition at line 842 of file class.WordLevelDiff.php.

Referenced by format().

◆ $trailing_context_lines

DiffFormatter::$trailing_context_lines = 0

Number of trailing context "lines" to preserve.

This should be left at zero for this class, but subclasses may want to set this to other values.

Definition at line 850 of file class.WordLevelDiff.php.

Referenced by format().


The documentation for this class was generated from the following file: