dhtmlx menus
来源:互联网 发布:mac rar解压软件免费 编辑:程序博客网 时间:2024/05/20 03:45
dhtmlx attachEvent("onClick",openlink) function , add new Attribute to a dom
<?php$userinfo = json_decode(VSession::get("user_info"), true);Yii::app()->params['username'] = $userinfo['name']; // set name to yii global variables?><style type='text/css'>.group_label{ clear: both; display: block; font-weight: normal; line-height: 20px; padding: 3px 10px; white-space: nowrap; font-weight:bold;}</style><div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <img src="<?php echo $baseUrl; ?>/img/global_advantest_logo.gif" class="brand pull-left" alt="Advantest" > <div id="nav_menu_id" class="nav-collapse" style="float: left; margin-left: 150px;"> <?php /** * author cherry * desc get all menus from database. * date : 2013/13/06 */ function getMenus() { $menu=array(); $sql = "SELECT auto_id as id,label,link,parent,roles FROM etlt_Menus"; $conn = Yii::app()->db; $rows = $conn->createCommand($sql)->queryAll(); //Yii::app()->params['cmenus'] = $rows; } function getMenuParent($id) { $cmenus = Yii::app()->params['cmenus']; $parent_menus = array(); foreach ($cmenus as $key => $v) { if ($v["parent"] == $id) { $parent_menus[] = $v; } } return $parent_menus; } /** * * dynamic build menus * @param <type> $menuId * @param <type> $order * @return string */ function buildMenu($menuId, $order) { $menus = getMenuParent($menuId); $order++; $html = ""; if ($menus) { if ($order == 1) { $html .="<ul id='yw0' class='pull-right nav' style='float: left;'>"; } else { $html .="<ul class='dropdown-menu'>"; } $role = json_decode(VSession::get("user_info"),TRUE); foreach ($menus as $menu) { if ($menu["roles"]=="*" || stripos($menu["roles"],$role["type"])!==false) { if ($menu["link"] == "#") { $html.="<li class='dropdown item-test' tabindex='-1' >"; $html.="<a href='#' data-toggle='dropdown' class='dropdown-toggle'>" . $menu["label"] . "<span class='caret'></span></a>"; } else { $html.="<li class='item-test'>"; $m_label = preg_replace("/(\(user\))/i", "(" . Yii::app()->params['username'] . ")", $menu["label"]); if ($menu["link"] != "") { $m_link = Yii::app()->createUrl($menu["link"]); $html.="<a href='" . $m_link . "'>" . $m_label . "</a>"; } else { $html.= "<label class='group_label'>".$m_label."</label>"; } } $html.= buildMenu($menu['id'], $order); $html.="</li>"; } } $html.="</ul>"; } return $html; } //getMenus(); //echo buildMenu(0, 0);function getparentmenu(){/*author : mort */ $sql = "SELECT auto_id as id,label,link,parent,roles FROM etlt_Menus WHERE parent=0"; $conn = Yii::app()->db; $rows = $conn->createCommand($sql)->queryAll(); return $rows;}function getsubmenubyid($id){ $sql = "SELECT auto_id as id,label,link,parent,roles FROM etlt_Menus WHERE parent="."'".$id."'"; $conn = Yii::app()->db; $rows = $conn->createCommand($sql)->queryAll(); return $rows;} ?> </div> </div><!-- container --> </div><!-- navbar-inner --></div><!-- subnav --><div id="menuData" style="display:none"> <?php $parentmenu=getparentmenu(); foreach($parentmenu as $k => $v){$html.='<div id='.'"'.$v['id'].'"'.' text='.'"'.$v['label'].'"'.'link='.'"'.$v['link'].'"'.'>';$submenus_by_id=getsubmenubyid($v["id"]); foreach($submenus_by_id as $s_k=>$s_v){$html.='<div id='.'"'.$s_v["id"].'"'.' text='.'"'.$s_v["label"].'"'.'link='.'"'.$s_v['link'].'"'.'></div>';}$html.="</div>";}echo $html;?></div><div style="display:none"><?php echo $html;?></div><script>document.getElementByTagName("div").setAttribute("link");var nav_Menu;function initMenu(){nav_Menu=new dhtmlXMenuObject("nav_menu_id");nav_Menu.setIconsPath("../../img/icons");nav_Menu.loadFromHTML("menuData",true);nav_Menu.attachEvent("onClick",openlink);}function openlink(id){var menu_clicked_href=document.getElementById(id).attributes["link"].value;window.location.href="<?php echo Yii::app()->request->baseUrl;?>"+"/"+menu_clicked_href;}</script><script>initMenu();</script>
0 0
- dhtmlx menus
- Dhtmlx
- Menus
- menus
- DHTMLX TabBar
- DHTMLX 简介
- dhtmlx touch
- dhtmlx使用
- 讲一讲dhtmlx
- ajax dhtmlx
- dhtmlx-calendar
- DHTMLX-Vault
- DHTMLX-Grid
- DHTMLX-Tree
- DHTMLX-Form
- DHTMLX-Tabbar
- DHTMLX-Windows
- Context Menus
- 黑马程序员-C语言学习日记一之基本运算符学习小结
- Oracle VM VirtualBox上安装ubuntu
- eric6 安装试用
- TP-LINK 703N无线路由器开启IPV6功能
- Python2.5-原理之模块
- dhtmlx menus
- 程序员必读书籍及导读指南
- Linux修改ip ,网关
- 源码编译安装MySQL-5.0.84
- C04结构体
- android Intent.Action 使用笔记
- Objective-C - 类方法与对象方法
- android eclipse 工具和环境(简单)
- [BZOJ1798]AHOI2009 维护序列|线段树|splay