MediaWiki REL1_37
TableDiffFormatter Class Reference

MediaWiki default table style diff formatter. More...

Inheritance diagram for TableDiffFormatter:
Collaboration diagram for TableDiffFormatter:

Public Member Functions

 __construct ()
 
- Public Member Functions inherited from DiffFormatter
 format ( $diff)
 Format a diff.
 

Static Public Member Functions

static escapeWhiteSpace ( $msg)
 

Protected Member Functions

 added ( $lines)
 Writes all lines to the output buffer, each enclosed in .
 
 addedLine ( $line)
 HTML-escape parameter before calling this.
 
 blockHeader ( $xbeg, $xlen, $ybeg, $ylen)
 
 changed ( $orig, $closing)
 Writes the two sets of lines to the output buffer, each enclosed in .
 
 context ( $lines)
 Writes all lines to the output buffer, each enclosed in .
 
 contextLine ( $line, string $side)
 HTML-escape parameter before calling this.
 
 deleted ( $lines)
 Writes all lines to the output buffer, each enclosed in .
 
 deletedLine ( $line)
 HTML-escape parameter before calling this.
 
 emptyLine (string $side)
 
 endBlock ()
 Called at the end of a block of connected edits.This default implementation does nothing.
 
 lines ( $lines, $prefix=' ', $color='white')
 
 startBlock ( $header)
 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

 
 wrapLine ( $marker, $class, $line)
 
- Protected Member Functions inherited from DiffFormatter
 block ( $xbeg, $xlen, $ybeg, $ylen, &$edits)
 
 endDiff ()
 
 lines ( $lines, $prefix=' ')
 Writes all (optionally prefixed) lines to the output buffer, separated by newlines.
 
 startDiff ()
 
 writeOutput ( $text)
 Writes a string to the output buffer.
 

Private Member Functions

 getClassForSide (string $side)
 Get a class for the given diff side, or throw if the side is invalid.
 

Private Attributes

const SIDE_ADDED = 'added'
 
const SIDE_CLASSES
 
const SIDE_DELETED = 'deleted'
 Constants for diff sides.
 

Additional Inherited Members

- Protected Attributes inherited from DiffFormatter
int $leadingContextLines = 0
 Number of leading context "lines" to preserve.
 
int $trailingContextLines = 0
 Number of trailing context "lines" to preserve.
 

Detailed Description

MediaWiki default table style diff formatter.

Todo:
document @newable

Definition at line 33 of file TableDiffFormatter.php.

Constructor & Destructor Documentation

◆ __construct()

TableDiffFormatter::__construct ( )

Definition at line 45 of file TableDiffFormatter.php.

Member Function Documentation

◆ added()

TableDiffFormatter::added (   $lines)
protected

Writes all lines to the output buffer, each enclosed in .

Parameters
string[]$lines

Reimplemented from DiffFormatter.

Definition at line 179 of file TableDiffFormatter.php.

References $line, $lines, addedLine(), emptyLine(), and DiffFormatter\writeOutput().

◆ addedLine()

TableDiffFormatter::addedLine (   $line)
protected

HTML-escape parameter before calling this.

Parameters
string$line
Returns
string

Definition at line 115 of file TableDiffFormatter.php.

References $line, getClassForSide(), and wrapLine().

Referenced by added(), and changed().

◆ blockHeader()

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

Reimplemented from DiffFormatter.

Definition at line 71 of file TableDiffFormatter.php.

◆ changed()

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

Writes the two sets of lines to the output buffer, each enclosed in .

Parameters
string[]$orig
string[]$closing

Reimplemented from DiffFormatter.

Definition at line 249 of file TableDiffFormatter.php.

References addedLine(), deletedLine(), emptyLine(), and DiffFormatter\writeOutput().

◆ context()

TableDiffFormatter::context (   $lines)
protected

Writes all lines to the output buffer, each enclosed in .

Parameters
string[]$lines

Reimplemented from DiffFormatter.

Definition at line 229 of file TableDiffFormatter.php.

References $line, $lines, contextLine(), and DiffFormatter\writeOutput().

◆ contextLine()

TableDiffFormatter::contextLine (   $line,
string  $side 
)
protected

HTML-escape parameter before calling this.

Parameters
string$line
string$sideself::SIDE_DELETED or self::SIDE_ADDED
Returns
string

Definition at line 138 of file TableDiffFormatter.php.

References $line, getClassForSide(), and wrapLine().

Referenced by context().

◆ deleted()

TableDiffFormatter::deleted (   $lines)
protected

Writes all lines to the output buffer, each enclosed in .

Parameters
string[]$lines

Reimplemented from DiffFormatter.

Definition at line 204 of file TableDiffFormatter.php.

References $line, $lines, deletedLine(), emptyLine(), and DiffFormatter\writeOutput().

◆ deletedLine()

TableDiffFormatter::deletedLine (   $line)
protected

HTML-escape parameter before calling this.

Parameters
string$line
Returns
string

Definition at line 126 of file TableDiffFormatter.php.

References $line, getClassForSide(), and wrapLine().

Referenced by changed(), and deleted().

◆ emptyLine()

TableDiffFormatter::emptyLine ( string  $side)
protected
Parameters
string$sideself::SIDE_DELETED or self::SIDE_ADDED
Returns
string

Definition at line 170 of file TableDiffFormatter.php.

References getClassForSide().

Referenced by added(), changed(), and deleted().

◆ endBlock()

TableDiffFormatter::endBlock ( )
protected

Called at the end of a block of connected edits.This default implementation does nothing.

Reimplemented from DiffFormatter.

Definition at line 97 of file TableDiffFormatter.php.

◆ escapeWhiteSpace()

static TableDiffFormatter::escapeWhiteSpace (   $msg)
static
Parameters
string$msg
Returns
string

Definition at line 55 of file TableDiffFormatter.php.

Referenced by wrapLine().

◆ getClassForSide()

TableDiffFormatter::getClassForSide ( string  $side)
private

Get a class for the given diff side, or throw if the side is invalid.

Parameters
string$sideself::SIDE_DELETED or self::SIDE_ADDED
Returns
string
Exceptions
InvalidArgumentException

Definition at line 281 of file TableDiffFormatter.php.

Referenced by addedLine(), contextLine(), deletedLine(), and emptyLine().

◆ lines()

TableDiffFormatter::lines (   $lines,
  $prefix = ' ',
  $color = 'white' 
)
protected
Parameters
string[]$lines
string$prefix
string$color

Definition at line 105 of file TableDiffFormatter.php.

◆ startBlock()

TableDiffFormatter::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 from DiffFormatter.

Definition at line 92 of file TableDiffFormatter.php.

References $header, and DiffFormatter\writeOutput().

◆ wrapLine()

TableDiffFormatter::wrapLine (   $marker,
  $class,
  $line 
)
protected
Parameters
string$marker
string | string[]$classA single class or a list of classes
string$line
Returns
string

Definition at line 149 of file TableDiffFormatter.php.

References $line, and escapeWhiteSpace().

Referenced by addedLine(), contextLine(), and deletedLine().

Member Data Documentation

◆ SIDE_ADDED

const TableDiffFormatter::SIDE_ADDED = 'added'
private

Definition at line 39 of file TableDiffFormatter.php.

◆ SIDE_CLASSES

const TableDiffFormatter::SIDE_CLASSES
private
Initial value:
= [
self::SIDE_DELETED => 'diff-side-deleted',
self::SIDE_ADDED => 'diff-side-added'
]

Definition at line 40 of file TableDiffFormatter.php.

◆ SIDE_DELETED

const TableDiffFormatter::SIDE_DELETED = 'deleted'
private

Constants for diff sides.

Note: these are also used for context lines.

Definition at line 38 of file TableDiffFormatter.php.


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