You are here

function xbbcode_filter in Extensible BBCode 6

Same name and namespace in other branches
  1. 5 xbbcode.module \xbbcode_filter()
1 call to xbbcode_filter()
xbbcode_filter_tips in ./xbbcode.module

File

./xbbcode.module, line 52

Code

function xbbcode_filter($op = 'list', $delta = 0, $format = -1, $text = '') {
  switch ($op) {
    case 'list':
      return array(
        'Extensible BBCode',
      );
    case 'description':
      return t('Allows custom BBCode tags');
    case 'no cache':
      return FALSE;
    case 'process':
      $filter = xbbcode_get_filter($format);
      return $filter
        ->process($text);
    case 'settings':
      $specific = db_result(db_query('SELECT COUNT(*) FROM {xbbcode_handlers} WHERE format = %d', $format));
      $override = $specific ? 'specific' : 'global';
      $form['xbbcode'] = array(
        '#type' => 'fieldset',
        '#title' => t('XBBCode'),
        '#collapsible' => TRUE,
      );
      $form['xbbcode']['xbbcode_filter_' . $format . '_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' => variable_get('xbbcode_filter_' . $format . '_autoclose', false),
      );
      $form['xbbcode']['override'] = array(
        '#type' => 'radios',
        '#title' => t('Override global settings'),
        '#options' => array(
          'global' => t('Use global settings (specific settings will be lost).'),
          'specific' => t('Use specific settings for this format.'),
        ),
        '#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.'),
      );
      require_once 'xbbcode.admin.inc';

      // include code for the settings form.
      $form['xbbcode']['tags'] = xbbcode_settings_handlers_form($format);
      $form['xbbcode']['tags']['tags']['#collapsed'] = $override == 'global';
      $form['#submit'][] = 'xbbcode_settings_handlers_submit';
      return $form;
  }
  return $text;
}