Commit 99d84c93 authored by Dries's avatar Dries
Browse files

- Committed Marco's pager improvements.

- Fixed another annoyance with editing content.
parent 9c11b14d
......@@ -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", "<br />", stripslashes($text))) : stripslashes($text)) : message_na();
if ($text) {
$text = stripslashes($text);
if (strip_tags($text, "<a><i><b><u><tt><code><cite><strong>") == $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("&amp;", $t) . ($anchor ? "#$anchor" : "");
......
......@@ -5,7 +5,7 @@ function pager_help() {
?>
<h3>Implementation note: making queries pagable</h3>
<p>The pager uses <code>LIMIT</code>-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 <code>COUNT(*)</code> in the original query, ie. by rewriting the original query <pre>SELECT nid, type FROM node WHERE status = '1' ORDER BY static DESC, created DESC</pre> to read <pre>SELECT COUNT(*) FROM node WHERE status = '1' ORDER BY static DESC, created DESC</pre>Rewriting the query is accomplished using a regular expression; <code>preg_replace("/SELECT.*FROM/i", "SELECT COUNT(*) FROM", $query)</code>.</p>
<p>Unfortunately, the call to <code>preg_replace()</code> does not work as intended for queries that already have a <code>COUNT()</code> clause; the original <code>COUNT()</code> will be removed from the query, possibly making the remainder of the query fail (eg. when the use of <code>HAVING</code> or <code>ORDER</code> depends on the value returned by <code>COUNT()</code>). In practice, for queries to be <code>db_query_pager()</code>-able, they shold be reformulated not to use <code>COUNT()</code>.</p>
<p>Unfortunately, the call to <code>preg_replace()</code> does not work as intended for queries that already have a <code>COUNT()</code> clause; the original <code>COUNT()</code> will be removed from the query, possibly making the remainder of the query fail (eg. when the use of <code>HAVING</code> or <code>ORDER</code> depends on the value returned by <code>COUNT()</code>). In practice, for queries to be <code>pager_query()</code>-able, they shold be reformulated not to use <code>COUNT()</code>.</p>
<?php
}
......@@ -24,8 +24,8 @@ function pager_help() {
*
* @return string html of pager
*/
function pager_display($tags = "", $limit = 10, $element = 0, $type = "default") {
return theme_invoke("pager_display_". $type, $tags, $limit, $element);
function pager_display($tags = "", $limit = 10, $element = 0, $type = "default", $attributes = array()) {
return theme_invoke("pager_display_". $type, $tags, $limit, $element, $attributes = array());
}
/**
......@@ -36,13 +36,13 @@ function pager_display($tags = "", $limit = 10, $element = 0, $type = "default")
*
* @see pager_display
*/
function pager_display_default($tags = "", $limit = 10, $element = 0) {
function pager_display_default($tags = "", $limit = 10, $element = 0, $attributes = array()) {
$output .= "<center><table cellpadding=\"10\"><tbody><tr>";
$output .= "<td align=\"center\">". pager_first(($tags[0] ? $tags[0] : t("first page")), $limit, $element) ."</td>";
$output .= "<td align=\"center\">". pager_previous(($tags[1] ? $tags[1] : t("previous page")), $limit, $element) ."</td>";
$output .= "<td align=\"center\">". pager_list($limit, $element, ($tags[2] ? $tags[2] : 9 )) ."</td>";
$output .= "<td align=\"center\">". pager_next(($tags[3] ? $tags[3] : t("next page")), $limit, $element) ."</td>";
$output .= "<td align=\"center\">". pager_last(($tags[4] ? $tags[4] : t("last page")), $limit, $element) ."</td>";
$output .= "<td align=\"center\">". pager_first(($tags[0] ? $tags[0] : t("first page")), $limit, $element, $attributes) ."</td>";
$output .= "<td align=\"center\">". pager_previous(($tags[1] ? $tags[1] : t("previous page")), $limit, $element, 1, $attributes) ."</td>";
$output .= "<td align=\"center\">". pager_list($limit, $element, ($tags[2] ? $tags[2] : 9 ), "", $attributes) ."</td>";
$output .= "<td align=\"center\">". pager_next(($tags[3] ? $tags[3] : t("next page")), $limit, $element, 1, $attributes) ."</td>";
$output .= "<td align=\"center\">". pager_last(($tags[4] ? $tags[4] : t("last page")), $limit, $element, $attributes) ."</td>";
$output .= "</tr></tbody></table></center>";
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 "<a href=\"". pager_link(pager_load_array(0, $element, $from_array)) ."\">$text</a>";
if ($pager_from_array[$element]) {
return "<a href=\"". pager_link(pager_load_array(0, $element, $pager_from_array), $attributes) ."\">$text</a>";
}
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 "<a href=\"". pager_link($from_new) ."\">$text</a>";
return "<a href=\"". pager_link($from_new, $attributes) ."\">$text</a>";
}
/**
......@@ -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 "<a href=\"". pager_link($from_new) ."\">$text</a>";
return "<a href=\"". pager_link($from_new, $attributes) ."\">$text</a>";
}
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 "<a href=\"". pager_link($from_new) ."\">$text</a>";
if (($from_new[$element] > $pager_from_array[$element]) && ($from_new[$element] > 0) && $from_new[$element] < $pager_total[$element]) {
return "<a href=\"". pager_link($from_new, $attributes) ."\">$text</a>";
}
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 .= "<b>$i</b> ";
}
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:<pre>
......@@ -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) {
......
......@@ -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)), "<center>". $theme->links($links). "</center>");
$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);
......
......@@ -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)), "<center>". $theme->links($links). "</center>");
$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);
......
......@@ -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, "<a><i><b><u><tt><code><cite><strong>") != $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)));
}
......
......@@ -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, "<a><i><b><u><tt><code><cite><strong>") != $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)));
}
......
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