diff options
author | Dries Buytaert <dries@buytaert.net> | 2003-10-03 14:10:05 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2003-10-03 14:10:05 +0000 |
commit | 35f3bcd0426ea207e40c4a2dd6cae8a1d26c794e (patch) | |
tree | 441fb3d6f529f83e3a338a8b2cb641883697c27a /includes | |
parent | 630325188ac228f5cb1919b2ce48716ccbdc7e4e (diff) | |
download | brdo-35f3bcd0426ea207e40c4a2dd6cae8a1d26c794e.tar.gz brdo-35f3bcd0426ea207e40c4a2dd6cae8a1d26c794e.tar.bz2 |
- Path modoule improvements. Modified path by Matt.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/common.inc | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/includes/common.inc b/includes/common.inc index 475c72c2b..da75fd47a 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -28,9 +28,13 @@ function conf_init() { /** * Build the alias/path array */ -function get_url_map() { +function drupal_get_path_map($action = "") { static $map; + if ($action == "rebuild") { + $map = NULL; + } + if (empty($map)) { $result = db_query("SELECT * FROM {path}"); while ($data = db_fetch_object($result)) { @@ -41,6 +45,10 @@ function get_url_map() { return $map; } +function drupal_rebuild_path_map() { + drupal_get_path_map("rebuild"); +} + function error_handler($errno, $message, $filename, $line, $variables) { $types = array(1 => "error", 2 => "warning", 4 => "parse error", 8 => "notice", 16 => "core error", 32 => "core warning", 64 => "compile error", 128 => "compile warning", 256 => "user error", 512 => "user warning", 1024 => "user notice"); $entry = $types[$errno] .": $message in $filename on line $line."; @@ -324,7 +332,7 @@ function valid_email_address($mail) { */ function valid_url($url) { - if (preg_match("/^[a-zA-z0-9\/:_\-_\.]+$/", $url)) { + if (preg_match("/^[a-zA-z0-9\/:_\-_\.,]+$/", $url)) { return 1; } else { @@ -1073,8 +1081,8 @@ function form_allowed_tags_text() { /** * Given an old url, return the alias. */ -function get_url_alias($path) { - $map = get_url_map(); +function drupal_get_path_alias($path) { + $map = drupal_get_path_map(); if ($map) { return array_search($path, $map); @@ -1082,10 +1090,10 @@ function get_url_alias($path) { } /** - * Given an alias, return the old url. + * Given an alias, return the default url. */ -function get_old_url($path) { - $map = get_url_map(); +function drupal_get_normal_path($path) { + $map = drupal_get_path_map(); return $map[$path]; } @@ -1103,7 +1111,7 @@ function url($url = NULL, $query = NULL) { $script = (strpos($_SERVER["SERVER_SOFTWARE"], "Apache") === false) ? "index.php" : ""; } - if ($alias = get_url_alias($url)) { + if ($alias = drupal_get_path_alias($url)) { $url = $alias; } @@ -1284,7 +1292,7 @@ header("Content-Type: text/html; charset=utf-8"); // initialize the _GET["q"] prior to loading the modules and invoking their 'init' hook: if (!empty($_GET["q"])) { - if ($path = get_old_url(trim($_GET["q"], "/"))) { + if ($path = drupal_get_normal_path(trim($_GET["q"], "/"))) { $_GET["q"] = $path; } } |