MediaWiki  1.23.2
DiffFormatter Class Reference

Base class for diff formatters. More...

Inheritance diagram for DiffFormatter:

Public Member Functions

 format ( $diff)
 Format a diff. More...
 

Protected Member Functions

 added ( $lines)
 
 block ( $xbeg, $xlen, $ybeg, $ylen, &$edits)
 
 blockHeader ( $xbeg, $xlen, $ybeg, $ylen)
 
 changed ( $orig, $closing)
 Writes the two sets of lines to the output buffer, separated by "---" and a newline. More...
 
 context ( $lines)
 
 deleted ( $lines)
 
 endBlock ()
 Called at the end of a block of connected edits. More...
 
 endDiff ()
 
 lines ( $lines, $prefix=' ')
 Writes all (optionally prefixed) lines to the output buffer, separated by newlines. More...
 
 startBlock ( $header)
 Called at the start of a block of connected edits. More...
 
 startDiff ()
 

Protected Attributes

int $leadingContextLines = 0
 Number of leading context "lines" to preserve. More...
 
int $trailingContextLines = 0
 Number of trailing context "lines" to preserve. More...
 

Detailed Description

Base class for diff formatters.

This class formats the diff in classic diff format. It is intended that this class be customized via inheritance, to obtain fancier outputs.

Todo:
document

Definition at line 36 of file DiffFormatter.php.

Member Function Documentation

◆ added()

DiffFormatter::added (   $lines)
protected
Parameters
string[]$lines

Reimplemented in TableDiffFormatter, and UnifiedDiffFormatter.

Definition at line 222 of file DiffFormatter.php.

References $lines, and lines().

Referenced by block(), and changed().

◆ block()

DiffFormatter::block (   $xbeg,
  $xlen,
  $ybeg,
  $ylen,
$edits 
)
protected
Parameters
int$xbeg
int$xlen
int$ybeg
int$ylen
$edits
Exceptions
MWExceptionIf the edit type is not known.

Definition at line 130 of file DiffFormatter.php.

References added(), as, blockHeader(), changed(), context(), deleted(), endBlock(), startBlock(), wfProfileIn(), and wfProfileOut().

Referenced by format().

◆ blockHeader()

DiffFormatter::blockHeader (   $xbeg,
  $xlen,
  $ybeg,
  $ylen 
)
protected
Parameters
int$xbeg
int$xlen
int$ybeg
int$ylen
Returns
string

Reimplemented in UnifiedDiffFormatter, and TableDiffFormatter.

Definition at line 172 of file DiffFormatter.php.

Referenced by block().

◆ changed()

DiffFormatter::changed (   $orig,
  $closing 
)
protected

Writes the two sets of lines to the output buffer, separated by "---" and a newline.

Parameters
string[]$orig
string[]$closing

Reimplemented in TableDiffFormatter, and UnifiedDiffFormatter.

Definition at line 239 of file DiffFormatter.php.

References added(), and deleted().

Referenced by block().

◆ context()

DiffFormatter::context (   $lines)
protected
Parameters
string[]$lines

Reimplemented in TableDiffFormatter.

Definition at line 215 of file DiffFormatter.php.

References $lines, and lines().

Referenced by block().

◆ deleted()

DiffFormatter::deleted (   $lines)
protected
Parameters
string[]$lines

Reimplemented in TableDiffFormatter, and UnifiedDiffFormatter.

Definition at line 229 of file DiffFormatter.php.

References $lines, and lines().

Referenced by block(), and changed().

◆ endBlock()

DiffFormatter::endBlock ( )
protected

Called at the end of a block of connected edits.

This default implementation does nothing.

Reimplemented in TableDiffFormatter.

Definition at line 197 of file DiffFormatter.php.

Referenced by block().

◆ endDiff()

DiffFormatter::endDiff ( )
protected
Returns
string

Definition at line 157 of file DiffFormatter.php.

Referenced by format().

◆ format()

DiffFormatter::format (   $diff)

Format a diff.

Parameters
Diff$diffA Diff object.
Returns
string The formatted output.

Reimplemented in ArrayDiffFormatter.

Definition at line 57 of file DiffFormatter.php.

References $leadingContextLines, $trailingContextLines, array(), as, block(), endDiff(), startDiff(), wfProfileIn(), and wfProfileOut().

◆ lines()

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

Writes all (optionally prefixed) lines to the output buffer, separated by newlines.

Parameters
string[]$lines
string$prefix

Definition at line 206 of file DiffFormatter.php.

References $line, $lines, and as.

Referenced by UnifiedDiffFormatter\added(), added(), context(), UnifiedDiffFormatter\deleted(), and deleted().

◆ startBlock()

DiffFormatter::startBlock (   $header)
protected

Called at the start of a block of connected edits.

This default implementation writes the header and a newline to the output buffer.

Parameters
string$header

Reimplemented in TableDiffFormatter.

Definition at line 189 of file DiffFormatter.php.

Referenced by block().

◆ startDiff()

DiffFormatter::startDiff ( )
protected

Definition at line 150 of file DiffFormatter.php.

Referenced by format().

Member Data Documentation

◆ $leadingContextLines

int DiffFormatter::$leadingContextLines = 0
protected

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 42 of file DiffFormatter.php.

Referenced by format().

◆ $trailingContextLines

int DiffFormatter::$trailingContextLines = 0
protected

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 48 of file DiffFormatter.php.

Referenced by format().


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