public function hclone() { $result = new coopy_SimpleTable($this->get_width(), $this->get_height()); $_g1 = 0; $_g = $this->get_height(); while ($_g1 < $_g) { $i = $_g1++; $_g3 = 0; $_g2 = $this->get_width(); while ($_g3 < $_g2) { $j = $_g3++; $result->setCell($j, $i, $this->getCell($j, $i)); unset($j); } unset($_g3, $_g2); unset($i); } if ($this->meta !== null) { $result->meta = $this->meta->cloneMeta($result); } return $result; }
public function asTable() { if ($this->has_properties && $this->metadata === null) { return $this->t; } if ($this->metadata === null) { return null; } $w = $this->t->get_width(); $props = new _hx_array(array()); if (null == $this->keys) { throw new HException('null iterable'); } $__hx__it = $this->keys->keys(); while ($__hx__it->hasNext()) { unset($k); $k = $__hx__it->next(); $props->push($k); } $props->sort(isset(Reflect::$compare) ? Reflect::$compare : array("Reflect", "compare")); $mt = new coopy_SimpleTable($w + 1, $props->length + 1); $mt->setCell(0, 0, "@"); $_g = 0; while ($_g < $w) { $x = $_g++; $name = $this->t->getCell($x, 0); $mt->setCell(1 + $x, 0, $name); if (!$this->metadata->exists($name)) { continue; } $vals = $this->metadata->get($name); $_g2 = 0; $_g1 = $props->length; while ($_g2 < $_g1) { $i = $_g2++; if ($vals->exists($props[$i])) { $mt->setCell(1 + $x, $i + 1, $vals->get($props[$i])); } unset($i); } unset($_g2, $_g1); unset($x, $vals, $name); } $_g11 = 0; $_g3 = $props->length; while ($_g11 < $_g3) { $y = $_g11++; $mt->setCell(0, $y + 1, $props[$y]); unset($y); } return $mt; }
public function jsonToTable($json) { $output = null; $_g = 0; $_g1 = Reflect::fields($json); while ($_g < $_g1->length) { $name = $_g1[$_g]; ++$_g; $t = Reflect::field($json, $name); $columns = Reflect::field($t, "columns"); if ($columns === null) { continue; } $rows = Reflect::field($t, "rows"); if ($rows === null) { continue; } $output = new coopy_SimpleTable($columns->length, $rows->length); $has_hash = false; $has_hash_known = false; $_g3 = 0; $_g2 = $rows->length; while ($_g3 < $_g2) { $i = $_g3++; $row = $rows[$i]; if (!$has_hash_known) { if (Reflect::fields($row)->length === $columns->length) { $has_hash = true; } $has_hash_known = true; } if (!$has_hash) { $lst = $row; $_g5 = 0; $_g4 = $columns->length; while ($_g5 < $_g4) { $j = $_g5++; $val = $lst[$j]; $output->setCell($j, $i, coopy_Coopy::cellFor($val)); unset($val, $j); } unset($_g5, $_g4); unset($lst); } else { $_g51 = 0; $_g41 = $columns->length; while ($_g51 < $_g41) { $j1 = $_g51++; $val1 = Reflect::field($row, $columns[$j1]); $output->setCell($j1, $i, coopy_Coopy::cellFor($val1)); unset($val1, $j1); } unset($_g51, $_g41); } unset($row, $i); } unset($_g3, $_g2); unset($t, $rows, $name, $has_hash_known, $has_hash, $columns); } if ($output !== null) { $output->trimBlank(); } return $output; }
public function asTable() { $pct = 3; $this->getColumns(); $w = $this->columnNames->length; $mt = new coopy_SimpleTable($w + 1, $pct); $mt->setCell(0, 0, "@"); $mt->setCell(0, 1, "type"); $mt->setCell(0, 2, "key"); $_g = 0; while ($_g < $w) { $x = $_g++; $i = $x + 1; $mt->setCell($i, 0, $this->columnNames[$x]); $mt->setCell($i, 1, _hx_array_get($this->columns, $x)->type_value); $mt->setCell($i, 2, _hx_array_get($this->columns, $x)->primary ? "primary" : ""); unset($x, $i); } return $mt; }