From 9281d0cdd7279b5e0e1d60c75bc38c2ae41c247a Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 9 Feb 2003 17:39:40 +0000 Subject: - Applied Alastair's date patch. - Removed all instances of '$user->nodes'. - Committed Moshe's taxonomy patch - minus the node_compact_list() bit. It needs a bit more thought/work. This patch changes the links of taxonomy pages/feeds so update your custom code and themes accordingly! Themes should now use "taxonomy_link("taxonomy terms", $node)" to get an array of taxonomy term links. The old construct is deprecated and should be changed. // old theme blob: if (function_exists("taxonomy_node_get_terms")) { foreach (taxonomy_node_get_terms($node->nid) as $term) { $terms[] = l($term->name, NULL, array(), "or=$term->tid"); } } // new theme blob: if (module_exist("taxonomy")) { $terms = taxonomy_link("taxonomy terms", $node); } // old URL: http://foo.com/index.php?or=1,2 // new URL: http://foo.com/?q=taxonomy/page/or/1,2 --- modules/node.module | 44 +++++++++++--------------------------------- 1 file changed, 11 insertions(+), 33 deletions(-) (limited to 'modules/node.module') diff --git a/modules/node.module b/modules/node.module index fc9d56c60..b8f402984 100644 --- a/modules/node.module +++ b/modules/node.module @@ -19,18 +19,19 @@ function node_system($field){ return $system[$field]; } -// accepts a db result object which includes nid and title from node table, and name from the user table -// returns an HTML list suitable as content for a block, and eventually other uses. +/* +** Accepts a DB result object which can be used to fetch node objects. +** Returns an HTML list suitable as content for a block. +*/ function node_title_list($result, $title = NULL) { // no queries if site is in distress - if (module_exist("statistics") && throttle_status() > 4) { + if (module_exist("statistics") && throttle_status() > 3) { return; } while ($node = db_fetch_object($result)) { $number = module_invoke("comment", "num_all", $node->nid); - $name = strip_tags(format_name($node)); // required for anonymous users to work - $items[] = l($node->title, "node/view/$node->nid", array("title" => t("Author: %name, comments: %number", array("%name" => $name, "%number" => $number)))); + $items[] = l($node->title, "node/view/$node->nid", array("title" => t("Comments: %number", array("%number" => $number)))); } return theme_invoke("theme_item_list", $items, $title); @@ -280,7 +281,7 @@ function node_view($node, $main = 0) { /* ** Remove the delimiter (if any) that seperates the teaser from the - ** body. + ** body. TODO: this strips legitimate uses of --- also. */ $node->body = str_replace("---", "", $node->body); @@ -385,7 +386,7 @@ function node_search($keys) { } function node_conf_options() { - $output .= form_select(t("Number of posts on main page"), "default_nodes_main", variable_get("default_nodes_main", 10), array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 15 => 15, 20 => 20, 25 => 25, 30 => 30), t("The default maximum number of posts to display on the main page.")); + $output .= form_select(t("Number of posts on main page"), "default_nodes_main", variable_get("default_nodes_main", 10), array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 15 => 15, 20 => 20, 25 => 25, 30 => 30), t("The default maximum number of posts to display on overview pages such as the main page.")); $output .= form_select(t("Length of trimmed posts"), "teaser_length", variable_get("teaser_length", 600), array(0 => t("Unlimited"), 200 => t("200 characters"), 400 => t("400 characters"), 600 => t("600 characters"), 800 => t("800 characters"), 1000 => t("1000 characters"), 1200 => t("1200 characters"), 1400 => t("1400 characters"), 1600 => t("1600 characters"), 1800 => t("1800 characters"), 2000 => t("2000 characters")), t("The maximum number of characters used in the trimmed version of a post. Drupal will use this setting to determine at which offset long posts should be trimmed. The trimmed version of a post is typically used as a teaser when displaying the post on the main page, in XML feeds, etc. To disable teasers, set to 'Unlimited'.")); return $output; } @@ -712,7 +713,7 @@ function node_feed($nodes = 0, $channel = array()) { $output .= "\n"; $output .= "]>\n"; - // NOTE: é - for example - is the correct ISO-8859-1 translation of é (e acute) but apparently XML parsers don't (have to) understand it. To solve this problem, we use a DTD that defines commonly used entity such as é. + // NOTE: é - for example - is the correct ISO-8859-1 translation of (e acute) but apparently XML parsers don't (have to) understand it. To solve this problem, we use a DTD that defines commonly used entity such as é. if (!$channel["version"]) $channel["version"] = "0.91"; if (!$channel["title"]) $channel["title"] = variable_get("site_name", "drupal") ." - ". variable_get("site_slogan", ""); if (!$channel["link"]) $channel["link"] = path_uri(); @@ -1264,35 +1265,12 @@ function node_page() { $theme->box(t("Delete post"), node_delete($edit)); break; default: - // prepare query - if ($or) { - foreach ((explode(",", $or)) as $t) { - $terms[] = "'".check_query($t)."'"; - } - } - else if ($and) { - foreach ((explode(",", $and)) as $t) { - $terms[] = "'".check_query($t)."'"; - } - } - - if ($or) { - // this is an OR of terms - $result = pager_query("SELECT DISTINCT(n.nid), type FROM node n LEFT JOIN term_node r ON n.nid = r.nid WHERE tid IN (".implode(",", $terms).") AND status = '1' ORDER BY static DESC, created DESC", ($user->nodes ? $user->nodes : variable_get("default_nodes_main", 10))); - } - else if ($and) { - // this is an AND - $result = pager_query("SELECT n.nid, n.type FROM node n LEFT JOIN term_node r ON n.nid = r.nid WHERE tid IN (".implode(",", $terms).") AND status = '1' GROUP BY n.nid, n.type, n.status, n.static, n.created HAVING COUNT(n.nid) = ".count($terms)." ORDER BY static DESC, created DESC", ($user->nodes ? $user->nodes : variable_get("default_nodes_main", 10))); - } - else { - $result = pager_query("SELECT nid, type FROM node WHERE promote = '1' AND status = '1' ORDER BY static DESC, created DESC", ($user->nodes ? $user->nodes : variable_get("default_nodes_main", 10))); - } + $result = pager_query("SELECT nid, type FROM node WHERE promote = '1' AND status = '1' ORDER BY static DESC, created DESC", variable_get("default_nodes_main", 10)); while ($node = db_fetch_object($result)) { node_view(node_load(array("nid" => $node->nid, "type" => $node->type)), 1); } - - print pager_display(NULL, ($user->nodes ? $user->nodes : variable_get("default_nodes_main", 10))); + print pager_display(NULL, variable_get("default_nodes_main", 10)); } } else { -- cgit v1.2.3