function build_menu_from_form(&$elements_ids, $level = 0) { $menu = null; $menu_element_id = $elements_ids['id']; $menu_name = retrieve(POST, 'menu_element_' . $menu_element_id . '_name', '', TSTRING_UNCHANGE); $menu_url = retrieve(POST, 'menu_element_' . $menu_element_id . '_url', ''); $menu_image = retrieve(POST, 'menu_element_' . $menu_element_id . '_image', ''); $array_size = count($elements_ids); if ($array_size == 1 && $level > 0) { $menu = new LinksMenuLink($menu_name, $menu_url, $menu_image); } else { $menu = new LinksMenu($menu_name, $menu_url, $menu_image); unset($elements_ids['id']); $array_size = count($elements_ids); for ($i = 0; $i < $array_size; $i++) { $menu->add(build_menu_from_form($elements_ids[$i], $level + 1)); } } $menu->set_auth(Authorizations::build_auth_array_from_form(AUTH_MENUS, 'menu_element_' . $menu_element_id . '_auth')); return $menu; }
function build_menu_from_form($elements_ids, $level = 0) { $menu = null; $menu_element_id = $elements_ids['id']; $menu_name = retrieve(POST, 'menu_element_' . $menu_element_id . '_name', '', TSTRING_UNCHANGE); $menu_url = retrieve(POST, 'menu_element_' . $menu_element_id . '_url', ''); $menu_image = retrieve(POST, 'menu_element_' . $menu_element_id . '_image', ''); $array_size = count($elements_ids); if ($array_size == 1 && $level > 0) { // If it's a menu, there's only one element; $menu = new LinksMenuLink($menu_name, $menu_url, $menu_image); } else { $menu = new LinksMenu($menu_name, $menu_url, $menu_image); // We unset the id key of the array unset($elements_ids['id']); $array_size = count($elements_ids); for ($i = 0; $i < $array_size; $i++) { // We build all its children and add it to its father $menu->add(build_menu_from_form($elements_ids[$i], $level + 1)); } } $menu->set_auth(Authorizations::build_auth_array_from_form(Menu::MENU_AUTH_BIT, 'menu_element_' . $menu_element_id . '_auth')); return $menu; }
function website_modules($menu_type = VERTICAL_MENU) { import('modules/modules_discovery_service'); $modules_menu = new LinksMenu('PHPBoost', '/', '', $menu_type); $modules_discovery_service = new ModulesDiscoveryService(); $modules = $modules_discovery_service->get_all_modules(); $sorted_modules = array(); foreach ($modules as $module) { $sorted_modules[$module->get_name()] = $module; } ksort($sorted_modules); foreach ($sorted_modules as $module) { $infos = $module->get_infos(); if (!empty($infos['infos']) && !empty($infos['infos']['starteable_page'])) { $img = ''; $img_url = PATH_TO_ROOT . '/' . $module->get_id() . '/' . $module->get_id(); import('io/filesystem/file'); foreach (array('_mini.png', '_mini.gif', '_mini.jpg') as $extension) { $file = new File($img_url . $extension); if ($file->exists()) { $img = '/' . $module->get_id() . '/' . $file->get_name(); break; } } $modules_menu->add(new LinksMenuLink($module->get_name(), '/' . $module->get_id() . '/' . $infos['infos']['starteable_page'], $img)); } } return $modules_menu; }
/** * @desc Return a menu with links to modules * @param int $menu_type the menu type * @return LinksMenu the menu with links to modules */ public static function website_modules($menu_type = LinksMenu::AUTOMATIC_MENU) { $modules_menu = new LinksMenu('PHPBoost', '/', '', $menu_type); $modules = ModulesManager::get_activated_modules_map_sorted_by_localized_name(); foreach ($modules as $module) { $configuration = $module->get_configuration(); $start_page = $configuration->get_home_page(); if (!empty($start_page)) { $img = ''; $img_url = PATH_TO_ROOT . '/' . $module->get_id() . '/' . $module->get_id(); foreach (array('_mini.png', '_mini.gif', '_mini.jpg') as $extension) { $file = new File($img_url . $extension); if ($file->exists()) { $img = '/' . $module->get_id() . '/' . $file->get_name(); break; } } $modules_menu->add(new LinksMenuLink($configuration->get_name(), '/' . $module->get_id() . '/', $img)); } } return $modules_menu; }