1 menu.theme.inc theme_menu_overview_form($variables)

Returns HTML for the menu overview form into a table.

Parameters

$variables: An associative array containing:

  • form: A render element representing the form.

Related topics

File

core/modules/menu/menu.theme.inc, line 38
Theme functions for the Menu module.

Code

function theme_menu_overview_form($variables) {
  $form = $variables['form'];

  $output = '';

  $form['langcode']['#field_suffix'] = backdrop_render($form['langcode_filter']);
  $output .= backdrop_render($form['langcode']);

  backdrop_add_tabledrag('menu-overview', 'match', 'parent', 'menu-plid', 'menu-plid', 'menu-mlid', TRUE, MENU_MAX_DEPTH - 1);
  backdrop_add_tabledrag('menu-overview', 'order', 'sibling', 'menu-weight');

  $header = array();
  $header[] = t('Menu link');
  if (module_exists('language')) {
    $header[] = t('Language');
  }
  $header[] = array('data' => t('Enabled'), 'class' => array('checkbox'));
  $header[] = t('Weight');
  $header[] = t('Operations');

  $rows = array();
  foreach (element_children($form) as $mlid) {
    if (isset($form[$mlid]['hidden'])) {
      $element = &$form[$mlid];

      // Add special classes to be used for tabledrag.js.
      $element['plid']['#attributes']['class'] = array('menu-plid');
      $element['mlid']['#attributes']['class'] = array('menu-mlid');
      $element['weight']['#attributes']['class'] = array('menu-weight');

      // Change the parent field to a hidden. This allows any value but hides the field.
      $element['plid']['#type'] = 'hidden';

      $row = array();
      $row[] = theme('indentation', array('size' => $element['#item']['depth'] - 1)) . backdrop_render($element['title']);
      if (module_exists('language')) {
        $row[] = backdrop_render($element['langcode']);
      }
      $row[] = array('data' => backdrop_render($element['hidden']), 'class' => array('checkbox', 'menu-enabled'));
      $row[] = backdrop_render($element['weight']) . backdrop_render($element['plid']) . backdrop_render($element['mlid']);
      $row[] = backdrop_render($element['operations']);

      $row = array_merge(array('data' => $row), $element['#attributes']);
      $row['class'][] = 'draggable';
      $rows[] = $row;
    }
  }

  $output .= theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => array('id' => 'menu-overview'),
    'empty' => t('There are no menu links yet. <a href="@link">Add link</a>.', array('@link' => url('admin/structure/menu/manage/' . $form['#menu']['menu_name'] . '/add'))),
  ));
  $output .= backdrop_render_children($form);
  return $output;
}