/** * generateTabsMenu */ public function generateTabsMenu($node_id) { if (!is_numeric($node_id)) { return false; } require_once 'models/common/common_node.php'; $Node = new common_node(); /** * get list of children */ $children = $Node->getChildren($node_id, 'priority DESC, id ASC'); if (!is_array($children)) { return false; } /** * filter only published items */ $children_published = array(); foreach ($children as $item) { if ($item['publish'] == 1) { $children_published[] = $item; } } /** * show only if any items are left */ if (is_array($children_published) && count($children_published) > 0) { $total_count = count($children_published); foreach ($children_published as $k => $item) { $first_last = ''; if ($k == 0) { $first_last = 'first'; } if ($k == $total_count - 1) { $first_last .= ' last'; } $this->tpl->assign('FIRST_LAST', $first_last); $this->tpl->assign('ITEM', $item); $this->tpl->parse('content.menu.item'); } $this->tpl->parse('content.menu'); } return true; }
/** * main action */ public function mainAction() { require_once 'models/common/common_node.php'; if (!is_numeric($this->GET['id'])) { msg('node_child: id is not numeric', 'error'); return false; } $Node = new common_node(); $node_detail = $Node->getDetail($this->GET['id']); if (!is_array($node_detail)) { msg("node_child: Node not found", 'error'); return false; } /** * set node group as parent if not provided */ if ($this->GET['node_group'] != '') { $this->tpl->assign('NODE_GROUP', $this->GET['node_group']); } else { $this->tpl->assign('NODE_GROUP', $node_detail['node_group']); } $this->tpl->assign("NODE", $node_detail); //get children $children = $Node->getChildren($node_detail['id']); if (is_array($children) && count($children) > 0) { foreach ($children as $child) { if ($child['publish'] == 0) { $child['class'] = 'disabled'; } $this->tpl->assign("CHILD", $child); $this->tpl->parse('content.children.item'); } $this->tpl->parse('content.children'); } else { $this->tpl->parse('content.empty'); } return true; }
public function getPageChildren($parent) { $Node = new common_node(); return $Node->getChildren($parent); }