ILIAS  release_8 Revision v8.24
DiffFormatter Class Reference
+ Inheritance diagram for DiffFormatter:
+ 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 1520 of file class.WordLevelDiff.php.

Member Function Documentation

◆ _added()

DiffFormatter::_added (   $lines)

Reimplemented in TableDiffFormatter.

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

1683 {
1684 $this->_lines($lines, '>');
1685 }
_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 1615 of file class.WordLevelDiff.php.

1616 {
1617 $fname = 'DiffFormatter::_block';
1618 //wfProfileIn( $fname );
1619 $this->_start_block($this->_block_header($xbeg, $xlen, $ybeg, $ylen));
1620 foreach ($edits as $edit) {
1621 if ($edit->type == 'copy') {
1622 $this->_context($edit->orig);
1623 } elseif ($edit->type == 'add') {
1624 $this->_added($edit->closing);
1625 } elseif ($edit->type == 'delete') {
1626 $this->_deleted($edit->orig);
1627 } elseif ($edit->type == 'change') {
1628 $this->_changed($edit->orig, $edit->closing);
1629 } else {
1630 trigger_error('Unknown edit type', E_USER_ERROR);
1631 }
1632 }
1633 $this->_end_block();
1634 //wfProfileOut( $fname );
1635 }
_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 
)

Reimplemented in TableDiffFormatter.

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

1650 {
1651 if ($xlen > 1) {
1652 $xbeg .= "," . ($xbeg + $xlen - 1);
1653 }
1654 if ($ylen > 1) {
1655 $ybeg .= "," . ($ybeg + $ylen - 1);
1656 }
1657
1658 return $xbeg . ($xlen ? ($ylen ? 'c' : 'd') : 'a') . $ybeg;
1659 }

Referenced by _block().

+ Here is the caller graph for this function:

◆ _changed()

DiffFormatter::_changed (   $orig,
  $closing 
)

Reimplemented in TableDiffFormatter.

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

1692 {
1693 $this->_deleted($orig);
1694 echo "---\n";
1695 $this->_added($closing);
1696 }

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)

Reimplemented in TableDiffFormatter.

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

1678 {
1679 $this->_lines($lines);
1680 }

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)

Reimplemented in TableDiffFormatter.

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

1687 {
1688 $this->_lines($lines, '<');
1689 }

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 ( )

Reimplemented in TableDiffFormatter.

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

1667 {
1668 }

Referenced by _block().

+ Here is the caller graph for this function:

◆ _end_diff()

DiffFormatter::_end_diff ( )

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

1643 {
1644 $val = ob_get_contents();
1645 ob_end_clean();
1646 return $val;
1647 }

Referenced by format().

+ Here is the caller graph for this function:

◆ _lines()

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

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

1671 {
1672 foreach ($lines as $line) {
1673 echo "$prefix $line\n";
1674 }
1675 }

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

+ Here is the caller graph for this function:

◆ _start_block()

DiffFormatter::_start_block (   $header)

Reimplemented in TableDiffFormatter.

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

1662 {
1663 echo $header;
1664 }

Referenced by _block().

+ Here is the caller graph for this function:

◆ _start_diff()

DiffFormatter::_start_diff ( )

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

1638 {
1639 ob_start();
1640 }

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 1544 of file class.WordLevelDiff.php.

1545 {
1546 $fname = 'DiffFormatter::format';
1547 //wfProfileIn( $fname );
1548
1549 $xi = $yi = 1;
1550 $block = false;
1551 $context = array();
1552
1555
1556 $this->_start_diff();
1557
1558 foreach ($diff->edits as $edit) {
1559 if ($edit->type == 'copy') {
1560 if (is_array($block)) {
1561 if (sizeof($edit->orig) <= $nlead + $ntrail) {
1562 $block[] = $edit;
1563 } else {
1564 if ($ntrail) {
1565 $context = array_slice($edit->orig, 0, $ntrail);
1566 $block[] = new _DiffOp_Copy($context);
1567 }
1568 $this->_block(
1569 $x0,
1570 $ntrail + $xi - $x0,
1571 $y0,
1572 $ntrail + $yi - $y0,
1573 $block
1574 );
1575 $block = false;
1576 }
1577 }
1578 $context = $edit->orig;
1579 } else {
1580 if (!is_array($block)) {
1581 $context = array_slice($context, sizeof($context) - $nlead);
1582 $x0 = $xi - sizeof($context);
1583 $y0 = $yi - sizeof($context);
1584 $block = array();
1585 if ($context) {
1586 $block[] = new _DiffOp_Copy($context);
1587 }
1588 }
1589 $block[] = $edit;
1590 }
1591
1592 if ($edit->orig) {
1593 $xi += sizeof($edit->orig);
1594 }
1595 if ($edit->closing) {
1596 $yi += sizeof($edit->closing);
1597 }
1598 }
1599
1600 if (is_array($block)) {
1601 $this->_block(
1602 $x0,
1603 $xi - $x0,
1604 $y0,
1605 $yi - $y0,
1606 $block
1607 );
1608 }
1609
1610 $end = $this->_end_diff();
1611 //wfProfileOut( $fname );
1612 return $end;
1613 }
_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:29

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 1528 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 1536 of file class.WordLevelDiff.php.

Referenced by format().


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