Commit 8759ca73 authored by Dries's avatar Dries

- Commited the URL aliasing patch.  Thanks Matt.

  This update requires you to run update.php!
parent 1252d512
Drupal x.x.x, xxxx-xx-xx (to be released)
------------------------
- added support for configurable URLs.
- database backend:
* added support for database table prefxing.
- performance improvements:
......
......@@ -186,6 +186,7 @@ CREATE TABLE [dbo].[node] (
[nid] [numeric](10, 0) NULL ,
[type] [varchar] (16) NOT NULL ,
[title] [varchar] (128) NOT NULL ,
[path] [varchar] (250) NULL ,
[score] [int] NOT NULL ,
[votes] [int] NOT NULL ,
[uid] [int] NOT NULL ,
......
......@@ -262,6 +262,7 @@ 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',
......
......@@ -261,6 +261,7 @@ CREATE TABLE node (
nid SERIAL,
type varchar(16) NOT NULL default '',
title varchar(128) NOT NULL default '',
path varchar(250) NULL default '',
score integer NOT NULL default '0',
votes integer NOT NULL default '0',
uid integer NOT NULL default '0',
......
......@@ -298,6 +298,21 @@ function valid_email_address($mail) {
}
}
/**
* Verify the syntax of the given URL.
*
* @param $url an URL
*/
function valid_url($url) {
if (preg_match("/^[a-zA-z0-9\/:_\-_\.]+$/", $url)) {
return 1;
}
else {
return 0;
}
}
/**
* Format a single result entry of a search query:
*
......
......@@ -4,7 +4,10 @@
include_once "includes/common.inc";
if (isset($_GET["q"])) {
$mod = arg(0);
if (module_exist("node") && $path = node_get_alias($_GET["q"])) {
$_GET["q"] = $path;
}
$mod = arg(0);
}
else {
$_GET["q"] = variable_get("site_frontpage", "node");
......
......@@ -121,13 +121,14 @@ 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, 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, 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);
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) {
......@@ -137,15 +138,16 @@ 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/view/$prev->nid", array("title" => $prev->title .": ". substr(strip_tags($prev->body), 0, 100)."..."));
$links[] = l(t("previous forum topic"), node_url($prev), array("title" => $prev->title .": ". substr(strip_tags($prev->body), 0, 100)."..."));
}
if ($next) {
$links[] = l(t("next forum topic"), "node/view/$next->nid", array("title" => $next->title .": ". substr(strip_tags($next->body), 0, 100)."..."));
$links[] = l(t("next forum topic"), node_url($next), array("title" => $next->title .": ". substr(strip_tags($next->body), 0, 100)."..."));
}
}
......
......@@ -121,13 +121,14 @@ 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, 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, 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);
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) {
......@@ -137,15 +138,16 @@ 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/view/$prev->nid", array("title" => $prev->title .": ". substr(strip_tags($prev->body), 0, 100)."..."));
$links[] = l(t("previous forum topic"), node_url($prev), array("title" => $prev->title .": ". substr(strip_tags($prev->body), 0, 100)."..."));
}
if ($next) {
$links[] = l(t("next forum topic"), "node/view/$next->nid", array("title" => $next->title .": ". substr(strip_tags($next->body), 0, 100)."..."));
$links[] = l(t("next forum topic"), node_url($next), array("title" => $next->title .": ". substr(strip_tags($next->body), 0, 100)."..."));
}
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -75,9 +75,9 @@ function page_link($type) {
$links = array();
if ($type == "page" && user_access("access content")) {
$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");
$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");
while ($page = db_fetch_object($result)) {
$links[] = l($page->link, "node/view/$page->nid", array("title" => $page->description));
$links[] = l($page->link, node_url($page), array("title" => $page->description));
}
}
......
......@@ -75,9 +75,9 @@ function page_link($type) {
$links = array();
if ($type == "page" && user_access("access content")) {
$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");
$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");
while ($page = db_fetch_object($result)) {
$links[] = l($page->link, "node/view/$page->nid", array("title" => $page->description));
$links[] = l($page->link, node_url($page), array("title" => $page->description));
}
}
......
......@@ -302,9 +302,6 @@ function statistics_admin_accesslog_table($type, $id) {
$header = array(t("timestamp"), t("post"), t("user"), t("hostname"), t("referrer"), array("data" => t("operations"), "colspan" => "3"));
while ($log = db_fetch_object($result)) {
if (!$node = node_load(array("nid" => $log->nid))) {
$node->nid = 0;
}
$user = user_load(array("uid" => $log->uid));
if ($log->url) {
......@@ -314,7 +311,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/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") : ""));
$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") : ""));
}
if ($pager = pager_display(NULL, 50, 0, "admin")) {
......
......@@ -302,9 +302,6 @@ function statistics_admin_accesslog_table($type, $id) {
$header = array(t("timestamp"), t("post"), t("user"), t("hostname"), t("referrer"), array("data" => t("operations"), "colspan" => "3"));
while ($log = db_fetch_object($result)) {
if (!$node = node_load(array("nid" => $log->nid))) {
$node->nid = 0;
}
$user = user_load(array("uid" => $log->uid));
if ($log->url) {
......@@ -314,7 +311,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/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") : ""));
$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") : ""));
}
if ($pager = pager_display(NULL, 50, 0, "admin")) {
......
......@@ -32,7 +32,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/view/$node->nid");
$title = l($node->title, node_url($node));
$author = format_name($node);
$rows[] = array(array("data" => $type, "class" => "type"), array("data" => $title, "class" => "content"), array("data" => $author, "class" => "author"));
}
......
......@@ -42,7 +42,7 @@ function tracker_posts($id = 0) {
}
$type = ucfirst(module_invoke($node->type, "node", "name"));
$title = l($node->title, "node/view/$node->nid") ." ". (node_is_new($node->nid, $node->changed) ? theme("theme_mark") : "");
$title = l($node->title, node_url($node)) ." ". (node_is_new($node->nid, $node->changed) ? theme("theme_mark") : "");
$author = format_name($node);
$comments = array();
......
......@@ -42,7 +42,7 @@ function tracker_posts($id = 0) {
}
$type = ucfirst(module_invoke($node->type, "node", "name"));
$title = l($node->title, "node/view/$node->nid") ." ". (node_is_new($node->nid, $node->changed) ? theme("theme_mark") : "");
$title = l($node->title, node_url($node)) ." ". (node_is_new($node->nid, $node->changed) ? theme("theme_mark") : "");
$author = format_name($node);
$comments = array();
......
......@@ -38,7 +38,8 @@
"2003-05-24" => "update_54",
"2003-05-31" => "update_55",
"2003-06-04" => "update_56",
"2003-06-08" => "update_57"
"2003-06-08" => "update_57",
"2003-06-08: first update since Drupal 4.2.0 release" => "update_58"
);
function update_32() {
......@@ -265,6 +266,10 @@ function update_57() {
update_sql("DELETE FROM variable WHERE name = 'site_charset'");
}
function update_58() {
update_sql("ALTER TABLE node ADD path varchar(250) NULL default ''");
}
/*
** System functions
*/
......
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