summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2003-09-30 17:01:34 +0000
committerDries Buytaert <dries@buytaert.net>2003-09-30 17:01:34 +0000
commit5a667eb580be3f20bde78232f564152f1cb869a9 (patch)
treecd347ca532f72b7527c37c2bd4b4009dacf5a2c3
parent13f12eb4177d79ffb1347aba355040a4e6b85738 (diff)
downloadbrdo-5a667eb580be3f20bde78232f564152f1cb869a9.tar.gz
brdo-5a667eb580be3f20bde78232f564152f1cb869a9.tar.bz2
- Url aliasing improvements. Patch by Matt. See mailing list for more
information.
-rw-r--r--database/database.mysql15
-rw-r--r--includes/common.inc47
-rw-r--r--index.php13
-rw-r--r--modules/forum.module8
-rw-r--r--modules/forum/forum.module8
-rw-r--r--modules/node.module89
-rw-r--r--modules/node/node.module89
-rw-r--r--modules/page.module4
-rw-r--r--modules/page/page.module4
-rw-r--r--modules/statistics.module2
-rw-r--r--modules/statistics/statistics.module2
-rw-r--r--modules/title.module2
-rw-r--r--modules/tracker.module2
-rw-r--r--modules/tracker/tracker.module2
-rw-r--r--themes/xtemplate/xtemplate.theme2
15 files changed, 98 insertions, 191 deletions
diff --git a/database/database.mysql b/database/database.mysql
index 1a53c39dd..f4438cd33 100644
--- a/database/database.mysql
+++ b/database/database.mysql
@@ -264,7 +264,6 @@ CREATE TABLE node (
nid int(10) unsigned NOT NULL auto_increment,
type varchar(16) NOT NULL default '',
title varchar(128) NOT NULL default '',
- path varchar(250) NULL default '',
score int(11) NOT NULL default '0',
votes int(11) NOT NULL default '0',
uid int(10) NOT NULL default '0',
@@ -286,7 +285,6 @@ CREATE TABLE node (
KEY status (status),
KEY uid (uid),
KEY node_moderate (moderate),
- KEY node_path (path(5)),
KEY node_promote_status (promote, status)
) TYPE=MyISAM;
@@ -304,6 +302,19 @@ CREATE TABLE page (
) TYPE=MyISAM;
--
+-- Table structure for table 'path'
+--
+
+CREATE TABLE path (
+ alid int(10) unsigned NOT NULL auto_increment,
+ old varchar(128) NOT NULL default '',
+ new varchar(128) NOT NULL default '',
+ PRIMARY KEY (alid),
+ UNIQUE KEY new (new),
+ UNIQUE KEY old (old)
+) TYPE=MyISAM;
+
+--
-- Table structure for table 'permission'
--
diff --git a/includes/common.inc b/includes/common.inc
index a88bb10b6..cf9876767 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -25,6 +25,22 @@ function conf_init() {
return "conf";
}
+/**
+ * Build the alias/path array
+ */
+function get_url_map() {
+ static $map;
+
+ if (empty($map)) {
+ $result = db_query("SELECT * FROM {path}");
+ while ($data = db_fetch_object($result)) {
+ $map[$data->new] = $data->old;
+ }
+ }
+
+ return $map;
+}
+
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.";
@@ -1054,6 +1070,23 @@ function form_allowed_tags_text() {
return variable_get("allowed_html", "") ? (t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", ""))) : "";
}
+/**
+ * Given an old url, return the alias.
+ */
+function get_url_alias($path) {
+ $map = get_url_map();
+
+ return array_search($path, $map);
+}
+
+/**
+ * Given an alias, return the old url.
+ */
+function get_old_url($path) {
+ $map = get_url_map();
+ return $map[$path];
+}
+
function url($url = NULL, $query = NULL) {
global $base_url;
@@ -1068,6 +1101,10 @@ function url($url = NULL, $query = NULL) {
$script = (strpos($_SERVER["SERVER_SOFTWARE"], "Apache") === false) ? "index.php" : "";
}
+ if ($alias = get_url_alias($url)) {
+ $url = $alias;
+ }
+
if (variable_get("clean_url", "0") == "0") {
if (isset($url)) {
if (isset($query)) {
@@ -1243,6 +1280,16 @@ set_error_handler("error_handler");
// spit out the correct charset http header
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"], "/"))) {
+ $_GET["q"] = $path;
+ }
+}
+else {
+ $_GET["q"] = variable_get("site_frontpage", "node");
+}
+
// initialize installed modules:
module_init();
diff --git a/index.php b/index.php
index 198b23ed7..fc58571b3 100644
--- a/index.php
+++ b/index.php
@@ -3,23 +3,14 @@
include_once "includes/common.inc";
-if (!empty($_GET["q"])) {
- if (module_exist("node") && $path = node_get_alias($_GET["q"])) {
- $_GET["q"] = $path;
- }
-}
-else {
- $_GET["q"] = variable_get("site_frontpage", "node");
-}
-
-$mod = arg(0);
-
drupal_page_header();
check_php_setting("magic_quotes_gpc", 0);
menu_build("system");
+$mod = arg(0);
+
if (isset($mod) && module_hook($mod, "page")) {
module_invoke($mod, "page");
}
diff --git a/modules/forum.module b/modules/forum.module
index 1f7c6e26e..dfa2a2ccd 100644
--- a/modules/forum.module
+++ b/modules/forum.module
@@ -110,14 +110,13 @@ function forum_link($type, $node = 0, $main = 0) {
if (!$main && $type == "node" && $node->type == "forum") {
// get previous and next topic
- $result = db_query("SELECT n.nid, n.title, n.body, n.path, GREATEST(n.created, MAX(c.timestamp)) AS date_sort, COUNT(c.nid) AS num_comments FROM {node} n INNER JOIN {forum} f ON n.nid = f.nid INNER JOIN {comments} c ON n.nid = c.nid WHERE n.nid = f.nid AND f.tid = %d AND n.status = 1 GROUP BY n.nid, n.title, n.body, n.created ORDER BY ". _forum_get_topic_order(isset($user->sortby) ? $user->sortby : variable_get("forum_order",1)), $node->tid);
+ $result = db_query("SELECT n.nid, n.title, n.body, GREATEST(n.created, MAX(c.timestamp)) AS date_sort, COUNT(c.nid) AS num_comments FROM {node} n INNER JOIN {forum} f ON n.nid = f.nid INNER JOIN {comments} c ON n.nid = c.nid WHERE n.nid = f.nid AND f.tid = %d AND n.status = 1 GROUP BY n.nid, n.title, n.body, n.created ORDER BY ". _forum_get_topic_order(isset($user->sortby) ? $user->sortby : variable_get("forum_order",1)), $node->tid);
while ($topic = db_fetch_object($result)) {
if ($stop == 1) {
$next->nid = $topic->nid;
$next->title = $topic->title;
$next->body = $topic->body;
- $next->path = $topic->path;
break;
}
if ($topic->nid == $node->nid) {
@@ -127,16 +126,15 @@ function forum_link($type, $node = 0, $main = 0) {
$prev->nid = $topic->nid;
$prev->title = $topic->title;
$prev->body = $topic->body;
- $prev->path = $topic->path;
}
}
if ($prev) {
- $links[] = l(t("previous forum topic"), node_url($prev), array("title" => $prev->title .": ". substr(strip_tags($prev->body), 0, 100)."..."));
+ $links[] = l(t("previous forum topic"), "node/view/$prev->nid", array("title" => $prev->title .": ". substr(strip_tags($prev->body), 0, 100)."..."));
}
if ($next) {
- $links[] = l(t("next forum topic"), node_url($next), array("title" => $next->title .": ". substr(strip_tags($next->body), 0, 100)."..."));
+ $links[] = l(t("next forum topic"), "node/view/$next->nid", array("title" => $next->title .": ". substr(strip_tags($next->body), 0, 100)."..."));
}
}
diff --git a/modules/forum/forum.module b/modules/forum/forum.module
index 1f7c6e26e..dfa2a2ccd 100644
--- a/modules/forum/forum.module
+++ b/modules/forum/forum.module
@@ -110,14 +110,13 @@ function forum_link($type, $node = 0, $main = 0) {
if (!$main && $type == "node" && $node->type == "forum") {
// get previous and next topic
- $result = db_query("SELECT n.nid, n.title, n.body, n.path, GREATEST(n.created, MAX(c.timestamp)) AS date_sort, COUNT(c.nid) AS num_comments FROM {node} n INNER JOIN {forum} f ON n.nid = f.nid INNER JOIN {comments} c ON n.nid = c.nid WHERE n.nid = f.nid AND f.tid = %d AND n.status = 1 GROUP BY n.nid, n.title, n.body, n.created ORDER BY ". _forum_get_topic_order(isset($user->sortby) ? $user->sortby : variable_get("forum_order",1)), $node->tid);
+ $result = db_query("SELECT n.nid, n.title, n.body, GREATEST(n.created, MAX(c.timestamp)) AS date_sort, COUNT(c.nid) AS num_comments FROM {node} n INNER JOIN {forum} f ON n.nid = f.nid INNER JOIN {comments} c ON n.nid = c.nid WHERE n.nid = f.nid AND f.tid = %d AND n.status = 1 GROUP BY n.nid, n.title, n.body, n.created ORDER BY ". _forum_get_topic_order(isset($user->sortby) ? $user->sortby : variable_get("forum_order",1)), $node->tid);
while ($topic = db_fetch_object($result)) {
if ($stop == 1) {
$next->nid = $topic->nid;
$next->title = $topic->title;
$next->body = $topic->body;
- $next->path = $topic->path;
break;
}
if ($topic->nid == $node->nid) {
@@ -127,16 +126,15 @@ function forum_link($type, $node = 0, $main = 0) {
$prev->nid = $topic->nid;
$prev->title = $topic->title;
$prev->body = $topic->body;
- $prev->path = $topic->path;
}
}
if ($prev) {
- $links[] = l(t("previous forum topic"), node_url($prev), array("title" => $prev->title .": ". substr(strip_tags($prev->body), 0, 100)."..."));
+ $links[] = l(t("previous forum topic"), "node/view/$prev->nid", array("title" => $prev->title .": ". substr(strip_tags($prev->body), 0, 100)."..."));
}
if ($next) {
- $links[] = l(t("next forum topic"), node_url($next), array("title" => $next->title .": ". substr(strip_tags($next->body), 0, 100)."..."));
+ $links[] = l(t("next forum topic"), "node/view/$next->nid", array("title" => $next->title .": ". substr(strip_tags($next->body), 0, 100)."..."));
}
}
diff --git a/modules/node.module b/modules/node.module
index e7844a37b..65f609de4 100644
--- a/modules/node.module
+++ b/modules/node.module
@@ -77,7 +77,7 @@ function node_system($field){
function node_title_list($result, $title = NULL) {
while ($node = db_fetch_object($result)) {
$number = module_invoke("comment", "num_all", $node->nid);
- $items[] = l($node->title, node_url($node), array("title" => format_plural($number, "%count comment", "%count comments")));
+ $items[] = l($node->title, "node/view/$node->nid", array("title" => format_plural($number, "%count comment", "%count comments")));
}
return theme("theme_node_list", $items, $title);
@@ -465,7 +465,7 @@ function node_access($op, $node = 0) {
}
function node_perm() {
- return array("administer nodes", "access content", "create custom URLs");
+ return array("administer nodes", "access content");
}
function node_search($keys) {
@@ -603,7 +603,7 @@ function node_admin_edit($node) {
$output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">";
$output .= " <tr><th>". t("older revisions") ."</th><th colspan=\"3\">". t("operations") ."</th></tr>";
foreach ($node->revisions as $key => $revision) {
- $output .= " <tr><td>". t("revision #%r revised by %u on %d", array("%r" => $key, "%u" => format_name(user_load(array("uid" => $revision["uid"]))), "%d" => format_date($revision["timestamp"], "small"))) . ($revision["history"] ? "<br /><small>". $revision["history"] ."</small>" : "") ."</td><td>". l(t("view revision"), node_url($node), array(), "revision=$key") ."</td><td>". l(t("rollback revision"), "admin/node/rollback+revision/$node->nid/$key") ."</td><td>". l(t("delete revision"), "admin/node/delete+revision/$node->nid/$key") ."</td></tr>";
+ $output .= " <tr><td>". t("revision #%r revised by %u on %d", array("%r" => $key, "%u" => format_name(user_load(array("uid" => $revision["uid"]))), "%d" => format_date($revision["timestamp"], "small"))) . ($revision["history"] ? "<br /><small>". $revision["history"] ."</small>" : "") ."</td><td>". l(t("view revision"), "node/view/$node->nid", array(), "revision=$key") ."</td><td>". l(t("rollback revision"), "admin/node/rollback+revision/$node->nid/$key") ."</td><td>". l(t("delete revision"), "admin/node/delete+revision/$node->nid/$key") ."</td></tr>";
}
$output .= "</table>";
}
@@ -698,7 +698,7 @@ function node_admin_nodes() {
$header = array(NULL, t("title"), t("type"), t("author"), t("status"), array ("data" => t("operations"), "colspan" => 2));
while ($node = db_fetch_object($result)) {
- $rows[] = array(form_checkbox(NULL, "status][$node->nid", 1, 0), l($node->title, node_url($node)) ." ". (node_is_new($node->nid, $node->changed) ? theme_mark() : ""), module_invoke($node->type, "node", "name"), format_name($node), ($node->status ? t("published") : t("not published")), l(t("edit node"), "admin/node/edit/$node->nid"), l(t("delete node"), "admin/node/delete/$node->nid"));
+ $rows[] = array(form_checkbox(NULL, "status][$node->nid", 1, 0), l($node->title, "node/view/$node->nid") ." ". (node_is_new($node->nid, $node->changed) ? theme_mark() : ""), module_invoke($node->type, "node", "name"), format_name($node), ($node->status ? t("published") : t("not published")), l(t("edit node"), "admin/node/edit/$node->nid"), l(t("delete node"), "admin/node/delete/$node->nid"));
}
if ($pager = pager_display(NULL, 50, 0, "admin")) {
@@ -945,23 +945,6 @@ function node_block($op = "list", $delta = 0) {
}
}
-function node_get_alias($path) {
-
- $result = db_query("SELECT nid FROM {node} WHERE path = '%s'", trim($path, "/"));
- if ($node = db_fetch_object($result)) {
- return "node/view/$node->nid";
- }
-}
-
-function node_url($node) {
- if ($node->path != NULL) {
- return $node->path;
- }
- else {
- return "node/view/$node->nid";
- }
-}
-
function node_feed($nodes = 0, $channel = array()) {
global $base_url, $languages;
@@ -974,7 +957,7 @@ function node_feed($nodes = 0, $channel = array()) {
*/
if (!$nodes) {
- $nodes = db_query_range("SELECT nid, path FROM {node} WHERE promote = '1' AND status = '1' ORDER BY created DESC", 0, 15);
+ $nodes = db_query_range("SELECT nid, FROM {node} WHERE promote = '1' AND status = '1' ORDER BY created DESC", 0, 15);
}
while ($node = db_fetch_object($nodes)) {
@@ -983,7 +966,7 @@ function node_feed($nodes = 0, $channel = array()) {
*/
$item = node_load(array("nid" => $node->nid));
- $link = url(node_url($node));
+ $link = url("node/view/$node->nid");
$items .= format_rss_item($item->title, $link, ($item->teaser ? $item->teaser : $item->body), array("pubDate" => date("r", $item->changed)));
}
@@ -1025,19 +1008,6 @@ function node_validate($node, &$error) {
}
/*
- ** Clean the path field:
- */
-
- if ($node->path) {
- if (!valid_url($node->path)) {
- $error["path"] = theme("theme_error", t("The specified path is not valid."));
- }
- else if (db_result(db_query("SELECT COUNT(nid) FROM {node} WHERE nid != %d AND path = '%s'", $node->nid, $node->path))) {
- $error["path"] = theme("theme_error", t("The specified path is already in use."));
- }
- }
-
- /*
** Common default values:
*/
@@ -1120,41 +1090,6 @@ function node_validate($node, &$error) {
}
-function node_clean_path($path) {
-/*
-** Clean the node path
-*/
- global $base_url;
-
- /*
- ** Replace absolute URL for this site with relative URL.
- */
- $path = str_replace($base_url, "", $path);
-
- /*
- ** Only allow alpha numeric characters and slashes.
- */
- $path = preg_replace("'[^a-zA-Z0-9/.]'", " ", $path);
-
- /*
- ** Remove all whitespace.
- */
- $path = str_replace(" ", "", $path);
-
- /*
- ** Replace two or more sequential slashes with only one slashes.
- */
- $path = preg_replace("'//*'","/",$path);
-
- /*
- ** Remove beginning and trailing slashes.
- */
- $path = trim($path, "/");
-
- return $path;
-}
-
-
function node_form($edit, $error = NULL) {
/*
@@ -1229,10 +1164,6 @@ function node_form($edit, $error = NULL) {
$output .= "<div class=\"standard\">";
$output .= form_textfield(t("Title"), "title", $edit->title, 60, 128, $error["title"]);
- if (user_access("create custom URLs")) {
- $output .= form_textfield(t("Path alias"), "path", ($edit->path == "node/view/$edit->nid") ? "" : $edit->path, 60, 250, $error["path"] ? $error["path"] : t("Optionally specify an alternative URL by which this node can be accessed. For example, type 'about' when writing an about page. Don't add a trailing slash or the URL won't work."));
- }
-
/*
** Add the node specific fields:
*/
@@ -1454,7 +1385,7 @@ function node_submit($node) {
if (node_access("update", $node)) {
$node->nid = node_save($node);
- watchdog("special", "$node->type: updated '$node->title'", l(t("view post"), node_url($node)));
+ watchdog("special", "$node->type: updated '$node->title'", l(t("view post"), "node/view/$node->nid"));
$output = t("The %name has been updated.", array ("%name" => module_invoke($node->type, "node", "name")));
}
}
@@ -1475,7 +1406,7 @@ function node_submit($node) {
throttle("node", variable_get("max_node_rate", 900));
$node->nid = node_save($node);
- watchdog("special", "$node->type: added '$node->title'", l(t("view post"), node_url($node)));
+ watchdog("special", "$node->type: added '$node->title'", l(t("view post"), "node/view/$node->nid"));
$output = t("Thanks for your submission.");
}
}
@@ -1496,7 +1427,7 @@ function node_submit($node) {
}
if ($node->nid && node_access("view", $node)) {
- $links[] = l(t("view"), node_url($node));
+ $links[] = l(t("view"), "node/view/$node->nid");
}
if ($node->nid && node_access("update", $node)) {
@@ -1643,7 +1574,7 @@ function node_nodeapi(&$node, $op, $arg = 0) {
$output[t("revision")] = form_checkbox("", "node_revision_$node->type", 1, variable_get("node_revision_$node->type", 0));
return $output;
case "fields":
- return array("nid", "uid", "type", "title", "path", "teaser", "body", "revisions", "status", "promote", "moderate", "static", "created", "changed");
+ return array("nid", "uid", "type", "title", "teaser", "body", "revisions", "status", "promote", "moderate", "static", "created", "changed");
}
}
diff --git a/modules/node/node.module b/modules/node/node.module
index e7844a37b..65f609de4 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -77,7 +77,7 @@ function node_system($field){
function node_title_list($result, $title = NULL) {
while ($node = db_fetch_object($result)) {
$number = module_invoke("comment", "num_all", $node->nid);
- $items[] = l($node->title, node_url($node), array("title" => format_plural($number, "%count comment", "%count comments")));
+ $items[] = l($node->title, "node/view/$node->nid", array("title" => format_plural($number, "%count comment", "%count comments")));
}
return theme("theme_node_list", $items, $title);
@@ -465,7 +465,7 @@ function node_access($op, $node = 0) {
}
function node_perm() {
- return array("administer nodes", "access content", "create custom URLs");
+ return array("administer nodes", "access content");
}
function node_search($keys) {
@@ -603,7 +603,7 @@ function node_admin_edit($node) {
$output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">";
$output .= " <tr><th>". t("older revisions") ."</th><th colspan=\"3\">". t("operations") ."</th></tr>";
foreach ($node->revisions as $key => $revision) {
- $output .= " <tr><td>". t("revision #%r revised by %u on %d", array("%r" => $key, "%u" => format_name(user_load(array("uid" => $revision["uid"]))), "%d" => format_date($revision["timestamp"], "small"))) . ($revision["history"] ? "<br /><small>". $revision["history"] ."</small>" : "") ."</td><td>". l(t("view revision"), node_url($node), array(), "revision=$key") ."</td><td>". l(t("rollback revision"), "admin/node/rollback+revision/$node->nid/$key") ."</td><td>". l(t("delete revision"), "admin/node/delete+revision/$node->nid/$key") ."</td></tr>";
+ $output .= " <tr><td>". t("revision #%r revised by %u on %d", array("%r" => $key, "%u" => format_name(user_load(array("uid" => $revision["uid"]))), "%d" => format_date($revision["timestamp"], "small"))) . ($revision["history"] ? "<br /><small>". $revision["history"] ."</small>" : "") ."</td><td>". l(t("view revision"), "node/view/$node->nid", array(), "revision=$key") ."</td><td>". l(t("rollback revision"), "admin/node/rollback+revision/$node->nid/$key") ."</td><td>". l(t("delete revision"), "admin/node/delete+revision/$node->nid/$key") ."</td></tr>";
}
$output .= "</table>";
}
@@ -698,7 +698,7 @@ function node_admin_nodes() {
$header = array(NULL, t("title"), t("type"), t("author"), t("status"), array ("data" => t("operations"), "colspan" => 2));
while ($node = db_fetch_object($result)) {
- $rows[] = array(form_checkbox(NULL, "status][$node->nid", 1, 0), l($node->title, node_url($node)) ." ". (node_is_new($node->nid, $node->changed) ? theme_mark() : ""), module_invoke($node->type, "node", "name"), format_name($node), ($node->status ? t("published") : t("not published")), l(t("edit node"), "admin/node/edit/$node->nid"), l(t("delete node"), "admin/node/delete/$node->nid"));
+ $rows[] = array(form_checkbox(NULL, "status][$node->nid", 1, 0), l($node->title, "node/view/$node->nid") ." ". (node_is_new($node->nid, $node->changed) ? theme_mark() : ""), module_invoke($node->type, "node", "name"), format_name($node), ($node->status ? t("published") : t("not published")), l(t("edit node"), "admin/node/edit/$node->nid"), l(t("delete node"), "admin/node/delete/$node->nid"));
}
if ($pager = pager_display(NULL, 50, 0, "admin")) {
@@ -945,23 +945,6 @@ function node_block($op = "list", $delta = 0) {
}
}
-function node_get_alias($path) {
-
- $result = db_query("SELECT nid FROM {node} WHERE path = '%s'", trim($path, "/"));
- if ($node = db_fetch_object($result)) {
- return "node/view/$node->nid";
- }
-}
-
-function node_url($node) {
- if ($node->path != NULL) {
- return $node->path;
- }
- else {
- return "node/view/$node->nid";
- }
-}
-
function node_feed($nodes = 0, $channel = array()) {
global $base_url, $languages;
@@ -974,7 +957,7 @@ function node_feed($nodes = 0, $channel = array()) {
*/
if (!$nodes) {
- $nodes = db_query_range("SELECT nid, path FROM {node} WHERE promote = '1' AND status = '1' ORDER BY created DESC", 0, 15);
+ $nodes = db_query_range("SELECT nid, FROM {node} WHERE promote = '1' AND status = '1' ORDER BY created DESC", 0, 15);
}
while ($node = db_fetch_object($nodes)) {
@@ -983,7 +966,7 @@ function node_feed($nodes = 0, $channel = array()) {
*/
$item = node_load(array("nid" => $node->nid));
- $link = url(node_url($node));
+ $link = url("node/view/$node->nid");
$items .= format_rss_item($item->title, $link, ($item->teaser ? $item->teaser : $item->body), array("pubDate" => date("r", $item->changed)));
}
@@ -1025,19 +1008,6 @@ function node_validate($node, &$error) {
}
/*
- ** Clean the path field:
- */
-
- if ($node->path) {
- if (!valid_url($node->path)) {
- $error["path"] = theme("theme_error", t("The specified path is not valid."));
- }
- else if (db_result(db_query("SELECT COUNT(nid) FROM {node} WHERE nid != %d AND path = '%s'", $node->nid, $node->path))) {
- $error["path"] = theme("theme_error", t("The specified path is already in use."));
- }
- }
-
- /*
** Common default values:
*/
@@ -1120,41 +1090,6 @@ function node_validate($node, &$error) {
}
-function node_clean_path($path) {
-/*
-** Clean the node path
-*/
- global $base_url;
-
- /*
- ** Replace absolute URL for this site with relative URL.
- */
- $path = str_replace($base_url, "", $path);
-
- /*
- ** Only allow alpha numeric characters and slashes.
- */
- $path = preg_replace("'[^a-zA-Z0-9/.]'", " ", $path);
-
- /*
- ** Remove all whitespace.
- */
- $path = str_replace(" ", "", $path);
-
- /*
- ** Replace two or more sequential slashes with only one slashes.
- */
- $path = preg_replace("'//*'","/",$path);
-
- /*
- ** Remove beginning and trailing slashes.
- */
- $path = trim($path, "/");
-
- return $path;
-}
-
-
function node_form($edit, $error = NULL) {
/*
@@ -1229,10 +1164,6 @@ function node_form($edit, $error = NULL) {
$output .= "<div class=\"standard\">";
$output .= form_textfield(t("Title"), "title", $edit->title, 60, 128, $error["title"]);
- if (user_access("create custom URLs")) {
- $output .= form_textfield(t("Path alias"), "path", ($edit->path == "node/view/$edit->nid") ? "" : $edit->path, 60, 250, $error["path"] ? $error["path"] : t("Optionally specify an alternative URL by which this node can be accessed. For example, type 'about' when writing an about page. Don't add a trailing slash or the URL won't work."));
- }
-
/*
** Add the node specific fields:
*/
@@ -1454,7 +1385,7 @@ function node_submit($node) {
if (node_access("update", $node)) {
$node->nid = node_save($node);
- watchdog("special", "$node->type: updated '$node->title'", l(t("view post"), node_url($node)));
+ watchdog("special", "$node->type: updated '$node->title'", l(t("view post"), "node/view/$node->nid"));
$output = t("The %name has been updated.", array ("%name" => module_invoke($node->type, "node", "name")));
}
}
@@ -1475,7 +1406,7 @@ function node_submit($node) {
throttle("node", variable_get("max_node_rate", 900));
$node->nid = node_save($node);
- watchdog("special", "$node->type: added '$node->title'", l(t("view post"), node_url($node)));
+ watchdog("special", "$node->type: added '$node->title'", l(t("view post"), "node/view/$node->nid"));
$output = t("Thanks for your submission.");
}
}
@@ -1496,7 +1427,7 @@ function node_submit($node) {
}
if ($node->nid && node_access("view", $node)) {
- $links[] = l(t("view"), node_url($node));
+ $links[] = l(t("view"), "node/view/$node->nid");
}
if ($node->nid && node_access("update", $node)) {
@@ -1643,7 +1574,7 @@ function node_nodeapi(&$node, $op, $arg = 0) {
$output[t("revision")] = form_checkbox("", "node_revision_$node->type", 1, variable_get("node_revision_$node->type", 0));
return $output;
case "fields":
- return array("nid", "uid", "type", "title", "path", "teaser", "body", "revisions", "status", "promote", "moderate", "static", "created", "changed");
+ return array("nid", "uid", "type", "title", "teaser", "body", "revisions", "status", "promote", "moderate", "static", "created", "changed");
}
}
diff --git a/modules/page.module b/modules/page.module
index d8f1934cf..204d7b8f1 100644
--- a/modules/page.module
+++ b/modules/page.module
@@ -89,9 +89,9 @@ function page_link($type) {
$links = array();
if ($type == "page" && user_access("access content")) {
- $result = db_query("SELECT n.nid, n.title, n.path, p.link, p.description FROM {page} p INNER JOIN {node} n ON p.nid = n.nid WHERE n.status = '1' AND p.link != '' ORDER BY p.link");
+ $result = db_query("SELECT n.nid, n.title, p.link, p.description FROM {page} p INNER JOIN {node} n ON p.nid = n.nid WHERE n.status = '1' AND p.link != '' ORDER BY p.link");
while ($page = db_fetch_object($result)) {
- $links[] = l($page->link, node_url($page), array("title" => $page->description));
+ $links[] = l($page->link, "node/view/$page->nid", array("title" => $page->description));
}
}
diff --git a/modules/page/page.module b/modules/page/page.module
index d8f1934cf..204d7b8f1 100644
--- a/modules/page/page.module
+++ b/modules/page/page.module
@@ -89,9 +89,9 @@ function page_link($type) {
$links = array();
if ($type == "page" && user_access("access content")) {
- $result = db_query("SELECT n.nid, n.title, n.path, p.link, p.description FROM {page} p INNER JOIN {node} n ON p.nid = n.nid WHERE n.status = '1' AND p.link != '' ORDER BY p.link");
+ $result = db_query("SELECT n.nid, n.title, p.link, p.description FROM {page} p INNER JOIN {node} n ON p.nid = n.nid WHERE n.status = '1' AND p.link != '' ORDER BY p.link");
while ($page = db_fetch_object($result)) {
- $links[] = l($page->link, node_url($page), array("title" => $page->description));
+ $links[] = l($page->link, "node/view/$page->nid", array("title" => $page->description));
}
}
diff --git a/modules/statistics.module b/modules/statistics.module
index fbfd3bc39..c847f60a1 100644
--- a/modules/statistics.module
+++ b/modules/statistics.module
@@ -400,7 +400,7 @@ function statistics_admin_accesslog_table($type, $id) {
$url = message_na();
}
- $rows[] = array(array("data" => format_date($log->timestamp, "small"), "nowrap" => "nowrap"), ($node->nid ? l($node->title, node_url($node)) : message_na()), format_name($user), $log->hostname ? $log->hostname : message_na(), $url, ($log->nid ? l(t("track node"), "admin/statistics/log/node/$log->nid") : ""), ($user->uid ? l(t("track user"), "admin/statistics/log/user/$user->uid") : ""), ($log->hostname ? l(t("track host"), "admin/statistics/log/host/$log->hostname") : ""));
+ $rows[] = array(array("data" => format_date($log->timestamp, "small"), "nowrap" => "nowrap"), ($node->nid ? l($node->title, "node/view/$node->nid") : message_na()), format_name($user), $log->hostname ? $log->hostname : message_na(), $url, ($log->nid ? l(t("track node"), "admin/statistics/log/node/$log->nid") : ""), ($user->uid ? l(t("track user"), "admin/statistics/log/user/$user->uid") : ""), ($log->hostname ? l(t("track host"), "admin/statistics/log/host/$log->hostname") : ""));
}
if ($pager = pager_display(NULL, 50, 0, "admin", tablesort_pager())) {
diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module
index fbfd3bc39..c847f60a1 100644
--- a/modules/statistics/statistics.module
+++ b/modules/statistics/statistics.module
@@ -400,7 +400,7 @@ function statistics_admin_accesslog_table($type, $id) {
$url = message_na();
}
- $rows[] = array(array("data" => format_date($log->timestamp, "small"), "nowrap" => "nowrap"), ($node->nid ? l($node->title, node_url($node)) : message_na()), format_name($user), $log->hostname ? $log->hostname : message_na(), $url, ($log->nid ? l(t("track node"), "admin/statistics/log/node/$log->nid") : ""), ($user->uid ? l(t("track user"), "admin/statistics/log/user/$user->uid") : ""), ($log->hostname ? l(t("track host"), "admin/statistics/log/host/$log->hostname") : ""));
+ $rows[] = array(array("data" => format_date($log->timestamp, "small"), "nowrap" => "nowrap"), ($node->nid ? l($node->title, "node/view/$node->nid") : message_na()), format_name($user), $log->hostname ? $log->hostname : message_na(), $url, ($log->nid ? l(t("track node"), "admin/statistics/log/node/$log->nid") : ""), ($user->uid ? l(t("track user"), "admin/statistics/log/user/$user->uid") : ""), ($log->hostname ? l(t("track host"), "admin/statistics/log/host/$log->hostname") : ""));
}
if ($pager = pager_display(NULL, 50, 0, "admin", tablesort_pager())) {
diff --git a/modules/title.module b/modules/title.module
index 8004c7017..311200ff0 100644
--- a/modules/title.module
+++ b/modules/title.module
@@ -33,7 +33,7 @@ function title_page() {
$header = array(t("Type"), t("Title"), t("Author"));
while ($node = db_fetch_object($result)) {
$type = ucfirst(module_invoke($node->type, "node", "name"));
- $title = l($node->title, node_url($node));
+ $title = l($node->title, "node/view/$node->nid");
$author = format_name($node);
$rows[] = array(array("data" => $type, "class" => "type"), array("data" => $title, "class" => "content"), array("data" => $author, "class" => "author"));
}
diff --git a/modules/tracker.module b/modules/tracker.module
index 3c98fa125..9286bb586 100644
--- a/modules/tracker.module
+++ b/modules/tracker.module
@@ -59,7 +59,7 @@ function tracker_posts($id = 0) {
}
$type = ucfirst(module_invoke($node->type, "node", "name"));
- $title = l($node->title, node_url($node)) ." ". (node_is_new($node->nid, $node->changed) ? theme("theme_mark") : "");
+ $title = l($node->title, "node/view/$node->nid") ." ". (node_is_new($node->nid, $node->changed) ? theme("theme_mark") : "");
$author = format_name($node);
$comments = array();
diff --git a/modules/tracker/tracker.module b/modules/tracker/tracker.module
index 3c98fa125..9286bb586 100644
--- a/modules/tracker/tracker.module
+++ b/modules/tracker/tracker.module
@@ -59,7 +59,7 @@ function tracker_posts($id = 0) {
}
$type = ucfirst(module_invoke($node->type, "node", "name"));
- $title = l($node->title, node_url($node)) ." ". (node_is_new($node->nid, $node->changed) ? theme("theme_mark") : "");
+ $title = l($node->title, "node/view/$node->nid") ." ". (node_is_new($node->nid, $node->changed) ? theme("theme_mark") : "");
$author = format_name($node);
$comments = array();
diff --git a/themes/xtemplate/xtemplate.theme b/themes/xtemplate/xtemplate.theme
index 5d1434fc5..ab96fa1d8 100644
--- a/themes/xtemplate/xtemplate.theme
+++ b/themes/xtemplate/xtemplate.theme
@@ -35,7 +35,7 @@ class Theme_xtemplate extends BaseTheme {
function node($node, $main = 0) {
$this->template->assign(array(
- "link" => url(node_url($node)),
+ "link" => url("node/view/$node->nid"),
"title" => ucfirst($node->title),
"author" => format_name($node),
"date" => format_date($node->created),