From 6f41d692fd407cf63bf3c4f560129cddca054ac9 Mon Sep 17 00:00:00 2001 From: Dries Buytaert <dries@buytaert.net> Date: Thu, 27 Aug 2009 21:18:20 +0000 Subject: [PATCH] - Patch #559658 by sun, dropcube: store filter settings per format, general API clean-up and documentation improvements. --- CHANGELOG.txt | 1 + modules/filter/filter.admin.inc | 85 +++++++----- modules/filter/filter.api.php | 136 ++++++++++++++---- modules/filter/filter.install | 87 +++++++++++- modules/filter/filter.module | 146 ++++++++++++-------- modules/filter/filter.test | 131 +++++++++--------- modules/php/php.install | 1 + modules/php/php.module | 2 +- modules/simpletest/tests/filter_test.module | 6 +- modules/system/system.install | 11 +- 10 files changed, 413 insertions(+), 193 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index fb83e6addf07..ead49ed0ed4f 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -79,6 +79,7 @@ Drupal 7.0, xxxx-xx-xx (development version) contributed date or event modules installed, user time zone settings will fallback to the system time zone and will have to be reconfigured by each user. - Filter system: + * Revamped the filter API and text format storage. * Refactored the HTML corrector to take advantage of PHP 5 features. - Removed ping module: * Contributed modules with similar functionality are available. diff --git a/modules/filter/filter.admin.inc b/modules/filter/filter.admin.inc index 0d7b6de86a82..c81786c40b6f 100644 --- a/modules/filter/filter.admin.inc +++ b/modules/filter/filter.admin.inc @@ -144,7 +144,7 @@ function filter_admin_format_form(&$form_state, $format) { } // Table with filters $filter_info = filter_get_filters(); - $enabled = filter_list_format($format->format); + $filters = filter_list_format($format->format); $form['filters'] = array('#type' => 'fieldset', '#title' => t('Filters'), @@ -155,7 +155,7 @@ function filter_admin_format_form(&$form_state, $format) { $form['filters'][$name] = array( '#type' => 'checkbox', '#title' => $filter['title'], - '#default_value' => isset($enabled[$name]), + '#default_value' => isset($filters[$name]), '#description' => $filter['description'], ); } @@ -201,22 +201,15 @@ function filter_admin_format_form_submit($form, &$form_state) { $format->format = isset($form_state['values']['format']) ? $form_state['values']['format'] : NULL; $status = filter_format_save($format); - // If a new filter was added, return to the main list of filters. - // Otherwise, stay on edit filter page to show new changes. - $return = 'admin/settings/formats'; - switch ($status) { case SAVED_NEW: drupal_set_message(t('Added text format %format.', array('%format' => $format->name))); - $return .= '/' . $format->format; break; + case SAVED_UPDATED: drupal_set_message(t('The text format settings have been updated.')); break; } - - $form_state['redirect'] = $return; - return; } /** @@ -259,7 +252,6 @@ function filter_admin_delete_submit($form, &$form_state) { $form_state['redirect'] = 'admin/settings/formats'; } - /** * Menu callback; display settings defined by a format's filters. */ @@ -269,39 +261,66 @@ function filter_admin_configure_page($format) { } /** - * Build a form to change the settings for a format's filters. + * Build a form to change the settings for filters in a text format. + * + * The form is built by merging the results of 'settings callback' for each + * enabled filter in the given format. * * @ingroup forms */ function filter_admin_configure(&$form_state, $format) { - $list = filter_list_format($format->format); + $filters = filter_list_format($format->format); $filter_info = filter_get_filters(); - $form = array(); - foreach ($list as $name => $filter) { + + $form['#format'] = $format; + foreach ($filters as $name => $filter) { if (isset($filter_info[$name]['settings callback']) && function_exists($filter_info[$name]['settings callback'])) { - $form_module = call_user_func($filter_info[$name]['settings callback'], $format->format); - } - if (isset($form_module) && is_array($form_module)) { - $form = array_merge($form, $form_module); + // Pass along stored filter settings and default settings, but also the + // format object and all filters to allow for complex implementations. + $defaults = (isset($filter_info[$name]['default settings']) ? $filter_info[$name]['default settings'] : array()); + $settings_form = $filter_info[$name]['settings callback']($form_state, $filters[$name], $defaults, $format, $filters); + if (isset($settings_form) && is_array($settings_form)) { + $form['settings'][$name] = array( + '#type' => 'fieldset', + '#title' => check_plain($filter->title), + ); + $form['settings'][$name] += $settings_form; + } } } - if (!empty($form)) { - $form = system_settings_form($form, TRUE); - } - else { + if (empty($form['settings'])) { $form['error'] = array('#markup' => t('No settings are available.')); + return $form; } - $form['format'] = array('#type' => 'hidden', '#value' => $format->format); - $form['#submit'][] = 'filter_admin_configure_submit'; + $form['settings']['#tree'] = TRUE; + $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration')); + return $form; } /** - * Clear the filter's cache when configuration settings are saved. + * Form submit handler for text format filter configuration form. + * + * @see filter_admin_configure() */ function filter_admin_configure_submit($form, &$form_state) { - cache_clear_all($form_state['values']['format'] . ':', 'cache_filter', TRUE); + $format = $form['#format']; + + foreach ($form_state['values']['settings'] as $name => $settings) { + db_update('filter') + ->fields(array( + 'settings' => serialize($settings), + )) + ->condition('format', $format->format) + ->condition('name', $name) + ->execute(); + } + + // Clear the filter's cache when configuration settings are saved. + cache_clear_all($format->format . ':', 'cache_filter', TRUE); + + drupal_set_message(t('The configuration options have been saved.')); } /** @@ -366,10 +385,14 @@ function theme_filter_admin_order($form) { */ function filter_admin_order_submit($form, &$form_state) { foreach ($form_state['values']['weights'] as $name => $weight) { - db_update('filter') - ->fields(array('weight' => $weight)) - ->condition('format', $form_state['values']['format']) - ->condition('name', $name) + db_merge('filter') + ->key(array( + 'format' => $form_state['values']['format'], + 'name' => $name, + )) + ->fields(array( + 'weight' => $weight, + )) ->execute(); } drupal_set_message(t('The filter ordering has been saved.')); diff --git a/modules/filter/filter.api.php b/modules/filter/filter.api.php index fea6178b0a4d..8b5db79ca52d 100644 --- a/modules/filter/filter.api.php +++ b/modules/filter/filter.api.php @@ -14,13 +14,32 @@ /** * Define content filters. * - * Content in Drupal is passed through a group of filters before it is - * output. This lets a module modify content to the site administrator's - * liking. + * Content in Drupal is passed through a group of filters before it is output. + * This lets a module modify content to the site administrator's liking. * - * This hook allows modules to declare input filters they provide. + * This hook allows modules to declare input filters they provide. A module can + * contain as many filters as it wants. * - * A module can contain as many filters as it wants. + * The overall, logical flow is as follows: + * - hook_filter_info() is invoked to retrieve one or more filter definitions. + * - The site administrator enables and configures the filter, where the + * following properties may be used: + * - 'title': The filter's title. + * - 'description': The filter's short-description. + * Additionally, if a filter is configurable: + * - 'settings callback': A form builder function name providing a settings + * form for the filter. + * - 'default settings': An array containing default settings for the filter. + * - When a form containing a text format-enabled text widget/textarea is + * rendered, the following property are checked: + * - 'tips callback': A function name providing filter guidelines to be + * displayed in the text format widget. + * - When a content using a text format is rendered, the following properties + * may be used: + * - 'prepare callback': A name of a function that escapes the to be filtered + * content before the actual filtering happens. + * - 'process callback': The name the function that performs the actual + * filtering. * * Filtering is a two-step process. First, the content is 'prepared' by calling * the 'prepare callback' function for every filter. The purpose of the 'prepare @@ -32,19 +51,22 @@ * necessary, and they can just return the input without changes. * * Filters should not use the 'prepare callback' step for anything other than - * escaping, because that would short-circuits the control the user has over the + * escaping, because that would short-circuit the control the user has over the * order in which filters are applied. * * The second step is the actual processing step. The result from the prepare * step gets passed to all the filters again, this time with the 'process - * callback' function. It's here that filters should perform actual changing of + * callback' function. It's here where filters should perform actual changing of * the content: transforming URLs into hyperlinks, converting smileys into * images, etc. * * An important aspect of the filtering system is 'text formats'. Every text * format is an entire filter setup: which filters to enable, in what order - * and with what settings. Filters that provide settings should usually store - * these settings per format. + * and with what settings. + * + * Filters that require settings should provide the form controls to configure + * the settings in a form builder function, specified in 'settings callback'. + * The filter system stores the settings in the database per text format. * * If the filter's behavior depends on an extensive list and/or external data * (e.g. a list of smileys, a list of glossary terms) then filters are allowed @@ -52,11 +74,59 @@ * per format. In that case, there should be a link from the format-specific * settings to the separate settings page. * + * The $filter object with the current settings is passed to the 'settings + * callback' function. If 'default settings' were defined in hook_filter_info(), + * those are passed as second argument to the 'settings callback'. Each filter + * should apply either the default settings or the configured settings contained + * in $filter->settings. + * + * 'settings callback' is invoked with the following arguments (most filter + * implementations will only need the first 3): + * - &$form_state: The form state of the (entire) configuration form. + * - $filter: The filter object containing settings for the given format. + * - $defaults: The default settings for the filter, as defined in 'default + * settings' in hook_filter_info(). + * - $format: The format object being configured. + * - $filters: Complete list of filter objects that are enabled for the given + * format. + * + * @code + * function mymodule_filter_settings(&$form_state, $filter, $defaults) { + * $form['mymodule_url_length'] = array( + * '#type' => 'textfield', + * '#title' => t('Maximum link text length'), + * '#default_value' => isset($filter->settings['mymodule_url_length']) ? $filter->settings['mymodule_url_length'] : $defaults['mymodule_url_length'], + * ); + * return $form; + * } + * @endcode + * + * 'prepare callback' and 'process callback' are invoked with the following + * arguments: + * - $text: The text to be filtered. + * - $filter: The filter object containing settings for the given format. + * - $format: The format object of the text to be filtered. + * - $langcode: (optional) The language code of the text to be filtered. + * - $cache: Boolean whether check_markup() will cache the filtered $text in + * {cache_filter}. + * - $cache_id: The cache ID used for $text in {cache_filter} when $cache is + * TRUE. + * + * @see check_markup() + * + * 'prepare callback' and 'process callback' functions may access the filter + * settings in $filter->settings['mymodule_url_length']. + * + * 'tips callback' is invoked with the following parameters: + * - $filter: The filter object containing settings for the given format. + * - $format: The format object of the text to be filtered. + * - $long: Boolean whether to return long or short filter guidelines. + * * For performance reasons content is only filtered once; the result is stored - * in the cache table and retrieved the next time the piece of content is - * displayed. If a filter's output is dynamic it can override the cache - * mechanism, but obviously this feature should be used with caution: having one - * filter that doesn't support caching in a particular text format disables + * in the cache table and retrieved from the cache the next time the same piece + * of content is displayed. If a filter's output is dynamic, it can override the + * cache mechanism, but obviously this should be used with caution: having one + * filter that does not support caching in a particular text format disables * caching for the entire format, not just for one filter. * * Beware of the filter cache when developing your module: it is advised to set @@ -68,21 +138,25 @@ * An array of filter items. Each filter item has a unique name, prefixed * with the name of the module that provides it. The item is an associative * array that may contain the following key-value pairs: - * - 'title': Required. The title of the filter. - * - 'description': Short description of what this filter does. - * - 'prepare callback': The callback function to call in the 'prepare' step + * - 'title': (required) The administrative title of the filter. + * - 'description': A short, administrative description of what this filter + * does. + * - 'prepare callback': A callback function to call in the 'prepare' step * of the filtering. - * - 'process callback': Required. The callback function to call in the + * - 'process callback': (required) The callback function to call in the * 'process' step of the filtering. - * - 'settings callback': The callback function that provides form controls - * for the filter's settings. These settings are stored with variable_set() - * when the form is submitted. Remember to use the $format identifier in the - * variable and control names to store settings per text format (e.g. - * 'mymodule_setting_$format'). - * - 'tips callback': The callback function that provide tips for using - * filters. A module's tips should be informative and to the point. Short + * - 'settings callback': A callback function that provides form controls + * for the filter's settings. Each filter should apply either the default + * settings or the configured settings contained in $filter->settings. The + * user submitted values are stored in the database. + * - 'default settings': An array containing default settings for a filter to + * be applied when the filter has not been configured yet. + * - 'tips callback': A callback function that provides tips for using the + * filter. A module's tips should be informative and to the point. Short * tips are preferably one-liners. - * - 'cache': Specify if the filter result can be cached. TRUE by default. + * - 'cache': Specifies whether the filtered text can be cached. TRUE by + * default. Note that defining FALSE makes the entire text format not + * cacheable, which may have an impact on the site's overall performance. * * For a detailed usage example, see filter_example.module. For an example of * using multiple filters in one module, see filter_filter_info(). @@ -93,6 +167,11 @@ function hook_filter_info() { 'description' => t('Allows you to restrict the HTML tags the user can use. It will also remove harmful content such as JavaScript events, JavaScript URLs and CSS styles from those tags that are not removed.'), 'process callback' => '_filter_html', 'settings callback' => '_filter_html_settings', + 'default settings' => array( + 'allowed_html' => '<a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>', + 'filter_html_help' => 1, + 'filter_html_nofollow' => 0, + ), 'tips callback' => '_filter_html_tips', ); $filters['filter_autop'] = array( @@ -115,6 +194,11 @@ function hook_filter_info_alter(&$info) { // Replace the PHP evaluator process callback with an improved // PHP evaluator provided by a module. $info['php_code']['process callback'] = 'my_module_php_evaluator'; + + // Alter the default settings of the URL filter provided by core. + $info['filter_url']['default settings'] = array( + 'filter_url_length' => 100, + ); } /** @@ -145,7 +229,7 @@ function hook_filter_format_insert($format) { */ function hook_filter_format_update($format) { mymodule_cache_rebuild(); -} +} /** * Perform actions when a text format has been deleted. diff --git a/modules/filter/filter.install b/modules/filter/filter.install index 78ca255aec45..f31db4bdeac9 100644 --- a/modules/filter/filter.install +++ b/modules/filter/filter.install @@ -13,11 +13,6 @@ function filter_schema() { $schema['filter'] = array( 'description' => 'Table that maps filters (HTML corrector) to text formats (Filtered HTML).', 'fields' => array( - 'fid' => array( - 'type' => 'serial', - 'not null' => TRUE, - 'description' => 'Primary Key: Auto-incrementing filter ID.', - ), 'format' => array( 'type' => 'int', 'not null' => TRUE, @@ -44,9 +39,22 @@ function filter_schema() { 'default' => 0, 'size' => 'tiny', 'description' => 'Weight of filter within format.', - ) + ), + 'status' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + 'description' => 'Filter enabled status. (1 = enabled, 0 = disabled)', + ), + 'settings' => array( + 'type' => 'text', + 'not null' => FALSE, + 'size' => 'big', + 'serialize' => TRUE, + 'description' => 'A serialized array of name value pairs that store the filter settings for the specific format.', + ), ), - 'primary key' => array('fid'), + 'primary key' => array('format', 'name'), 'unique keys' => array( 'fmn' => array('format', 'module', 'name'), ), @@ -187,3 +195,68 @@ function filter_update_7003() { return $ret; } +/** + * Move filter settings storage into {filter} table. + * + * - Remove {filter}.fid. + * - Add (format, name) as primary key for {filter}. + * - Add {filter}.status. + * - Add {filter}.settings. + */ +function filter_update_7004() { + $ret = array(); + db_drop_field($ret, 'filter', 'fid'); + db_add_primary_key($ret, 'filter', array('format', 'name')); + db_add_field($ret, 'filter', 'status', + array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + 'description' => 'Filter enabled status. (1 = enabled, 0 = disabled)', + ) + ); + db_add_field($ret, 'filter', 'settings', + array( + 'type' => 'text', + 'not null' => FALSE, + 'size' => 'big', + 'serialize' => TRUE, + 'description' => 'A serialized array of name value pairs that store the filter settings for the specific format.', + ) + ); + + // Enable all existing filters ({filter} contained only enabled previously). + $ret[] = update_sql("UPDATE {filter} SET status = 1"); + + // Move filter settings from system variables into {filter}.settings. + $filters = db_query("SELECT * FROM {filter} WHERE module = :name", array(':name' => 'filter')); + foreach ($filters as $filter) { + $settings = array(); + if ($filter->name == 'filter_html') { + if ($setting = variable_get("allowed_html_{$filter->format}", NULL)) { + $settings['allowed_html'] = $setting; + variable_del("allowed_html_{$filter->format}"); + } + if ($setting = variable_get("filter_html_help_{$filter->format}", NULL)) { + $settings['filter_html_help'] = $setting; + variable_del("filter_html_help_{$filter->format}"); + } + if ($setting = variable_get("filter_html_nofollow_{$filter->format}", NULL)) { + $settings['filter_html_nofollow'] = $setting; + variable_del("filter_html_nofollow_{$filter->format}"); + } + } + elseif ($filter->name == 'filter_url') { + if ($setting = variable_get("filter_url_length_{$filter->format}", NULL)) { + $settings['filter_url_length'] = $setting; + variable_del("filter_url_length_{$filter->format}"); + } + } + if (!empty($settings)) { + $ret[] = update_sql("UPDATE {filter} SET settings = '" . serialize($settings) . "' WHERE format = {$filter->format} AND name = '{$filter->name}'"); + } + } + + return $ret; +} + diff --git a/modules/filter/filter.module b/modules/filter/filter.module index 71df8fcaa164..345911f31652 100644 --- a/modules/filter/filter.module +++ b/modules/filter/filter.module @@ -140,8 +140,17 @@ function filter_menu() { return $items; } -function filter_format_load($arg) { - return filter_formats($arg); +/** + * Load a text format object from the database. + * + * @param $format + * The format ID. + * + * @return + * A fully-populated text format object. + */ +function filter_format_load($format) { + return filter_formats($format); } /** @@ -155,45 +164,47 @@ function filter_format_save($format) { // We should always set all roles to TRUE when saving the default format. // We use leading and trailing comma's to allow easy substring matching. $roles = array_filter($format->roles); - if ($format->format == variable_get('filter_default_format', 1)) { + if (!empty($format->format) && $format->format == variable_get('filter_default_format', 1)) { $roles = ',' . implode(',', array_keys(user_roles())) . ','; } else { - $roles = ',' . implode(',',array_keys($roles)) . ','; + $roles = ',' . implode(',', array_keys($roles)) . ','; } $format->roles = $roles; $format->name = trim($format->name); // Add a new text format. if (empty($format->format)) { - $status = drupal_write_record('filter_format', $format); + $return = drupal_write_record('filter_format', $format); } else { - $status = drupal_write_record('filter_format', $format, 'format'); + $return = drupal_write_record('filter_format', $format, 'format'); } - db_delete('filter') - ->condition('format', $format->format) - ->execute(); - // Get the filters currently active in the format, to add new filters // to the bottom. $current = filter_list_format($format->format); - $query = db_insert('filter')->fields(array('format', 'name', 'weight')); $filters = $format->filters; - foreach (array_keys(array_filter($filters)) as $name) { + foreach ($filters as $name => $status) { + $fields = array(); // Add new filters to the bottom. - $weight = isset($current[$name]->weight) ? $current[$name]->weight : 10; - $query->values(array( - 'format' => $format->format, - 'name' => $name, - 'weight' => $weight, - )); + $fields['weight'] = isset($current[$name]->weight) ? $current[$name]->weight : 10; + $fields['status'] = $status; + // Only update settings if there are any. + if (!empty($format->settings[$name])) { + $fields['settings'] = serialize($format->settings[$name]); + } + db_merge('filter') + ->key(array( + 'format' => $format->format, + 'name' => $name, + )) + ->fields($fields) + ->execute(); } - $query->execute(); - if ($status == SAVED_NEW) { + if ($return == SAVED_NEW) { module_invoke_all('filter_format_insert', $format); } else { @@ -202,7 +213,7 @@ function filter_format_save($format) { cache_clear_all($format->format . ':', 'cache_filter', TRUE); - return $status; + return $return; } /** @@ -259,12 +270,12 @@ function filter_cron() { * @{ * Filters implemented by the filter.module. */ -function _filter_html_tips($format, $long = FALSE) { +function _filter_html_tips($filter, $format, $long = FALSE) { global $base_url; - if ($allowed_html = variable_get("allowed_html_$format", '<a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>')) { + if ($allowed_html = $filter->settings['allowed_html']) { if ($long) { $output = '<p>' . t('Allowed HTML tags: @tags', array('@tags' => $allowed_html)) . '</p>'; - if (!variable_get("filter_html_help_$format", 1)) { + if (!$filter->settings['filter_html_help']) { return $output; } @@ -355,7 +366,7 @@ function _filter_html_tips($format, $long = FALSE) { } } -function _filter_autop_tips($format, $long = FALSE) { +function _filter_autop_tips($filter, $format, $long = FALSE) { if ($long) { return t('Lines and paragraphs are automatically recognized. The <br /> line break, <p> paragraph and </p> close paragraph tags are inserted automatically. If paragraphs are not recognized simply add a couple blank lines.'); } @@ -364,11 +375,11 @@ function _filter_autop_tips($format, $long = FALSE) { } } -function _filter_url_tips() { +function _filter_url_tips($filter, $format, $long = FALSE) { return t('Web page addresses and e-mail addresses turn into links automatically.'); } -function _filter_html_escape_tips() { +function _filter_html_escape_tips($filter, $format, $long = FALSE) { return t('No HTML tags allowed.'); } @@ -462,6 +473,11 @@ function filter_format_allowcache($format) { /** * Retrieve a list of filters for a certain format. + * + * @param $format + * The format ID. + * @return + * An array of filter objects assosiated to the given format. */ function filter_list_format($format) { static $filters = array(); @@ -469,10 +485,28 @@ function filter_list_format($format) { if (!isset($filters[$format])) { $filters[$format] = array(); - $result = db_query("SELECT * FROM {filter} WHERE format = :format ORDER BY weight, module, name", array(':format' => (int) $format)); + $result = db_select('filter', 'filter') + ->fields('filter') + ->condition('format', $format) + ->condition('status', 1) + ->orderBy('weight') + ->orderBy('module') + ->orderBy('name') + ->execute(); foreach ($result as $filter) { if (isset($filter_info[$filter->name])) { $filter->title = $filter_info[$filter->name]['title']; + // Unpack stored filter settings. + if (isset($filter->settings)) { + $filter->settings = unserialize($filter->settings); + } + else { + $filter->settings = array(); + } + // Apply default filter settings. + if (isset($filter_info[$filter->name]['default settings'])) { + $filter->settings = array_merge($filter_info[$filter->name]['default settings'], $filter->settings); + } $filters[$format][$filter->name] = $filter; } } @@ -533,14 +567,14 @@ function check_markup($text, $format = FILTER_FORMAT_DEFAULT, $langcode = '', $c // Give filters the chance to escape HTML-like data such as code or formulas. foreach ($filters as $name => $filter) { if (isset($filter_info[$name]['prepare callback']) && function_exists($filter_info[$name]['prepare callback'])) { - $text = call_user_func($filter_info[$name]['prepare callback'], $text, $format, $langcode, $cache_id); + $text = $filter_info[$name]['prepare callback']($text, $filter, $format, $langcode, $cache, $cache_id); } } // Perform filtering. foreach ($filters as $name => $filter) { if (isset($filter_info[$name]['process callback']) && function_exists($filter_info[$name]['process callback'])) { - $text = call_user_func($filter_info[$name]['process callback'], $text, $format, $langcode, $cache_id); + $text = $filter_info[$name]['process callback']($text, $filter, $format, $langcode, $cache, $cache_id); } } @@ -647,8 +681,8 @@ function _filter_tips($format, $long = FALSE) { $tips[$format->name] = array(); foreach ($filters as $name => $filter) { if (isset($filter_info[$name]['tips callback']) && function_exists($filter_info[$name]['tips callback'])) { - $tip = call_user_func($filter_info[$name]['tips callback'],$format->format, $long); - $tips[$format->name][] = array('tip' => $tip, 'id' => $name); + $tip = $filter_info[$name]['tips callback']($filter, $format, $long); + $tips[$format->name][$name] = array('tip' => $tip, 'id' => $name); } } } @@ -735,6 +769,11 @@ function filter_filter_info() { 'description' => t('Allows you to restrict the HTML tags the user can use. It will also remove harmful content such as JavaScript events, JavaScript URLs and CSS styles from those tags that are not removed.'), 'process callback' => '_filter_html', 'settings callback' => '_filter_html_settings', + 'default settings' => array( + 'allowed_html' => '<a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>', + 'filter_html_help' => 1, + 'filter_html_nofollow' => 0, + ), 'tips callback' => '_filter_html_tips', ); $filters['filter_autop'] = array( @@ -748,6 +787,9 @@ function filter_filter_info() { 'description' => t('Turns web and e-mail addresses into clickable links.'), 'process callback' => '_filter_url', 'settings callback' => '_filter_url_settings', + 'default settings' => array( + 'filter_url_length' => 72, + ), 'tips callback' => '_filter_url_tips', ); $filters['filter_htmlcorrector'] = array( @@ -767,30 +809,25 @@ function filter_filter_info() { /** * Settings callback for the HTML filter. */ -function _filter_html_settings($format) { - $form['filter_html'] = array( - '#type' => 'fieldset', - '#title' => t('HTML filter'), - '#collapsible' => TRUE, - ); - $form['filter_html']["allowed_html_$format"] = array( +function _filter_html_settings(&$form_state, $filter, $defaults) { + $form['allowed_html'] = array( '#type' => 'textfield', '#title' => t('Allowed HTML tags'), - '#default_value' => variable_get("allowed_html_$format", '<a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>'), + '#default_value' => isset($filter->settings['allowed_html']) ? $filter->settings['allowed_html'] : $defaults['allowed_html'], '#size' => 64, '#maxlength' => 1024, '#description' => t('Specify a list of tags which should not be stripped. (Note that JavaScript event attributes are always stripped.)'), ); - $form['filter_html']["filter_html_help_$format"] = array( + $form['filter_html_help'] = array( '#type' => 'checkbox', '#title' => t('Display HTML help'), - '#default_value' => variable_get("filter_html_help_$format", 1), + '#default_value' => isset($filter->settings['filter_html_help']) ? $filter->settings['filter_html_help'] : $defaults['filter_html_help'], '#description' => t('If enabled, Drupal will display some basic HTML help in the long filter tips.'), ); - $form['filter_html']["filter_html_nofollow_$format"] = array( + $form['filter_html_nofollow'] = array( '#type' => 'checkbox', '#title' => t('Spam link deterrent'), - '#default_value' => variable_get("filter_html_nofollow_$format", FALSE), + '#default_value' => isset($filter->settings['filter_html_nofollow']) ? $filter->settings['filter_html_nofollow'] : $defaults['filter_html_nofollow'], '#description' => t('If enabled, Drupal will add rel="nofollow" to all links, as a measure to reduce the effectiveness of spam links. Note: this will also prevent valid links from being followed by search engines, therefore it is likely most effective when enabled for anonymous users.'), ); return $form; @@ -799,11 +836,11 @@ function _filter_html_settings($format) { /** * HTML filter. Provides filtering of input into accepted HTML. */ -function _filter_html($text, $format) { - $allowed_tags = preg_split('/\s+|<|>/', variable_get("allowed_html_$format", '<a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>'), -1, PREG_SPLIT_NO_EMPTY); +function _filter_html($text, $filter) { + $allowed_tags = preg_split('/\s+|<|>/', $filter->settings['allowed_html'], -1, PREG_SPLIT_NO_EMPTY); $text = filter_xss($text, $allowed_tags); - if (variable_get("filter_html_nofollow_$format", FALSE)) { + if ($filter->settings['filter_html_nofollow']) { $html_dom = filter_dom_load($text); $links = $html_dom->getElementsByTagName('a'); foreach($links as $link) { @@ -818,16 +855,11 @@ function _filter_html($text, $format) { /** * Settings callback for URL filter. */ -function _filter_url_settings($format) { - $form['filter_urlfilter'] = array( - '#type' => 'fieldset', - '#title' => t('URL filter'), - '#collapsible' => TRUE, - ); - $form['filter_urlfilter']['filter_url_length_' . $format] = array( +function _filter_url_settings(&$form_state, $filter, $defaults) { + $form['filter_url_length'] = array( '#type' => 'textfield', '#title' => t('Maximum link text length'), - '#default_value' => variable_get('filter_url_length_' . $format, 72), + '#default_value' => isset($filter->settings['filter_url_length']) ? $filter->settings['filter_url_length'] : $defaults['filter_url_length'], '#maxlength' => 4, '#description' => t('URLs longer than this number of characters will be truncated to prevent long strings that break formatting. The link itself will be retained; just the text portion of the link will be truncated.'), ); @@ -838,9 +870,9 @@ function _filter_url_settings($format) { * URL filter. Automatically converts text web addresses (URLs, e-mail addresses, * ftp links, etc.) into hyperlinks. */ -function _filter_url($text, $format) { +function _filter_url($text, $filter) { // Pass length to regexp callback - _filter_url_trim(NULL, variable_get('filter_url_length_' . $format, 72)); + _filter_url_trim(NULL, $filter->settings['filter_url_length']); $text = ' ' . $text . ' '; diff --git a/modules/filter/filter.test b/modules/filter/filter.test index 2b49a32c47ff..3e1c713036f8 100644 --- a/modules/filter/filter.test +++ b/modules/filter/filter.test @@ -17,7 +17,7 @@ class FilterAdminTestCase extends DrupalWebTestCase { // URL filter. $first_filter = 'filter_url'; // Line filter. - $second_filter = 'filter_autop'; + $second_filter = 'filter_autop'; // Create users. $admin_user = $this->drupalCreateUser(array('administer filters')); @@ -36,11 +36,11 @@ class FilterAdminTestCase extends DrupalWebTestCase { // Add an additional tag. $edit = array(); - $edit['allowed_html_1'] = '<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <quote>'; + $edit['settings[filter_html][allowed_html]'] = '<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <quote>'; $this->drupalPost('admin/settings/formats/' . $filtered . '/configure', $edit, t('Save configuration')); $this->assertText(t('The configuration options have been saved.'), t('Allowed HTML tag added.')); - $this->assertRaw(htmlentities($edit['allowed_html_1']), t('Tag displayed.')); + $this->assertRaw(htmlentities($edit['settings[filter_html][allowed_html]']), t('Tag displayed.')); $result = db_query('SELECT * FROM {cache_filter}')->fetchObject(); $this->assertFalse($result, t('Cache cleared.')); @@ -64,7 +64,7 @@ class FilterAdminTestCase extends DrupalWebTestCase { // Add filter. $edit = array(); $edit['name'] = $this->randomName(); - $edit['roles[2]'] = TRUE; + $edit['roles[2]'] = 1; $edit['filters[' . $second_filter . ']'] = TRUE; $edit['filters[' . $first_filter . ']'] = TRUE; $this->drupalPost('admin/settings/formats/add', $edit, t('Save configuration')); @@ -93,7 +93,8 @@ class FilterAdminTestCase extends DrupalWebTestCase { // Allow authenticated users on full HTML. $edit = array(); - $edit['roles[2]'] = TRUE; + $edit['roles[1]'] = 0; + $edit['roles[2]'] = 1; $this->drupalPost('admin/settings/formats/' . $full, $edit, t('Save configuration')); $this->assertText(t('The text format settings have been updated.'), t('Full HTML format successfully updated.')); @@ -129,7 +130,7 @@ class FilterAdminTestCase extends DrupalWebTestCase { // Clean up. // Allowed tags. $edit = array(); - $edit['allowed_html_1'] = '<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>'; + $edit['settings[filter_html][allowed_html]'] = '<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>'; $this->drupalPost('admin/settings/formats/' . $filtered . '/configure', $edit, t('Save configuration')); $this->assertText(t('The configuration options have been saved.'), t('Changes reverted.')); @@ -186,9 +187,7 @@ class FilterAdminTestCase extends DrupalWebTestCase { /** * Unit tests for core filters. */ -class FilterUnitTest extends DrupalWebTestCase { - protected $format; - +class FilterUnitTestCase extends DrupalWebTestCase { public static function getInfo() { return array( 'name' => 'Core filters', @@ -422,35 +421,41 @@ class FilterUnitTest extends DrupalWebTestCase { * or better a whitelist approach should be used for that too. */ function testFilter() { - $format = 'fake_format'; + // Setup dummy filter object. + $filter = new stdClass; + $filter->settings = array( + 'allowed_html' => '<a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>', + 'filter_html_help' => 1, + 'filter_html_nofollow' => 0, + ); // HTML filter is not able to secure some tags, these should never be // allowed. - $f = _filter_html('<script />', $format); + $f = _filter_html('<script />', $filter); $this->assertNoNormalized($f, 'script', t('HTML filter should always remove script tags.')); - $f = _filter_html('<iframe />', $format); + $f = _filter_html('<iframe />', $filter); $this->assertNoNormalized($f, 'iframe', t('HTML filter should always remove iframe tags.')); - $f = _filter_html('<object />', $format); + $f = _filter_html('<object />', $filter); $this->assertNoNormalized($f, 'object', t('HTML filter should always remove object tags.')); - $f = _filter_html('<style />', $format); + $f = _filter_html('<style />', $filter); $this->assertNoNormalized($f, 'style', t('HTML filter should always remove style tags.')); // Some tags make CSRF attacks easier, let the user take the risk herself. - $f = _filter_html('<img />', $format); + $f = _filter_html('<img />', $filter); $this->assertNoNormalized($f, 'img', t('HTML filter should remove img tags on default.')); - $f = _filter_html('<input />', $format); + $f = _filter_html('<input />', $filter); $this->assertNoNormalized($f, 'img', t('HTML filter should remove input tags on default.')); // Filtering content of some attributes is infeasible, these shouldn't be // allowed too. - $f = _filter_html('<p style="display: none;" />', $format); + $f = _filter_html('<p style="display: none;" />', $filter); $this->assertNoNormalized($f, 'style', t('HTML filter should remove style attribute on default.')); - $f = _filter_html('<p onerror="alert(0);" />', $format); + $f = _filter_html('<p onerror="alert(0);" />', $filter); $this->assertNoNormalized($f, 'onerror', t('HTML filter should remove on* attributes on default.')); } @@ -458,26 +463,32 @@ class FilterUnitTest extends DrupalWebTestCase { * Test the spam deterrent. */ function testNoFollowFilter() { - variable_set('filter_html_nofollow_f', TRUE); + // Setup dummy filter object. + $filter = new stdClass; + $filter->settings = array( + 'allowed_html' => '<a>', + 'filter_html_help' => 1, + 'filter_html_nofollow' => 1, + ); // Test if the rel="nofollow" attribute is added, even if we try to prevent // it. - $f = _filter_html('<a href="http://www.example.com/">text</a>', 'f'); + $f = _filter_html('<a href="http://www.example.com/">text</a>', $filter); $this->assertNormalized($f, 'rel="nofollow"', t('Spam deterrent -- no evasion.')); - $f = _filter_html('<A href="http://www.example.com/">text</a>', 'f'); + $f = _filter_html('<A href="http://www.example.com/">text</a>', $filter); $this->assertNormalized($f, 'rel="nofollow"', t('Spam deterrent evasion -- capital A.')); - $f = _filter_html("<a/href=\"http://www.example.com/\">text</a>", 'f'); + $f = _filter_html("<a/href=\"http://www.example.com/\">text</a>", $filter); $this->assertNormalized($f, 'rel="nofollow"', t('Spam deterrent evasion -- non whitespace character after tag name.')); - $f = _filter_html("<\0a\0 href=\"http://www.example.com/\">text</a>", 'f'); + $f = _filter_html("<\0a\0 href=\"http://www.example.com/\">text</a>", $filter); $this->assertNormalized($f, 'rel="nofollow"', t('Spam deterrent evasion -- some nulls.')); - $f = _filter_html('<!--[if true]><a href="http://www.example.com/">text</a><![endif]-->', 'f'); + $f = _filter_html('<!--[if true]><a href="http://www.example.com/">text</a><![endif]-->', $filter); $this->assertNormalized($f, 'rel="nofollow"', t('Spam deterrent evasion -- link within a comment.')); - $f = _filter_html('<a href="http://www.example.com/" rel="follow">text</a>', 'f'); + $f = _filter_html('<a href="http://www.example.com/" rel="follow">text</a>', $filter); $this->assertNoNormalized($f, 'rel="follow"', t('Spam deterrent evasion -- with rel set - rel="follow" removed.')); $this->assertNormalized($f, 'rel="nofollow"', t('Spam deterrent evasion -- with rel set - rel="nofollow" added.')); } @@ -521,76 +532,80 @@ class FilterUnitTest extends DrupalWebTestCase { * Test the URL filter. */ function testUrlFilter() { - variable_set('filter_url_length_f', 496); + // Setup dummy filter object. + $filter = new stdClass; + $filter->settings = array( + 'filter_url_length' => 496, + ); // Converting URLs. - $f = _filter_url('http://www.example.com/', 'f'); + $f = _filter_url('http://www.example.com/', $filter); $this->assertEqual($f, '<a href="http://www.example.com/" title="http://www.example.com/">http://www.example.com/</a>', t('Converting URLs.')); - $f = _filter_url('http://www.example.com/?a=1&b=2', 'f'); + $f = _filter_url('http://www.example.com/?a=1&b=2', $filter); $this->assertEqual($f, '<a href="http://www.example.com/?a=1&b=2" title="http://www.example.com/?a=1&b=2">http://www.example.com/?a=1&b=2</a>', t('Converting URLs -- ampersands.')); - $f = _filter_url('ftp://user:pass@ftp.example.com/dir1/dir2', 'f'); + $f = _filter_url('ftp://user:pass@ftp.example.com/dir1/dir2', $filter); $this->assertEqual($f, '<a href="ftp://user:pass@ftp.example.com/dir1/dir2" title="ftp://user:pass@ftp.example.com/dir1/dir2">ftp://user:pass@ftp.example.com/dir1/dir2</a>', t('Converting URLs -- FTP scheme.')); // Converting domain names. - $f = _filter_url('www.example.com', 'f'); + $f = _filter_url('www.example.com', $filter); $this->assertEqual($f, '<a href="http://www.example.com" title="www.example.com">www.example.com</a>', t('Converting domain names.')); - $f = _filter_url('<li>www.example.com</li>', 'f'); + $f = _filter_url('<li>www.example.com</li>', $filter); $this->assertEqual($f, '<li><a href="http://www.example.com" title="www.example.com">www.example.com</a></li>', t('Converting domain names -- domain in a list.')); - $f = _filter_url('(www.example.com/dir?a=1&b=2#a)', 'f'); + $f = _filter_url('(www.example.com/dir?a=1&b=2#a)', $filter); $this->assertEqual($f, '(<a href="http://www.example.com/dir?a=1&b=2#a" title="www.example.com/dir?a=1&b=2#a">www.example.com/dir?a=1&b=2#a</a>)', t('Converting domain names -- domain in parentheses.')); // Converting e-mail addresses. - $f = _filter_url('johndoe@example.com', 'f'); + $f = _filter_url('johndoe@example.com', $filter); $this->assertEqual($f, '<a href="mailto:johndoe@example.com">johndoe@example.com</a>', t('Converting e-mail addresses.')); - $f = _filter_url('aaa@sub.tv', 'f'); + $f = _filter_url('aaa@sub.tv', $filter); $this->assertEqual($f, '<a href="mailto:aaa@sub.tv">aaa@sub.tv</a>', t('Converting e-mail addresses -- a short e-mail from Tuvalu.')); // URL trimming. - variable_set('filter_url_length_f', 28); + $filter->settings['filter_url_length'] = 28; - $f = _filter_url('http://www.example.com/d/ff.ext?a=1&b=2#a1', 'f'); + $f = _filter_url('http://www.example.com/d/ff.ext?a=1&b=2#a1', $filter); $this->assertNormalized($f, 'http://www.example.com/d/ff....', t('URL trimming.')); // Not breaking existing links. - $f = _filter_url('<a href="http://www.example.com">www.example.com</a>', 'f'); + $f = _filter_url('<a href="http://www.example.com">www.example.com</a>', $filter); $this->assertEqual($f, '<a href="http://www.example.com">www.example.com</a>', t('Converting URLs -- do not break existing links.')); - $f = _filter_url('<a href="foo">http://www.example.com</a>', 'f'); + $f = _filter_url('<a href="foo">http://www.example.com</a>', $filter); $this->assertEqual($f, '<a href="foo">http://www.example.com</a>', t('Converting URLs -- do not break existing, relative links.')); // Addresses within some tags such as code or script should not be converted. - $f = _filter_url('<code>http://www.example.com</code>', 'f'); + $f = _filter_url('<code>http://www.example.com</code>', $filter); $this->assertEqual($f, '<code>http://www.example.com</code>', t('Converting URLs -- skip code contents.')); - $f = _filter_url('<code><em>http://www.example.com</em></code>', 'f'); + $f = _filter_url('<code><em>http://www.example.com</em></code>', $filter); $this->assertEqual($f, '<code><em>http://www.example.com</em></code>', t('Converting URLs -- really skip code contents.')); - $f = _filter_url('<script>http://www.example.com</script>', 'f'); + $f = _filter_url('<script>http://www.example.com</script>', $filter); $this->assertEqual($f, '<script>http://www.example.com</script>', t('Converting URLs -- do not process scripts.')); // Addresses in attributes should not be converted. - $f = _filter_url('<p xmlns="http://www.example.com" />', 'f'); + $f = _filter_url('<p xmlns="http://www.example.com" />', $filter); $this->assertEqual($f, '<p xmlns="http://www.example.com" />', t('Converting URLs -- do not convert addresses in attributes.')); - $f = _filter_url('<a title="Go to www.example.com" href="http://www.example.com">text</a>', 'f'); + $f = _filter_url('<a title="Go to www.example.com" href="http://www.example.com">text</a>', $filter); $this->assertEqual($f, '<a title="Go to www.example.com" href="http://www.example.com">text</a>', t('Converting URLs -- do not break existing links with custom title attribute.')); // Even though a dot at the end of a URL can indicate a fully qualified // domain name, such usage is rare compared to using a link at the end // of a sentence, so remove the dot from the link. // @todo It can also be used at the end of a filename or a query string. - $f = _filter_url('www.example.com.', 'f'); + $f = _filter_url('www.example.com.', $filter); $this->assertEqual($f, '<a href="http://www.example.com" title="www.example.com">www.example.com</a>.', t('Converting URLs -- do not recognize a dot at the end of a domain name (FQDNs).')); - $f = _filter_url('http://www.example.com.', 'f'); + $f = _filter_url('http://www.example.com.', $filter); $this->assertEqual($f, '<a href="http://www.example.com" title="http://www.example.com">http://www.example.com</a>.', t('Converting URLs -- do not recognize a dot at the end of an URL (FQDNs).')); - $f = _filter_url('www.example.com/index.php?a=.', 'f'); + $f = _filter_url('www.example.com/index.php?a=.', $filter); $this->assertEqual($f, '<a href="http://www.example.com/index.php?a=" title="www.example.com/index.php?a=">www.example.com/index.php?a=</a>.', t('Converting URLs -- do forget about a dot at the end of a query string.')); } @@ -682,22 +697,6 @@ class FilterUnitTest extends DrupalWebTestCase { $this->assertEqual($f, '<p>دروبال</p>', t('HTML corrector -- Encoding is correctly kept.')); } - function createFormat($filter) { - $edit = array( - 'name' => $this->randomName(), - 'roles[2]' => TRUE, - 'filters[filter/' . $filter . ']' => TRUE, - ); - $this->drupalPost('admin/settings/filter/add', $edit, t('Save configuration')); - return db_query("SELECT * FROM {filter_format} WHERE name = :name", array(':name' => $edit['name']))->fetchObject(); - } - - function deleteFormat($format) { - if ($format !== NULL) { - $this->drupalPost('admin/settings/formats/' . $format->format . '/delete', array(), t('Delete')); - } - } - /** * Asserts that a text transformed to lowercase with HTML entities decoded does contains a given string. * @@ -751,7 +750,7 @@ class FilterUnitTest extends DrupalWebTestCase { * Tests for filter hook invocation. */ class FilterHooksTestCase extends DrupalWebTestCase { - function getInfo() { + public static function getInfo() { return array( 'name' => 'Filter format hooks', 'description' => 'Test hooks for text formats insert/update/delete.', @@ -776,7 +775,7 @@ class FilterHooksTestCase extends DrupalWebTestCase { $edit['roles[1]'] = 1; $this->drupalPost('admin/settings/formats/add', $edit, t('Save configuration')); $this->assertRaw(t('Added text format %format.', array('%format' => $name)), t('New format created.')); - $this->assertText(t('hook_filter_format_insert invoked.'), t('hook_filter_format_insert invoked.')); + $this->assertText('hook_filter_format_insert invoked.', t('hook_filter_format_insert was invoked.')); $format = db_query("SELECT format FROM {filter_format} WHERE name = :name", array(':name' => $name))->fetchField(); @@ -785,7 +784,7 @@ class FilterHooksTestCase extends DrupalWebTestCase { $edit['roles[2]'] = 1; $this->drupalPost('admin/settings/formats/' . $format, $edit, t('Save configuration')); $this->assertRaw(t('The text format settings have been updated.'), t('Full HTML format successfully updated.')); - $this->assertText(t('hook_filter_format_update invoked.'), t('hook_filter_format_update() was invoked.')); + $this->assertText('hook_filter_format_update invoked.', t('hook_filter_format_update() was invoked.')); // Add a new custom block. $box = array(); @@ -804,7 +803,7 @@ class FilterHooksTestCase extends DrupalWebTestCase { // Delete the text format. $this->drupalPost('admin/settings/formats/' . $format . '/delete', array(), t('Delete')); $this->assertRaw(t('Deleted text format %format.', array('%format' => $name)), t('Format successfully deleted.')); - $this->assertText(t('hook_filter_format_delete invoked.'), t('hook_filter_format_delete() was invoked.')); + $this->assertText('hook_filter_format_delete invoked.', t('hook_filter_format_delete() was invoked.')); // Verify that the deleted format was replaced with the default format. $current_format = db_select('box', 'b') diff --git a/modules/php/php.install b/modules/php/php.install index d378c17224e9..a94882c74e8c 100644 --- a/modules/php/php.install +++ b/modules/php/php.install @@ -31,6 +31,7 @@ function php_install() { 'module' => 'php', 'name' => 'php_code', 'weight' => 0, + 'status' => 1, )) ->execute(); diff --git a/modules/php/php.module b/modules/php/php.module index 4dd23f5ea4f2..f9b7d5bcf448 100644 --- a/modules/php/php.module +++ b/modules/php/php.module @@ -79,7 +79,7 @@ function php_eval($code) { /** * Tips callback for php filter. */ -function _php_filter_tips($format, $long = FALSE) { +function _php_filter_tips($filter, $format, $long = FALSE) { global $base_url; if ($long) { $output = '<h4>' . t('Using custom PHP code') . '</h4>'; diff --git a/modules/simpletest/tests/filter_test.module b/modules/simpletest/tests/filter_test.module index 4adba88b9e02..6494154325a3 100644 --- a/modules/simpletest/tests/filter_test.module +++ b/modules/simpletest/tests/filter_test.module @@ -10,20 +10,20 @@ * Implement hook_filter_format_insert(). */ function filter_test_filter_format_insert($format) { - drupal_set_message(t('hook_filter_format_insert invoked.')); + drupal_set_message('hook_filter_format_insert invoked.'); } /** * Implement hook_filter_format_update(). */ function filter_test_filter_format_update($format) { - drupal_set_message(t('hook_filter_format_update invoked.')); + drupal_set_message('hook_filter_format_update invoked.'); } /** * Implement hook_filter_format_delete(). */ function filter_test_filter_format_delete($format, $default) { - drupal_set_message(t('hook_filter_format_delete invoked.')); + drupal_set_message('hook_filter_format_delete invoked.'); } diff --git a/modules/system/system.install b/modules/system/system.install index 613f029be568..f774df37ee44 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -425,13 +425,14 @@ function system_install() { // Filtered HTML: db_insert('filter') - ->fields(array('format', 'module', 'name', 'weight')) + ->fields(array('format', 'module', 'name', 'weight', 'status')) // URL filter. ->values(array( 'format' => $filtered_html_format, 'module' => 'filter', 'name' => 'filter_url', 'weight' => 0, + 'status' => 1, )) // HTML filter. ->values(array( @@ -439,6 +440,7 @@ function system_install() { 'module' => 'filter', 'name' => 'filter_html', 'weight' => 1, + 'status' => 1, )) // Line break filter. ->values(array( @@ -446,6 +448,7 @@ function system_install() { 'module' => 'filter', 'name' => 'filter_autop', 'weight' => 2, + 'status' => 1, )) // HTML corrector filter. ->values(array( @@ -453,6 +456,7 @@ function system_install() { 'module' => 'filter', 'name' => 'filter_htmlcorrector', 'weight' => 10, + 'status' => 1, )) // Full HTML: // URL filter. @@ -460,7 +464,8 @@ function system_install() { 'format' => $full_html_format, 'module' => 'filter', 'name' => 'filter_url', - 'weight' => 0, + 'weight' => 0, + 'status' => 1, )) // Line break filter. ->values(array( @@ -468,6 +473,7 @@ function system_install() { 'module' => 'filter', 'name' => 'filter_autop', 'weight' => 1, + 'status' => 1, )) // HTML corrector filter. ->values(array( @@ -475,6 +481,7 @@ function system_install() { 'module' => 'filter', 'name' => 'filter_htmlcorrector', 'weight' => 10, + 'status' => 1, )) ->execute(); -- GitLab