function _htmlpurifier_settings in HTML Purifier 6.2
Same name and namespace in other branches
- 5 htmlpurifier.module \_htmlpurifier_settings()
- 6 htmlpurifier.module \_htmlpurifier_settings()
- 7.2 htmlpurifier.module \_htmlpurifier_settings()
- 7 htmlpurifier.module \_htmlpurifier_settings()
Generates a settings form for configuring HTML Purifier.
Parameters
int $delta: Whether or not to use advanced form (1) or not (0).
int $format: Input format being configured.
Return value
Form API array.
1 call to _htmlpurifier_settings()
- htmlpurifier_filter in ./
htmlpurifier.module - Implementation of hook_filter().
File
- ./
htmlpurifier.module, line 404 - Implements HTML Purifier as a Drupal filter.
Code
function _htmlpurifier_settings($delta, $format) {
_htmlpurifier_load();
// Dry run, testing for errors:
_htmlpurifier_process('', $format, FALSE);
$module_path = drupal_get_path('module', 'htmlpurifier');
drupal_add_css("{$module_path}/config-form.css");
// Makes all configuration links open in new windows; can safe lots of grief!
drupal_add_js('$(function(){$(".hp-config a").click(function(){window.open(this.href);return false;});});', 'inline');
drupal_add_js(HTMLPurifier_Printer_ConfigForm::getJavaScript(), 'inline');
$form = array();
$form['dashboard'] = array(
'#type' => 'fieldset',
'#title' => t('HTML Purifier Dashboard'),
'#collapsible' => true,
);
$form['dashboard']["enter_hack"] = array(
// hack to make normal form submission when <ENTER> is pressed
'#value' => '<input type="submit" name="op" id="edit-submit" value="Save configuration" class="form-submit" style="display:none;" />',
);
$form['dashboard']["htmlpurifier_clear_cache"] = array(
'#type' => 'submit',
'#value' => t('Clear cache (Warning: Can result in performance degradation)'),
'#submit' => array(
'_htmlpurifier_clear_cache',
),
);
$form['htmlpurifier'] = array(
'#type' => 'fieldset',
'#title' => t('HTML Purifier'),
'#collapsible' => TRUE,
);
$form['htmlpurifier']["htmlpurifier_help_{$format}"] = array(
'#type' => 'checkbox',
'#title' => t('Display help text'),
'#default_value' => variable_get("htmlpurifier_help_{$format}", TRUE),
'#description' => t('If enabled, a short note will be added to the filter tips explaining that HTML will be transformed to conform with HTML standards. You may want to disable this option when the HTML Purifier is used to check the output of another filter like BBCode.'),
);
if ($config_function = _htmlpurifier_config_load($format)) {
$form['htmlpurifier']['notice'] = array(
'#type' => 'markup',
'#value' => t('<div>Configuration function <code>!function()</code> is already defined. To edit HTML Purifier\'s configuration, edit the corresponding configuration file, which is usually <code>htmlpurifier/config/!format.php</code>. To restore the web configuration form, delete or rename this file.</div>', array(
'!function' => $config_function,
'!format' => $format,
)),
);
}
else {
if ($delta == 0) {
$title = t('Configure HTML Purifier');
$allowed = array(
'URI.DisableExternalResources',
'URI.DisableResources',
'URI.Munge',
'Attr.EnableID',
'HTML.Allowed',
'HTML.ForbiddenElements',
'HTML.ForbiddenAttributes',
'HTML.SafeObject',
'Output.FlashCompat',
'AutoFormat.RemoveEmpty',
'AutoFormat.Linkify',
'AutoFormat.AutoParagraph',
);
}
else {
$title = t('Advanced configuration options');
$allowed = TRUE;
$form['htmlpurifier']["htmlpurifier_doublecache"] = array(
'#type' => 'checkbox',
'#title' => t('Allow double caching'),
'#default_value' => variable_get("htmlpurifier_doublecache", FALSE),
'#description' => t('If enabled, HTML Purifier will tell filter that its output is cacheable. This is not usually necessary, because HTML Purifier maintains its own cache, but may be helpful if you have later filters that need to be cached. Warning: this applies to ALL filters, not just this one'),
);
}
$intro = '<div class="form-item"><h3>' . $title . '</h3><div class="description">' . t('Please click on a directive name for more information on what it does before enabling or changing anything! Changes will not apply to old entries until you clear the cache (see the dashboard)') . '</div></div>';
$config = _htmlpurifier_get_config($format);
$config_form = new HTMLPurifier_Printer_ConfigForm("htmlpurifier_config_{$format}", 'http://htmlpurifier.org/live/configdoc/plain.html#%s');
$form['htmlpurifier']["htmlpurifier_config_{$format}"] = array(
'#value' => $intro . $config_form
->render($config, $allowed, FALSE),
'#after_build' => array(
'_htmlpurifier_config_hack',
),
);
}
return $form;
}