function menu_links_features_export_options in Features 6
Same name and namespace in other branches
- 7.2 includes/features.menu.inc \menu_links_features_export_options()
- 7 includes/features.menu.inc \menu_links_features_export_options()
Implementation of hook_features_export_options().
File
- includes/
features.menu.inc, line 130
Code
function menu_links_features_export_options() {
// We can't use the menu_tree_all_data function as it statically caches it's menu items
// so if something calls the function before now without $menu_admin set to true we
// won't see all the links. Instead we reproduce the essential parts of the
// function here.
$menu_links = array();
foreach (array_reverse(menu_get_menus()) as $menu_name => $menu_title) {
$data = array();
$cid = 'links:' . $menu_name . ':all-cid:0';
$cache = cache_get($cid, 'cache_menu');
if ($cache && isset($cache->data)) {
// If the cache entry exists, it will just be the cid for the actual data.
// This avoids duplication of large amounts of data.
$cache = cache_get($cache->data, 'cache_menu');
if ($cache && isset($cache->data)) {
$data = $cache->data;
}
}
else {
$data['tree'] = menu_tree_data(db_query("\n SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.*\n FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path\n WHERE ml.menu_name = '%s'\n ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC", $menu_name));
$data['node_links'] = array();
menu_tree_collect_node_links($data['tree'], $data['node_links']);
// May as well cache the data, if it is not already in the cache.
$tree_cid = _menu_tree_cid($menu_name, $data);
if (!cache_get($tree_cid, 'cache_menu')) {
cache_set($tree_cid, $data, 'cache_menu');
}
// Cache the cid of the (shared) data using the menu and item-specific cid.
cache_set($cid, $tree_cid, 'cache_menu');
}
$GLOBALS['menu_admin'] = TRUE;
menu_tree_check_access($data['tree'], $data['node_links']);
$GLOBALS['menu_admin'] = FALSE;
_menu_links_features_export_options_recurse($data['tree'], $menu_name, '--', $menu_links);
}
return $menu_links;
}