function getChilds($node, $root) { $data = array(); $select = Axis::model('cms/category')->select('*'); if ($root) { $select->where('cc.site_id = ?', $node)->where('cc.parent_id is NULL'); } else { $select->where('cc.parent_id = ?', $node); } //get categories foreach ($select->fetchAssoc() as $_category) { $data[] = array('leaf' => false, 'id' => $_category['id'], 'site_id' => $_category['site_id'], 'text' => $_category['name'], 'iconCls' => 'icon-folder', 'expanded' => true, 'cls' => $_category['is_active'] ? '' : 'disabledNode', 'children' => getChilds($_category['id'], false)); } return $data; }
function getChilds($results, $parent_id, $level) { $childmenu = array(); $level++; $i = 0; foreach ($results as $result) { // echo $result['id']." ".$parent_id. ", level:".$level." ".$result['level']."\n"; if ($result['parent_id'] == $parent_id && $result['level'] == $level) { $childmenu[$i]['label'] = $result['label']; $childmenu[$i]['link'] = $result['link']; $child = getChilds($results, $result['id'], $result['level']); if (!empty($child)) { $childmenu[$i]['child'] = $child; } else { $childmenu[$i]['child'] = ""; } } $i++; } return $childmenu; }
function getChilds($f_iParent = null, &$arrDone = array()) { $szHtml = ''; if (is_null($f_iParent)) { $RD = db_select('r_d_available a', '0=(SELECT COUNT(1) FROM r_d_requires WHERE r_d_id=a.id)'); } else { $RD = db_select('r_d_available a, r_d_requires r', 'a.id = r.r_d_id AND r.r_d_requires_id = ' . (int) $f_iParent . ' AND a.id NOT IN(\'' . implode("','", $arrDone) . '\')'); } if (count($RD)) { $szHtml .= '<table border="0" cellpadding="0" cellspacing="0">'; foreach ($RD as $rd) { $arrDone[$rd['id']] = $rd['id']; $szHtml .= '<tr valign="top"><td><b>' . $rd['name'] . '</b></td>'; $c = getChilds($rd['id'], $arrDone); if ($c) { $szHtml .= '<td>' . $c . '</td>'; } $szHtml .= '</tr>'; } $szHtml .= '</table>'; } return $szHtml; }
$kaoyan_img = sp_getslide('kaoyan_img'); $kyimg = $kaoyan_img[0]; $nav_label = isset($nav_label) ? $nav_label : $post_title; $nid = sp_nav_id($nav_label); $nav_cid = sp_nav_cid($nid); if ($nav_cid == 1) { $navList = tree_to_list($navTree); } else { $navT = sp_get_menu_tree($nav_cid); $navList = tree_to_list($navT); } $snav = getParents($navList, $nid); $parent_sid = $snav[0]['id']; $parent_slabel = $snav[0]['label']; $parent_shref = $snav[0]['href']; $child_snav = getChilds($navList, $parent_sid); foreach ($child_snav as $key => $value) { if ($key % 2 == 0) { $ou[] = $value; } else { $ji[] = $value; } } $child_snav = array_merge($ou, $ji); $child_snav_height = count($child_snav) * 35; ?> <div class="sidebarbox" style="position: absolute; top: 150px;"> <aside class="sidebar" data-defaulth="295"> <header><h3 class="title"><span><?php echo $parent_slabel; ?>
function getLoadTreeMenuData() { header("content-type: text/xml"); global $G_TMP_MENU; $oMenu = new Menu(); $oMenu->load('cases'); $oCases = new Cases(); $aTypes = array('to_do', 'draft', 'cancelled', 'sent', 'paused', 'completed', 'selfservice'); //'to_revise', //'to_reassign' $aTypesID = array('CASES_INBOX' => 'to_do', 'CASES_DRAFT' => 'draft', 'CASES_CANCELLED' => 'cancelled', 'CASES_SENT' => 'sent', 'CASES_PAUSED' => 'paused', 'CASES_COMPLETED' => 'completed', 'CASES_SELFSERVICE' => 'selfservice'); //'CASES_TO_REVISE'=>'to_revise', //'CASES_TO_REASSIGN'=>'to_reassign' $list = array(); $list['count'] = ' '; $empty = array(); foreach ($aTypes as $key => $val) { $empty[$val] = $list; } $aCount = $empty; //$oCases->getAllConditionCasesCount($aTypes, true); $processNameMaxSize = 20; //now drawing the treeview using the menu options from menu/cases.php $menuCases = array(); for ($i = 0; $i < count($oMenu->Options); $i++) { if ($oMenu->Types[$i] == 'blockHeader') { $CurrentBlockID = $oMenu->Id[$i]; $menuCases[$CurrentBlockID]['blockTitle'] = $oMenu->Labels[$i]; if ($oMenu->Options[$i] != "") { $menuCases[$CurrentBlockID]['link'] = $oMenu->Options[$i]; } } elseif ($oMenu->Types[$i] == 'blockNestedTree') { $CurrentBlockID = $oMenu->Id[$i]; $menuCases[$CurrentBlockID]['blockTitle'] = $oMenu->Labels[$i]; $menuCases[$CurrentBlockID]['blockType'] = $oMenu->Types[$i]; $menuCases[$CurrentBlockID]['loaderurl'] = $oMenu->Options[$i]; } elseif ($oMenu->Types[$i] == 'blockHeaderNoChild') { $CurrentBlockID = $oMenu->Id[$i]; $menuCases[$CurrentBlockID]['blockTitle'] = $oMenu->Labels[$i]; $menuCases[$CurrentBlockID]['blockType'] = $oMenu->Types[$i]; $menuCases[$CurrentBlockID]['link'] = $oMenu->Options[$i]; } elseif ($oMenu->Types[$i] == 'rootNode') { $menuCases[$CurrentBlockID]['blockItems'][$oMenu->Id[$i]] = array('label' => $oMenu->Labels[$i], 'link' => $oMenu->Options[$i], 'icon' => isset($oMenu->Icons[$i]) && $oMenu->Icons[$i] != '' ? $oMenu->Icons[$i] : 'kcmdf.png'); $index = $i; list($childs, $index) = getChilds($oMenu, ++$index); $menuCases[$CurrentBlockID]['blockItems'][$oMenu->Id[$i]]['childs'] = $childs; $i = $index; } else { $menuCases[$CurrentBlockID]['blockItems'][$oMenu->Id[$i]] = array('label' => $oMenu->Labels[$i], 'link' => $oMenu->Options[$i], 'icon' => isset($oMenu->Icons[$i]) && $oMenu->Icons[$i] != '' ? $oMenu->Icons[$i] : 'kcmdf.png'); if (isset($aTypesID[$oMenu->Id[$i]])) { $menuCases[$CurrentBlockID]['blockItems'][$oMenu->Id[$i]]['cases_count'] = $aCount[$aTypesID[$oMenu->Id[$i]]]['count']; } } } // Build xml nodes for a specific child node by its "id" on var "$_POST['node']" passed in a POST request if (isset($_POST['node']) && in_array($_POST['node'], array_keys($menuCases))) { $xml = new SimpleXMLElement('<?xml version="1.0" standalone="yes"?><menu_cases />'); if (array_key_exists('blockItems', $menuCases[$_POST['node']]) && is_array($menuCases[$_POST['node']]['blockItems'])) { foreach ($menuCases[$_POST['node']]['blockItems'] as $key => $item) { $option = $xml->addChild('option'); $option->addAttribute('id', $key); $option->addAttribute('title', $item['label']); $option->addAttribute('url', $item['link']); if (!empty($item['cases_count'])) { $option->addAttribute('cases_count', $item['cases_count']); } } } echo $xml->asXML(); die; } // Build xml document for all tree nodes $xml = new SimpleXMLElement('<?xml version="1.0" standalone="yes"?><menu_cases />'); foreach ($menuCases as $menuId => $menuBlock) { if (isset($menuBlock['blockItems']) && count($menuBlock['blockItems']) > 0) { // adding "menu_block" node $menuBlockNode = $xml->addChild('menu_block'); $menuBlockNode->addAttribute('id', $menuId); $menuBlockNode->addAttribute('blockTitle', $menuBlock['blockTitle']); if (!empty($menuBlock['link'])) { $menuBlockNode->addAttribute('url', $menuBlock['link']); } // adding "menu_block" childs nodes foreach ($menuBlock['blockItems'] as $id => $menu) { if (!empty($menu['childs'])) { $rootNode = $menuBlockNode->addChild('menu_block'); $rootNode->addAttribute('id', $id); $rootNode->addAttribute('title', $menu['label']); $rootNode->addAttribute('url', $menu['link']); $rootNode->addAttribute('expanded', true); foreach ($menu['childs'] as $id => $child) { $childNode = $rootNode->addChild('option'); $childNode->addAttribute('id', $id); $childNode->addAttribute('title', $child['label']); $childNode->addAttribute('url', $child['link']); } continue; } $option = $menuBlockNode->addChild('option'); $option->addAttribute('id', $id); $option->addAttribute('title', $menu['label']); $option->addAttribute('url', $menu['link']); if (!empty($menu['cases_count'])) { $option->addAttribute('cases_count', $menu['cases_count']); } } } elseif (isset($menuBlock['blockType']) && $menuBlock['blockType'] == "blockNestedTree") { $menuBlockNode = $xml->addChild('menu_block'); $menuBlockNode->addAttribute('id', $menuId); $menuBlockNode->addAttribute('folderId', "0"); $menuBlockNode->addAttribute('blockTitle', $menuBlock['blockTitle']); $menuBlockNode->addAttribute('blockNestedTree', $menuBlock['loaderurl']); } elseif (isset($menuBlock['blockType']) && $menuBlock['blockType'] == "blockHeaderNoChild") { $menuBlockNode = $xml->addChild('menu_block'); $menuBlockNode->addAttribute('id', $menuId); $menuBlockNode->addAttribute('blockTitle', $menuBlock['blockTitle']); $menuBlockNode->addAttribute('blockHeaderNoChild', "blockHeaderNoChild"); $menuBlockNode->addAttribute('url', $menuBlock['link']); } } echo $xml->asXML(); die; // Build xml document for all tree nodes /*$xml = '<menu_cases>'; $i = 0; foreach ($menuCases as $menu => $aMenuBlock) { if (isset( $aMenuBlock['blockItems'] ) && sizeof( $aMenuBlock['blockItems'] ) > 0) { $urlProperty = ""; if ((isset( $aMenuBlock['link'] )) && ($aMenuBlock['link'] != "")) { $urlProperty = "url='" . $aMenuBlock['link'] . "'"; } $xml .= '<menu_block blockTitle="' . $aMenuBlock['blockTitle'] . '" id="' . $menu . '" ' . $urlProperty . '>'; foreach ($aMenuBlock['blockItems'] as $id => $aMenu) { $i ++; if (isset( $aMenu['cases_count'] ) && $aMenu['cases_count'] !== '') { $nofifier = "cases_count=\"{$aMenu['cases_count']}\" "; } else { $nofifier = ''; } $xml .= '<option title="' . $aMenu['label'] . '" id="' . $id . '" ' . $nofifier . ' url="' . $aMenu['link'] . '">'; $xml .= '</option>'; } $xml .= '</menu_block>'; } elseif (isset( $aMenuBlock['blockType'] ) && $aMenuBlock['blockType'] == "blockNestedTree") { $xml .= '<menu_block blockTitle="' . $aMenuBlock['blockTitle'] . '" blockNestedTree = "' . $aMenuBlock['loaderurl'] . '" id="' . $menu . '" folderId="0">'; $xml .= '</menu_block>'; } elseif (isset( $aMenuBlock['blockType'] ) && $aMenuBlock['blockType'] == "blockHeaderNoChild") { $xml .= '<menu_block blockTitle="' . $aMenuBlock['blockTitle'] . '" blockHeaderNoChild="blockHeaderNoChild" url = "' . $aMenuBlock['link'] . '" id="' . $menu . '">'; //$xml .= '<option title="" id="" ></option>'; $xml .= '</menu_block>'; } } $xml .= '</menu_cases>'; print $xml;*/ }
function getChilds($tree, $items, $selfId = 0, $prefix = '') { $prefix .= '--'; foreach ($items as $item) { if ($item['self']->id != $selfId) { $tree[$item['self']->id] = $prefix . ' ' . $item['self']->name; $tree = getChilds($tree, $item['childs'], $selfId, $prefix); } } return $tree; }
function getChilds($foo) { $obj = new organisationseinheit(); $arr = array(); $arr1 = $obj->getDirectChilds($foo); foreach ($arr1 as $value) { $arr[$value] = array(); } foreach ($arr as $val => $k) { $hlp = getChilds($val); $arr[$val] = $hlp; } return $arr; }
function getChilds($node, $root) { $data = array(); $select = Axis::single('cms/category')->select('*'); if ($root) { $select->where('cc.site_id = ?', $node)->where('cc.parent_id is NULL'); } else { $select->where('cc.parent_id = ?', $node); } //get categories foreach ($select->fetchAssoc() as $_category) { $data[] = array('leaf' => false, 'id' => "_" . $_category['id'], 'siteId' => 'null', 'catId' => $_category['id'], 'pageId' => 'null', 'text' => $_category['name'], 'iconCls' => 'icon-folder', 'expanded' => true, 'cls' => $_category['is_active'] ? '' : 'disabledNode', 'children' => getChilds($_category['id'], false)); } //get pages if (!$root) { $pages = Axis::single('cms/page')->select(array('name', 'id', 'is_active'))->join('cms_page_category', 'cp.id = cpc.cms_page_id', 'cms_category_id')->where('cpc.cms_category_id = ?', $node)->fetchAll(); foreach ($pages as $page) { $data[] = array('leaf' => true, 'siteId' => 'null', 'catId' => 'null', 'pageId' => $page['id'], 'text' => $page['name'], 'iconCls' => 'icon-page', 'cls' => $page['is_active'] ? '' : 'disabledNode'); } } return $data; }
function getChilds($foo) { $obj = new organisationseinheit(); $arr = array(); $arr1 = $obj->getDirectChilds($foo); foreach ($arr1 as $value) { if ($daten = getDaten($value)) { $arr[$value]['dat'] = $daten; } } if (!is_array($arr) && !is_object($arr) || count($arr) < 1) { return null; } reset($arr); foreach ($arr as $key => $val) { $arr[$key]['child'] = getChilds($key); } return $arr; }