You are here

function og_menu_edit_item_form in Organic Groups Menu (OG Menu) 7.3

Same name and namespace in other branches
  1. 6.2 og_menu.module \og_menu_edit_item_form()
  2. 6 og_menu.module \og_menu_edit_item_form()
  3. 7.2 og_menu.pages.inc \og_menu_edit_item_form()

Form callback; Build the menu link editing form.

1 string reference to 'og_menu_edit_item_form'
og_menu_menu in ./og_menu.module
Implements hook_menu().

File

./og_menu.pages.inc, line 261
Contains page callbacks for og_menu

Code

function og_menu_edit_item_form($form, &$form_state, $type, $group_type, $gid, $menu, $item = array()) {
  module_load_include('inc', 'menu', 'menu.admin');
  $form = menu_edit_item($form, $form_state, $type, $item, $menu);

  // Set the breadcrumb now to override menu_edit_item() breadcrumb.
  og_set_breadcrumb($group_type, $gid, array(
    l(t('Group'), "{$group_type}/{$gid}/group"),
  ));
  $b = drupal_get_breadcrumb();
  $b[] = l(t('Menus'), 'group/' . $group_type . '/' . $gid . '/admin/menus');
  $b[] = l($menu['title'], 'group/' . $group_type . '/' . $gid . '/admin/menus/' . $menu['menu_name']);
  drupal_set_breadcrumb($b);
  $list = array();
  $menus = og_menu_get_group_menus(array(
    $group_type => array(
      0 => $gid,
    ),
  ));
  foreach ($menus as $option) {
    $list[$option['menu_name']] = $option['title'];
  }

  // Set the title of the page.
  drupal_set_title(t('Add link into menu !mtitle', array(
    '!mtitle' => $menu['title'],
  )), PASS_THROUGH);

  // Build the form.
  $form['parent']['#options'] = menu_parent_options($list, array(
    'mlid' => 0,
  ));
  $form['og_menu_group_type'] = array(
    '#type' => 'value',
    '#value' => $group_type,
  );
  $form['og_menu_gid'] = array(
    '#type' => 'value',
    '#value' => $gid,
  );
  $form['og_menu_name'] = array(
    '#type' => 'value',
    '#value' => $menu['menu_name'],
  );
  $form['#submit'][] = 'menu_edit_item_submit';
  $form['#submit'][] = 'og_menu_redirect';
  $form['#validate'][] = 'menu_edit_item_validate';
  if (!empty($item)) {
    $form['actions']['delete'] = array(
      '#type' => 'link',
      '#title' => 'Delete',
      '#href' => 'group/' . $group_type . '/' . $gid . '/admin/menus/' . $menu['menu_name'] . '/item/' . $item['mlid'] . '/delete',
      '#weight' => 10,
    );
  }

  // Integrate with Menu Attributes if installed.
  if (module_exists('menu_attributes') && function_exists('_menu_attributes_form_alter')) {
    $item = $form['original_item']['#value'];
    _menu_attributes_form_alter($form, $item, $form);
  }

  // Integrate with Multi Path Autocomplete (mpac) if installed.
  if (module_exists('mpac')) {
    mpac_form_menu_edit_item_alter($form, $form_state);
  }

  // Integrate with Special Menu Items if installed.
  if (module_exists('special_menu_items')) {
    special_menu_items_form_menu_edit_item_alter($form, $form_state);
  }
  return $form;
}