From c2151b52485c84f87cb5ac10ff5a0aa72ed8cff7 Mon Sep 17 00:00:00 2001 From: Steven Wittens Date: Mon, 5 Jan 2004 19:19:05 +0000 Subject: Committed filter separation patch: all filter-related things are now in filter.module (which is a required module). To do this cleanly, I reorganised some bits of system.module: there is now a generic handler available for simple variable-get/set based configuration pages. Look at filter_admin() or system_view() for example usage. (based on the patch by Goba) --- includes/common.inc | 109 ---------------------------------------------------- 1 file changed, 109 deletions(-) (limited to 'includes/common.inc') diff --git a/includes/common.inc b/includes/common.inc index 2de172c89..304e753ca 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -454,115 +454,6 @@ function check_form($text) { return drupal_specialchars($text, ENT_QUOTES); } -function filter($text) { - $modules = module_list(); - - /* - ** Make sure the HTML filters that are part of the node module - ** are run first. - */ - - if (in_array("node", $modules)) { - $text = module_invoke("node", "filter", $text); - } - - foreach ($modules as $name) { - if (module_hook($name, "filter") && $name != "node") { - $text = module_invoke($name, "filter", $text); - } - } - - return $text; -} - -function rewrite_old_urls($text) { - global $base_url; - - $end = substr($base_url, 12); - - /* - ** This is a *temporary* filter to rewrite old-style URLs to new-style - ** URLs (clean URLs). Currently, URLs are being rewritten dynamically - ** (ie. "on output"), however when these rewrite rules have been tested - ** enough, we will use them to permanently rewrite the links in node - ** and comment bodies. - */ - - if (variable_get("clean_url", "0") == "0") { - /* - ** Relative URLs: - */ - - // rewrite 'node.php?id=[&cid=]' style URLs: - $text = eregi_replace("\"(node)\.php\?id=([[:digit:]]+)(&cid=)?([[:digit:]]*)", "\"?q=\\1/view/\\2/\\4", $text); - - // rewrite 'module.php?mod={&=}' style URLs: - $text = ereg_replace("\"module\.php\?(&?[[:alpha:]]+=([[:alnum:]]+))(&?[[:alpha:]]+=([[:alnum:]]+))(&?[[:alpha:]]+=([[:alnum:]]+))", "\"?q=\\2/\\4/\\6" , $text); - $text = ereg_replace("\"module\.php\?(&?[[:alpha:]]+=([[:alnum:]]+))(&?[[:alpha:]]+=([[:alnum:]]+))", "\"?q=\\2/\\4", $text); - $text = ereg_replace("\"module\.php\?(&?[[:alpha:]]+=([[:alnum:]]+))", "\"?q=\\2", $text); - - /* - ** Absolute URLs: - */ - - // rewrite 'node.php?id=[&cid=]' style URLs: - $text = eregi_replace("$end/(node)\.php\?id=([[:digit:]]+)(&cid=)?([[:digit:]]*)", "$end/?q=\\1/view/\\2/\\4", $text); - - // rewrite 'module.php?mod={&=}' style URLs: - $text = ereg_replace("$end/module\.php\?(&?[[:alpha:]]+=([[:alnum:]]+))(&?[[:alpha:]]+=([[:alnum:]]+))(&?[[:alpha:]]+=([[:alnum:]]+))", "$end/?q=\\2/\\4/\\6" , $text); - $text = ereg_replace("$end/module\.php\?(&?[[:alpha:]]+=([[:alnum:]]+))(&?[[:alpha:]]+=([[:alnum:]]+))", "$end/?q=\\2/\\4", $text); - $text = ereg_replace("$end/module\.php\?(&?[[:alpha:]]+=([[:alnum:]]+))", "\"$end/?q=\\2", $text); - } - else { - /* - ** Relative URLs: - */ - - // rewrite 'node.php?id=[&cid=]' style URLs: - $text = eregi_replace("\"(node)\.php\?id=([[:digit:]]+)(&cid=)?([[:digit:]]*)", "\"\\1/view/\\2/\\4", $text); - - // rewrite 'module.php?mod={&=}' style URLs: - $text = ereg_replace("\"module\.php\?(&?[[:alpha:]]+=([[:alnum:]]+))(&?[[:alpha:]]+=([[:alnum:]]+))(&?[[:alpha:]]+=([[:alnum:]]+))", "\"\\2/\\4/\\6", $text); - $text = ereg_replace("\"module\.php\?(&?[[:alpha:]]+=([[:alnum:]]+))(&?[[:alpha:]]+=([[:alnum:]]+))", "\"\\2/\\4", $text); - $text = ereg_replace("\"module\.php\?(&?[[:alpha:]]+=([[:alnum:]]+))", "\"\\2", $text); - - /* - ** Absolute URLs: - */ - - // rewrite 'node.php?id=[&cid=]' style URLs: - $text = eregi_replace("$end/(node)\.php\?id=([[:digit:]]+)(&cid=)?([[:digit:]]*)", "$end/\\1/view/\\2/\\4", $text); - - // rewrite 'module.php?mod={&=}' style URLs: - $text = ereg_replace("$end/module\.php\?(&?[[:alpha:]]+=([[:alnum:]]+))(&?[[:alpha:]]+=([[:alnum:]]+))(&?[[:alpha:]]+=([[:alnum:]]+))", "$end/\\2/\\4/\\6", $text); - $text = ereg_replace("$end/module\.php\?(&?[[:alpha:]]+=([[:alnum:]]+))(&?[[:alpha:]]+=([[:alnum:]]+))", "$end/\\2/\\4", $text); - $text = ereg_replace("$end/module\.php\?(&?[[:alpha:]]+=([[:alnum:]]+))", "$end/\\2", $text); -} - - return $text; -} - -function check_output($text) { - if (isset($text)) { - // filter content on output: - $text = filter($text); - - /* - ** If only inline elements are used and no block level elements, we - ** replace all newlines with HTML line breaks. - */ - if (strip_tags($text, '