ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 1405 of file class.WordLevelDiff.php.

Member Function Documentation

◆ _added()

DiffFormatter::_added (   $lines)

Reimplemented in TableDiffFormatter.

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

1544 {
1545 $this->_lines($lines, '>');
1546 }
_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 1489 of file class.WordLevelDiff.php.

1489 {
1490 $fname = 'DiffFormatter::_block';
1491 //wfProfileIn( $fname );
1492 $this->_start_block($this->_block_header($xbeg, $xlen, $ybeg, $ylen));
1493 foreach ($edits as $edit) {
1494 if ($edit->type == 'copy')
1495 $this->_context($edit->orig);
1496 elseif ($edit->type == 'add')
1497 $this->_added($edit->closing);
1498 elseif ($edit->type == 'delete')
1499 $this->_deleted($edit->orig);
1500 elseif ($edit->type == 'change')
1501 $this->_changed($edit->orig, $edit->closing);
1502 else
1503 trigger_error('Unknown edit type', E_USER_ERROR);
1504 }
1505 $this->_end_block();
1506 //wfProfileOut( $fname );
1507 }
_block_header($xbeg, $xlen, $ybeg, $ylen)
_changed($orig, $closing)
if(PHP_SAPI=='cli') else

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

1519 {
1520 if ($xlen > 1)
1521 $xbeg .= "," . ($xbeg + $xlen - 1);
1522 if ($ylen > 1)
1523 $ybeg .= "," . ($ybeg + $ylen - 1);
1524
1525 return $xbeg . ($xlen ? ($ylen ? 'c' : 'd') : 'a') . $ybeg;
1526 }

Referenced by _block().

+ Here is the caller graph for this function:

◆ _changed()

DiffFormatter::_changed (   $orig,
  $closing 
)

Reimplemented in TableDiffFormatter.

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

1551 {
1552 $this->_deleted($orig);
1553 echo "---\n";
1554 $this->_added($closing);
1555 }

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

1540 {
1541 $this->_lines($lines);
1542 }

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

1547 {
1548 $this->_lines($lines, '<');
1549 }

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

1532 {
1533 }

Referenced by _block().

+ Here is the caller graph for this function:

◆ _end_diff()

DiffFormatter::_end_diff ( )

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

1513 {
1514 $val = ob_get_contents();
1515 ob_end_clean();
1516 return $val;
1517 }

Referenced by format().

+ Here is the caller graph for this function:

◆ _lines()

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

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

1535 {
1536 foreach ($lines as $line)
1537 echo "$prefix $line\n";
1538 }

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

1528 {
1529 echo $header;
1530 }
$header

References $header.

Referenced by _block().

+ Here is the caller graph for this function:

◆ _start_diff()

DiffFormatter::_start_diff ( )

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

1509 {
1510 ob_start();
1511 }

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

1429 {
1430 $fname = 'DiffFormatter::format';
1431 //wfProfileIn( $fname );
1432
1433 $xi = $yi = 1;
1434 $block = false;
1435 $context = array();
1436
1439
1440 $this->_start_diff();
1441
1442 foreach ($diff->edits as $edit) {
1443 if ($edit->type == 'copy') {
1444 if (is_array($block)) {
1445 if (sizeof($edit->orig) <= $nlead + $ntrail) {
1446 $block[] = $edit;
1447 }
1448 else{
1449 if ($ntrail) {
1450 $context = array_slice($edit->orig, 0, $ntrail);
1451 $block[] = new _DiffOp_Copy($context);
1452 }
1453 $this->_block($x0, $ntrail + $xi - $x0,
1454 $y0, $ntrail + $yi - $y0,
1455 $block);
1456 $block = false;
1457 }
1458 }
1459 $context = $edit->orig;
1460 }
1461 else {
1462 if (! is_array($block)) {
1463 $context = array_slice($context, sizeof($context) - $nlead);
1464 $x0 = $xi - sizeof($context);
1465 $y0 = $yi - sizeof($context);
1466 $block = array();
1467 if ($context)
1468 $block[] = new _DiffOp_Copy($context);
1469 }
1470 $block[] = $edit;
1471 }
1472
1473 if ($edit->orig)
1474 $xi += sizeof($edit->orig);
1475 if ($edit->closing)
1476 $yi += sizeof($edit->closing);
1477 }
1478
1479 if (is_array($block))
1480 $this->_block($x0, $xi - $x0,
1481 $y0, $yi - $y0,
1482 $block);
1483
1484 $end = $this->_end_diff();
1485 //wfProfileOut( $fname );
1486 return $end;
1487 }
$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.

References $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 1413 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 1421 of file class.WordLevelDiff.php.

Referenced by format().


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