function On_PostAction_iterator_fetch($a_data) { // Find iterator in template $doc = new Template_Document($a_data->post['iterator_template']); function search_func($node, $args) { if ($node instanceof Template_TagNode) { return $node->getAttribute("name") == $args; } else { return false; } } $itrs = $doc->getElementsByFunc(search_func, $a_data->post['iterator_name']); $iterator = $itrs[0]; // Generate id $id = Time("U") . substr((string) microtime(), 2, 6); // Build iterator template $node = new Node(-$id); $node->Build($iterator); // Pack JSON data $data = array(); $data['id'] = $id; $data['content'] = Editor::$m_data['module_data'][-$id]; print json_encode($data); }
public function Build() { // Load module data $result = Database::Query("SELECT * FROM `" . DB_TBL_MODULE_TEMPLATE . "` WHERE `id` = '" . $this->m_id . "'"); if (!$result->HasData()) { die("Module::Build(): Module #" . $this->m_id . " not found!"); } $module_template = $result->GetRow(); // Load template $doc = new Template_Document('modules/' . $module_template['type'] . '/' . $module_template['template'] . '.tmpl'); $node = new Node($this->m_id); $node->Build($doc); if (Compiler::$Mode == COMPILER_MODE_EDITOR) { $container = new Template_Document(); $container->addChild(new Template_TextNode('<div data-moduleid="' . $this->m_id . '">')); $container->addChild($doc); $container->addChild(new Template_TextNode('</div>')); return $container; } else { return $doc; } }