ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 1509 of file class.WordLevelDiff.php.

Member Function Documentation

◆ _added()

DiffFormatter::_added (   $lines)

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

1674  {

◆ _block()

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

Definition at line 1604 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') {
_block_header($xbeg, $xlen, $ybeg, $ylen)

◆ _block_header()

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

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

1641  {
1642  ob_start();
1643  }
1644 
1645  public function _end_diff()
1646  {
1647  $val = ob_get_contents();
1648  ob_end_clean();

◆ _changed()

DiffFormatter::_changed (   $orig,
  $closing 
)

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

1681  {
1682  $this->_lines($lines);
1683  }
1684 
1685  public function _added($lines)
_lines($lines, $prefix=' ')

◆ _context()

DiffFormatter::_context (   $lines)

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

1670  {

◆ _deleted()

DiffFormatter::_deleted (   $lines)

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

1675  {
1676  echo "$prefix $line\n";
1677  }
1678  }

◆ _end_block()

DiffFormatter::_end_block ( )

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

1657  {

◆ _end_diff()

DiffFormatter::_end_diff ( )

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

1632  {
1633  trigger_error('Unknown edit type', E_USER_ERROR);
1634  }
1635  }
1636  $this->_end_block();

◆ _lines()

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

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

1661  : 'd') : 'a') . $ybeg;
1662  }
1663 
1664  public function _start_block($header)

◆ _start_block()

DiffFormatter::_start_block (   $header)

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

1653  {

◆ _start_diff()

DiffFormatter::_start_diff ( )

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

1626  {
1627  $this->_added($edit->closing);
1628  } elseif ($edit->type == 'delete') {
1629  $this->_deleted($edit->orig);

◆ format()

DiffFormatter::format (   $diff)

Format a diff.

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

Definition at line 1533 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 
$leading_context_lines
Number of leading context "lines" to preserve.
_block($xbeg, $xlen, $ybeg, $ylen, &$edits)
Create styles array
The data for the language used.
$trailing_context_lines
Number of trailing context "lines" to preserve.

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

◆ $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 1525 of file class.WordLevelDiff.php.


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