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(); }
<?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();
public function renderTable($name, $t) { $renderer = new coopy_DiffRender(); $renderer->usePrettyArrows($this->pretty); $renderer->render($t); if (!$this->fragment) { $renderer->completeHtml(); } if ($this->format_preference === "www") { $this->io->sendToBrowser($renderer->html()); } else { $this->saveText($name, $renderer->html()); } if ($this->css_output !== null) { $this->saveText($this->css_output, $renderer->sampleCss()); } return true; }