ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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 1506 of file class.WordLevelDiff.php.

Member Function Documentation

◆ _added()

DiffFormatter::_added (   $lines)

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

1671  {

◆ _block()

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

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

◆ _block_header()

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

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

1638  {
1639  ob_start();
1640  }
1641 
1642  public function _end_diff()
1643  {
1644  $val = ob_get_contents();
1645  ob_end_clean();

◆ _changed()

DiffFormatter::_changed (   $orig,
  $closing 
)

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

1678  {
1679  $this->_lines($lines);
1680  }
1681 
1682  public function _added($lines)
_lines($lines, $prefix=' ')

◆ _context()

DiffFormatter::_context (   $lines)

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

1667  {

◆ _deleted()

DiffFormatter::_deleted (   $lines)

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

1672  {
1673  echo "$prefix $line\n";
1674  }
1675  }

◆ _end_block()

DiffFormatter::_end_block ( )

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

1654  {

◆ _end_diff()

DiffFormatter::_end_diff ( )

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

1629  {
1630  trigger_error('Unknown edit type', E_USER_ERROR);
1631  }
1632  }
1633  $this->_end_block();

◆ _lines()

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

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

1658  : 'd') : 'a') . $ybeg;
1659  }
1660 
1661  public function _start_block($header)

◆ _start_block()

DiffFormatter::_start_block (   $header)

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

1650  {

◆ _start_diff()

DiffFormatter::_start_diff ( )

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

1623  {
1624  $this->_added($edit->closing);
1625  } elseif ($edit->type == 'delete') {
1626  $this->_deleted($edit->orig);

◆ format()

DiffFormatter::format (   $diff)

Format a diff.

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

Definition at line 1530 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 
$leading_context_lines
Number of leading context "lines" to preserve.
$context
Definition: webdav.php:29
_block($xbeg, $xlen, $ybeg, $ylen, $edits)
$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 1514 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 1522 of file class.WordLevelDiff.php.


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