function _menu_import_export_recurse in Menu Export/Import 6
Same name and namespace in other branches
- 7 includes/export.inc \_menu_import_export_recurse()
Generates export file recursively.
1 call to _menu_import_export_recurse()
- menu_import_export_menu in includes/
export.inc - Exports menu to a string.
File
- includes/
export.inc, line 123 - Export functions for menu_import module.
Code
function _menu_import_export_recurse($tree, $level, &$output) {
global $me_options;
foreach ($tree as $data) {
$link = $data['link'];
$indentation = str_repeat('-', $level);
$details = array();
// Use alias if exists.
$alias = drupal_lookup_path('alias', $link['link_path']);
$details['url'] = $alias ? $alias : $link['link_path'];
if (!empty($link['options']['attributes']['title'])) {
$details['description'] = $link['options']['attributes']['title'];
}
if ($link['hidden']) {
$details['hidden'] = TRUE;
}
if ($link['expanded']) {
$details['expanded'] = TRUE;
}
if (!empty($me_options['export_language']) && isset($link['options']['langcode'])) {
// Language is stored in 'options'.
$details['lang'] = $link['options']['langcode'];
}
// Export options.
if ($me_options['options']) {
// Already exported as description.
if (!empty($details['description'])) {
unset($link['options']['attributes']['title']);
}
if (empty($link['options']['attributes'])) {
unset($link['options']['attributes']);
}
if (!empty($link['options'])) {
$details['options'] = $link['options'];
}
}
// Allow other modules to alter the exported data.
drupal_alter('menu_export', $link, $details);
$output .= $indentation . $link['link_title'] . ' ' . json_encode($details) . $me_options['line_ending'];
if ($data['below']) {
_menu_import_export_recurse($data['below'], $level + 1, $output);
}
}
}