ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 1523 of file class.WordLevelDiff.php.

Member Function Documentation

◆ _added()

DiffFormatter::_added (   $lines)

Reimplemented in TableDiffFormatter.

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

1686 {
1687 $this->_lines($lines, '>');
1688 }
_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 1618 of file class.WordLevelDiff.php.

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

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

Referenced by _block().

+ Here is the caller graph for this function:

◆ _changed()

DiffFormatter::_changed (   $orig,
  $closing 
)

Reimplemented in TableDiffFormatter.

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

1695 {
1696 $this->_deleted($orig);
1697 echo "---\n";
1698 $this->_added($closing);
1699 }

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

1681 {
1682 $this->_lines($lines);
1683 }

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

1690 {
1691 $this->_lines($lines, '<');
1692 }

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

1670 {
1671 }

Referenced by _block().

+ Here is the caller graph for this function:

◆ _end_diff()

DiffFormatter::_end_diff ( )

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

1646 {
1647 $val = ob_get_contents();
1648 ob_end_clean();
1649 return $val;
1650 }

Referenced by format().

+ Here is the caller graph for this function:

◆ _lines()

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

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

1674 {
1675 foreach ($lines as $line) {
1676 echo "$prefix $line\n";
1677 }
1678 }

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

1665 {
1666 echo $header;
1667 }

Referenced by _block().

+ Here is the caller graph for this function:

◆ _start_diff()

DiffFormatter::_start_diff ( )

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

1641 {
1642 ob_start();
1643 }

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

1548 {
1549 $fname = 'DiffFormatter::format';
1550 //wfProfileIn( $fname );
1551
1552 $xi = $yi = 1;
1553 $block = false;
1554 $context = array();
1555
1558
1559 $this->_start_diff();
1560
1561 foreach ($diff->edits as $edit) {
1562 if ($edit->type == 'copy') {
1563 if (is_array($block)) {
1564 if (sizeof($edit->orig) <= $nlead + $ntrail) {
1565 $block[] = $edit;
1566 } else {
1567 if ($ntrail) {
1568 $context = array_slice($edit->orig, 0, $ntrail);
1569 $block[] = new _DiffOp_Copy($context);
1570 }
1571 $this->_block(
1572 $x0,
1573 $ntrail + $xi - $x0,
1574 $y0,
1575 $ntrail + $yi - $y0,
1576 $block
1577 );
1578 $block = false;
1579 }
1580 }
1581 $context = $edit->orig;
1582 } else {
1583 if (!is_array($block)) {
1584 $context = array_slice($context, sizeof($context) - $nlead);
1585 $x0 = $xi - sizeof($context);
1586 $y0 = $yi - sizeof($context);
1587 $block = array();
1588 if ($context) {
1589 $block[] = new _DiffOp_Copy($context);
1590 }
1591 }
1592 $block[] = $edit;
1593 }
1594
1595 if ($edit->orig) {
1596 $xi += sizeof($edit->orig);
1597 }
1598 if ($edit->closing) {
1599 $yi += sizeof($edit->closing);
1600 }
1601 }
1602
1603 if (is_array($block)) {
1604 $this->_block(
1605 $x0,
1606 $xi - $x0,
1607 $y0,
1608 $yi - $y0,
1609 $block
1610 );
1611 }
1612
1613 $end = $this->_end_diff();
1614 //wfProfileOut( $fname );
1615 return $end;
1616 }
$leading_context_lines
Number of leading context "lines" to preserve.
_block($xbeg, $xlen, $ybeg, $ylen, &$edits)
$trailing_context_lines
Number of trailing context "lines" to preserve.
$context
Definition: webdav.php:26

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

Referenced by format().


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