public static function asd_menu($params) { $data = array('menu' => array('class' => 'menu', 'parent' => 'parent', 'active' => 'active', 'depth' => 0, 'hidechild' => 0), 'icon' => array('width' => 50, 'height' => 50, 'text' => false, 'empty' => false, 'enable' => false)); if (!empty($params['name'])) { $page = \Ip\Internal\Pages\Model::getPageByAlias(ipContent()->getCurrentLanguage()->getCode(), $params['name']); $data['menu']['name'] = $page['id']; } elseif (!empty($params['id'])) { $data['menu']['name'] = $params['id']; } if (!empty($params['class'])) { $data['menu']['class'] = $params['class']; } if (!empty($params['active'])) { $data['menu']['active'] = $params['active']; } if (!empty($params['parent'])) { $data['menu']['parent'] = $params['parent']; } if (!empty($params['depth'])) { $data['menu']['depth'] = $params['depth']; } if (!empty($params['nochild'])) { $data['menu']['nochild'] = $params['nochild']; } if (!empty($params['icon'])) { $data['icon']['enable'] = true; if (!empty($params['icon']['width'])) { $data['icon']['width'] = $params['icon']['width']; } if (!empty($params['icon']['height'])) { $data['icon']['height'] = $params['icon']['height']; } if (!empty($params['icon']['text'])) { $data['icon']['text'] = $params['icon']['text']; } if (!empty($params['icon']['empty'])) { $data['icon']['empty'] = $params['icon']['empty']; } } echo ipView('Widget/Menu/skin/default.php', array('data' => $data))->render(); }
public function getPageTree() { $language = ipContent()->getCurrentLanguage(); $sitemap = array(array('text' => $language->getAbbreviation(), 'type' => 'language', 'icon' => 'fa fa-flag-o', 'state' => array('opened' => true), 'children' => array())); $menuList = \Ip\Internal\Pages\Model::getMenuList($language->getCode()); foreach ($menuList as $menu) { $page = ipPage($menu['id']); $children = array('text' => $menu['title'], 'icon' => 'fa fa-folder-o', 'li_attr' => (object) array('data-url' => $page->getLink()), 'children' => array()); foreach ($page->getChildren() as $child) { $children['children'][] = $this->_addPageToTree($child); } $sitemap[0]['children'][] = $children; } $data = array('status' => 'success', 'sitemap' => $sitemap); return new \Ip\Response\Json($data); }