You are here

function ckeditor_filter_filter_ckeditor_filter_settings in CKEditor Filter 7

Implements hook_filter_FILTER_settings

1 string reference to 'ckeditor_filter_filter_ckeditor_filter_settings'
ckeditor_filter_filter_info in ./ckeditor_filter.module
Implements hook_filter_info().

File

./ckeditor_filter.module, line 196
Provides an input filter that allows site administrators configure which HTML elements, attributes and style properties are allowed.

Code

function ckeditor_filter_filter_ckeditor_filter_settings($form, $form_state, $filter, $format, $defaults) {
  $settings = $filter->settings;
  $settings += $defaults;

  // carry over settings for other formats
  $filterform = array();

  // *** valid elements ***
  $valid_elements = $settings['valid_elements'];
  $valid_elements_rows = min(20, max(5, substr_count($valid_elements, "\n") + 2));

  // show blacklisted elements in description
  $elements_blacklist = ckeditor_filter_get_elements_blacklist();

  //wysiwyg_filter_get_elements_blacklist();
  foreach ($elements_blacklist as $i => $element) {
    $elements_blacklist[$i] = '<' . $element . '>';
  }
  $filterform['valid_elements'] = array(
    '#type' => 'textarea',
    '#title' => t('Valid HTML elements'),
    '#default_value' => $valid_elements,
    '#cols' => 60,
    '#rows' => $valid_elements_rows,
    '#description' => t('<p>
  This option allows you to specify which HTML elements allowed.
  </p>
  <ul>
    <li>The following elements cannot be whitelisted due to security reasons, to prevent users from breaking site layout and/or to avoid posting invalid HTML. Forbidden elements: %elements-blacklist.</li>
  </ul>', array(
      '%elements-blacklist' => implode(' ', $elements_blacklist),
    )),
  );

  // *** valid attributes ***
  $valid_attributes = $settings['valid_attributes'];
  $valid_attributes_rows = min(20, max(5, substr_count($valid_attributes, "\n") + 2));
  $filterform['valid_attributes'] = array(
    '#type' => 'textarea',
    '#title' => t('Valid element attributes'),
    '#default_value' => $valid_attributes,
    '#cols' => 60,
    '#rows' => $valid_attributes_rows,
    '#description' => t('<p>
  This option allows you to specify which element attributes allowed.  Note: to use inline styles, &quot;style&quot; must be included here.
  </p>'),
  );

  // *** valid styles ***
  $valid_styles = $settings['valid_styles'];
  $valid_styles_rows = min(20, max(5, substr_count($valid_styles, "\n") + 2));

  // *** Style properties ***
  $filterform['valid_styles'] = array(
    '#type' => 'textarea',
    '#title' => t('Valid Style properties'),
    '#default_value' => $valid_styles,
    '#cols' => 60,
    '#rows' => $valid_styles_rows,
    '#description' => '<p>' . t('This section allows you to select which style properties can be used for HTML styles where the &quot;style&quot; attribute has been allowed. The <em>WYSIWYG Filter</em> will strip out style properties (and their values) not explicitly enabled here.') . '</p>',
  );
  return $filterform;
}