You are here

function path_breadcrumbs_ui_settings in Path Breadcrumbs 7.3

Same name and namespace in other branches
  1. 7.2 path_breadcrumbs_ui/path_breadcrumbs_ui.admin.inc \path_breadcrumbs_ui_settings()

Path Breadcrumbs settings form.

1 string reference to 'path_breadcrumbs_ui_settings'
path_breadcrumbs_ui_menu in path_breadcrumbs_ui/path_breadcrumbs_ui.module
Implements hook_menu().

File

path_breadcrumbs_ui/path_breadcrumbs_ui.admin.inc, line 119
Administrative callbacks for PATH BREADCRUMBS UI module.

Code

function path_breadcrumbs_ui_settings($form, $form_state) {

  // Theme settings.
  $form['path_breadcrumbs_theme'] = array(
    '#type' => 'fieldset',
    '#title' => t('Theming settings'),
    '#description' => t('Additional theme settings for all site breadcrumbs. You have to enable option "%option" to use Path Breadcrumbs theming features.', array(
      '%option' => t('Use module breadcrumbs render function'),
    )),
  );
  $form['path_breadcrumbs_theme']['path_breadcrumbs_internal_render'] = array(
    '#type' => 'checkbox',
    '#title' => '<strong>' . t('Use module breadcrumbs render function') . '</strong>',
    '#default_value' => variable_get('path_breadcrumbs_internal_render', 1),
    '#description' => t("If this value checked module will replace system or theme breadcrumb render function by module's one.<br/>Note that if this checkbox is unchecked module will not be able to implement settings below."),
  );
  $form['path_breadcrumbs_theme']['themes_fieldset'] = array(
    '#type' => 'fieldset',
    '#collapsed' => !count(variable_get('path_breadcrumbs_internal_render_themes', array())),
    '#collapsible' => TRUE,
    '#title' => t('Per theme settings'),
  );
  $form['path_breadcrumbs_theme']['themes_fieldset']['path_breadcrumbs_internal_render_themes'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Use internal Path Breadcrumbs rendering only for specific themes'),
    '#options' => _path_breadcrumbs_themes_option_list(),
    '#default_value' => variable_get('path_breadcrumbs_internal_render_themes', array()),
    '#description' => t('If you select no themes, there will be no specific limitation for Path Breadcrumbs render function.'),
    '#states' => array(
      'disabled' => array(
        ':input[name="path_breadcrumbs_internal_render"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  $form['path_breadcrumbs_theme']['path_breadcrumbs_delimiter'] = array(
    '#type' => 'textfield',
    '#title' => t('Delimiter'),
    '#default_value' => variable_get('path_breadcrumbs_delimiter', '»'),
    '#size' => 3,
    '#description' => t('Symbol that separates breadcrumbs. HTML is not allowed. You can use <code>.delimiter</code> class name to style the delimiter in CSS.'),
    '#states' => array(
      'disabled' => array(
        ':input[name="path_breadcrumbs_internal_render"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  $form['path_breadcrumbs_theme']['path_breadcrumbs_rich_snippets'] = array(
    '#type' => 'select',
    '#title' => t('Rich snippets support'),
    '#options' => array(
      PATH_BREADCRUMBS_RICH_SNIPPETS_DISABLED => t('Disabled'),
      PATH_BREADCRUMBS_RICH_SNIPPETS_RDFA => t('RDFa'),
      PATH_BREADCRUMBS_RICH_SNIPPETS_MICRODATA => t('Microdata'),
    ),
    '#default_value' => variable_get('path_breadcrumbs_rich_snippets', PATH_BREADCRUMBS_RICH_SNIPPETS_DISABLED),
    '#description' => t('Provides rich snippets support for breadcrumbs. It is important to build a structure of a site in the SERP.'),
    '#states' => array(
      'disabled' => array(
        ':input[name="path_breadcrumbs_internal_render"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  $form['path_breadcrumbs_theme']['path_breadcrumbs_hide_single_breadcrumb'] = array(
    '#type' => 'checkbox',
    '#title' => t('Hide breadcrumbs navigation for single breadcrumb'),
    '#default_value' => variable_get('path_breadcrumbs_hide_single_breadcrumb', 0),
    '#description' => t('If breacrumbs navigation contains only one breadcrumb then breadcrumb navigation will be hidden.'),
    '#states' => array(
      'disabled' => array(
        ':input[name="path_breadcrumbs_internal_render"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );

  // Cache settings.
  $form['path_breadcrumbs_cache'] = array(
    '#type' => 'fieldset',
    '#title' => t('Performance settings'),
  );
  $form['path_breadcrumbs_cache']['path_breadcrumbs_cache_enabled'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable cache for the breadcrumbs'),
    '#description' => t("Enables caching of breadcrumb's navigations. Use only on production sites."),
    '#default_value' => variable_get('path_breadcrumbs_cache_enabled', FALSE),
  );
  $form['path_breadcrumbs_cache']['path_breadcrumbs_cache_lifetime'] = array(
    '#type' => 'select',
    '#title' => t('Cache lifetime'),
    '#options' => array(
      CACHE_PERMANENT => t('Permanent'),
      CACHE_TEMPORARY => t('Temporary'),
      60 * 5 => t('@amount minutes', array(
        '@amount' => 5,
      )),
      60 * 15 => t('@amount minutes', array(
        '@amount' => 15,
      )),
      60 * 30 => t('@amount minutes', array(
        '@amount' => 30,
      )),
      60 * 60 => t('@amount minutes', array(
        '@amount' => 60,
      )),
      60 * 60 * 2 => t('@amount hours', array(
        '@amount' => 2,
      )),
      60 * 60 * 4 => t('@amount hours', array(
        '@amount' => 4,
      )),
      60 * 60 * 8 => t('@amount hours', array(
        '@amount' => 8,
      )),
      60 * 60 * 12 => t('@amount hours', array(
        '@amount' => 12,
      )),
      60 * 60 * 24 => t('@amount hours', array(
        '@amount' => 24,
      )),
      60 * 60 * 24 * 3 => t('@amount days', array(
        '@amount' => 3,
      )),
      60 * 60 * 24 * 7 => t('@amount days', array(
        '@amount' => 7,
      )),
    ),
    '#description' => t('You can read more information about cache settings <a href="@url">here</a>.', array(
      '@url' => url('http://api.drupal.org/api/drupal/includes!cache.inc/function/cache_set/7', array(
        'external' => TRUE,
      )),
    )),
    '#default_value' => variable_get('path_breadcrumbs_cache_lifetime', CACHE_PERMANENT),
  );

  // Home link settings.
  $form['path_breadcrumbs_home_link'] = array(
    '#type' => 'fieldset',
    '#title' => t('Home link settings'),
  );
  $form['path_breadcrumbs_home_link']['path_breadcrumbs_home_link_enabled'] = array(
    '#type' => 'checkbox',
    '#title' => t('Prepend breadcrumbs with a home link by default'),
    '#default_value' => variable_get('path_breadcrumbs_home_link_enabled', 1),
    '#description' => t('This value does not changes current breadcrumbs navigation. It is just set default value for new path breadcrumbs.'),
  );
  $form['path_breadcrumbs_home_link']['path_breadcrumbs_home_link_title'] = array(
    '#type' => 'textfield',
    '#title' => t('Home link title'),
    '#default_value' => variable_get('path_breadcrumbs_home_link_title', 'Home'),
    '#description' => t('Title of the link that points to the front page.'),
    '#size' => 30,
  );

  // Other settings.
  $form['path_breadcrumbs_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Other settings'),
  );
  $url_cleaning_method_options = array(
    'none' => t('Disabled'),
    'ctools' => t('CTools'),
  );
  $url_cleaning_method_help[] = t('CTools method: transliterate (if <a href="@url">Transliteration</a> enabled), lower case, replace whitespace with "-".', array(
    '@url' => 'https://drupal.org/project/transliteration',
  ));
  if (module_exists('pathauto')) {
    $url_cleaning_method_options['pathauto'] = t('Pathauto');
    $url_cleaning_method_help[] = t('Pathauto method: clean with <a href="@url">Pathauto settings</a>.', array(
      '@url' => url('admin/config/search/path/settings', array(
        'query' => array(
          'destination' => current_path(),
        ),
      )),
    ));
  }
  else {
    $url_cleaning_method_help[] = t('Pathauto method (disabled): clean with <a href="@url">Pathauto module</a>.', array(
      '@url' => 'https://drupal.org/project/pathauto',
    ));
  }
  $url_cleaning_method_help = '<p>' . implode('<br />', $url_cleaning_method_help) . '</p>';
  $form['path_breadcrumbs_settings']['path_breadcrumbs_url_cleaning_method'] = array(
    '#type' => 'select',
    '#title' => t('URL path cleaning method'),
    '#default_value' => variable_get('path_breadcrumbs_url_cleaning_method', 'none'),
    '#options' => $url_cleaning_method_options,
    '#description' => $url_cleaning_method_help . t('Choose the path cleaning method to be applied to URLs in Path Breadcrumbs.'),
  );
  $form['path_breadcrumbs_settings']['path_breadcrumbs_truncate_title_length'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum title length'),
    '#default_value' => variable_get('path_breadcrumbs_truncate_title_length', ''),
    '#element_validate' => array(
      'element_validate_integer_positive',
    ),
    '#size' => 3,
    '#description' => t('An upper limit of symbols in the Path Breadcrumbs title. Title over the limit will be truncated with adding ellipsis at the end. Leave blank to disable truncating.'),
    '#field_suffix' => '<span class="description">' . (variable_get('path_breadcrumbs_truncate_title_length', '') ? t('To disable truncating leave field blank.') : t('Now truncating is disabled.')) . '</span>',
  );
  $form['path_breadcrumbs_settings']['path_breadcrumbs_decode_entities'] = array(
    '#type' => 'checkbox',
    '#title' => t('Decode HTML entities'),
    '#description' => t('Converts quotes in the breadcrumbs to their applicable characters.'),
    '#default_value' => variable_get('path_breadcrumbs_decode_entities', TRUE),
  );
  $form['path_breadcrumbs_settings']['path_breadcrumbs_enable_on_error_pages'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable Path Breadcrumbs on error pages'),
    '#description' => t('Enables Path Breadcrumbs on error pages (403, 404). <strong>Only for advanced users. May require additional access checks.</strong>'),
    '#default_value' => variable_get('path_breadcrumbs_enable_on_error_pages', FALSE),
  );
  $form['#submit'][] = 'path_breadcrumbs_ui_settings_submit';
  return system_settings_form($form);
}