X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fdiff%2FTableDiffFormatter.php;h=bcae7467f777e008c62131713f6b96f720e6b514;hb=3c9b4b1eb13e072f2216facc424e400d3bfdde1b;hp=be38e8759c3dbd000cac55c22535e24263823e9b;hpb=8732532d47866f75d9d145d877e3e41bbd3a29d2;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/diff/TableDiffFormatter.php b/includes/diff/TableDiffFormatter.php
index be38e8759c..bcae7467f7 100644
--- a/includes/diff/TableDiffFormatter.php
+++ b/includes/diff/TableDiffFormatter.php
@@ -80,7 +80,7 @@ class TableDiffFormatter extends DiffFormatter {
* @param string $header
*/
protected function startBlock( $header ) {
- echo $header;
+ $this->writeOutput( $header );
}
protected function endBlock() {
@@ -157,9 +157,9 @@ class TableDiffFormatter extends DiffFormatter {
*/
protected function added( $lines ) {
foreach ( $lines as $line ) {
- echo '
' . $this->emptyLine() .
+ $this->writeOutput( '
' . $this->emptyLine() .
$this->addedLine( '' .
- htmlspecialchars( $line ) . '' ) . "
\n";
+ htmlspecialchars( $line ) . '' ) . "\n" );
}
}
@@ -170,9 +170,9 @@ class TableDiffFormatter extends DiffFormatter {
*/
protected function deleted( $lines ) {
foreach ( $lines as $line ) {
- echo '' . $this->deletedLine( '' .
+ $this->writeOutput( '' . $this->deletedLine( '' .
htmlspecialchars( $line ) . '' ) .
- $this->emptyLine() . "
\n";
+ $this->emptyLine() . "
\n" );
}
}
@@ -183,9 +183,9 @@ class TableDiffFormatter extends DiffFormatter {
*/
protected function context( $lines ) {
foreach ( $lines as $line ) {
- echo '' .
+ $this->writeOutput( '
' .
$this->contextLine( htmlspecialchars( $line ) ) .
- $this->contextLine( htmlspecialchars( $line ) ) . "
\n";
+ $this->contextLine( htmlspecialchars( $line ) ) . "\n" );
}
}
@@ -204,16 +204,13 @@ class TableDiffFormatter extends DiffFormatter {
# Notice that WordLevelDiff returns HTML-escaped output.
# Hence, we will be calling addedLine/deletedLine without HTML-escaping.
- $line = array_shift( $del );
- while ( $line ) {
- $aline = array_shift( $add );
- echo '' . $this->deletedLine( $line ) .
- $this->addedLine( $aline ) . "
\n";
- $line = array_shift( $del );
- }
- foreach ( $add as $line ) { # If any leftovers
- echo '' . $this->emptyLine() .
- $this->addedLine( $line ) . "
\n";
+ $ndel = count( $del );
+ $nadd = count( $add );
+ $n = max( $ndel, $nadd );
+ for ( $i = 0; $i < $n; $i++ ) {
+ $delLine = $i < $ndel ? $this->deletedLine( $del[$i] ) : $this->emptyLine();
+ $addLine = $i < $nadd ? $this->addedLine( $add[$i] ) : $this->emptyLine();
+ $this->writeOutput( "{$delLine}{$addLine}
\n" );
}
}