You are here

function xbbcode_filter_settings in Extensible BBCode 7

Same name and namespace in other branches
  1. 8 xbbcode.module \xbbcode_filter_settings()

Settings callback for the filter settings of xbbcode.

1 string reference to 'xbbcode_filter_settings'
xbbcode_filter_info in ./xbbcode.module
Implements hook_filter_info().

File

./xbbcode.module, line 102
The main module file containing hook implementations.

Code

function xbbcode_filter_settings(&$form, &$form_state, $filter, $format, $defaults, $filters) {

  // Load the database and admin interface.
  module_load_include('inc', 'xbbcode', 'xbbcode.crud');
  module_load_include('inc', 'xbbcode', 'xbbcode.admin');
  $settings = array(
    '#type' => 'fieldset',
    '#title' => t('BBCode'),
    '#collapsible' => TRUE,
  );
  $settings['autoclose'] = array(
    '#type' => 'checkbox',
    '#title' => t("Automatically close tags left open at the end of the text."),
    '#description' => t("You will need to enable this option if you use automatic teasers on your site. BBCode will never generate broken HTML, but otherwise the BBCode tags broken by the teaser will simply not be processed."),
    '#default_value' => isset($filter->settings['autoclose']) ? $filter->settings['autoclose'] : $defaults['autoclose'],
  );
  $override = !empty($filter->settings['override']);
  $settings['override'] = array(
    '#type' => 'checkbox',
    '#title' => t('Override the <a href="@url">global settings</a> with specific settings for this format.', array(
      '@url' => url('admin/config/content/xbbcode/settings'),
    )),
    '#default_value' => $override,
    '#description' => t('Overriding the global settings allows you to disallow or allow certain special tags for this format, while other formats will not be affected by the change.'),
    '#attributes' => array(
      'onchange' => 'Drupal.toggleFieldset(jQuery("#edit-filters-xbbcode-settings-tags"))',
    ),
  );
  $settings['tags'] = xbbcode_settings_handlers_format(!empty($format->format) ? $format->format : XBBCODE_GLOBAL);
  $settings['tags']['#collapsed'] = !$override;

  // Make sure to keep the default #submit while adding a new one.
  if (!isset($form['#submit'])) {
    $form['#submit'] = array(
      'filter_admin_format_form_submit',
    );
  }
  $form['#submit'][] = 'xbbcode_settings_handlers_save_submit';
  return $settings;
}