/** * @author Matthew McNaney <mcnaney at gmail dot com> * @version $Id$ */ function menu_install(&$content) { PHPWS_Core::initModClass('menu', 'Menu_Item.php'); $menu = new Menu_Item(); $menu->title = dgettext('menu', 'Main menu'); $menu->template = 'basic'; $menu->pin_all = 1; $result = $menu->save(); if (PHPWS_Error::isError($result)) { PHPWS_Error::log($result); return false; } else { $content[] = dgettext('menu', 'Default menu created successfully.'); return true; } }
public function testItemConfigOverridesDefaults() { $default_item_config = Menu_Item::get_default_config(); $menu_item = new Menu_Item(['title' => 'test1', 'classes' => ['class1']], $this->_menu); $this->assertEquals('test1', $menu_item->title); $this->assertEquals(['class1'], $menu_item->classes); $this->assertEquals($default_item_config['visible'], $menu_item->visible); }
public function delete($save_links = false) { $db = $this->getDB(); $db->addWhere('id', $this->id); $db->delete(); $db->reset(); $menu = new Menu_Item($this->menu_id); $menu->reorderLinks(); $db->addWhere('parent', $this->id); if ($save_links) { $db->addValue('parent', $this->parent); return $db->update(); } else { return $db->delete(); } }
/** * @modified Verdon Vaillancourt */ public static function siteMap() { if (!isset($_GET['site_map'])) { PHPWS_Core::errorPage('404'); } PHPWS_Core::initModClass('menu', 'Menu_Item.php'); if ($_GET['site_map'] == 'all') { $db = new PHPWS_DB('menus'); $result = $db->getObjects('Menu_Item'); if ($result) { foreach ($result as $menu) { if (empty($menu->title)) { PHPWS_Core::errorPage('404'); } $result = $menu->getLinks(); if (PHPWS_Error::logIfError($result)) { PHPWS_Core::errorPage(); } $content = array(); if (!empty($result)) { Menu::walkLinks($result, $content); } $site['TITLE'] = $menu->getTitle() . ' - ' . dgettext('menu', 'Site map'); $site['CONTENT'] = implode('', $content); $tpl['site-map'][] = $site; } } else { $tpl['TITLE'] = $menu->getTitle() . ' - ' . dgettext('menu', 'Site map'); $tpl['CONTENT'] = dgettext('menu', 'Sorry, no menus have been created'); } } else { $menu = new Menu_Item((int) $_GET['site_map']); if (empty($menu->title)) { PHPWS_Core::errorPage('404'); } $result = $menu->getLinks(); if (PHPWS_Error::isError($result)) { PHPWS_Error::log($result); PHPWS_Core::errorPage(); } $content = array(); if (!empty($result)) { Menu::walkLinks($result, $content); } $tpl['TITLE'] = $menu->getTitle() . ' - ' . dgettext('menu', 'Site map'); $tpl['CONTENT'] = implode('', $content); } Layout::add(PHPWS_Template::process($tpl, 'menu', 'site_map.tpl')); }
private function adminLinks($request) { $menu = new \Menu_Item($request->getVar('menu_id')); $menu->_show_all = true; $menu->template = 'admin'; $data['html'] = $menu->view(true); $data['pin_all'] = $menu->pin_all; echo json_encode($data); }