From 5b8150bd15383d1b873a6587441a9abfaec61e5c Mon Sep 17 00:00:00 2001 From: Rifat Wahid Alif Date: Thu, 9 Feb 2017 16:03:59 +0600 Subject: [PATCH] Menu improved --- plugins/system/core/classes/menu.php | 87 ++++++++++++++++------------ 1 file changed, 49 insertions(+), 38 deletions(-) diff --git a/plugins/system/core/classes/menu.php b/plugins/system/core/classes/menu.php index 2201a99..64eedde 100644 --- a/plugins/system/core/classes/menu.php +++ b/plugins/system/core/classes/menu.php @@ -250,31 +250,37 @@ private function dropdown($item) { $dropdown_style .= 'left: -'. $dropdown_width .'px;'; } - $this->menu .= '
'; - $this->menu .= '
'; - $this->navigation($item, $firstitem, 0, 'sp-dropdown-items'); + if (count($items)) { + if ((count($this->children[$item->id]) == 1 && $this->children[$item->id][0]->params->get('menu_show') !== 0) || count($this->children[$item->id]) > 1) { - // only module exist - if (count($item->params->get('menulayout')) == 1) { - $mega_json = $item->params->get('menulayout'); - $mega = json_decode($mega_json); - $layout = $mega->layout; + $this->menu .= '
'; + $this->menu .= '
'; + $this->navigation($item, $firstitem, 0, 'sp-dropdown-items'); - $layout = $layout[0]; - $col = $layout->attr[0]; - $mod_ids = ($col->moduleId)? explode(',', $col->moduleId):array(); + // only module exist + if (count($item->params->get('menulayout')) == 1) { + $mega_json = $item->params->get('menulayout'); + $mega = json_decode($mega_json); + $layout = $mega->layout; - if (count($mod_ids)) - { - foreach ($mod_ids as $mod_id) - { - $this->menu .= $this->load_module($mod_id); + $layout = $layout[0]; + $col = $layout->attr[0]; + $mod_ids = ($col->moduleId)? explode(',', $col->moduleId):array(); + + if (count($mod_ids)) + { + foreach ($mod_ids as $mod_id) + { + $this->menu .= $this->load_module($mod_id); + } + } } - } - } - $this->menu .= '
'; - $this->menu .= '
'; + $this->menu .= '
'; + $this->menu .= '
'; + } + } + } private function mega($item) @@ -299,8 +305,7 @@ private function mega($item) $this->menu .='
'; $this->menu .='
'; - foreach ($layout as $row) - { + foreach ($layout as $row) { $this->menu .='
'; foreach ($row->attr as $col) @@ -381,7 +386,9 @@ private function start_el( $args = array() ) $class = 'sp-menu-item'; if( !empty( $this->children[$item->id] ) ) { - $class .= ' sp-has-child'; + if ((count($this->children[$item->id]) == 1 && $this->children[$item->id][0]->params->get('menu_show') !== 0) || count($this->children[$item->id]) > 1) { + $class .= ' sp-has-child'; + } } else if( isset( $item->megamenu ) && ( $item->megamenu ) ) { $class .= ' sp-has-child'; } @@ -416,8 +423,8 @@ private function item($item, $extra_class=''){ $class = $extra_class; $title = $item->anchor_title ? 'title="' . $item->anchor_title . '" ' : ''; - $class .= ($item->anchor_css && $class) ? ' ' . $item->anchor_css : $item->anchor_css; - $class = ($class) ? 'class="' . $class . '"' : ''; + $item->anchor_css = ($item->anchor_css) ? ' ' . $item->anchor_css : ''; + $class = ($class) ? 'class="' . $class . $item->anchor_css . '" ' : ''; if ($item->menu_image) { @@ -449,21 +456,25 @@ private function item($item, $extra_class=''){ $flink = JFilterOutput::ampReplace(htmlspecialchars($flink)); $output = ''; - $options =''; if ($item->params->get('menu_show', 1) != 0) { - switch ($item->browserNav) { - default: - case 0: - $output .= ''.$linktitle.''; - break; - case 1: - $output .= ''. $linktitle .''; - break; - case 2: - $options .= 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,' . $item->params->get('window_open'); - $output .= ''. $linktitle .''; - break; + if ($item->type == 'separator' || $item->type == 'heading') { + $output .= '' . $linktitle . ''; + } else{ + switch ($item->browserNav) { + default: + case 0: + $output .= ''.$linktitle.''; + break; + case 1: + $output .= ''. $linktitle .''; + break; + case 2: + $options .= 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,' . $item->params->get('window_open'); + $output .= ''. $linktitle .''; + break; + } } + } return $output;