You are here

function menu_import_preview in Menu Export/Import 7

Renders the menu for preview.

Parameters

$menu: The whole menu structure.

$options: Array of import options.

Return value

Array understandable by Drupal's theme engine.

1 call to menu_import_preview()
menu_import_form_step2 in includes/admin.inc
Step 2.

File

includes/admin.inc, line 369
Administrative page callbacks for menu_import module.

Code

function menu_import_preview($menu, array $options) {
  $menu_name = $menu[0]['menu_name'];
  $menus = menu_get_menus();
  $descriptions = array();
  if ($options['remove_menu_items']) {
    $descriptions[] = t('Current menu items will be removed');
  }
  $descriptions[] = t('Import @count items into "@menu_title" menu (@menu_name)', array(
    '@count' => count($menu) - 3,
    // Minus errors/warnings and root item.
    '@menu_title' => $menus[$menu_name],
    '@menu_name' => $menu_name,
  ));
  if ($options['link_to_content']) {
    $descriptions[] = t('Link to existing content if found');
  }
  if ($options['create_content']) {
    $descriptions[] = t('Initial content of type "@type" will be created', array(
      '@type' => $options['node_type'],
    ));
    $author = user_load($options['node_author']);
    $descriptions[] = t('Content author: @author', array(
      '@author' => $author->name,
    ));
    $status = $options['node_status'] ? t('published') : t('not published');
    $descriptions[] = t('Content status: @status', array(
      '@status' => $status,
    ));
    if ($options['node_alias']) {
      $descriptions[] = t('Path aliases will be created.');
    }
  }
  $descriptions[] = t('Language: @lang', array(
    '@lang' => $options['language'] == LANGUAGE_NONE ? t('not defined') : $options['language'],
  ));
  $rows = array();
  $depth = 0;
  foreach ($menu[0]['children'] as $index) {
    $new_rows = _menu_import_preview_row_recurse($menu, $index, $depth, $options);
    foreach ($new_rows as $row) {
      $rows[] = $row;
    }
  }
  $build['options'] = array(
    '#theme' => 'item_list',
    '#items' => $descriptions,
    '#title' => t('Import options'),
    '#type' => 'ul',
  );
  $header = array(
    t('Menu Item'),
    t('Content exists'),
    t('Path'),
    t('System path'),
  );
  $header[] = t('Weight');
  $build['menu'] = array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#caption' => t('Menu preview'),
  );
  return $build;
}