? pathauto_start.patch
? modules/devel
? modules/pathauto
Index: database/database.4.0.mysql
===================================================================
RCS file: /cvs/drupal/drupal/database/database.4.0.mysql,v
retrieving revision 1.3
diff -u -F^f -r1.3 database.4.0.mysql
--- database/database.4.0.mysql 12 May 2006 08:50:22 -0000 1.3
+++ database/database.4.0.mysql 15 May 2006 09:40:21 -0000
@@ -412,6 +412,7 @@
promote int(2) NOT NULL default '0',
moderate int(2) NOT NULL default '0',
sticky int(2) NOT NULL default '0',
+ path varchar(255) NOT NULL default '',
PRIMARY KEY (nid, vid),
UNIQUE KEY vid (vid),
KEY node_type (type(4)),
Index: database/database.4.1.mysql
===================================================================
RCS file: /cvs/drupal/drupal/database/database.4.1.mysql,v
retrieving revision 1.3
diff -u -F^f -r1.3 database.4.1.mysql
--- database/database.4.1.mysql 12 May 2006 08:50:22 -0000 1.3
+++ database/database.4.1.mysql 15 May 2006 09:40:22 -0000
@@ -440,6 +440,7 @@
promote int(2) NOT NULL default '0',
moderate int(2) NOT NULL default '0',
sticky int(2) NOT NULL default '0',
+ path varchar(255) NOT NULL default '',
PRIMARY KEY (nid, vid),
UNIQUE KEY vid (vid),
KEY node_type (type(4)),
Index: database/database.pgsql
===================================================================
RCS file: /cvs/drupal/drupal/database/database.pgsql,v
retrieving revision 1.174
diff -u -F^f -r1.174 database.pgsql
--- database/database.pgsql 12 May 2006 08:50:22 -0000 1.174
+++ database/database.pgsql 15 May 2006 09:40:22 -0000
@@ -419,6 +419,7 @@
promote integer NOT NULL default '0',
moderate integer NOT NULL default '0',
sticky integer NOT NULL default '0',
+ path varchar(255) NOT NULL default '',
PRIMARY KEY (nid)
);
CREATE INDEX node_type_idx ON node(type);
Index: database/updates.inc
===================================================================
RCS file: /cvs/drupal/drupal/database/updates.inc,v
retrieving revision 1.227
diff -u -F^f -r1.227 updates.inc
--- database/updates.inc 12 May 2006 08:50:22 -0000 1.227
+++ database/updates.inc 15 May 2006 09:40:24 -0000
@@ -1987,3 +1987,27 @@ function system_update_181() {
}
return $ret;
}
+
+function system_update_182() {
+ $ret = array();
+ switch ($GLOBALS['db_type']) {
+ case 'mysql':
+ case 'mysqli':
+ $ret[] = update_sql("ALTER TABLE {node} ADD path varchar(255) NOT NULL DEFAULT '' AFTER sticky;");
+ // update the default values in the node, default values are 'node/nid'
+ $ret[] = update_sql("UPDATE {node} SET path = CONCAT('node/', nid) WHERE path = ''");
+ break;
+ case 'pgsql':
+ db_add_column($ret, 'node', 'path', 'varchar(255)', array('not null' => TRUE, 'default' => "''"));
+ // update the default values in the node, default values are 'node/nid'
+ $ret[] = update_sql("UPDATE {node} SET path = 'node/' || nid WHERE path = ''");
+ }
+
+ // PostgreSQL needs CREATE TABLE foobar _AS_ SELECT ...
+ $AS = ($GLOBALS['db_type'] == 'pgsql') ? 'AS' : '';
+ $ret[] = update_sql("CREATE TABLE {tmp_node_path} $AS SELECT n.nid, n.path, u.dst FROM node n, url_alias u WHERE n.path = u.src");
+ $ret[] = update_sql('UPDATE {node} n, {tmp_node_path} t SET n.path = t.dst WHERE n.nid = t.nid');
+ $ret[] = update_sql('DROP TABLE {tmp_node_path}');
+
+ return $ret;
+}
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.539
diff -u -F^f -r1.539 common.inc
--- includes/common.inc 9 May 2006 14:19:03 -0000 1.539
+++ includes/common.inc 15 May 2006 09:40:25 -0000
@@ -1052,14 +1052,14 @@ function drupal_attributes($attributes =
*
* @param $text
* The text to be enclosed with the anchor tag.
- * @param $path
- * The Drupal path being linked to, such as "admin/node". Can be an external
- * or internal URL.
- * - If you provide the full URL, it will be considered an
- * external URL.
+ * @param $pathsrc
+ * Either a Drupal node or a string containing the Drupal path being linked to,
+ * such as "admin/node". If a string, the path be an external or internal URL.
+ * - If you provide the full URL, it will be considered an external URL.
* - If you provide only the path (e.g. "admin/node"), it is considered an
* internal link. In this case, it must be a system URL as the url() function
* will generate the alias.
+ * If a node, the path member variable will be used for the path string
* @param $attributes
* An associative array of HTML attributes to apply to the anchor tag.
* @param $query
@@ -1077,7 +1077,11 @@ function drupal_attributes($attributes =
* @return
* an HTML string containing a link to the given path.
*/
-function l($text, $path, $attributes = array(), $query = NULL, $fragment = NULL, $absolute = FALSE, $html = FALSE) {
+function l($text, $pathsrc, $attributes = array(), $query = NULL, $fragment = NULL, $absolute = FALSE, $html = FALSE) {
+
+ // if path is an object, assume node object and use the path
+ $path = (is_object($pathsrc)) ? $pathsrc->path : $pathsrc;
+
if ($path == $_GET['q']) {
if (isset($attributes['class'])) {
$attributes['class'] .= ' active';
@@ -1086,6 +1090,7 @@ function l($text, $path, $attributes = a
$attributes['class'] = 'active';
}
}
+
return ''. ($html ? $text : check_plain($text)) .'';
}
Index: modules/blog.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/blog.module,v
retrieving revision 1.248
diff -u -F^f -r1.248 blog.module
--- modules/blog.module 15 May 2006 06:11:00 -0000 1.248
+++ modules/blog.module 15 May 2006 09:40:26 -0000
@@ -235,7 +235,7 @@ function blog_view(&$node, $teaser = FAL
// Breadcrumb navigation
$breadcrumb[] = array('path' => 'blog', 'title' => t('blogs'));
$breadcrumb[] = array('path' => 'blog/'. $node->uid, 'title' => t("%name's blog", array('%name' => $node->name)));
- $breadcrumb[] = array('path' => 'node/'. $node->nid);
+ $breadcrumb[] = array('path' => $node->path);
menu_set_location($breadcrumb);
}
$node = node_prepare($node, $teaser);
Index: modules/blogapi.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/blogapi.module,v
retrieving revision 1.83
diff -u -F^f -r1.83 blogapi.module
--- modules/blogapi.module 7 May 2006 00:08:36 -0000 1.83
+++ modules/blogapi.module 15 May 2006 09:40:26 -0000
@@ -230,7 +230,7 @@ function blogapi_blogger_new_post($appke
$node = node_submit($edit);
node_save($node);
if ($node->nid) {
- watchdog('content', t('%type: added %title using blog API.', array('%type' => ''. t($node->type) .'', '%title' => theme('placeholder', $node->title))), WATCHDOG_NOTICE, l(t('view'), "node/$node->nid"));
+ watchdog('content', t('%type: added %title using blog API.', array('%type' => ''. t($node->type) .'', '%title' => theme('placeholder', $node->title))), WATCHDOG_NOTICE, l(t('view'), $node->path));
// blogger.newPost returns a string so we cast the nid to a string by putting it in double quotes:
return "$node->nid";
}
@@ -284,7 +284,7 @@ function blogapi_blogger_edit_post($appk
$node = node_submit($node);
node_save($node);
if ($node->nid) {
- watchdog('content', t('%type: updated %title using blog API.', array('%type' => ''. t($node->type) .'', '%title' => theme('placeholder', $node->title))), WATCHDOG_NOTICE, l(t('view'), "node/$node->nid"));
+ watchdog('content', t('%type: updated %title using blog API.', array('%type' => ''. t($node->type) .'', '%title' => theme('placeholder', $node->title))), WATCHDOG_NOTICE, l(t('view'), $node->path));
return true;
}
@@ -693,8 +693,8 @@ function _blogapi_get_post($node, $bodie
'dateCreated' => xmlrpc_date($node->created),
'title' => $node->title,
'postid' => $node->nid,
- 'link' => url('node/'.$node->nid, NULL, NULL, true),
- 'permaLink' => url('node/'.$node->nid, NULL, NULL, true),
+ 'link' => url($node->path, NULL, NULL, true),
+ 'permaLink' => url($node->path, NULL, NULL, true),
);
if ($bodies) {
if ($node->comment = 1) {
Index: modules/book.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/book.module,v
retrieving revision 1.364
diff -u -F^f -r1.364 book.module
--- modules/book.module 13 May 2006 10:02:54 -0000 1.364
+++ modules/book.module 15 May 2006 09:40:27 -0000
@@ -148,7 +148,7 @@ function book_block($op = 'list', $delta
else if ($op == 'view') {
// Only display this block when the user is browsing a book:
if (arg(0) == 'node' && is_numeric(arg(1))) {
- $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.parent FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE n.nid = %d'), arg(1));
+ $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, n.path, b.parent FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE n.nid = %d'), arg(1));
if (db_num_rows($result) > 0) {
$node = db_fetch_object($result);
@@ -369,7 +369,7 @@ function book_outline_submit($form_id, $
*
*/
function book_location($node, $nodes = array()) {
- $parent = db_fetch_object(db_query(db_rewrite_sql('SELECT n.nid, n.title, b.parent, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE n.nid = %d'), $node->parent));
+ $parent = db_fetch_object(db_query(db_rewrite_sql('SELECT n.nid, n.title, n.path, b.parent, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE n.nid = %d'), $node->parent));
if ($parent->title) {
$nodes = book_location($parent, $nodes);
$nodes[] = $parent;
@@ -381,7 +381,7 @@ function book_location($node, $nodes = a
* Accumulates the nodes up to the root of the book from the given node in the $nodes array.
*/
function book_location_down($node, $nodes = array()) {
- $last_direct_child = db_fetch_object(db_query(db_rewrite_sql('SELECT n.nid, n.title, b.parent, b.weight FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.status = 1 AND b.parent = %d ORDER BY b.weight DESC, n.title DESC'), $node->nid));
+ $last_direct_child = db_fetch_object(db_query(db_rewrite_sql('SELECT n.nid, n.title, n.path, b.parent, b.weight FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.status = 1 AND b.parent = %d ORDER BY b.weight DESC, n.title DESC'), $node->nid));
if ($last_direct_child) {
$nodes[] = $last_direct_child;
$nodes = book_location_down($last_direct_child, $nodes);
@@ -399,7 +399,7 @@ function book_prev($node) {
}
// Previous on the same level:
- $direct_above = db_fetch_object(db_query(db_rewrite_sql("SELECT n.nid, n.title, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE b.parent = %d AND n.status = 1 AND n.moderate = 0 AND (b.weight < %d OR (b.weight = %d AND n.title < '%s')) ORDER BY b.weight DESC, n.title DESC"), $node->parent, $node->weight, $node->weight, $node->title));
+ $direct_above = db_fetch_object(db_query(db_rewrite_sql("SELECT n.nid, n.title, n.path, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE b.parent = %d AND n.status = 1 AND n.moderate = 0 AND (b.weight < %d OR (b.weight = %d AND n.title < '%s')) ORDER BY b.weight DESC, n.title DESC"), $node->parent, $node->weight, $node->weight, $node->title));
if ($direct_above) {
// Get last leaf of $above.
$path = book_location_down($direct_above);
@@ -408,7 +408,7 @@ function book_prev($node) {
}
else {
// Direct parent:
- $prev = db_fetch_object(db_query(db_rewrite_sql('SELECT n.nid, n.title FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE n.nid = %d AND n.status = 1 AND n.moderate = 0'), $node->parent));
+ $prev = db_fetch_object(db_query(db_rewrite_sql('SELECT n.nid, n.title, n.path FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE n.nid = %d AND n.status = 1 AND n.moderate = 0'), $node->parent));
return $prev;
}
}
@@ -418,7 +418,7 @@ function book_prev($node) {
*/
function book_next($node) {
// get first direct child
- $child = db_fetch_object(db_query(db_rewrite_sql('SELECT n.nid, n.title, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE b.parent = %d AND n.status = 1 AND n.moderate = 0 ORDER BY b.weight ASC, n.title ASC'), $node->nid));
+ $child = db_fetch_object(db_query(db_rewrite_sql('SELECT n.nid, n.title, n.path, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE b.parent = %d AND n.status = 1 AND n.moderate = 0 ORDER BY b.weight ASC, n.title ASC'), $node->nid));
if ($child) {
return $child;
}
@@ -428,7 +428,7 @@ function book_next($node) {
$path[] = $node;
while (($leaf = array_pop($path)) && count($path)) {
- $next = db_fetch_object(db_query(db_rewrite_sql("SELECT n.nid, n.title, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE b.parent = %d AND n.status = 1 AND n.moderate = 0 AND (b.weight > %d OR (b.weight = %d AND n.title > '%s')) ORDER BY b.weight ASC, n.title ASC"), $leaf->parent, $leaf->weight, $leaf->weight, $leaf->title));
+ $next = db_fetch_object(db_query(db_rewrite_sql("SELECT n.nid, n.title, n.path, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE b.parent = %d AND n.status = 1 AND n.moderate = 0 AND (b.weight > %d OR (b.weight = %d AND n.title > '%s')) ORDER BY b.weight ASC, n.title ASC"), $leaf->parent, $leaf->weight, $leaf->weight, $leaf->title));
if ($next) {
return $next;
}
@@ -481,7 +481,7 @@ function book_nodeapi(&$node, $op, $teas
foreach ($path as $level) {
$node->breadcrumb[] = array('path' => 'node/'. $level->nid, 'title' => $level->title);
}
- $node->breadcrumb[] = array('path' => 'node/'. $node->nid);
+ $node->breadcrumb[] = array('path' => $node->path);
$node->body .= theme('book_navigation', $node);
@@ -513,16 +513,16 @@ function theme_book_navigation($node) {
$tree = book_tree($node->nid);
if ($prev = book_prev($node)) {
- drupal_add_link(array('rel' => 'prev', 'href' => url('node/'. $prev->nid)));
- $links .= l(t('‹ ') . $prev->title, 'node/'. $prev->nid, array('class' => 'page-previous', 'title' => t('Go to previous page')));
+ drupal_add_link(array('rel' => 'prev', 'href' => url($prev->path)));
+ $links .= l(t('‹ ') . $prev->title, $prev->path, array('class' => 'page-previous', 'title' => t('Go to previous page')));
}
if ($node->parent) {
drupal_add_link(array('rel' => 'index', 'href' => url('node/'. $node->parent)));
$links .= l(t('up'), 'node/'. $node->parent, array('class' => 'page-up', 'title' => t('Go to parent page')));
}
if ($next = book_next($node)) {
- drupal_add_link(array('rel' => 'next', 'href' => url('node/'. $next->nid)));
- $links .= l($next->title . t(' ›'), 'node/'. $next->nid, array('class' => 'page-next', 'title' => t('Go to next page')));
+ drupal_add_link(array('rel' => 'next', 'href' => url($next->path)));
+ $links .= l($next->title . t(' ›'), $next->path, array('class' => 'page-next', 'title' => t('Go to next page')));
}
if (isset($tree) || isset($links)) {
@@ -560,7 +560,7 @@ function book_toc_recurse($nid, $indent,
* Returns an array of titles and nid entries of book pages in table of contents order.
*/
function book_toc($exclude = 0) {
- $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.parent, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE n.status = 1 ORDER BY b.weight, n.title'));
+ $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, n.path, b.parent, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE n.status = 1 ORDER BY b.weight, n.title'));
while ($node = db_fetch_object($result)) {
if (!$children[$node->parent]) {
@@ -590,20 +590,20 @@ function book_tree_recurse($nid, $depth,
if (in_array($node->nid, $unfold)) {
if ($tree = book_tree_recurse($node->nid, $depth - 1, $children, $unfold)) {
$output .= '
';
- $output .= l($node->title, 'node/'. $node->nid);
+ $output .= l($node->title, $node->path);
$output .= '';
$output .= '';
}
else {
- $output .= ''. l($node->title, 'node/'. $node->nid) .'';
+ $output .= ''. l($node->title, $node->path) .'';
}
}
else {
if ($tree = book_tree_recurse($node->nid, 1, $children)) {
- $output .= ''. l($node->title, 'node/'. $node->nid) .'';
+ $output .= ''. l($node->title, $node->path) .'';
}
else {
- $output .= ''. l($node->title, 'node/'. $node->nid) .'';
+ $output .= ''. l($node->title, $node->path) .'';
}
}
}
@@ -618,9 +618,10 @@ function book_tree_recurse($nid, $depth,
* as a tree.
*/
function book_tree($parent = 0, $depth = 3, $unfold = array()) {
- $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.parent, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE n.status = 1 AND n.moderate = 0 ORDER BY b.weight, n.title'));
+ $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, n.path, b.parent, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE n.status = 1 AND n.moderate = 0 ORDER BY b.weight, n.title'));
while ($node = db_fetch_object($result)) {
+ $node->path = empty($node->path) ? 'node/' . $node->nid : $node->path;
$list = $children[$node->parent] ? $children[$node->parent] : array();
$list[] = $node;
$children[$node->parent] = $list;
@@ -635,11 +636,11 @@ function book_tree($parent = 0, $depth =
* Menu callback; prints a listing of all books.
*/
function book_render() {
- $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE b.parent = 0 AND n.status = 1 AND n.moderate = 0 ORDER BY b.weight, n.title'));
+ $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, n.path, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE b.parent = 0 AND n.status = 1 AND n.moderate = 0 ORDER BY b.weight, n.title'));
$books = array();
while ($node = db_fetch_object($result)) {
- $books[] = l($node->title, 'node/'. $node->nid);
+ $books[] = l($node->title, $node->path);
}
return theme('item_list', $books);
@@ -665,7 +666,7 @@ function book_render() {
*/
function book_export($type = 'html', $nid = 0) {
$type = drupal_strtolower($type);
- $node_result = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.parent FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE n.nid = %d'), $nid);
+ $node_result = db_query(db_rewrite_sql('SELECT n.nid, n.title, n.path, b.parent FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE n.nid = %d'), $nid);
if (db_num_rows($node_result) > 0) {
$node = db_fetch_object($node_result);
}
@@ -762,7 +763,7 @@ function theme_book_export_html($title,
* - the output generated in visiting each node
*/
function book_recurse($nid = 0, $depth = 1, $visit_pre, $visit_post) {
- $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE n.status = 1 AND n.nid = %d AND n.moderate = 0 ORDER BY b.weight, n.title'), $nid);
+ $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, n.path, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE n.status = 1 AND n.nid = %d AND n.moderate = 0 ORDER BY b.weight, n.title'), $nid);
while ($page = db_fetch_object($result)) {
// Load the node:
$node = node_load($page->nid);
@@ -775,7 +776,7 @@ function book_recurse($nid = 0, $depth =
$output .= book_node_visitor_html_pre($node, $depth, $nid);
}
- $children = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE n.status = 1 AND b.parent = %d AND n.moderate = 0 ORDER BY b.weight, n.title'), $node->nid);
+ $children = db_query(db_rewrite_sql('SELECT n.nid, n.title, n.path, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE n.status = 1 AND b.parent = %d AND n.moderate = 0 ORDER BY b.weight, n.title'), $node->nid);
while ($childpage = db_fetch_object($children)) {
$childnode = node_load($childpage->nid);
if ($childnode->nid != $node->nid) {
@@ -919,7 +920,7 @@ function book_admin_edit($nid) {
* Menu callback; displays a listing of all orphaned book pages.
*/
function book_admin_orphan() {
- $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, n.status, b.parent FROM {node} n INNER JOIN {book} b ON n.vid = b.vid'));
+ $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, n.path, n.status, b.parent FROM {node} n INNER JOIN {book} b ON n.vid = b.vid'));
$pages = array();
while ($page = db_fetch_object($result)) {
@@ -960,7 +961,7 @@ function book_admin_edit_submit($form_id
$node->weight = $row['weight'];
node_save($node);
- watchdog('content', t('%type: updated %title.', array('%type' => theme('placeholder', t('book')), '%title' => theme('placeholder', $node->title))), WATCHDOG_NOTICE, l(t('view'), 'node/'. $node->nid));
+ watchdog('content', t('%type: updated %title.', array('%type' => theme('placeholder', t('book')), '%title' => theme('placeholder', $node->title))), WATCHDOG_NOTICE, l(t('view'), $node->path));
}
}
@@ -991,9 +992,9 @@ function book_admin($nid = 0) {
* Returns an administrative overview of all books.
*/
function book_admin_overview() {
- $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE b.parent = 0 ORDER BY b.weight, n.title'));
+ $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, n.path, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE b.parent = 0 ORDER BY b.weight, n.title'));
while ($book = db_fetch_object($result)) {
- $rows[] = array(l($book->title, "node/$book->nid"), l(t('outline'), "admin/node/book/$book->nid"));
+ $rows[] = array(l($book->title, $book->path), l(t('outline'), "admin/node/book/$book->nid"));
}
$headers = array(t('Book'), t('Operations'));
Index: modules/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment.module,v
retrieving revision 1.457
diff -u -F^f -r1.457 comment.module
--- modules/comment.module 7 May 2006 00:08:36 -0000 1.457
+++ modules/comment.module 15 May 2006 09:40:29 -0000
@@ -195,10 +195,10 @@ function comment_link($type, $node = 0,
$new = comment_num_new($node->nid);
if ($all) {
- $links[] = l(format_plural($all, '1 comment', '%count comments'), "node/$node->nid", array('title' => t('Jump to the first comment of this posting.')), NULL, 'comment');
+ $links[] = l(format_plural($all, '1 comment', '%count comments'), $node->path, array('title' => t('Jump to the first comment of this posting.')), NULL, 'comment');
if ($new) {
- $links[] = l(format_plural($new, '1 new comment', '%count new comments'), "node/$node->nid", array('title' => t('Jump to the first new comment of this posting.')), NULL, 'new');
+ $links[] = l(format_plural($new, '1 new comment', '%count new comments'), $node->path, array('title' => t('Jump to the first new comment of this posting.')), NULL, 'new');
}
}
else {
@@ -307,7 +307,7 @@ function comment_nodeapi(&$node, $op, $a
return format_plural($comments, '1 comment', '%count comments');
case 'rss item':
- return array(array('key' => 'comments', 'value' => url('node/'. $node->nid, NULL, 'comment', TRUE)));
+ return array(array('key' => 'comments', 'value' => url($node->path, NULL, 'comment', TRUE)));
}
}
Index: modules/forum.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum.module,v
retrieving revision 1.330
diff -u -F^f -r1.330 forum.module
--- modules/forum.module 8 May 2006 15:16:16 -0000 1.330
+++ modules/forum.module 15 May 2006 09:40:30 -0000
@@ -306,7 +306,7 @@ function forum_view(&$node, $teaser = FA
$breadcrumb[] = array('path' => 'forum/'. $p->tid, 'title' => $p->name);
}
}
- $breadcrumb[] = array('path' => 'node/'. $node->nid);
+ $breadcrumb[] = array('path' => $node->path);
menu_set_location($breadcrumb);
}
@@ -993,8 +993,8 @@ function theme_forum_topic_list($tid, $t
else {
$rows[] = array(
array('data' => theme('forum_icon', $topic->new, $topic->num_comments, $topic->comment_mode, $topic->sticky), 'class' => 'icon'),
- array('data' => l($topic->title, "node/$topic->nid"), 'class' => 'topic'),
- array('data' => $topic->num_comments . ($topic->new_replies ? '
'. l(format_plural($topic->new_replies, '1 new', '%count new'), "node/$topic->nid", NULL, NULL, 'new') : ''), 'class' => 'replies'),
+ array('data' => l($topic->title, $topic->path), 'class' => 'topic'),
+ array('data' => $topic->num_comments . ($topic->new_replies ? '
'. l(format_plural($topic->new_replies, '1 new', '%count new'), $topic->path, NULL, NULL, 'new') : ''), 'class' => 'replies'),
array('data' => _forum_format($topic), 'class' => 'created'),
array('data' => _forum_format($topic->last_reply), 'class' => 'last-reply')
);
@@ -1048,7 +1048,7 @@ function theme_forum_topic_navigation($n
$output = '';
// get previous and next topic
- $sql = "SELECT n.nid, n.title, n.sticky, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND n.type = 'forum' ORDER BY n.sticky DESC, ". _forum_get_topic_order_sql(variable_get('forum_order', 1));
+ $sql = "SELECT n.nid, n.title, n.sticky, n.path, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND n.type = 'forum' ORDER BY n.sticky DESC, ". _forum_get_topic_order_sql(variable_get('forum_order', 1));
$result = db_query(db_rewrite_sql($sql), $node->tid);
while ($topic = db_fetch_object($result)) {
@@ -1056,6 +1056,7 @@ function theme_forum_topic_navigation($n
$next = new StdClass();
$next->nid = $topic->nid;
$next->title = $topic->title;
+ $next->path = empty($topic->path) ? 'node/' . $topic->nid : $topic->path;
break;
}
if ($topic->nid == $node->nid) {
@@ -1065,6 +1066,7 @@ function theme_forum_topic_navigation($n
$prev = new StdClass();
$prev->nid = $topic->nid;
$prev->title = $topic->title;
+ $prev->path = empty($topic->path) ? 'node/' . $topic->nid : $topic->path;
}
}
@@ -1072,10 +1074,10 @@ function theme_forum_topic_navigation($n
$output .= '';
if ($prev) {
- $output .= l(t('‹ ') . $prev->title, 'node/'. $prev->nid, array('class' => 'topic-previous', 'title' => t('Go to previous forum topic')));
+ $output .= l(t('‹ ') . $prev->title, $prev->path, array('class' => 'topic-previous', 'title' => t('Go to previous forum topic')));
}
if ($next) {
- $output .= l($next->title . t(' ›'), 'node/'. $next->nid, array('class' => 'topic-next', 'title' => t('Go to next forum topic')));
+ $output .= l($next->title . t(' ›'), $next->path, array('class' => 'topic-next', 'title' => t('Go to next forum topic')));
}
$output .= '
';
Index: modules/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node.module,v
retrieving revision 1.649
diff -u -F^f -r1.649 node.module
--- modules/node.module 15 May 2006 06:18:01 -0000 1.649
+++ modules/node.module 15 May 2006 09:40:32 -0000
@@ -72,7 +72,7 @@ function node_cron() {
*/
function node_title_list($result, $title = NULL) {
while ($node = db_fetch_object($result)) {
- $items[] = l($node->title, 'node/'. $node->nid, $node->comment_count ? array('title' => format_plural($node->comment_count, '1 comment', '%count comments')) : '');
+ $items[] = l($node->title, $node, $node->comment_count ? array('title' => format_plural($node->comment_count, '1 comment', '%count comments')) : '');
}
return theme('node_list', $items, $title);
@@ -366,13 +366,19 @@ function node_load($param = array(), $re
// Retrieve the node.
if ($revision) {
array_unshift($arguments, $revision);
- $node = db_fetch_object(db_query(db_rewrite_sql('SELECT n.nid, r.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.moderate, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revisions} r ON r.nid = n.nid AND r.vid = %d WHERE '. $cond), $arguments));
+ $node = db_fetch_object(db_query(db_rewrite_sql('SELECT n.nid, r.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.moderate, n.sticky, n.path, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revisions} r ON r.nid = n.nid AND r.vid = %d WHERE '. $cond), $arguments));
}
else {
- $node = db_fetch_object(db_query(db_rewrite_sql('SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.moderate, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revisions} r ON r.vid = n.vid WHERE '. $cond), $arguments));
+ $node = db_fetch_object(db_query(db_rewrite_sql('SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.moderate, n.sticky, n.path, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revisions} r ON r.vid = n.vid WHERE '. $cond), $arguments));
}
if ($node->nid) {
+
+ // default the path to the node value
+ if (empty($node->path)) {
+ $node->path = 'node/' . $node->nid;
+ }
+
// Call the node specific callback (if any) and piggy-back the
// results to the node or overwrite some values.
if ($extra = node_invoke($node, 'load')) {
@@ -431,6 +437,9 @@ function node_save(&$node) {
}
// The changed timestamp is always updated for bookkeeping purposes (revisions, searching, ...)
$node->changed = time();
+ if (empty($node->path)) {
+ $node->path = 'node/' . $node->nid;
+ }
// Split off revisions data to another structure
$revisions_table_values = array('nid' => $node->nid, 'vid' => $node->vid,
@@ -446,13 +455,13 @@ function node_save(&$node) {
'status' => $node->status, 'created' => $node->created,
'changed' => $node->changed, 'comment' => $node->comment,
'promote' => $node->promote, 'moderate' => $node->moderate,
- 'sticky' => $node->sticky);
+ 'sticky' => $node->sticky, 'path' => $node->path);
$node_table_types = array('nid' => '%d', 'vid' => '%d',
'title' => "'%s'", 'type' => "'%s'", 'uid' => '%d',
'status' => '%d', 'created' => '%d',
'changed' => '%d', 'comment' => '%d',
'promote' => '%d', 'moderate' => '%d',
- 'sticky' => '%d');
+ 'sticky' => '%d', 'path' => "'%s'");
//Generate the node table query and the
//the node_revisions table query
@@ -810,7 +819,7 @@ function node_link($type, $node = 0, $ma
}
if ($main == 1 && $node->teaser && $node->readmore) {
- $links[] = l(t('read more'), "node/$node->nid", array('title' => t('Read the rest of this posting.'), 'class' => 'read-more'));
+ $links[] = l(t('read more'), $node, array('title' => t('Read the rest of this posting.'), 'class' => 'read-more'));
}
}
@@ -1140,7 +1149,7 @@ function node_admin_nodes() {
$destination = drupal_get_destination();
while ($node = db_fetch_object($result)) {
$nodes[$node->nid] = '';
- $form['title'][$node->nid] = array('#value' => l($node->title, 'node/'. $node->nid) .' '. theme('mark', node_mark($node->nid, $node->changed)));
+ $form['title'][$node->nid] = array('#value' => l($node->title, $node) .' '. theme('mark', node_mark($node->nid, $node->changed)));
$form['name'][$node->nid] = array('#value' => node_get_name($node));
$form['username'][$node->nid] = array('#value' => theme('username', $node));
$form['status'][$node->nid] = array('#value' => ($node->status ? t('published') : t('not published')));
@@ -1275,7 +1284,7 @@ function node_revision_overview($node) {
$operations = array();
if ($revision->current_vid > 0) {
- $row[] = array('data' => t('%date by %username', array('%date' => l(format_date($revision->timestamp, 'small'), "node/$node->nid"), '%username' => theme('username', $revision)))
+ $row[] = array('data' => t('%date by %username', array('%date' => l(format_date($revision->timestamp, 'small'), $node), '%username' => theme('username', $revision)))
. (($revision->log != '') ? ''. filter_xss($revision->log) .'
' : ''),
'class' => 'revision-current');
$operations[] = array('data' => theme('placeholder', t('current revision')), 'class' => 'revision-current', 'colspan' => 2);
@@ -1413,7 +1422,7 @@ function node_feed($nodes = 0, $channel
while ($node = db_fetch_object($nodes)) {
// Load the specified node:
$item = node_load($node->nid);
- $link = url("node/$node->nid", NULL, NULL, 1);
+ $link = url($node->path, NULL, NULL, 1);
if ($item_length != 'title') {
$teaser = ($item_length == 'teaser') ? TRUE : FALSE;
@@ -1438,7 +1447,7 @@ function node_feed($nodes = 0, $channel
case 'teaser':
$item_text = $item->teaser;
if ($item->readmore) {
- $item_text .= ''. l(t('read more'), 'node/'. $item->nid, NULL, NULL, NULL, TRUE) .'
';
+ $item_text .= ''. l(t('read more'), $item, NULL, NULL, NULL, TRUE) .'
';
}
break;
case 'title':
@@ -1835,7 +1844,7 @@ function node_form_submit($form_id, $edi
// perform this operation:
if (node_access('update', $node)) {
node_save($node);
- watchdog('content', t('%type: updated %title.', array('%type' => theme('placeholder', t($node->type)), '%title' => theme('placeholder', $node->title))), WATCHDOG_NOTICE, l(t('view'), 'node/'. $node->nid));
+ watchdog('content', t('%type: updated %title.', array('%type' => theme('placeholder', t($node->type)), '%title' => theme('placeholder', $node->title))), WATCHDOG_NOTICE, l(t('view'), $node));
drupal_set_message(t('The %post was updated.', array ('%post' => node_get_name($node))));
}
}
@@ -1844,13 +1853,13 @@ function node_form_submit($form_id, $edi
// perform this operation:
if (node_access('create', $node)) {
node_save($node);
- watchdog('content', t('%type: added %title.', array('%type' => theme('placeholder', t($node->type)), '%title' => theme('placeholder', $node->title))), WATCHDOG_NOTICE, l(t('view'), "node/$node->nid"));
+ watchdog('content', t('%type: added %title.', array('%type' => theme('placeholder', t($node->type)), '%title' => theme('placeholder', $node->title))), WATCHDOG_NOTICE, l(t('view'), $node));
drupal_set_message(t('Your %post was created.', array ('%post' => node_get_name($node))));
}
}
if ($node->nid) {
if (node_access('view', $node)) {
- return 'node/'. $node->nid;
+ return $node->path;
}
else {
return '';
Index: modules/path.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/path.module,v
retrieving revision 1.84
diff -u -F^f -r1.84 path.module
--- modules/path.module 7 May 2006 00:08:36 -0000 1.84
+++ modules/path.module 15 May 2006 09:40:32 -0000
@@ -211,11 +211,15 @@ function path_nodeapi(&$node, $op, $arg)
}
else if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE dst = '%s' AND src != '%s'", $node->path, "node/$node->nid"))) {
form_set_error('path', t('The path is already in use.'));
+ }
+ else if (db_result(db_query("SELECT COUNT(nid) FROM {node} WHERE path = '%s' AND nid != %d", $node->path, $node->nid))) {
+ form_set_error('path', t('The path is already in use.'));
}
break;
case 'load':
- $path = "node/$node->nid";
+ $path = (empty($node->path)) ? "node/$node->nid" : $node->path;
+
// We don't use drupal_get_path_alias() to avoid custom rewrite functions.
// We only care about exact aliases.
$result = db_query("SELECT dst FROM {url_alias} WHERE src = '%s'", $path);
Index: modules/poll.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/poll.module,v
retrieving revision 1.196
diff -u -F^f -r1.196 poll.module
--- modules/poll.module 7 May 2006 00:08:36 -0000 1.196
+++ modules/poll.module 15 May 2006 09:40:33 -0000
@@ -261,7 +261,7 @@ function poll_page() {
$result = pager_query($sql, 15);
$output = '';
while ($node = db_fetch_object($result)) {
- $output .= '- '. l($node->title, "node/$node->nid") .' - '. format_plural($node->votes, '1 vote', '%count votes') .' - '. ($node->active ? t('open') : t('closed')) .'
';
+ $output .= '- '. l($node->title, $node) .' - '. format_plural($node->votes, '1 vote', '%count votes') .' - '. ($node->active ? t('open') : t('closed')) .'
';
}
$output .= '
';
$output .= theme("pager", NULL, 15);
@@ -305,7 +305,7 @@ function poll_view_voting(&$node, $tease
}
$form['nid'] = array('#type' => 'hidden', '#value' => $node->nid);
$form['vote'] = array('#type' => 'submit', '#value' => t('Vote'));
- $form['#action'] = url('node/'. $node->nid);
+ $form['#action'] = url($node->path);
return drupal_get_form('poll_view_voting', $form);
}
Index: modules/tracker.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/tracker.module,v
retrieving revision 1.130
diff -u -F^f -r1.130 tracker.module
--- modules/tracker.module 7 May 2006 00:08:36 -0000 1.130
+++ modules/tracker.module 15 May 2006 09:40:33 -0000
@@ -105,13 +105,13 @@ function tracker_page($uid = 0) {
if ($new = comment_num_new($node->nid)) {
$comments .= '
';
- $comments .= l(format_plural($new, '1 new', '%count new'), "node/$node->nid", NULL, NULL, 'new');
+ $comments .= l(format_plural($new, '1 new', '%count new'), $node, NULL, NULL, 'new');
}
}
$rows[] = array(
node_get_name($node->type),
- l($node->title, "node/$node->nid") .' '. theme('mark', node_mark($node->nid, $node->changed)),
+ l($node->title, $node) .' '. theme('mark', node_mark($node->nid, $node->changed)),
theme('username', $node),
array('class' => 'replies', 'data' => $comments),
t('%time ago', array('%time' => format_interval(time() - $node->last_post)))
Index: modules/upload.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/upload.module,v
retrieving revision 1.103
diff -u -F^f -r1.103 upload.module
--- modules/upload.module 12 May 2006 08:50:22 -0000 1.103
+++ modules/upload.module 15 May 2006 09:40:34 -0000
@@ -53,7 +53,7 @@ function upload_link($type, $node = 0, $
}
}
if ($num_files) {
- $links[] = l(format_plural($num_files, '1 attachment', '%count attachments'), "node/$node->nid", array('title' => t('Read full article to view attachments.')), NULL, 'attachments');
+ $links[] = l(format_plural($num_files, '1 attachment', '%count attachments'), $node, array('title' => t('Read full article to view attachments.')), NULL, 'attachments');
}
}
Index: themes/chameleon/chameleon.theme
===================================================================
RCS file: /cvs/drupal/drupal/themes/chameleon/chameleon.theme,v
retrieving revision 1.44
diff -u -F^f -r1.44 chameleon.theme
--- themes/chameleon/chameleon.theme 15 Apr 2006 04:07:18 -0000 1.44
+++ themes/chameleon/chameleon.theme 15 May 2006 09:40:34 -0000
@@ -117,7 +117,7 @@ function chameleon_node($node, $teaser =
$output = "status) ? ' node-unpublished' : '') ."\">\n";
if (!$page) {
- $output .= "
". ($teaser ? l($node->title, "node/$node->nid") : check_plain($node->title)) ."
\n";
+ $output .= "
". ($teaser ? l($node->title, $node) : check_plain($node->title)) ."
\n";
}
$output .= "
\n";
Index: themes/engines/phptemplate/phptemplate.engine
===================================================================
RCS file: /cvs/drupal/drupal/themes/engines/phptemplate/phptemplate.engine,v
retrieving revision 1.35
diff -u -F^f -r1.35 phptemplate.engine
--- themes/engines/phptemplate/phptemplate.engine 7 May 2006 00:08:36 -0000 1.35
+++ themes/engines/phptemplate/phptemplate.engine 15 May 2006 09:40:34 -0000
@@ -235,7 +235,7 @@ function phptemplate_node($node, $teaser
'links' => $node->links ? theme('links', $node->links) : '',
'name' => theme('username', $node),
'node' => $node, // we pass the actual node to allow more customization
- 'node_url' => url('node/'. $node->nid),
+ 'node_url' => url($node->path),
'page' => $page,
'taxonomy' => $taxonomy,
'teaser' => $teaser,