From bfba335376c8a15c74ec0e8ec71541193b458073 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 6 Feb 2004 19:07:56 +0000 Subject: - Added the possibility to reorder filters. Patch by UnConeD. --- modules/filter.module | 151 ++++++++++++++++++++++++++++++++++++------- modules/filter/filter.module | 151 ++++++++++++++++++++++++++++++++++++------- modules/title.module | 17 ++++- 3 files changed, 269 insertions(+), 50 deletions(-) (limited to 'modules') diff --git a/modules/filter.module b/modules/filter.module index e41f6d2a4..ca7431882 100644 --- a/modules/filter.module +++ b/modules/filter.module @@ -6,7 +6,13 @@ function filter_help($section = "admin/help#filter") { case 'admin/system/modules#description': return t("Framework for handling filtering of content."); case 'admin/system/filters': - return t("Filters fit between the raw text in a node and the HTML output. They allow you to replace text selectively. Uses include automatic conversion of emoticons into graphics and filtering HTML content from users' submissions."); + return t(" +

Filters fit between the raw text in a node and the HTML output. They allow you to replace text selectively. Uses include automatic conversion of emoticons into graphics and filtering HTML content from users' submissions.

+

If you notice some filters are causing conflicts in the output, you can rearrange them.

", array("%url" => url("admin/system/filters/order"))); + case 'admin/system/filters/order': + return t(" +

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.

+

Filters are executed from top-to-bottom. You can use the weight column to rearrange them: heavier filters 'sink' to the bottom. Standard HTML filtering is always run first.

"); case 'filter#long-tip': case 'filter#short-tip': switch (variable_get("filter_html", 1)) { @@ -32,17 +38,65 @@ function filter_link($type) { if ($type == "system") { if (user_access("administer site configuration")) { menu("admin/system/filters", t("filters"), "filter_admin", 5); + menu("admin/system/filters/order", t("ordering"), "filter_admin", 5); } menu("filter/tips", t("Compose tips"), "filter_tips_long", 0, MENU_HIDE); } } +function filter_admin_order() { + $edit = $_POST["edit"]; + $op = $_POST["op"]; + if ($op == t("Save configuration")) { + foreach ($edit as $module => $filter) { + db_query("UPDATE {filters} SET weight = '%d' WHERE module = '%s'", $filter["weight"], $module); + } + } + + // Get list (with forced refresh) + filter_refresh(); + $filters = filter_list(); + + $header = array("name", "weight"); + $rows = array(); + + // Standard HTML filters are always run first, we add a dummy row to indicate this + $rows[] = array(t("HTML filtering"), array("data" => t("locked"))); + + foreach ($filters as $module => $filter) { + $name = module_invoke($module, "filter", "name"); + $rows[] = array($name, array("data" => form_weight(NULL, $module ."][weight", $filter["weight"]))); + } + + $form = theme("table", $header, $rows); + $form .= form_submit(t("Save configuration")); + $output = form($form); + + return $output; +} + +function filter_admin_settings() { + system_settings_save(); + + filter_refresh(); + + $form = filter_default_settings(); + $form .= implode("\n", module_invoke_all("filter", "settings")); + $output = system_settings_form($form); + + return $output; +} + function filter_admin() { if (user_access("administer site configuration")) { - system_settings_save(); - - $form = implode("\n", module_invoke_all("conf_filters")); - $output = system_settings_form($form); + switch (arg(3)) { + case "order": + $output = filter_admin_order(); + break; + default: + $output = filter_admin_settings(); + break; + } print theme("page", $output); } else { @@ -50,30 +104,56 @@ function filter_admin() { } } -function filter_conf_filters() { - $group1 .= form_radios(t("Filter HTML tags"), "filter_html", variable_get("filter_html", 0), array(0 => t("Do not filter"), 1 => t("Strip tags"), 2 => t("Escape tags")), t("How to deal with HTML and PHP tags in user-contributed content. If set to \"Strip tags\", dangerous tags are removed (see below). If set to \"Escape tags\", all HTML is escaped and presented as it was typed.")); - $group1 .= form_textfield(t("Allowed HTML tags"), "allowed_html", variable_get("allowed_html", "