Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(!function_exists('display_menu_admin')) {
- function display_menu_admin($parent, $level) {
- $ci =& get_instance();
- $ci->load->database();
- $ci->load->model('model_menu');
- $result = $ci->db->query("SELECT a.id, a.label,a.icon_color, a.type, a.link,a.icon, Deriv1.Count FROM `menu` a LEFT OUTER JOIN (SELECT parent, COUNT(*) AS Count FROM `menu` GROUP BY parent) Deriv1 ON a.id = Deriv1.parent WHERE a.menu_type_id = 1 AND a.parent=" . $parent." and active = 1 order by `sort` ASC")->result();
- $ret = '';
- if ($result) {
- if (($level > 1) AND ($parent > 0) ) {
- $ret .= '<ul class="treeview-menu">';
- } else {
- $ret = '';
- }
- foreach ($result as $row) {
- $perms = 'menu_'.strtolower(str_replace(' ', '_', $row->label));
- $links = explode('/', $row->link);
- $segments = array_slice($ci->uri->segment_array(), 0, count($links));
- if (implode('/', $segments) == implode('/', $links)) {
- $active = 'active';
- } else {
- $active = '';
- }
- $link = filter_var($row->link, FILTER_VALIDATE_URL) ? $row->link : base_url($row->link);
- if ($row->type == 'label') {
- if ($ci->aauth->is_allowed($perms)) {
- $ret .= '<li class="header treeview">'._ent($row->label).'</li>';
- }
- } else {
- if ($row->Count > 0) {
- if ($ci->aauth->is_allowed($perms)) {
- $ret .= '<li class="'.$active.' ">
- <a href="'.$link.'">';
- if ($parent) {
- $ret .= '<i class="fa fa-circle-o '._ent($row->icon_color).'"></i> <span>'._ent($row->label).'</span>
- <span class="pull-right-container">
- <i class="fa fa-angle-left pull-right"></i>
- </span>
- </a>';
- } else {
- $ret .= '<i class="fa '._ent($row->icon).' '._ent($row->icon_color).'"></i> <span>'._ent($row->label).'</span>
- <span class="pull-right-container">
- <i class="fa fa-angle-left pull-right"></i>
- </span>
- </a>';
- }
- $ret .= display_menu_admin($row->id, $level + 1);
- $ret .= "</li>";
- }
- } elseif ($row->Count==0) {
- if ($ci->aauth->is_allowed($perms)) {
- $ret .= '<li class="'.$active.' ">
- <a href="'.$link.'">';
- if ($parent) {
- $ret .= '<i class="fa fa-circle-o '._ent($row->icon_color).'"></i> <span>'._ent($row->label).'</span>
- <span class="pull-right-container"></i>
- </span>
- </a>';
- } else {
- $ret .= '<i class="fa '._ent($row->icon).' '._ent($row->icon_color).'"></i> <span>'._ent($row->label).'</span>
- <span class="pull-right-container"></i>
- </span>
- </a>';
- }
- $ret .= "</li>";
- }
- }
- }
- if ($row->id == 14) {
- $ret .= cicool()->getSidebar();
- }
- }
- if ($level != 1) {
- $ret .= '</ul>';
- }
- }
- return $ret;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement