public function display($supress_output = false) { if (!array_key_exists('HTTP_HOST', $_SERVER)) { exit("No command line usage for this page"); } if (!$this->get_exists('delay_index')) { I2CE::raiseError("Invalid tree data request: 'request' is missing"); return false; } $delay_index = $this->get('delay_index'); if (!array_key_exists('tree_data', $_SESSION) || !is_array($_SESSION['tree_data']) || !array_key_exists($delay_index, $_SESSION['tree_data'])) { return false; } $data = $_SESSION['tree_data'][$delay_index]; unset($_SESSION['tree_data'][$delay_index]); if (!is_array($data)) { return false; } $template = new I2CE_Template(); $template->loadRootText("<span id='root'>"); $root = $template->getElementById('root'); $doc = $template->getDoc(); I2CE_Module_TreeSelect::createTreeData($template, $root, $data); $tdoc = new DOMDocument(); $tdoc->appendChild($tdoc->importNode($root, true)); echo $tdoc->saveHTML(); die; }
/** * Ensure that a node is really a node. If it is not, hopes that it is an ID * and then makes it the corresponding node * @param I2CE_Template $template * @param mixed &$node. Either a DOMNode or a node id. * @param bool $make_doc_on_failure defaults to true. If we can't find the node, make it the document element * If false, we leave $node alone. */ protected function _ensureNode($template, &$node, $make_doc_on_failure = true) { if (isset($node) && $node instanceof DOMNode) { //we are good so quit. return; } $new_node = null; if (is_string($node)) { $new_node = $template->getElementById($node); } if ($new_node == null) { if ($make_doc_on_failure) { $node = $template->getDoc()->documentElement; } } else { $node = $new_node; } }