cms/drupal/sites/all/modules/htmlpurifier/htmlpurifier.admin.inc
changeset 541 e756a8c72c3d
equal deleted inserted replaced
540:07239de796bb 541:e756a8c72c3d
       
     1 <?php
       
     2 
       
     3 /**
       
     4  * @file
       
     5  * Administrative page callbacks for the HTML Purifier module.
       
     6  */
       
     7 
       
     8 /**
       
     9  * Generate a form for configuring overall HTML Purifier settings.
       
    10  *
       
    11  * @ingroup forms
       
    12  * @see htmlpurifier_admin_settings_submit()
       
    13  */
       
    14 function htmlpurifier_admin_settings($form, &$form_state) {
       
    15   $form['htmlpurifier_introduction'] = array(
       
    16     '#markup' => t('<p>This page contains global settings for all HTML Purifier enabled filters.  If you are looking for specific filter configuration options, check <a href="@format">the format configurations page</a> and select the specific format you would like to configure.</p>', array('@filter' => url('admin/config/content/formats'))),
       
    17   );
       
    18   $form['htmlpurifier_clear_cache'] = array(
       
    19     '#type' => 'submit',
       
    20     '#value' => t('Clear cache (Warning: Can result in performance degradation)'),
       
    21     '#submit' => array('_htmlpurifier_clear_cache')
       
    22   );
       
    23 
       
    24   $form = system_settings_form($form);
       
    25   $form['#submit'][] = 'htmlpurifier_admin_settings_submit';
       
    26   return $form;
       
    27 }
       
    28 
       
    29 /**
       
    30  * Submit handler for the HTML Purifier settings form.
       
    31  */
       
    32 function htmlpurifier_admin_settings_submit($form, &$form_state) {
       
    33   // Resave all text formats so that the new cache settings for each format are
       
    34   // recorded.
       
    35   // TODO: There should be a better way to do this.
       
    36   foreach (filter_formats() as $format) {
       
    37     $format->filters = filter_list_format($format->format);
       
    38     foreach ($format->filters as &$filter) {
       
    39       $filter = (array) $filter;
       
    40     }
       
    41     filter_format_save($format);
       
    42   }
       
    43 }