You are here

function _bigmenu_overview_tree_form in Big Menu 6

Same name and namespace in other branches
  1. 7 bigmenu.admin.inc \_bigmenu_overview_tree_form()

Recursive helper function for menu_overview_form().

Copied from core, and modified to limit recursion

See also

_menu_overview_tree_form()

2 calls to _bigmenu_overview_tree_form()
bigmenu_overview_form in ./bigmenu.admin.inc
Form for editing an entire menu tree at once.
bigmenu_slice_form in ./bigmenu.admin.inc
Form for editing the immediate children of the given menu item id

File

./bigmenu.admin.inc, line 166
Administrative page callbacks for bigmenu module.

Code

function _bigmenu_overview_tree_form($tree, $depth = 0) {
  static $form = array(
    '#tree' => TRUE,
  );
  foreach ($tree as $data) {
    $title = '';
    $item = $data['link'];

    // Don't show callbacks; these have $item['hidden'] < 0.
    if ($item && $item['hidden'] >= 0) {
      $mlid = 'mlid:' . $item['mlid'];
      $form[$mlid]['#item'] = $item;
      $form[$mlid]['#attributes'] = $item['hidden'] ? array(
        'class' => 'menu-disabled',
      ) : array(
        'class' => 'menu-enabled',
      );
      $form[$mlid]['title']['#value'] = l($item['title'], $item['href'], $item['localized_options']) . ($item['hidden'] ? ' (' . t('disabled') . ')' : '');
      $form[$mlid]['hidden'] = array(
        '#type' => 'checkbox',
        '#default_value' => !$item['hidden'],
      );
      $form[$mlid]['expanded'] = array(
        '#type' => 'checkbox',
        '#default_value' => $item['expanded'],
      );
      $form[$mlid]['weight'] = array(
        '#type' => 'weight',
        '#delta' => 50,
        '#default_value' => isset($form_state[$mlid]['weight']) ? $form_state[$mlid]['weight'] : $item['weight'],
      );
      $form[$mlid]['mlid'] = array(
        '#type' => 'hidden',
        #'#type' => 'textfield', '#size' => 5,
        '#value' => $item['mlid'],
      );
      $form[$mlid]['plid'] = array(
        '#type' => 'textfield',
        '#default_value' => isset($form_state[$mlid]['plid']) ? $form_state[$mlid]['plid'] : $item['plid'],
        '#size' => 6,
      );

      // Build a list of operations.
      $operations = array();
      $operations['edit'] = l(t('edit'), 'admin/build/menu/item/' . $item['mlid'] . '/edit');

      // Only items created by the menu module can be deleted.
      if ($item['module'] == 'menu' || $item['updated'] == 1) {
        $operations['delete'] = l(t('delete'), 'admin/build/menu/item/' . $item['mlid'] . '/delete');
      }
      elseif ($item['module'] == 'system' && $item['customized']) {
        $operations['reset'] = l(t('reset'), 'admin/build/menu/item/' . $item['mlid'] . '/reset');
      }
      $form[$mlid]['operations'] = array();
      foreach ($operations as $op => $value) {
        $form[$mlid]['operations'][$op] = array(
          '#value' => $value,
        );
      }
    }
    if ($data['below']) {
      if ($depth > 0) {
        _bigmenu_overview_tree_form($data['below'], $depth - 1);
      }
      else {

        // 'below' contains both immediate children and something else
        $strings = array(
          '!show_children' => t('Show children'),
          '%count' => count($data['below']),
          '!tooltip' => t('Click to expand and show child items'),
        );
        $text = strtr('<span class="bigmenu-toggle">+</span> <span class="count" title="!tooltip"><span class="hide-show">!show_children</span> (%count)</span>', $strings);
        $indicator = l($text, "admin/build/bigmenu-customize/{$item['menu_name']}/subform/{$item['mlid']}", array(
          'html' => TRUE,
          attributes => array(
            'class' => 'bigmenu-childindictor',
          ),
        ));
        $form[$mlid]['title']['#value'] .= '<br/>' . $indicator;
        $form[$mlid]['#attributes']['class'] = 'bigmenu-collapsed';
      }
    }
  }
  return $form;
}