You are here

function menu_breadcrumb_admin_settings_form in Menu Breadcrumb 6

Same name and namespace in other branches
  1. 7 menu_breadcrumb.module \menu_breadcrumb_admin_settings_form()

Menu breadcrumb admin settings form.

Return value

The settings form used by Menu breadcrumb.

1 string reference to 'menu_breadcrumb_admin_settings_form'
menu_breadcrumb_menu in ./menu_breadcrumb.module
Implementation of hook_menu().

File

./menu_breadcrumb.module, line 363
The main file for the menu_breadcrumb module.

Code

function menu_breadcrumb_admin_settings_form() {
  $form['menu_breadcrumb_determine_menu'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use menu the page belongs to for the breadcrumb.'),
    '#description' => t('By default, Drupal 6 will use the Navigation menu for the breadcrumb. If you want to use the menu the active page belongs to for the breadcrumb, enable this option.'),
    '#default_value' => variable_get('menu_breadcrumb_determine_menu', 1),
  );
  $form['menu_breadcrumb_append_node_title'] = array(
    '#type' => 'checkbox',
    '#title' => t('Append page title to breadcrumb'),
    '#description' => t('Choose whether or not the page title should be included in the breadcrumb.'),
    '#default_value' => variable_get('menu_breadcrumb_append_node_title', 0),
  );
  $form['menu_breadcrumb_append_node_url'] = array(
    '#type' => 'checkbox',
    '#title' => t('Appended page title as an URL.'),
    '#description' => t('Choose whether or not the appended page title should be an URL.'),
    '#default_value' => variable_get('menu_breadcrumb_append_node_url', 0),
  );
  $form['menu_breadcrumb_hide_on_single_item'] = array(
    '#type' => 'checkbox',
    '#title' => t('Hide the breadcrumb if the breadcrumb only contains the link to the front page.'),
    '#description' => t('Choose whether or not the breadcrumb should be hidden if the breadcrumb only contains a link to the front page (<em>Home</em>.).'),
    '#default_value' => variable_get('menu_breadcrumb_hide_on_single_item', 0),
  );
  $form['include_exclude'] = array(
    '#type' => 'fieldset',
    '#title' => t('Enable / Disable Menus'),
    '#description' => t('The breadcrumb will be generated from the first "enabled" menu that contains a menu item for the page. Re-order the list to change the priority of each menu.'),
  );
  $form['include_exclude']['note_about_navigation'] = array(
    '#type' => 'markup',
    '#prefix' => '<p class="description">',
    '#suffix' => '</p>',
    '#value' => t("Note: If none of the enabled menus contain an item for a given page, Drupal will look in the 'Navigation' menu by default, even if it is 'disabled' here."),
  );

  // Orderable list of menu selections.
  $form['include_exclude']['menu_breadcrumb_menus'] = array(
    '#tree' => TRUE,
    '#theme' => 'menu_breadcrumb_menus_table',
  );

  // Load stored configuration.
  $menus = _menu_breadcrumb_get_menus();
  $weight_delta = count($menus);
  foreach ($menus as $menu_name => $menu) {

    // Load menu titles.
    $title = !empty($menu['title']) ? $menu['title'] : $menu_name;
    if ($menu['type'] == 'menu') {
      $drupal_menu = menu_load($menu_name);
      if (!empty($drupal_menu['title'])) {
        $title = $drupal_menu['title'];
      }
    }

    // Ensure that regex patterns do not cause invalid id attributes.
    $safe_id_prefix = 'edit-menu-breadcrumb-menus-' . menu_breadcrumb_html_id($menu_name);
    $form['include_exclude']['menu_breadcrumb_menus'][$menu_name] = array(
      'enabled' => array(
        '#type' => 'checkbox',
        '#id' => $safe_id_prefix . '-enabled',
        '#title' => '',
        '#default_value' => $menu['enabled'],
      ),
      'label' => array(
        '#value' => $menu_name,
      ),
      'weight' => array(
        '#type' => 'weight',
        '#default_value' => !empty($menu['weight']) ? (int) $menu['weight'] : 0,
        '#delta' => $weight_delta,
        '#id' => $safe_id_prefix . '-weight-wrapper',
      ),
      'type' => array(
        '#type' => 'value',
        '#value' => $menu['type'],
      ),
      'title' => array(
        '#type' => 'value',
        '#value' => $title,
      ),
      'title_display' => array(
        '#type' => 'markup',
        '#value' => check_plain($title),
      ),
    );

    // Provide helpful title attributes for special menus.
    $title_field =& $form['include_exclude']['menu_breadcrumb_menus'][$menu_name]['title_display'];
    if ($menu['type'] == 'pattern') {
      $title_field['#value'] = t('<span title="@title">@name <em>(@hint)</em></span>', array(
        '@title' => t("See 'Advanced' settings below."),
        '@name' => $title_field['#value'],
        '@hint' => t('pattern'),
      ));
    }
    elseif ($menu['type'] == 'menu_breadcrumb_default_menu') {
      $title_field['#value'] = t('<em><span title="@title">@text</span></em>', array(
        '@title' => t('Default setting for future menus.'),
        '@text' => t('Default setting (see below)'),
      ));
    }
  }
  $form['include_exclude']['description'] = array(
    '#type' => 'markup',
    '#prefix' => '<p class="description">',
    '#suffix' => '</p>',
    '#value' => t('<strong>Default setting</strong> is not a real menu - it defines the default position and enabled status for future menus. If it is "enabled", Menu Breadcrumb will automatically consider newly-added menus when establishing breadcrumbs. If it is disabled, new menus will not be used for breadcrumbs until they have explicitly been enabled here.'),
  );
  $form['include_exclude']['advanced'] = array(
    '#type' => 'fieldset',
    '#title' => t('Advanced'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['include_exclude']['advanced']['pattern_help'] = array(
    '#type' => 'markup',
    '#prefix' => '<p class="description">',
    '#suffix' => '</p>',
    '#value' => t("Enter regular expressions (one per line) to aggregate matching menu names into a single replacement title in the above list."),
  );
  $form['include_exclude']['advanced']['menu_breadcrumb_menu_patterns'] = array(
    '#type' => 'textarea',
    '#title' => t('Patterns'),
    '#default_value' => variable_get('menu_breadcrumb_menu_patterns', MENU_BREADCRUMB_REGEX_DEFAULT),
    '#description' => t("Syntax: /regex/title/<br/>e.g.: /^book-toc-\\d+\$/Books/"),
  );

  // Explicitly set our submit handler, due to system_settings_form().
  $form['#submit'][] = 'menu_breadcrumb_admin_settings_form_submit';
  return system_settings_form($form);
}