From 99d84c933003d6ecc5a7fe2d81f87cb0e1de9017 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 14 Dec 2002 11:55:54 +0000 Subject: - Committed Marco's pager improvements. - Fixed another annoyance with editing content. --- includes/common.inc | 72 +++++++++++++++++------ includes/pager.inc | 145 +++++++++++++++++++---------------------------- modules/blog.module | 4 +- modules/blog/blog.module | 4 +- modules/node.module | 18 ++---- modules/node/node.module | 18 ++---- 6 files changed, 126 insertions(+), 135 deletions(-) diff --git a/includes/common.inc b/includes/common.inc index 9fd254497..cd01940b1 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -369,19 +369,11 @@ function check_form($text) { return htmlspecialchars(stripslashes($text)); } -function check_export($text) { - return htmlspecialchars(stripslashes($text)); -} - -function check_code($text) { - return $text; -} - -function check_preview($text) { - return check_output(check_input($text)); +function check_query($text) { + return addslashes(stripslashes($text)); } -function check_query($text) { +function check_input($text) { return addslashes(stripslashes($text)); } @@ -395,12 +387,19 @@ function filter($text) { return $text; } -function check_input($text) { - return check_query($text); -} - function check_output($text, $nl2br = 0) { - return ($text) ? ($nl2br ? str_replace("\r", "", str_replace("\n", "
", stripslashes($text))) : stripslashes($text)) : message_na(); + if ($text) { + $text = stripslashes($text); + + if (strip_tags($text, "") == $text) { + $text = nl2br($text); + } + } + else { + $text = message_na(); + } + + return $text; } function check_file($filename) { @@ -640,6 +639,34 @@ function form_weight($title = NULL, $name = "weight", $value = 0, $delta = 10, $ return form_select($title, $name, $value, $weights, $description, $extra); } +/** + * Parse an URL; this function must be follow the changes of a clean url implementation + * + * @param string $url optional, url to parse; default to request_uri() + * @return array $result associative array: + * script => index/node/module/admin + * query => GET variables + * + */ +function drupal_parse_url($url = NULL) { + global $PHP_SELF; + static $cache; + + if ($url == NULL) { + $url = $PHP_SELF ."?". getenv("QUERY_STRING"); + } + + if (!$cache[$url]) { + $parts = parse_url($url); + preg_match("/(\w+?)\.php/", $parts["path"], $found); + $cache[$url]["script"] = $found[1]; + parse_str($parts["query"], $cache[$url]["query"]); + $cache[$url]["anchor"] = $parts["fragment"]; + } + + return $cache[$url]; +} + /** * Build an URL; use this functions when you must write an URL * for example in a form or a redirect. @@ -649,9 +676,20 @@ function form_weight($title = NULL, $name = "weight", $value = 0, $delta = 10, $ * @param $anchor optional, anchor name */ function drupal_url($args = array(), $script = "node", $anchor = 0) { + static $search, $replace; + + if (!$search) { + /* + According to RFC 1738 [3] the special characters "$-_.+!*'()," and the + reserved characters "/:@#?&=" can be used unencoded within an URL + */ + $search = array("%24", "%2B", "%21", "%2A", "%27", "%28", "%29", "%2C", "%2F", "%3A", "%40", "%23", "%3F", "%26", "%3D"); + $replace = array("$", "+", "!", "*", "'", "(", ")", ",", "/", ":", "@", "#", "?", "&", "="); + } + $t = array(); foreach ($args as $key => $value) { - $t[] = "$key=". urlencode($value); + $t[] = "$key=". str_replace($search, $replace, urlencode($value)); } if (count($t)) { return "$script.php?". implode("&", $t) . ($anchor ? "#$anchor" : ""); diff --git a/includes/pager.inc b/includes/pager.inc index a7cb48784..8f93a5a54 100644 --- a/includes/pager.inc +++ b/includes/pager.inc @@ -5,7 +5,7 @@ function pager_help() { ?>

Implementation note: making queries pagable

The pager uses LIMIT-based queries to fetch only the records required to render a certain page. However, it has to learn the total number of records returned by the query to (among others) compute the number of pages (= number of all records / number of records per page). This is done by inserting COUNT(*) in the original query, ie. by rewriting the original query

SELECT nid, type FROM node WHERE status = '1' ORDER BY static DESC, created DESC
to read
SELECT COUNT(*) FROM node WHERE status = '1' ORDER BY static DESC, created DESC
Rewriting the query is accomplished using a regular expression; preg_replace("/SELECT.*FROM/i", "SELECT COUNT(*) FROM", $query).

-

Unfortunately, the call to preg_replace() does not work as intended for queries that already have a COUNT() clause; the original COUNT() will be removed from the query, possibly making the remainder of the query fail (eg. when the use of HAVING or ORDER depends on the value returned by COUNT()). In practice, for queries to be db_query_pager()-able, they shold be reformulated not to use COUNT().

+

Unfortunately, the call to preg_replace() does not work as intended for queries that already have a COUNT() clause; the original COUNT() will be removed from the query, possibly making the remainder of the query fail (eg. when the use of HAVING or ORDER depends on the value returned by COUNT()). In practice, for queries to be pager_query()-able, they shold be reformulated not to use COUNT().

"; - $output .= ""; - $output .= ""; - $output .= ""; - $output .= ""; - $output .= ""; + $output .= ""; + $output .= ""; + $output .= ""; + $output .= ""; + $output .= ""; $output .= "
". pager_first(($tags[0] ? $tags[0] : t("first page")), $limit, $element) ."". pager_previous(($tags[1] ? $tags[1] : t("previous page")), $limit, $element) ."". pager_list($limit, $element, ($tags[2] ? $tags[2] : 9 )) ."". pager_next(($tags[3] ? $tags[3] : t("next page")), $limit, $element) ."". pager_last(($tags[4] ? $tags[4] : t("last page")), $limit, $element) ."". pager_first(($tags[0] ? $tags[0] : t("first page")), $limit, $element, $attributes) ."". pager_previous(($tags[1] ? $tags[1] : t("previous page")), $limit, $element, 1, $attributes) ."". pager_list($limit, $element, ($tags[2] ? $tags[2] : 9 ), "", $attributes) ."". pager_next(($tags[3] ? $tags[3] : t("next page")), $limit, $element, 1, $attributes) ."". pager_last(($tags[4] ? $tags[4] : t("last page")), $limit, $element, $attributes) ."
"; return "$output"; @@ -56,13 +56,13 @@ function pager_display_default($tags = "", $limit = 10, $element = 0) { * * @see pager_display */ -function pager_display_simple($tags = "", $limit = 10, $element = 0) { +function pager_display_simple($tags = "", $limit = 10, $element = 0, $attributes = array()) { /* ** It's left as an exercise to theme writers to create an alternative ** pager for pager_display_simple(). if your theme does not offer a ** replacement, the theme.inc pager_display_default() is used. */ - return pager_display_default($tags, $limit, $element); + return pager_display_default($tags, $limit, $element, $attributes); } /** @@ -73,13 +73,13 @@ function pager_display_simple($tags = "", $limit = 10, $element = 0) { * * @see pager_display */ -function pager_display_admin($tags = "", $limit = 10, $element = 0) { +function pager_display_admin($tags = "", $limit = 10, $element = 0, $attributes = array()) { /* ** It's left as an exercise to theme writers to create an alternative ** pager for pager_display_admin(). if your theme does not offer a ** replacement, the pager.inc pager_display_default() is used. */ - return pager_display_default($tags, $limit, $element); + return pager_display_default($tags, $limit, $element, $attributes); } /* ******************************************************************* @@ -94,11 +94,11 @@ function pager_display_admin($tags = "", $limit = 10, $element = 0) { * * @see pager_previous */ -function pager_first($text, $limit, $element = 0) { - global $from_array; +function pager_first($text, $limit, $element = 0, $attributes = array()) { + global $pager_from_array; - if ($from_array[$element]) { - return "
$text"; + if ($pager_from_array[$element]) { + return "$text"; } else { // we are already at the first page, return nothing @@ -116,13 +116,13 @@ function pager_first($text, $limit, $element = 0) { * * @return string html of this pager piece */ -function pager_previous($text, $limit, $element = 0, $n = 1) { - global $from_array; - $from_new = pager_load_array(((int)$from_array[$element] - ((int)$limit * (int)$n)), $element, $from_array); +function pager_previous($text, $limit, $element = 0, $n = 1, $attributes = array()) { + global $pager_from_array; + $from_new = pager_load_array(((int)$pager_from_array[$element] - ((int)$limit * (int)$n)), $element, $pager_from_array); if ($from_new[$element] < 1) { - return pager_first($text, $limit, $element); + return pager_first($text, $limit, $element, $attributes); } - return "$text"; + return "$text"; } /** @@ -130,11 +130,11 @@ function pager_previous($text, $limit, $element = 0, $n = 1) { * * @see pager_previous */ -function pager_next($text, $limit, $element = 0, $n = 1) { - global $from_array, $pager_total; - $from_new = pager_load_array(((int)$from_array[$element] + ((int)$limit * (int)$n)), $element, $from_array); +function pager_next($text, $limit, $element = 0, $n = 1, $attributes = array()) { + global $pager_from_array, $pager_total; + $from_new = pager_load_array(((int)$pager_from_array[$element] + ((int)$limit * (int)$n)), $element, $pager_from_array); if ($from_new[$element] < $pager_total[$element]) { - return "$text"; + return "$text"; } return " "; } @@ -144,15 +144,15 @@ function pager_next($text, $limit, $element = 0, $n = 1) { * * @see pager_previous */ -function pager_last($text, $limit, $element = 0) { - global $from_array, $pager_total; +function pager_last($text, $limit, $element = 0, $attributes = array()) { + global $pager_from_array, $pager_total; - $from_new = pager_load_array(($pager_total[$element] - $limit), $element, $from_array); - if ($from_new[$element] < ($from_array[$element] + $limit)) { - return pager_next($text, $limit, $element); + $from_new = pager_load_array(($pager_total[$element] - $limit), $element, $pager_from_array); + if ($from_new[$element] < ($pager_from_array[$element] + $limit)) { + return pager_next($text, $limit, $element, 1, $attributes); } - if (($from_new[$element] > $from_array[$element]) && ($from_new[$element] > 0) && $from_new[$element] < $pager_total[$element]) { - return "$text"; + if (($from_new[$element] > $pager_from_array[$element]) && ($from_new[$element] > 0) && $from_new[$element] < $pager_total[$element]) { + return "$text"; } return " "; } @@ -164,10 +164,10 @@ function pager_last($text, $limit, $element = 0) { * @see pager_previous */ function pager_detail($limit, $element = 0, $format = "%d through %d of %d.") { - global $from_array, $pager_total; + global $pager_from_array, $pager_total; - if ($pager_total[$element] > (int)$from_array[$element] + 1) { - $output = sprintf($format, (int)$from_array[$element] + 1, ((int)$from_array[$element] + $limit <= $pager_total[$element] ? (int)$from_array[$element] + $limit : $pager_total[$element]), $pager_total[$element]); + if ($pager_total[$element] > (int)$pager_from_array[$element] + 1) { + $output = sprintf($format, (int)$pager_from_array[$element] + 1, ((int)$pager_from_array[$element] + $limit <= $pager_total[$element] ? (int)$pager_from_array[$element] + $limit : $pager_total[$element]), $pager_total[$element]); } return $output; @@ -180,16 +180,16 @@ function pager_detail($limit, $element = 0, $format = "%d through %d of %d.") { * @param string $text optional text to display before the page list * @see pager_previous */ -function pager_list($limit, $element = 0, $quantity = 5, $text = "") { - global $from_array, $pager_total; +function pager_list($limit, $element = 0, $quantity = 5, $text = "", $attributes = array()) { + global $pager_from_array, $pager_total; // calculate various markers within this pager piece: // middle used to "center" pages around current page $pager_middle = ceil((int)$quantity / 2); // offset adds "offset" second page - $pager_offset = (int)$from_array[$element] % (int)$limit; + $pager_offset = (int)$pager_from_array[$element] % (int)$limit; // current is the page we are currently paged to - if (($pager_current = (ceil(($from_array[$element] + 1) / $limit))) < 1) { + if (($pager_current = (ceil(($pager_from_array[$element] + 1) / $limit))) < 1) { $pager_current = 1; } // first is the first page listed by this pager piece (re quantity) @@ -231,13 +231,13 @@ function pager_list($limit, $element = 0, $quantity = 5, $text = "") { // finally we're ready to generate the actual pager piece for (; $i <= $pager_last && $i <= $pager_max; $i++) { if ($i < $pager_current) { - $output .= pager_previous($i, $limit, $element, ($pager_current - $i)) ." "; + $output .= pager_previous($i, $limit, $element, ($pager_current - $i), $attributes) ." "; } if ($i == $pager_current) { $output .= "$i "; } if ($i > $pager_current) { - $output .= pager_next($i, $limit, $element, ($i - $pager_current)) ." "; + $output .= pager_next($i, $limit, $element, ($i - $pager_current), $attributes) ." "; } } @@ -259,9 +259,6 @@ function pager_list($limit, $element = 0, $quantity = 5, $text = "") { * Use this function when doing select queries you wish to be able to page. * * TODO: - * - remove database dependency ($db_type) piece - * . use db_query_range from - * . rename db_query_pager() to pager_query() * - examine a better solution for the "no COUNT in $query" requirement (see (output of) {@link pager_help()}) * * @param string $query the database query *without* "LIMIT" in it. examples:
@@ -272,57 +269,33 @@ function pager_list($limit, $element = 0, $quantity = 5, $text = "") {
  *
  * @return  resource  MySQL query result
  */
-function db_query_pager($query, $limit = 10, $element = 0) {
-  global $from, $from_array, $db_type, $pager_total;
+function pager_query($query, $limit = 10, $element = 0) {
+  global $from, $pager_from_array, $db_type, $pager_total;
 
   // count the total number of records in this query:
-  $array = db_fetch_array(db_query(preg_replace("/SELECT.*FROM/i", "SELECT COUNT(*) FROM", $query)));
-  if ($array) {
-    $pager_total[$element] = array_pop($array);
-  }
-  else {
-    $pager_total[$element] = 0;
-  }
+  $pager_total[$element] = db_result(db_query(preg_replace("/SELECT.*FROM/i", "SELECT COUNT(*) FROM", $query)));
 
   // convert comma separated $from to an array, used by other functions:
-  $from_array = explode(",", $from);
+  $pager_from_array = explode(",", $from);
 
-  if ((int)$from_array[$element]) {
-    if ($db_type == "mysql") {
-      // MySQL formatted limit query with offset:
-      $limit_query = $query . " LIMIT " . (int)$from_array[$element] . ", $limit";
-    }
-    else {
-      // pear formatted limit query with offset:
-      $limit_query = $query . " LIMIT $limit OFFSET " . (int)$from_array[$element];
-    }
-  }
-  else {
-    // standard limit query without offset:
-    $limit_query = $query . " LIMIT $limit";
-  }
-  return db_query($limit_query);
+  return db_query_range($query, (int)$pager_from_array[$element], (int)$limit);
 }
 
-function pager_link($from_new) {
-  $from_list = @implode(",", $from_new);
-  if ("$from_list" == "0") {
-    // single pager at zero, so remove the $from
-    return preg_replace(array("/from=*[^&]*/", "/[&]$/", "/[?]$/"), "", request_uri());
-  }
-  if (preg_match("/from=/", request_uri())) {
-    // replace existing from=
-    return preg_replace("/from=*[^&]*/", "from=$from_list", request_uri());
-  }
-  if (preg_match("/[?]/", request_uri())) {
-    // append &from=
-    $href = request_uri() . "&from=$from_list";
+function pager_link($from_new, $attributes = array()) {
+  $url = drupal_parse_url();
+
+  if (count($from_new) == 0 || (count($from_new) == 1 && $from_new[0] == 0)) {
+    unset($url["query"]["from"]);
   }
   else {
-    // append ?from=
-    $href = request_uri() . "?from=$from_list";
+    $url["query"]["from"] = implode(",", $from_new);
   }
-  return $href;
+
+  if (count($attributes)) {
+    $url["query"] = array_merge($url["query"], $attributes);
+  }
+
+  return drupal_url($url["query"], $url["script"]);
 }
 
 function pager_load_array($value, $element, $old_array) {
diff --git a/modules/blog.module b/modules/blog.module
index 14cf276b6..14863d550 100644
--- a/modules/blog.module
+++ b/modules/blog.module
@@ -157,7 +157,7 @@ function blog_page_user($uid = 0) {
   $links[] = lm(t("view recent blog entries"), array("mod" => "blog", "op" => "view"), "", array("title" => t("View all recent blog entries.")));
   $theme->box(t("%username's blog", array ("%username" => $account->name)), "
". $theme->links($links). "
"); - $result = db_query_pager("SELECT nid FROM node WHERE type = 'blog' AND uid = '$account->uid' AND status = 1 ORDER BY nid DESC", $user->nodes ? $user->nodes : variable_get("default_nodes_main", 10)); + $result = pager_query("SELECT nid FROM node WHERE type = 'blog' AND uid = '$account->uid' AND status = 1 ORDER BY nid DESC", $user->nodes ? $user->nodes : variable_get("default_nodes_main", 10)); while ($node = db_fetch_object($result)) { node_view(node_load(array("nid" => $node->nid)), 1); } @@ -168,7 +168,7 @@ function blog_page_user($uid = 0) { function blog_page_last() { global $user, $theme; - $result = db_query_pager("SELECT nid FROM node WHERE type = 'blog' AND status = 1 ORDER BY nid DESC", $user->nodes ? $user->nodes : variable_get("default_nodes_main", 10)); + $result = pager_query("SELECT nid FROM node WHERE type = 'blog' AND status = 1 ORDER BY nid DESC", $user->nodes ? $user->nodes : variable_get("default_nodes_main", 10)); while ($node = db_fetch_object($result)) { $output = node_view(node_load(array("nid" => $node->nid)), 1); diff --git a/modules/blog/blog.module b/modules/blog/blog.module index 14cf276b6..14863d550 100644 --- a/modules/blog/blog.module +++ b/modules/blog/blog.module @@ -157,7 +157,7 @@ function blog_page_user($uid = 0) { $links[] = lm(t("view recent blog entries"), array("mod" => "blog", "op" => "view"), "", array("title" => t("View all recent blog entries."))); $theme->box(t("%username's blog", array ("%username" => $account->name)), "
". $theme->links($links). "
"); - $result = db_query_pager("SELECT nid FROM node WHERE type = 'blog' AND uid = '$account->uid' AND status = 1 ORDER BY nid DESC", $user->nodes ? $user->nodes : variable_get("default_nodes_main", 10)); + $result = pager_query("SELECT nid FROM node WHERE type = 'blog' AND uid = '$account->uid' AND status = 1 ORDER BY nid DESC", $user->nodes ? $user->nodes : variable_get("default_nodes_main", 10)); while ($node = db_fetch_object($result)) { node_view(node_load(array("nid" => $node->nid)), 1); } @@ -168,7 +168,7 @@ function blog_page_user($uid = 0) { function blog_page_last() { global $user, $theme; - $result = db_query_pager("SELECT nid FROM node WHERE type = 'blog' AND status = 1 ORDER BY nid DESC", $user->nodes ? $user->nodes : variable_get("default_nodes_main", 10)); + $result = pager_query("SELECT nid FROM node WHERE type = 'blog' AND status = 1 ORDER BY nid DESC", $user->nodes ? $user->nodes : variable_get("default_nodes_main", 10)); while ($node = db_fetch_object($result)) { $output = node_view(node_load(array("nid" => $node->nid)), 1); diff --git a/modules/node.module b/modules/node.module index 5c05c6a76..587c94662 100644 --- a/modules/node.module +++ b/modules/node.module @@ -399,16 +399,6 @@ function node_filter_line($text) { ** mark-up and use of line breaks and paragraphs. */ - /* - ** When block tags are used, regular line breaks get stripped. - ** However, when only text formatting tags are used, Drupal will - ** insert linebreaks. - */ - - if (strip_tags($text, "") != $text) { - $text = ereg_replace("[\r\n]", "", $text); - } - /* ** Replace some common "artifacts": */ @@ -549,7 +539,7 @@ function node_admin_nodes() { $queries = array(array("ORDER BY n.created DESC", "new nodes"), array("ORDER BY n.changed DESC", "updated nodes"), array("WHERE n.status = 1 AND n.moderate = 0 ORDER BY n.nid DESC", "published nodes"), array("WHERE n.status = 0 AND n.moderate = 0 ORDER BY n.nid DESC", "non-published nodes"), array("WHERE n.status = 1 AND n.moderate = 1 ORDER BY n.nid DESC", "pending nodes"), array("WHERE n.status = 1 AND n.promote = 1 ORDER BY n.nid DESC", "promoted nodes")); - $result = db_query_pager("SELECT n.*, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid ". $queries[$query ? $query : 1][0], 50); + $result = pager_query("SELECT n.*, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid ". $queries[$query ? $query : 1][0], 50); foreach ($queries as $key => $value) { $links[] = la($value[1], array("mod" => "node", "op" => "nodes", "query" => $key)); @@ -1348,14 +1338,14 @@ function node_page() { if ($or) { // this is an OR of terms - $result = db_query_pager("SELECT DISTINCT(n.nid), type FROM node n LEFT JOIN term_node r ON n.nid = r.nid WHERE tid IN (".implode(",", $terms).") AND ". ($id ? "nid = '$id' AND " : "") ."status = '1' ORDER BY static DESC, created DESC", ($user->nodes ? $user->nodes : variable_get("default_nodes_main", 10))); + $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 ". ($id ? "nid = '$id' 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 = db_query_pager("SELECT n.nid, n.type FROM node n LEFT JOIN term_node r ON n.nid = r.nid WHERE tid IN (".implode(",", $terms).") AND ". ($id ? "nid = '$id' 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))); + $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 ". ($id ? "nid = '$id' 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 = db_query_pager("SELECT nid, type FROM node WHERE ". ($id ? "nid = '$id'" : "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 ". ($id ? "nid = '$id'" : "promote = '1'") ." AND status = '1' ORDER BY static DESC, created DESC", ($user->nodes ? $user->nodes : variable_get("default_nodes_main", 10))); } diff --git a/modules/node/node.module b/modules/node/node.module index 5c05c6a76..587c94662 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -399,16 +399,6 @@ function node_filter_line($text) { ** mark-up and use of line breaks and paragraphs. */ - /* - ** When block tags are used, regular line breaks get stripped. - ** However, when only text formatting tags are used, Drupal will - ** insert linebreaks. - */ - - if (strip_tags($text, "") != $text) { - $text = ereg_replace("[\r\n]", "", $text); - } - /* ** Replace some common "artifacts": */ @@ -549,7 +539,7 @@ function node_admin_nodes() { $queries = array(array("ORDER BY n.created DESC", "new nodes"), array("ORDER BY n.changed DESC", "updated nodes"), array("WHERE n.status = 1 AND n.moderate = 0 ORDER BY n.nid DESC", "published nodes"), array("WHERE n.status = 0 AND n.moderate = 0 ORDER BY n.nid DESC", "non-published nodes"), array("WHERE n.status = 1 AND n.moderate = 1 ORDER BY n.nid DESC", "pending nodes"), array("WHERE n.status = 1 AND n.promote = 1 ORDER BY n.nid DESC", "promoted nodes")); - $result = db_query_pager("SELECT n.*, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid ". $queries[$query ? $query : 1][0], 50); + $result = pager_query("SELECT n.*, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid ". $queries[$query ? $query : 1][0], 50); foreach ($queries as $key => $value) { $links[] = la($value[1], array("mod" => "node", "op" => "nodes", "query" => $key)); @@ -1348,14 +1338,14 @@ function node_page() { if ($or) { // this is an OR of terms - $result = db_query_pager("SELECT DISTINCT(n.nid), type FROM node n LEFT JOIN term_node r ON n.nid = r.nid WHERE tid IN (".implode(",", $terms).") AND ". ($id ? "nid = '$id' AND " : "") ."status = '1' ORDER BY static DESC, created DESC", ($user->nodes ? $user->nodes : variable_get("default_nodes_main", 10))); + $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 ". ($id ? "nid = '$id' 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 = db_query_pager("SELECT n.nid, n.type FROM node n LEFT JOIN term_node r ON n.nid = r.nid WHERE tid IN (".implode(",", $terms).") AND ". ($id ? "nid = '$id' 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))); + $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 ". ($id ? "nid = '$id' 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 = db_query_pager("SELECT nid, type FROM node WHERE ". ($id ? "nid = '$id'" : "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 ". ($id ? "nid = '$id'" : "promote = '1'") ." AND status = '1' ORDER BY static DESC, created DESC", ($user->nodes ? $user->nodes : variable_get("default_nodes_main", 10))); } -- cgit v1.2.3