protected function _quickDiff($data1, $data2) { $table1 = new coopy_PhpTableView($data1); $table2 = new coopy_PhpTableView($data2); $data_diff = []; $table_diff = new coopy_PhpTableView($data_diff); $highlighter = new coopy_TableDiff(coopy_Coopy::compareTables($table1, $table2)->align(), new coopy_CompareFlags()); $highlighter->hilite($table_diff); $diff2html = new coopy_DiffRender(); $diff2html->usePrettyArrows(false); $diff2html->render($table_diff); return $diff2html->html(); }
public function getText($x, $y, $color) { $val = $this->t->getCell($x, $y); $cell = coopy_DiffRender::renderCell($this->t, $this->v, $x, $y); if ($color) { $code = null; if ($cell->category !== null) { $code = $this->codes->get($cell->category); } if ($cell->category_given_tr !== null) { $code_tr = $this->codes->get($cell->category_given_tr); if ($code_tr !== null) { $code = $code_tr; } } if ($code !== null) { if ($cell->rvalue !== null) { $val = _hx_string_or_null($this->codes->get("remove")) . _hx_string_or_null($cell->lvalue) . _hx_string_or_null($this->codes->get("modify")) . _hx_string_or_null($cell->pretty_separator) . _hx_string_or_null($this->codes->get("add")) . _hx_string_or_null($cell->rvalue) . _hx_string_or_null($this->codes->get("done")); if ($cell->pvalue !== null) { $val = _hx_string_or_null($this->codes->get("conflict")) . _hx_string_or_null($cell->pvalue) . _hx_string_or_null($this->codes->get("modify")) . _hx_string_or_null($cell->pretty_separator) . Std::string($val); } } else { $val = $cell->pretty_value; $val = _hx_string_or_null($code) . Std::string($val) . _hx_string_or_null($this->codes->get("done")); } } } else { $val = $cell->pretty_value; } return $this->csv->renderCell($this->v, $val); }
public function finishRows() { if ($this->useMetaForRowChanges()) { return; } if ($this->source->get_width() === 0) { if ($this->source->get_height() !== 0) { $this->source->resize(0, 0); } return; } $fate = new _hx_array(array()); $this->permuteRows(); if ($this->rowPermutation->length > 0) { $_g = 0; $_g1 = $this->mods; while ($_g < $_g1->length) { $mod = $_g1[$_g]; ++$_g; if ($mod->sourceRow >= 0) { $mod->sourceRow = $this->rowPermutation[$mod->sourceRow]; } unset($mod); } } if ($this->rowPermutation->length > 0) { $this->source->insertOrDeleteRows($this->rowPermutation, $this->rowPermutation->length); } $len = $this->processMods($this->mods, $fate, $this->source->get_height()); $this->source->insertOrDeleteRows($fate, $len); $this->needDestColumns(); $_g2 = 0; $_g11 = $this->mods; while ($_g2 < $_g11->length) { $mod1 = $_g11[$_g2]; ++$_g2; if (!$mod1->rem) { if ($mod1->add) { if (null == $this->headerPost) { throw new HException('null iterable'); } $__hx__it = $this->headerPost->iterator(); while ($__hx__it->hasNext()) { unset($c); $c = $__hx__it->next(); $offset = $this->patchInDestCol->get($c); if ($offset !== null && $offset >= 0) { $this->source->setCell($offset, $mod1->destRow, $this->patch->getCell($c, $mod1->patchRow)); } unset($offset); } } else { if ($mod1->update) { $this->currentRow = $mod1->patchRow; $this->checkAct(); if (!$this->rowInfo->updated) { continue; } if (null == $this->headerPre) { throw new HException('null iterable'); } $__hx__it = $this->headerPre->iterator(); while ($__hx__it->hasNext()) { unset($c1); $c1 = $__hx__it->next(); $txt = $this->view->toString($this->patch->getCell($c1, $mod1->patchRow)); coopy_DiffRender::examineCell(0, 0, $this->view, $txt, "", $this->rowInfo->value, "", $this->cellInfo, null); if (!$this->cellInfo->updated) { continue; } if ($this->cellInfo->conflicted) { continue; } $d = $this->view->toDatum($this->csv->parseCell($this->cellInfo->rvalue)); $offset1 = $this->patchInDestCol->get($c1); if ($offset1 !== null && $offset1 >= 0) { $this->source->setCell($this->patchInDestCol->get($c1), $mod1->destRow, $d); } unset($txt, $offset1, $d); } } } } unset($mod1); } $this->fillInNewColumns(); $_g12 = 0; $_g3 = $this->source->get_width(); while ($_g12 < $_g3) { $i = $_g12++; $name = $this->view->toString($this->source->getCell($i, 0)); $next_name = $this->headerRename->get($name); if ($next_name === null) { continue; } $this->source->setCell($i, 0, $this->view->toDatum($next_name)); unset($next_name, $name, $i); } }
static function diffAsHtml($local, $remote, $flags = null) { $comp = new coopy_TableComparisonState(); $td = coopy_Coopy::align($local, $remote, $flags, $comp); $o = coopy_Coopy::getBlankTable($td, $comp); if ($comp->a !== null) { $o = $comp->a->create(); } if ($o === null && $comp->b !== null) { $o = $comp->b->create(); } if ($o === null) { $o = new coopy_SimpleTable(0, 0); } $os = new coopy_Tables($o); $td->hiliteWithNesting($os); $render = new coopy_DiffRender(); return $render->renderTables($os)->html(); }
static function renderCell($tab, $view, $x, $y) { $cell = new coopy_CellInfo(); $corner = $view->toString($tab->getCell(0, 0)); $off = null; if ($corner === "@:@") { $off = 1; } else { $off = 0; } coopy_DiffRender::examineCell($x, $y, $view, $tab->getCell($x, $y), $view->toString($tab->getCell($x, $off)), $view->toString($tab->getCell($off, $y)), $corner, $cell, $off); return $cell; }
<?php if (version_compare(PHP_VERSION, '5.1.0', '<')) { exit('Your current PHP version is: ' . PHP_VERSION . '. Haxe/PHP generates code for version 5.1.0 or later'); } require_once dirname(__FILE__) . '/lib/php/Boot.class.php'; $data1 = [['Country', 'Capital'], ['Ireland', 'Dublin'], ['France', 'Paris'], ['Spain', 'Barcelona']]; $data2 = [['Country', 'Code', 'Capital'], ['Ireland', 'ie', 'Dublin'], ['France', 'fr', 'Paris'], ['Spain', 'es', 'Madrid'], ['Germany', 'de', 'Berlin']]; $table1 = new coopy_PhpTableView($data1); $table2 = new coopy_PhpTableView($data2); $alignment = coopy_Coopy::compareTables($table1, $table2)->align(); $data_diff = []; $table_diff = new coopy_PhpTableView($data_diff); $flags = new coopy_CompareFlags(); $highlighter = new coopy_TableDiff($alignment, $flags); $highlighter->hilite($table_diff); $diff2html = new coopy_DiffRender(); $diff2html->usePrettyArrows(false); $diff2html->render($table_diff); $table_diff_html = $diff2html->html(); echo $table_diff_html; $patcher = new coopy_HighlightPatch($table1, $table_diff); $patcher->apply();
static function diffAsHtml($local, $remote, $flags = null) { $o = coopy_Coopy::diff($local, $remote, $flags); $render = new coopy_DiffRender(); return $render->render($o)->html(); }