From 20397ad3d9dad39670ed92923d2513bd89c7b0bb Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 20 May 2001 13:51:40 +0000 Subject: CHANGES - Redid settings.module and even renamed it to conf.module. * Settings are now grouped in basic categories like "system settings", "module settings" and "filters". * Added new settings to make Drupal easier to configure and to make some aspects like the watchdog scale better. - Renamed includes/settings.php to includes/conf.php. - Added filter support to conf.module and introduced filter hooks so modules can implement and export new filters. Example filters are an HTML filter (implemented), a profanity filter, an url converter, ASCII smileys to images filter and so on ... - Reworked the check_* functions: user contributed content/input is only verified and filtered once in its lifespan. NOTES - Altough this is a large commit, no database changes are required. --- modules/node/node.module | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'modules/node/node.module') diff --git a/modules/node/node.module b/modules/node/node.module index 53c32219f..98b6482ef 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -11,13 +11,34 @@ class Node { } } -function node_macro($text) { +function node_conf_filters() { + $output .= form_select(t("Strip HTML tags"), "filter_html", variable_get("filter_html", 0), array("Disabled", "Enabled"), t("Strip HTML and PHP tags.")); + $output .= form_textfield(t("Allowed HTML tags"), "allowed_html", variable_get("allowed_html", "
      • "), 64, 128, t("If enabled, optionally specify tags which should not be stripped. 'STYLE' attributes, 'ON' attributes and unclosed tags are always stripped.")); + $output .= "
        "; + $output .= form_select(t("Strip link tags"), "filter_link", variable_get("filter_link", 0), array("Disabled", "Enabled"), t("Substitute special [[link]] tags.")); + $output .= "
        "; + return $output; +} + +function node_filter_html($text) { + $text = eregi_replace("([ \f\r\t\n\'\"])style=[^>]+", "\\1", $text); + $text = eregi_replace("([ \f\r\t\n\'\"])on[a-z]+=[^>]+", "\\1", $text); + $text = strip_tags($text, variable_get("allowed_html", "")); + return $text; +} + +function node_filter_link($text) { $src = array("/\[\[(([^\|]*?)(\|([^\|]*?))?)\]\]/e"); // [link|description] $dst = array(format_tag('\\2', '\\4')); // [link|description] - return preg_replace($src, $dst, $text); } +function node_filter($text) { + if (variable_get("filter_html", 0)) $text = node_filter_html($text); + if (variable_get("filter_link", 0)) $text = node_filter_link($text); + return $text; +} + function node_overview($query = array()) { global $user; -- cgit v1.2.3