public function menu_items() { // Получаем массив с корневой директорией $items = parent::menu_items(); // Выделяем жирным корневую директорию - если активна она if ($this->cur_category->id == $this->root->id) { $items['items'][$this->root->scope - 1]['active_root'] = true; } // В зависимости от уровня текущей категории - берем нужных детей // Если выбра подпункт меню, то в качестве детей берем детей корновой категории if (empty($this->childrens_root)) { $childrens =& $this->childrens; } else { $childrens =& $this->childrens_root; } // Добавляем категории первого уровня for ($i = 0; $i < count($childrens); $i++) { // Делаем маркер корневой категории открытым $items['items'][$this->root->scope - 1]['open_root'] = true; // Создаем пункт меню $items['items'][$this->root->scope - 1]['sub_items'][$i]['name'] = $childrens[$i]->name; $items['items'][$this->root->scope - 1]['sub_items'][$i]['url'] = '/admin/catalog/' . (!empty($this->is_category) ? 'open' : 'edit') . '/' . $childrens[$i]->id; $items['items'][$this->root->scope - 1]['sub_items'][$i]['hav_sub_items2'] = $this->get_have_childrens($childrens[$i]->id); // Выделяем активный элемент if ($this->cur_category->id == $childrens[$i]->id) { $items['items'][$this->root->scope - 1]['sub_items'][$i]['active'] = true; } // Если выбрана текущая категория первого уровня или // подпункт текущей категории - регистрируем подкатегории if ($this->cur_category->id == $childrens[$i]->id or $this->parent->id == $childrens[$i]->id) { // Если это подпункт категории - то берем детей его родителя if ($this->parent->id == $childrens[$i]->id) { $childrens_parent = $this->parent->children->as_array(); // Сортируем массив детей родителя usort($childrens_parent, array('View_Layout', 'sort_func_ord')); } else { $childrens_parent =& $this->childrens; } // Проходим по всем детям текущей категории for ($r = 0; $r < count($childrens_parent); $r++) { // Делаем маркер категории первого уровня открытым $items['items'][$this->root->scope - 1]['sub_items'][$i]['open'] = true; // Если открыта последняя категория первого уровня // то для ее подкатегорий надо установить класс last - иначе остается линия левая if ($i == count($childrens) - 1) { $items['items'][$this->root->scope - 1]['sub_items'][$i]['sub_items2'][$r]['last'] = true; } // Создаем пункт меню $items['items'][$this->root->scope - 1]['sub_items'][$i]['sub_items2'][$r]['name'] = $childrens_parent[$r]->name; $items['items'][$this->root->scope - 1]['sub_items'][$i]['sub_items2'][$r]['url'] = '/admin/catalog/edit/' . $childrens_parent[$r]->id; // Выделяем активный элемент if ($this->cur_category->id == $childrens_parent[$r]->id) { $items['items'][$this->root->scope - 1]['sub_items'][$i]['sub_items2'][$r]['active2'] = true; } } } } return $items; }
public function menu_items($my = false) { $items = parent::menu_items($my); $items['items'][1]['active_root'] = true; return $items; }