} break; default: if (!empty($move)) { // Move a Menu MenuService::move($menu, $move); } break; } MenuService::generate_cache(); AppContext::get_response()->redirect('menus.php' . ($action != 'delete' ? '#m' . $id : '')); } // Try to find out new mini-modules and delete old ones MenuService::update_mini_modules_list(false); // Retrieves all the menu $menus_blocks = MenuService::get_menus_map(); function get_block($position) { $blocks = array(Menu::BLOCK_POSITION__HEADER => 'mod_header', Menu::BLOCK_POSITION__SUB_HEADER => 'mod_subheader', Menu::BLOCK_POSITION__TOP_CENTRAL => 'mod_topcentral', Menu::BLOCK_POSITION__NOT_ENABLED => 'mod_central', Menu::BLOCK_POSITION__BOTTOM_CENTRAL => 'mod_bottomcentral', Menu::BLOCK_POSITION__TOP_FOOTER => 'mod_topfooter', Menu::BLOCK_POSITION__FOOTER => 'mod_footer', Menu::BLOCK_POSITION__LEFT => 'mod_left', Menu::BLOCK_POSITION__RIGHT => 'mod_right'); return $blocks[$position]; } function save_position($block_position) { $menus = MenuService::get_menu_list(); $menus_tree = json_decode(TextHelper::html_entity_decode(AppContext::get_request()->get_value('menu_tree_' . get_block($block_position)))); foreach ($menus_tree as $position => $tree) { $id = $tree->id; if (array_key_exists($id, $menus)) { $menu = $menus[$id]; $menu->set_block_position($position + 1); MenuService::move($menu, $block_position, $menu->get_block_position());
static function generate_cache($return_string = false) { $cache_str = '$MENUS = array();'; $cache_str .= '$MENUS[BLOCK_POSITION__HEADER] = \'\';'; $cache_str .= '$MENUS[BLOCK_POSITION__SUB_HEADER] = \'\';'; $cache_str .= '$MENUS[BLOCK_POSITION__TOP_CENTRAL] = \'\';'; $cache_str .= '$MENUS[BLOCK_POSITION__BOTTOM_CENTRAL] = \'\';'; $cache_str .= '$MENUS[BLOCK_POSITION__TOP_FOOTER] = \'\';'; $cache_str .= '$MENUS[BLOCK_POSITION__FOOTER] = \'\';'; $cache_str .= '$MENUS[BLOCK_POSITION__LEFT] = \'\';'; $cache_str .= '$MENUS[BLOCK_POSITION__RIGHT] = \'\';'; $cache_str .= 'global $User;' . "\n"; $menus_map = MenuService::get_menus_map(); foreach ($menus_map as $block => $block_menus) { if ($block != BLOCK_POSITION__NOT_ENABLED) { foreach ($block_menus as $menu) { if ($menu->is_enabled()) { $cache_str .= '$__menu=\'' . $menu->cache_export() . '\';' . "\n"; $cache_str .= '$MENUS[' . $menu->get_block() . '].=$__menu;' . "\n"; } } } } $cache_str = preg_replace(array('`\\t*`', '`\\s*\\n\\s*\\n\\s*`', '`[ ]{2,}`', '`>\\s`', '`\\n `', '`\'\\.\'`', '`\\$__menu\\.=\'\';`'), array('', "\n", ' ', '> ', "\n", '', ''), $cache_str); if ($return_string) { return $cache_str; } Cache::write('menus', $cache_str); return ''; }