output = '
'; foreach ($in as $node) { $this->output .= $this->gem($node); } $this->output .= '
'; file_put_contents(base_path("gem/forms/{$argv[2]}/build/form.blade.php"), $this->output); echo "OK"; } public function gem($_node, $_parentKey = false, $_level = 0) { $output = ''; $key = ($_parentKey ? $_parentKey . '__' : '') . $_node->K; // start container $output .= $this->ln('
', $_level + 1); // label $output .= $this->ln('', $_level + 2); // input if (!!@$_node->T) { switch ($_node->T) { case 'YNUM': // start $output .= $this->ln('
', $_level + 1); // YES $output .= $this->ln('', $_level + 2); // NO $output .= $this->ln('', $_level + 2); // NO $output .= $this->ln('', $_level + 2); // MEMO $output .= $this->ln('', $_level + 2); // end $output .= $this->ln('
', $_level + 1); break; } } // subs if (!!@$_node->S) { $output .= '
'; foreach ($_node->S as $sub) { $output .= $this->gem($sub, $key, $_level + 1); } $output .= '
'; } // close container $output .= $this->ln('
', $_level + 1); $output .= $this->nl(); return $output; } public function ln($_line, $_indent = 1, $_nlAfter = true) { return str_repeat(" ", $_indent * 4) . $_line . ($_nlAfter ? "\n" : ''); } public function nl() { return "\n"; } }