Commit f551d7d7 authored by Dries's avatar Dries
Browse files

#64280: Renamed from filter.module to filter/filter.module

parent e7f58c54
<?php
// $Id$
/**
* @file
* Framework for handling filtering of content.
*/
// This is a special format ID which means "use the default format". This value
// can be passed to the filter APIs as a format ID: this is equivalent to not
// passing an explicit format at all.
define('FILTER_FORMAT_DEFAULT', 0);
define('FILTER_HTML_STRIP', 1);
define('FILTER_HTML_ESCAPE', 2);
/**
* Implementation of hook_help().
*/
function filter_help($section) {
switch ($section) {
case 'admin/help#filter':
$output = '<p>'. t('The filter module allows administrators to configure text input formats for the site. For example, an administrator may want a filter to strip out malicious HTML from user\'s comments. Administrators may also want to make URLs linkable even if they are only entered in an unlinked format.') .'</p>';
$output .= '<p>'. t('Users can choose between the available input formats when creating or editing content. Administrators can configure which input formats are available to which user roles, as well as choose a default input format. Administrators can also create new input formats. Each input format can be configured to use a selection of filters.') .'</p>';
$output .= t('<p>You can</p>
<ul>
<li>administer input format permissions and settings at <a href="%admin-filters">administer &gt;&gt; input formats</a>.</li>
<li>configure the filters for each input format at <a href="%admin-filters">administer &gt;&gt; input formats &gt;&gt; configure</a>.</li>
</ul>
', array('%admin-filters' => url('admin/filters')));
$output .= '<p>'. t('For more information please read the configuration and customization handbook <a href="%filter">Filter page</a>.', array('%filter' => 'http://drupal.org/handbook/modules/filter/')) .'</p>';
return $output;
case 'admin/modules#description':
return t('Handles the filtering of content in preparation for display.');
case 'admin/filters':
return t('
<p><em>Input formats</em> define a way of processing user-supplied text in Drupal. Every input format has its own settings of which <em>filters</em> to apply. Possible filters include stripping out malicious HTML and making URLs clickable.</p>
<p>Users can choose between the available input formats when submitting content.</p>
<p>Below you can configure which input formats are available to which roles, as well as choose a default input format (used for imported content, for example).</p>
<p>Note that (1) the default format is always available to all roles, and (2) all filter formats can always be used by roles with the "administer filters" permission even if they are not explicitly listed in the Roles column of this table.</p>');
case 'admin/filters/'. arg(2):
return t('
<p>Every <em>filter</em> performs one particular change on the user input, for example stripping out malicious HTML or making URLs clickable. Choose which filters you want to apply to text in this input format.</p>
<p>If you notice some filters are causing conflicts in the output, you can <a href="%rearrange">rearrange them</a>.</p>', array('%rearrange' => url('admin/filters/'. arg(2) .'/order')));
case 'admin/filters/'. arg(2) .'/configure':
return t('
<p>If you cannot find the settings for a certain filter, make sure you\'ve enabled it on the <a href="%url">view tab</a> first.</p>', array('%url' => url('admin/filters/'. arg(2))));
case 'admin/filters/'. arg(2) .'/order':
return t('
<p>Because of the flexible filtering system, you might encounter a situation where one filter prevents another from doing its job. For example: a word in an URL gets converted into a glossary term, before the URL can be converted in a clickable link. When this happens, you will need to rearrange the order in which filters get executed.</p>
<p>Filters are executed from top-to-bottom. You can use the weight column to rearrange them: heavier filters \'sink\' to the bottom.</p>');
}
}
/**
* Implementation of hook_menu().
*/
function filter_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array('path' => 'admin/filters',
'title' => t('input formats'),
'callback' => 'filter_admin_overview',
'access' => user_access('administer filters'),
);
$items[] = array('path' => 'admin/filters/list',
'title' => t('list'),
'callback' => 'filter_admin_overview',
'type' => MENU_DEFAULT_LOCAL_TASK,
'access' => user_access('administer filters'),
);
$items[] = array('path' => 'admin/filters/add',
'title' => t('add input format'),
'callback' => 'filter_admin_format_form',
'type' => MENU_LOCAL_TASK,
'weight' => 1,
'access' => user_access('administer filters'),
);
$items[] = array('path' => 'admin/filters/delete',
'title' => t('delete input format'),
'callback' => 'filter_admin_delete',
'type' => MENU_CALLBACK,
'access' => user_access('administer filters'),
);
$items[] = array('path' => 'filter/tips',
'title' => t('compose tips'),
'callback' => 'filter_tips_long',
'access' => TRUE,
'type' => MENU_SUGGESTED_ITEM,
);
}
else {
if (arg(0) == 'admin' && arg(1) == 'filters' && is_numeric(arg(2))) {
$formats = filter_formats();
if (isset($formats[arg(2)])) {
$items[] = array('path' => 'admin/filters/'. arg(2),
'title' => t("'%format' input format", array('%format' => $formats[arg(2)]->name)),
'callback' => 'filter_admin_format_form',
'callback arguments' => array('format' => $formats[arg(2)]),
'type' => MENU_CALLBACK,
'access' => user_access('administer filters'),
);
$items[] = array('path' => 'admin/filters/'. arg(2) .'/list',
'title' => t('view'),
'callback' => 'filter_admin_format_form',
'callback arguments' => array('format' => $formats[arg(2)]),
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => 0,
'access' => user_access('administer filters'),
);
$items[] = array('path' => 'admin/filters/'. arg(2) .'/configure',
'title' => t('configure'),
'callback' => 'filter_admin_configure',
'type' => MENU_LOCAL_TASK,
'weight' => 1,
'access' => user_access('administer filters'),
);
$items[] = array('path' => 'admin/filters/'. arg(2) .'/order',
'title' => t('rearrange'),
'callback' => 'filter_admin_order',
'callback arguments' => array('format' => $formats[arg(2)]),
'type' => MENU_LOCAL_TASK,
'weight' => 2,
'access' => user_access('administer filters'),
);
}
}
}
return $items;
}
/**
* Implementation of hook_perm().
*/
function filter_perm() {
return array('administer filters');
}
/**
* Implementation of hook_filter_tips().
*/
function filter_filter_tips($delta, $format, $long = FALSE) {
global $base_url;
switch ($delta) {
case 0:
if (variable_get("filter_html_$format", FILTER_HTML_STRIP) == FILTER_HTML_STRIP) {
if ($allowed_html = variable_get("allowed_html_$format", '<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>')) {
switch ($long) {
case 0:
return t('Allowed HTML tags') .': '. check_plain($allowed_html);
case 1:
$output = '<p>'. t('Allowed HTML tags') .': '. check_plain($allowed_html) .'</p>';
if (!variable_get("filter_html_help_$format", 1)) {
return $output;
}
$output .= t('
<p>This site allows HTML content. While learning all of HTML may feel intimidating, learning how to use a very small number of the most basic HTML "tags" is very easy. This table provides examples for each tag that is enabled on this site.</p>
<p>For more information see W3C\'s <a href="http://www.w3.org/TR/html/">HTML Specifications</a> or use your favorite search engine to find other sites that explain HTML.</p>');
$tips = array(
'a' => array( t('Anchors are used to make links to other pages.'), '<a href="'. $base_url .'">'. variable_get('site_name', 'drupal') .'</a>'),
'br' => array( t('By default line break tags are automatically added, so use this tag to add additional ones. Use of this tag is different because it is not used with an open/close pair like all the others. Use the extra " /" inside the tag to maintain XHTML 1.0 compatibility'), t('Text with <br />line break')),
'p' => array( t('By default paragraph tags are automatically added, so use this tag to add additional ones.'), '<p>'. t('Paragraph one.') .'</p> <p>'. t('Paragraph two.') .'</p>'),
'strong' => array( t('Strong'), '<strong>'. t('Strong'). '</strong>'),
'em' => array( t('Emphasized'), '<em>'. t('Emphasized') .'</em>'),
'cite' => array( t('Cited'), '<cite>'. t('Cited') .'</cite>'),
'code' => array( t('Coded text used to show programming source code'), '<code>'. t('Coded') .'</code>'),
'b' => array( t('Bolded'), '<b>'. t('Bolded') .'</b>'),
'u' => array( t('Underlined'), '<u>'. t('Underlined') .'</u>'),
'i' => array( t('Italicized'), '<i>'. t('Italicized') .'</i>'),
'sup' => array( t('Superscripted'), t('<sup>Super</sup>scripted')),
'sub' => array( t('Subscripted'), t('<sub>Sub</sub>scripted')),
'pre' => array( t('Preformatted'), '<pre>'. t('Preformatted') .'</pre>'),
'abbr' => array( t('Abbreviation'), t('<abbr title="Abbreviation">Abbrev.</abbr>')),
'acronym' => array( t('Acronym'), t('<acronym title="Three-Letter Acronym">TLA</acronym>')),
'blockquote' => array( t('Block quoted'), '<blockquote>'. t('Block quoted') .'</blockquote>'),
'q' => array( t('Quoted inline'), '<q>'. t('Quoted inline') .'</q>'),
// Assumes and describes tr, td, th.
'table' => array( t('Table'), '<table> <tr><th>'. t('Table header') .'</th></tr> <tr><td>'. t('Table cell') .'</td></tr> </table>'),
'tr' => NULL, 'td' => NULL, 'th' => NULL,
'del' => array( t('Deleted'), '<del>'. t('Deleted') .'</del>'),
'ins' => array( t('Inserted'), '<ins>'. t('Inserted') .'</ins>'),
// Assumes and describes li.
'ol' => array( t('Ordered list - use the &lt;li&gt; to begin each list item'), '<ol> <li>'. t('First item') .'</li> <li>'. t('Second item') .'</li> </ol>'),
'ul' => array( t('Unordered list - use the &lt;li&gt; to begin each list item'), '<ul> <li>'. t('First item') .'</li> <li>'. t('Second item') .'</li> </ul>'),
'li' => NULL,
// Assumes and describes dt and dd.
'dl' => array( t('Definition lists are similar to other HTML lists. &lt;dl&gt; begins the definition list, &lt;dt&gt; begins the definition term and &lt;dd&gt; begins the definition description.'), '<dl> <dt>'. t('First term') .'</dt> <dd>'. t('First definition') .'</dd> <dt>'. t('Second term') .'</dt> <dd>'. t('Second definition') .'</dd> </dl>'),
'dt' => NULL, 'dd' => NULL,
'h1' => array( t('Header'), '<h1>'. t('Title') .'</h1>'),
'h2' => array( t('Header'), '<h2>'. t('Subtitle') .'</h2>'),
'h3' => array( t('Header'), '<h3>'. t('Subtitle three') .'</h3>'),
'h4' => array( t('Header'), '<h4>'. t('Subtitle four') .'</h4>'),
'h5' => array( t('Header'), '<h5>'. t('Subtitle five') .'</h5>'),
'h6' => array( t('Header'), '<h6>'. t('Subtitle six') .'</h6>')
);
$header = array(t('Tag Description'), t('You Type'), t('You Get'));
preg_match_all('/<([a-z0-9]+)[^a-z0-9]/i', $allowed_html, $out);
foreach ($out[1] as $tag) {
if (array_key_exists($tag, $tips)) {
if ($tips[$tag]) {
$rows[] = array(
array('data' => $tips[$tag][0], 'class' => 'description'),
array('data' => '<code>'. check_plain($tips[$tag][1]) .'</code>', 'class' => 'type'),
array('data' => $tips[$tag][1], 'class' => 'get')
);
}
}
else {
$rows[] = array(
array('data' => t('No help provided for tag %tag.', array('%tag' => check_plain($tag))), 'class' => 'description', 'colspan' => 3),
);
}
}
$output .= theme('table', $header, $rows);
$output .= t('
<p>Most unusual characters can be directly entered without any problems.</p>
<p>If you do encounter problems, try using HTML character entities. A common example looks like &amp;amp; for an ampersand &amp; character. For a full list of entities see HTML\'s <a href="http://www.w3.org/TR/html4/sgml/entities.html">entities</a> page. Some of the available characters include:</p>');
$entities = array(
array( t('Ampersand'), '&amp;'),
array( t('Greater than'), '&gt;'),
array( t('Less than'), '&lt;'),
array( t('Quotation mark'), '&quot;'),
);
$header = array(t('Character Description'), t('You Type'), t('You Get'));
unset($rows);
foreach ($entities as $entity) {
$rows[] = array(
array('data' => $entity[0], 'class' => 'description'),
array('data' => '<code>'. check_plain($entity[1]) .'</code>', 'class' => 'type'),
array('data' => $entity[1], 'class' => 'get')
);
}
$output .= theme('table', $header, $rows);
return $output;
}
}
else {
return t('No HTML tags allowed');
}
}
break;
case 1:
switch ($long) {
case 0:
return t('You may post PHP code. You should include &lt;?php ?&gt; tags.');
case 1:
return t('
<h4>Using custom PHP code</h4>
<p>If you know how to script in PHP, Drupal gives you the power to embed any script you like. It will be executed when the page is viewed and dynamically embedded into the page. This gives you amazing flexibility and power, but of course with that comes danger and insecurity if you don\'t write good code. If you are not familiar with PHP, SQL or with the site engine, avoid experimenting with PHP because you can corrupt your database or render your site insecure or even unusable! If you don\'t plan to do fancy stuff with your content then you\'re probably better off with straight HTML.</p>
<p>Remember that the code within each PHP item must be valid PHP code - including things like correctly terminating statements with a semicolon. It is highly recommended that you develop your code separately using a simple test script on top of a test database before migrating to your production environment.</p>
<p>Notes:</p><ul><li>You can use global variables, such as configuration parameters, within the scope of your PHP code but remember that global variables which have been given values in your code will retain these values in the engine afterwards.</li><li>register_globals is now set to <strong>off</strong> by default. If you need form information you need to get it from the "superglobals" $_POST, $_GET, etc.</li><li>You can either use the <code>print</code> or <code>return</code> statement to output the actual content for your item.</li></ul>
<p>A basic example:</p>
<blockquote><p>You want to have a box with the title "Welcome" that you use to greet your visitors. The content for this box could be created by going:</p>
<pre>
print t("Welcome visitor, ... welcome message goes here ...");
</pre>
<p>If we are however dealing with a registered user, we can customize the message by using:</p>
<pre>
global $user;
if ($user->uid) {
print t("Welcome $user->name, ... welcome message goes here ...");
}
else {
print t("Welcome visitor, ... welcome message goes here ...");
}
</pre></blockquote>
<p>For more in-depth examples, we recommend that you check the existing Drupal code and use it as a starting point, especially for sidebar boxes.</p>');
}
case 2:
switch ($long) {
case 0:
return t('Lines and paragraphs break automatically.');
case 1:
return t('Lines and paragraphs are automatically recognized. The &lt;br /&gt; line break, &lt;p&gt; paragraph and &lt;/p&gt; close paragraph tags are inserted automatically. If paragraphs are not recognized simply add a couple blank lines.');
}
}
}
/**
* Displays a list of all input formats and which one is the default
*/
function filter_admin_overview() {
// Overview of all formats.
$formats = filter_formats();
$error = FALSE;
$rows = array();
foreach ($formats as $id => $format) {
$roles = array();
foreach (user_roles() as $rid => $name) {
// Prepare a roles array with roles that may access the filter
if (strstr($format->roles, ",$rid,")) {
$roles[] = $name;
}
}
$row = array();
$default = ($id == variable_get('filter_default_format', 1));
$options[$id] = '';
$form[$format->name]['id'] = array('#value' => $id);
$form[$format->name]['roles'] = array('#value' => $default ? t('All roles may use default format') : ($roles ? implode(', ',$roles) : t('No roles may use this format')));
$form[$format->name]['configure'] = array('#value' => l(t('configure'), 'admin/filters/'. $id));
$form[$format->name]['delete'] = array('#value' => $default ? '' : l(t('delete'), 'admin/filters/delete/'. $id));
}
$form['default'] = array('#type' => 'radios', '#options' => $options, '#default_value' => variable_get('filter_default_format', 1));
$form['submit'] = array('#type' => 'submit', '#value' => t('Set default format'));
return drupal_get_form('filter_admin_overview', $form);
}
function filter_admin_overview_submit($form_id, $form_values) {
// Process form submission to set the default format
if (is_numeric($form_values['default'])) {
drupal_set_message(t('Default format updated.'));
variable_set('filter_default_format', $form_values['default']);
}
}
function theme_filter_admin_overview($form) {
foreach ($form as $name => $element) {
if (isset($element['roles']) && is_array($element['roles'])) {
$rows[] = array(
form_render($form['default'][$element['id']['#value']]),
check_plain($name),
form_render($element['roles']),
form_render($element['configure']),
form_render($element['delete'])
);
unset($form[$name]);
}
}
$header = array(t('Default'), t('Name'), t('Roles'), array('data' => t('Operations'), 'colspan' => 2));
$output = theme('table', $header, $rows);
$output .= form_render($form);
return $output;
}
/**
* Menu callback; confirm deletion of a format.
*/
function filter_admin_delete() {
$format = arg(3);
$format = db_fetch_object(db_query('SELECT * FROM {filter_formats} WHERE format = %d', $format));
if ($format) {
if ($format->format != variable_get('filter_default_format', 1)) {
$form['format'] = array('#type' => 'hidden', '#value' => $format->format);
$form['name'] = array('#type' => 'hidden', '#value' => $format->name);
return confirm_form('filter_admin_delete', $form, t('Are you sure you want to delete the input format %format?', array('%format' => theme('placeholder', $format->name))), 'admin/filters', t('If you have any content left in this input format, it will be switched to the default input format. This action cannot be undone.'), t('Delete'), t('Cancel'));
}
else {
drupal_set_message(t('The default format cannot be deleted.'));
drupal_goto('admin/filters');
}
}
else {
drupal_not_found();
}
}
/**
* Process filter delete form submission.
*/
function filter_admin_delete_submit($form_id, $form_values) {
db_query("DELETE FROM {filter_formats} WHERE format = %d", $form_values['format']);
db_query("DELETE FROM {filters} WHERE format = %d", $form_values['format']);
$default = variable_get('filter_default_format', 1);
// Replace existing instances of the deleted format with the default format.
db_query("UPDATE {node_revisions} SET format = %d WHERE format = %d", $default, $form_values['format']);
db_query("UPDATE {comments} SET format = %d WHERE format = %d", $default, $form_values['format']);
db_query("UPDATE {boxes} SET format = %d WHERE format = %d", $default, $form_values['format']);
cache_clear_all('filter:'. $form_values['format'], TRUE);
drupal_set_message(t('Deleted input format %format.', array('%format' => theme('placeholder', $form_values['name']))));
return 'admin/filters';
}
/**
* Generate a filter format form.
*/
function filter_admin_format_form($format = NULL) {
$default = ($format->format == variable_get('filter_default_format', 1));
if ($default) {
$help = t('All roles for the default format must be enabled and cannot be changed.');
$form['default_format'] = array('#type' => 'hidden', '#value' => 1);
}
$form['name'] = array('#type' => 'textfield',
'#title' => 'Name',
'#default_value' => $format->name,
'#description' => t('Specify a unique name for this filter format.'),
'#required' => TRUE,
);
// Add a row of checkboxes for form group.
$form['roles'] = array('#type' => 'fieldset',
'#title' => t('Roles'),
'#description' => $default ? $help : t('Choose which roles may use this filter format. Note that roles with the "administer filters" permission can always use all the filter formats.'),
'#tree' => TRUE,
);
foreach (user_roles() as $rid => $name) {
$checked = strstr($format->roles, ",$rid,");
$form['roles'][$rid] = array('#type' => 'checkbox',
'#title' => $name,
'#default_value' => ($default || $checked),
);
if ($default) {
$form['roles'][$rid]['#attributes'] = array('disabled' => 'disabled');
}
}
// Table with filters
$all = filter_list_all();
$enabled = filter_list_format($format->format);
$form['filters'] = array('#type' => 'fieldset',
'#title' => t('Filters'),
'#description' => t('Choose the filters that will be used in this filter format.'),
'#tree' => TRUE,
);
foreach ($all as $id => $filter) {
$form['filters'][$id] = array('#type' => 'checkbox',
'#title' => $filter->name,
'#default_value' => isset($enabled[$id]),
'#description' => module_invoke($filter->module, 'filter', 'description', $filter->delta),
);
}
$form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
if (isset($format)) {
$form['format'] = array('#type' => 'hidden', '#value' => $format->format);
// Composition tips (guidelines)
$tips = _filter_tips($format->format, FALSE);
$extra = l(t('More information about formatting options'), 'filter/tips');
$tiplist = theme('filter_tips', $tips, FALSE, $extra);
if (!$tiplist) {
$tiplist = t('<p>No guidelines available.</p>');
}
$group = t('<p>These are the guidelines that users will see for posting in this input format. They are automatically generated from the filter settings.</p>');
$group .= $tiplist;
$output = '<h2>'. t('Formatting guidelines') .'</h2>'. $group;
}
$output = drupal_get_form('filter_admin_format_form', $form) . $output;
return $output;
}
/**
* Validate filter format form submissions.
*/
function filter_admin_format_form_validate($form_id, $form_values) {
if (!isset($form_values['format'])) {
$name = trim($form_values['name']);
$result = db_fetch_object(db_query("SELECT format FROM {filter_formats} WHERE name='%s'", $name));
if ($result) {
form_set_error('name', t('Filter format names need to be unique. A format named %name already exists.', array('%name' => theme('placeholder', $name))));
}
}
}
/**
* Process filter format form submissions.
*/
function filter_admin_format_form_submit($form_id, $form_values) {
$format = isset($form_values['format']) ? $form_values['format'] : NULL;
$current = filter_list_format($format);
$name = trim($form_values['name']);
$cache = TRUE;
// Add a new filter format.
if (!$format) {
$new = TRUE;
db_query("INSERT INTO {filter_formats} (name) VALUES ('%s')", $name);
$result = db_fetch_object(db_query("SELECT MAX(format) AS format FROM {filter_formats}"));
$format = $result->format;
drupal_set_message(t('Added input format %format.', array('%format' => theme('placeholder', $name))));
}
else {
drupal_set_message(t('The input format settings have been updated.'));
}
db_query("DELETE FROM {filters} WHERE format = %d", $format);
foreach ($form_values['filters'] as $id => $checked) {
if ($checked) {
list($module, $delta) = explode('/', $id);
// Add new filters to the bottom.
$weight = isset($current[$id]->weight) ? $current[$id]->weight : 10;
db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", $format, $module, $delta, $weight);
// Check if there are any 'no cache' filters.
$cache &= !module_invoke($module, 'filter', 'no cache', $delta);
}
}
// We store the roles as a string for ease of use.
// We should always set all roles to TRUE when saving a default role.
// We use leading and trailing comma's to allow easy substring matching.
$roles = array();
if (isset($form_values['roles'])) {
foreach ($form_values['roles'] as $id => $checked) {
if ($checked) {
$roles[] = $id;
}
}
}
$roles = ','. implode(',', ($form_values['default_format'] ? user_roles() : $roles)) .',';
db_query("UPDATE {filter_formats} SET cache = %d, name='%s', roles = '%s' WHERE format = %d", $cache, $name, $roles, $format);
cache_clear_all('filter:'. $format, TRUE);
// If a new filter was added, return to the main list of filters. Otherwise, stay on edit filter page to show new changes.
if ($new) {
return 'admin/filters/';
}
else {
return 'admin/filters/'. $format;
}
}
/**
* Menu callback; display form for ordering filters for a format.
*/
function filter_admin_order($format = NULL) {
// Get list (with forced refresh)
$filters = filter_list_format($format->format);
$form['weights'] = array('#tree' => TRUE);
foreach ($filters as $id => $filter) {
$form['names'][$id] = array('#value' => $filter->name);
$form['weights'][$id] = array('#type' => 'weight', '#default_value' => $filter->weight);
}
$form['format'] = array('#type' => 'hidden', '#value' => $format->format);
$form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
return drupal_get_form('filter_admin_order', $form);
}
/**
* Theme filter order configuration form.
*/
function theme_filter_admin_order($form) {
$header = array(t('Name'), t('Weight'));
$rows = array();
foreach (element_children($form['names']) as $id) {
// Don't take form control structures
if (is_array($form['names'][$id])) {
$rows[] = array(form_render($form['names'][$id]), form_render($form['weights'][$id]));
}
}
$output = theme('table', $header, $rows);
$output .= form_render($form);
return $output;
}
/**
* Process filter order configuration form submission.
*/
function filter_admin_order_submit($form_id, $form_values) {
foreach ($form_values['weights'] as $id => $weight) {
list($module, $delta) = explode('/', $id);
db_query("UPDATE {filters} SET weight = %d WHERE format = %d AND module = '%s' AND delta = %d", $weight, $form_values['format'], $module, $delta);
}
drupal_set_message(t('The filter ordering has been saved.'));
cache_clear_all('filter:'. $form_values['format'], TRUE);
}
/**
* Menu callback; display settings defined by filters.
*/
function filter_admin_configure() {
$format = arg(2);
$list = filter_list_format($format);
$form = array();
foreach ($list as $filter) {
$form_module = module_invoke($filter->module, 'filter', 'settings', $filter->delta, $format);
if (isset($form_module) && is_array($form_module)) {
$form = array_merge($form, $form_module);
}
}
if (!empty($form)) {
$output = system_settings_form('filter_admin_configure', $form);
}