You are here

function page_manager_page_form_menu in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 page_manager/plugins/tasks/page.admin.inc \page_manager_page_form_menu()

Form to handle menu item controls.

2 string references to 'page_manager_page_form_menu'
page_manager_page_add_subtask in page_manager/plugins/tasks/page.admin.inc
Page callback to add a subtask.
page_manager_page_build_subtask in page_manager/plugins/tasks/page.inc
Build a subtask array for a given page.

File

page_manager/plugins/tasks/page.admin.inc, line 644
Administrative functions for the page subtasks.

Code

function page_manager_page_form_menu(&$form, &$form_state) {
  ctools_include('dependent');
  $form['menu'] = array(
    '#prefix' => '<div class="clear-block">',
    '#suffix' => '</div>',
    '#tree' => TRUE,
  );
  $menu = $form_state['page']->subtask['subtask']->menu;
  if (empty($menu)) {
    $menu = array(
      'type' => 'none',
      'title' => '',
      'weight' => 0,
      'name' => 'navigation',
      'parent' => array(
        'type' => 'none',
        'title' => '',
        'weight' => 0,
        'name' => 'navigation',
      ),
    );
  }
  $form['menu']['type'] = array(
    '#title' => t('Type'),
    '#type' => 'radios',
    '#options' => array(
      'none' => t('No menu entry'),
      'normal' => t('Normal menu entry'),
      'tab' => t('Menu tab'),
      'default tab' => t('Default menu tab'),
    ),
    '#default_value' => $menu['type'],
  );
  $form['menu']['title'] = array(
    '#title' => t('Title'),
    '#type' => 'textfield',
    '#default_value' => $menu['title'],
    '#description' => t('If set to normal or tab, enter the text to use for the menu item.'),
    '#process' => array(
      'ctools_dependent_process',
    ),
    '#dependency' => array(
      'radio:menu[type]' => array(
        'normal',
        'tab',
        'default tab',
      ),
    ),
  );
  list($major, $minor) = explode('.', VERSION, 2);
  $form['menu']['name-warning'] = array(
    '#type' => 'markup',
    '#prefix' => '<div class="warning">',
    '#value' => t("Warning: Changing this item's menu will not work reliably in Drupal 6.4 or earlier. Please upgrade your copy of Drupal at !url.", array(
      '!url' => l('drupal.org', 'http://drupal.org/project/Drupal+project'),
    )),
    '#suffix' => '</div>',
    '#process' => array(
      'ctools_dependent_process',
    ),
    '#dependency' => array(
      'radio:menu[type]' => array(
        'normal',
      ),
    ),
    '#access' => $minor < 5,
  );

  // Only display the menu selector if menu module is enabled.
  if (module_exists('menu')) {
    $form['menu']['name'] = array(
      '#title' => t('Menu'),
      '#type' => 'select',
      '#options' => menu_get_menus(),
      '#default_value' => $menu['name'],
      '#description' => t('Insert item into an available menu.'),
      '#process' => array(
        'ctools_dependent_process',
      ),
      '#dependency' => array(
        'radio:menu[type]' => array(
          'normal',
        ),
      ),
    );
  }
  else {
    $form['menu']['name'] = array(
      '#type' => 'value',
      '#value' => $menu['name'],
    );
    $form['menu']['markup'] = array(
      '#value' => t('Menu selection requires the activation of menu module.'),
    );
  }
  $form['menu']['weight'] = array(
    '#title' => t('Weight'),
    '#type' => 'textfield',
    '#default_value' => isset($menu['weight']) ? $menu['weight'] : 0,
    '#description' => t('The lower the weight the higher/further left it will appear.'),
    '#process' => array(
      'ctools_dependent_process',
    ),
    '#dependency' => array(
      'radio:menu[type]' => array(
        'normal',
        'tab',
        'default tab',
      ),
    ),
  );
  $form['menu']['parent']['type'] = array(
    '#prefix' => '<div id="edit-menu-parent-type-wrapper">',
    '#suffix' => '</div>',
    '#title' => t('Parent menu item'),
    '#type' => 'radios',
    '#options' => array(
      'none' => t('Already exists'),
      'normal' => t('Normal menu item'),
      'tab' => t('Menu tab'),
    ),
    '#default_value' => $menu['parent']['type'],
    '#description' => t('When providing a menu item as a default tab, Drupal needs to know what the parent menu item of that tab will be. Sometimes the parent will already exist, but other times you will need to have one created. The path of a parent item will always be the same path with the last part left off. i.e, if the path to this view is <em>foo/bar/baz</em>, the parent path would be <em>foo/bar</em>.'),
    '#process' => array(
      'expand_radios',
      'ctools_dependent_process',
    ),
    '#dependency' => array(
      'radio:menu[type]' => array(
        'default tab',
      ),
    ),
  );
  $form['menu']['parent']['title'] = array(
    '#title' => t('Parent item title'),
    '#type' => 'textfield',
    '#default_value' => $menu['parent']['title'],
    '#description' => t('If creating a parent menu item, enter the title of the item.'),
    '#process' => array(
      'ctools_dependent_process',
    ),
    '#dependency' => array(
      'radio:menu[type]' => array(
        'default tab',
      ),
      'radio:menu[parent][type]' => array(
        'normal',
        'tab',
      ),
    ),
    '#dependency_count' => 2,
  );

  // Only display the menu selector if menu module is enabled.
  if (module_exists('menu')) {
    $form['menu']['parent']['name'] = array(
      '#title' => t('Parent item menu'),
      '#type' => 'select',
      '#options' => menu_get_menus(),
      '#default_value' => $menu['parent']['name'],
      '#description' => t('Insert item into an available menu.'),
      '#process' => array(
        'ctools_dependent_process',
      ),
      '#dependency' => array(
        'radio:menu[type]' => array(
          'default tab',
        ),
        'radio:menu[parent][type]' => array(
          'normal',
        ),
      ),
      '#dependency_count' => 2,
    );
  }
  else {
    $form['menu']['parent']['name'] = array(
      '#type' => 'value',
      '#value' => $menu['parent']['name'],
    );
  }
  $form['menu']['parent']['weight'] = array(
    '#title' => t('Tab weight'),
    '#type' => 'textfield',
    '#default_value' => $menu['parent']['weight'],
    '#size' => 5,
    '#description' => t('If the parent menu item is a tab, enter the weight of the tab. The lower the number, the more to the left it will be.'),
    '#process' => array(
      'ctools_dependent_process',
    ),
    '#dependency' => array(
      'radio:menu[type]' => array(
        'default tab',
      ),
      'radio:menu[parent][type]' => array(
        'tab',
      ),
    ),
    '#dependency_count' => 2,
  );
}