Commit 35f3bcd0 authored by Dries's avatar Dries

- Path modoule improvements. Modified path by Matt.

parent 63032518
......@@ -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 @@ function drupal_page_footer() {
// 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;
}
}
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment