function _menu_overview_tree_form

Recursive helper function for menu_overview_form().

Parameters

$tree: The menu_tree retrieved by menu_tree_data.

$delta: The number of items to use in the menu weight selector. Defaults to 50.

1 call to _menu_overview_tree_form()
menu_overview_form in modules/menu/menu.admin.inc
Form for editing an entire menu tree at once.

File

modules/menu/menu.admin.inc, line 98

Code

function _menu_overview_tree_form($tree, $delta = 50) {
    $form =& drupal_static(__FUNCTION__, 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' => array(
                    'menu-disabled',
                ),
            ) : array(
                'class' => array(
                    'menu-enabled',
                ),
            );
            $form[$mlid]['title']['#markup'] = l($item['title'], $item['href'], $item['localized_options']);
            menu_add_link_labels($form[$mlid]['title']['#markup'], $item);
            $form[$mlid]['hidden'] = array(
                '#type' => 'checkbox',
                '#title' => t('Enable @title menu link', array(
                    '@title' => $item['title'],
                )),
                '#title_display' => 'invisible',
                '#default_value' => !$item['hidden'],
            );
            $form[$mlid]['weight'] = array(
                '#type' => 'weight',
                '#delta' => $delta,
                '#default_value' => $item['weight'],
                '#title_display' => 'invisible',
                '#title' => t('Weight for @title', array(
                    '@title' => $item['title'],
                )),
            );
            $form[$mlid]['mlid'] = array(
                '#type' => 'hidden',
                '#value' => $item['mlid'],
            );
            $form[$mlid]['plid'] = array(
                '#type' => 'hidden',
                '#default_value' => $item['plid'],
            );
            // Build a list of operations.
            $operations = array();
            $operations['edit'] = array(
                '#type' => 'link',
                '#title' => t('edit'),
                '#href' => 'admin/structure/menu/item/' . $item['mlid'] . '/edit',
            );
            // Only items created by the menu module can be deleted.
            if ($item['module'] == 'menu' || $item['updated'] == 1) {
                $operations['delete'] = array(
                    '#type' => 'link',
                    '#title' => t('delete'),
                    '#href' => 'admin/structure/menu/item/' . $item['mlid'] . '/delete',
                );
            }
            elseif ($item['module'] == 'system' && $item['customized']) {
                $operations['reset'] = array(
                    '#type' => 'link',
                    '#title' => t('reset'),
                    '#href' => 'admin/structure/menu/item/' . $item['mlid'] . '/reset',
                );
            }
            $form[$mlid]['operations'] = $operations;
        }
        if ($data['below']) {
            _menu_overview_tree_form($data['below'], $delta);
        }
    }
    return $form;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.