Skip to content

Commit

Permalink
Remove normalize format function
Browse files Browse the repository at this point in the history
  • Loading branch information
jschroed91 committed Feb 24, 2016
1 parent e5e79e5 commit a071252
Showing 1 changed file with 0 additions and 66 deletions.
66 changes: 0 additions & 66 deletions lib/Caxy/HtmlDiff/Table/TableDiff.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,79 +70,13 @@ public function build()

$this->diffDom = new \DOMDocument();

// $this->normalizeFormat();

$this->indexCellValues($this->newTable);

$this->diffTableContent();

return $this->content;
}

protected function normalizeFormat()
{
$oldRows = $this->oldTable->getRows();
$newRows = $this->newTable->getRows();

foreach ($newRows as $rowIndex => $newRow) {
$oldRow = isset($oldRows[$rowIndex]) ? $oldRows[$rowIndex] : null;

if (!$oldRow) {
continue;
}

$newRowOffset = 0;
$oldRowOffset = 0;

$newCells = $newRow->getCells();
$oldCells = $oldRow->getCells();

foreach ($newCells as $cellIndex => $newCell) {
$oldCell = isset($oldCells[$cellIndex]) ? $oldCells[$cellIndex] : null;

if ($oldCell) {
$oldNode = $oldCell->getDomNode();
$newNode = $newCell->getDomNode();

$oldRowspan = $oldNode->getAttribute('rowspan') ?: 1;
$newRowspan = $newNode->getAttribute('rowspan') ?: 1;

if ($oldRowspan > $newRowspan) {
// add placeholders in next row of new rows
$offset = $oldRowspan - $newRowspan;
if ($offset > $newRowOffset) {
$newRowOffset = $offset;
}
} elseif ($newRowspan > $oldRowspan) {
$offset = $newRowspan - $oldRowspan;
if ($offset > $oldRowOffset) {
$oldRowOffset = $offset;
}
}
}
}

if ($oldRowOffset > 0 && isset($newRows[$rowIndex + 1])) {
$blankRow = $this->diffDom->createElement('tr');

$insertArray = array();
for ($i = 0; $i < $oldRowOffset; $i++) {
$insertArray[] = new TableRow($blankRow);
}

$this->oldTable->insertRows($insertArray, $rowIndex + 1);
} elseif ($newRowOffset > 0 && isset($newRows[$rowIndex + 1])) {
$blankRow = $this->diffDom->createElement('tr');

$insertArray = array();
for ($i = 0; $i < $newRowOffset; $i++) {
$insertArray[] = new TableRow($blankRow);
}
$this->newTable->insertRows($insertArray, $rowIndex + 1);
}
}
}

protected function diffTableContent()
{
$this->diffDom = new \DOMDocument();
Expand Down

0 comments on commit a071252

Please sign in to comment.