You are here

function bootstrap_library_settings in Bootstrap Library 7

Module settings form.

8 string references to 'bootstrap_library_settings'
bootstrap_library_check_theme in ./bootstrap_library.module
bootstrap_library_init in ./bootstrap_library.module
Implements hook_init().
bootstrap_library_install in ./bootstrap_library.install
Implementation of hook_install(). This will create our system variable defaults. The benefit is that we do not need to pass defaults to variable_get(), which allows centralization of defaults.
bootstrap_library_libraries_info in ./bootstrap_library.module
Implements hook_libraries_info().
bootstrap_library_menu in ./bootstrap_library.module
Implementation of hook_menu().

... See full list

File

./bootstrap_library.module, line 123
Primarily Drupal hooks.

Code

function bootstrap_library_settings($form, &$form_state) {
  $settings = variable_get('bootstrap_library_settings');
  $themes = list_themes();
  $active_themes = array();
  foreach ($themes as $theme) {
    if ($theme->status) {
      $active_themes[$theme->name] = $theme->info['name'];
    }
  }
  $options['bootstrap'] = array(
    '#type' => 'vertical_tabs',
  );
  $options['minimized'] = array(
    '#type' => 'fieldset',
    '#title' => t('Libraries Options'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#group' => 'bootstrap',
  );
  $options['minimized']['options'] = array(
    '#type' => 'radios',
    '#title' => t('Choose minimized or not libraries.'),
    '#options' => array(
      0 => t('Use non minimized libraries (Development)'),
      1 => t('Use minimized libraries (Production)'),
    ),
    '#default_value' => $settings['minimized']['options'],
  );

  // Per-path visibility.
  $options['visibility'] = array(
    '#type' => 'fieldset',
    '#title' => t('Pages Visibility'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#group' => 'bootstrap',
  );
  $options['visibility']['visibility'] = array(
    '#type' => 'radios',
    '#title' => t('Activate on specific pages'),
    '#options' => array(
      0 => t('All pages except those listed'),
      1 => t('Only the listed pages'),
    ),
    '#default_value' => $settings['visibility']['visibility'],
  );
  $options['visibility']['pages'] = array(
    '#type' => 'textarea',
    '#title' => 'List of pages to activate',
    '#default_value' => $settings['visibility']['pages'],
    '#description' => t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array(
      '%blog' => 'blog',
      '%blog-wildcard' => 'blog/*',
      '%front' => '<front>',
    )),
  );

  // Per-path visibility.
  $options['theme'] = array(
    '#type' => 'fieldset',
    '#title' => t('Themes Visibility'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#group' => 'bootstrap',
  );
  $options['theme']['visibility'] = array(
    '#type' => 'radios',
    '#title' => t('Activate on specific themes'),
    '#options' => array(
      0 => t('All themes except those listed'),
      1 => t('Only the listed themes'),
    ),
    '#default_value' => $settings['theme']['visibility'],
  );
  $options['theme']['themes'] = array(
    '#type' => 'select',
    '#title' => 'List of themes where library will be loaded.',
    '#options' => $active_themes,
    '#multiple' => TRUE,
    '#default_value' => $settings['theme']['themes'],
    '#description' => t("Specify in which themes you wish the library to load."),
  );

  // Files settings.
  $options['files'] = array(
    '#type' => 'fieldset',
    '#title' => t('Files Settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#group' => 'bootstrap',
  );
  $options['files']['types'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Select which files to load from the library. By default you should check both, but in some cases you will need to load only CSS or JS Bootstrap files.'),
    '#options' => array(
      'css' => t('CSS files'),
      'js' => t('Javascript files'),
    ),
    '#default_value' => $settings['files']['types'],
  );
  $options['#tree'] = TRUE;
  $form['bootstrap_library_settings'] = $options;

  // Disable automatic defaults, which don't work with nested values.
  return system_settings_form($form, FALSE);
}