Commit 70f5b864 authored by Dries's avatar Dries

A batch of changes:

- Renamed '---' to '<!--break-->'.

- Removed hard-coded call to the statistics module from the node module.
  Patch by Gerhard.

- Removed tables from poll module.  Modified patch by Al.  Changes to Al's
  patch are:
    "polltext" -> "poll-text"
    "pollfg"   -> "poll-foreground"
    "pollbg"   -> "poll-background"

- Changed some 'statistics.foo's to 's.foo's.  Patch by Gary.

[If this closes any bug reports, please update them on drupal.org.]
parent 2116f7a0
......@@ -75,7 +75,7 @@ function node_is_new($nid, $timestamp) {
global $user;
static $cache;
if (!$cache[$nid]) {
if (!isset($cache[$nid])) {
if ($user->uid) {
$history = db_fetch_object(db_query("SELECT timestamp FROM history WHERE uid = '%d' AND nid = '%d'", $user->uid, $nid));
$cache[$nid] = $history->timestamp ? $history->timestamp : 0;
......@@ -120,7 +120,7 @@ function node_teaser($body) {
** the allowed range but no more than a factor two.
*/
$delimiter = strpos($body, "---");
$delimiter = strpos($body, "<!--break-->");
if ($delimiter > 0 && $delimiter < $size * 2) {
return substr($body, 0, $delimiter);
}
......@@ -332,10 +332,10 @@ function node_view($node, $main = 0) {
/*
** Remove the delimiter (if any) that seperates the teaser from the
** body. TODO: this strips legitimate uses of --- also.
** body. TODO: this strips legitimate uses of '<!--break-->' also.
*/
$node->body = str_replace("---", "", $node->body);
$node->body = str_replace("<!--break-->", "", $node->body);
/*
** The "view" hook can be implemented to overwrite the default function
......@@ -1203,7 +1203,7 @@ function node_preview($node, $error = NULL) {
if ($view->teaser && $view->teaser != $view->body) {
print "<h3>". t("Preview trimmed version") ."</h3>";
node_view($view, 1);
print "<p><i>". t("The trimmed version of your post shows how your post looks like when promoted to the main page or when exported for syndication. You can insert a delimiter '---' (without the quotes) to fine-tune where your post gets split. However note that delimiter will be ignored when misplaced.") ."</i></p>";
print "<p><i>". t("The trimmed version of your post shows how your post looks like when promoted to the main page or when exported for syndication. You can insert a delimiter '&lt;!--break--&gt' (without the quotes) to fine-tune where your post gets split. However note that delimiter will be ignored when misplaced.") ."</i></p>";
print "<h3>". t("Preview full version") ."</h3>";
node_view($view, 0);
}
......@@ -1338,12 +1338,6 @@ function node_delete($edit) {
module_invoke("taxonomy", "node_delete", $node->nid);
/*
** Delete related node statistics
*/
module_invoke("statistics", "node_delete", $node->nid);
/*
** Call the node specific callback (if any):
*/
......
......@@ -75,7 +75,7 @@ function node_is_new($nid, $timestamp) {
global $user;
static $cache;
if (!$cache[$nid]) {
if (!isset($cache[$nid])) {
if ($user->uid) {
$history = db_fetch_object(db_query("SELECT timestamp FROM history WHERE uid = '%d' AND nid = '%d'", $user->uid, $nid));
$cache[$nid] = $history->timestamp ? $history->timestamp : 0;
......@@ -120,7 +120,7 @@ function node_teaser($body) {
** the allowed range but no more than a factor two.
*/
$delimiter = strpos($body, "---");
$delimiter = strpos($body, "<!--break-->");
if ($delimiter > 0 && $delimiter < $size * 2) {
return substr($body, 0, $delimiter);
}
......@@ -332,10 +332,10 @@ function node_view($node, $main = 0) {
/*
** Remove the delimiter (if any) that seperates the teaser from the
** body. TODO: this strips legitimate uses of --- also.
** body. TODO: this strips legitimate uses of '<!--break-->' also.
*/
$node->body = str_replace("---", "", $node->body);
$node->body = str_replace("<!--break-->", "", $node->body);
/*
** The "view" hook can be implemented to overwrite the default function
......@@ -1203,7 +1203,7 @@ function node_preview($node, $error = NULL) {
if ($view->teaser && $view->teaser != $view->body) {
print "<h3>". t("Preview trimmed version") ."</h3>";
node_view($view, 1);
print "<p><i>". t("The trimmed version of your post shows how your post looks like when promoted to the main page or when exported for syndication. You can insert a delimiter '---' (without the quotes) to fine-tune where your post gets split. However note that delimiter will be ignored when misplaced.") ."</i></p>";
print "<p><i>". t("The trimmed version of your post shows how your post looks like when promoted to the main page or when exported for syndication. You can insert a delimiter '&lt;!--break--&gt' (without the quotes) to fine-tune where your post gets split. However note that delimiter will be ignored when misplaced.") ."</i></p>";
print "<h3>". t("Preview full version") ."</h3>";
node_view($view, 0);
}
......@@ -1338,12 +1338,6 @@ function node_delete($edit) {
module_invoke("taxonomy", "node_delete", $node->nid);
/*
** Delete related node statistics
*/
module_invoke("statistics", "node_delete", $node->nid);
/*
** Call the node specific callback (if any):
*/
......
......@@ -303,16 +303,10 @@ function poll_view_results(&$node, $main, $block, $links) {
$width = round($node->chvotes[$key] * 100 / $votesmax);
$percentage = round($node->chvotes[$key] * 100 / max($votestotal, 1));
$output .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"95%\" align=\"center\"><tr><td>$value</td><td><div align=\"right\"> $percentage%". (!$block ? " (". format_plural($node->chvotes[$key], "1 vote", "%count votes") .")" : "") ."</div></td></tr></table>";
if ($width == 0) {
$output .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"95%\" align=\"center\"><tr><td class=\"pollbg\" width=\"100%\">&nbsp;</td></tr></table>";
}
else if ($width == 100) {
$output .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"95%\" align=\"center\"><tr><td class=\"pollfg\" width=\"100%\">&nbsp;</td></tr></table>";
}
else {
$output .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"95%\" align=\"center\"><tr><td class=\"pollfg\" width=\"". $width ."%\">&nbsp;</td><td class=\"pollbg\" width=\"". (100 - $width) ."%\">&nbsp;</td></tr></table>";
}
$output .= "<div class=\"poll-text\">$value</div>";
$output .= "<div style=\"float:left; width:". $width ."%; height: 1em;\" class=\"poll-foreground\"></div>";
$output .= "<div style=\"float:left; width:". (100 - $width) ."%; height: 1em;\" class=\"poll-background\"></div>";
$output .= "<div align=\"right\"> $percentage%". (!$block ? " (". format_plural($node->chvotes[$key], "1 vote", "%count votes") .")" : "") ."</div>";
}
}
}
......
......@@ -303,16 +303,10 @@ function poll_view_results(&$node, $main, $block, $links) {
$width = round($node->chvotes[$key] * 100 / $votesmax);
$percentage = round($node->chvotes[$key] * 100 / max($votestotal, 1));
$output .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"95%\" align=\"center\"><tr><td>$value</td><td><div align=\"right\"> $percentage%". (!$block ? " (". format_plural($node->chvotes[$key], "1 vote", "%count votes") .")" : "") ."</div></td></tr></table>";
if ($width == 0) {
$output .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"95%\" align=\"center\"><tr><td class=\"pollbg\" width=\"100%\">&nbsp;</td></tr></table>";
}
else if ($width == 100) {
$output .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"95%\" align=\"center\"><tr><td class=\"pollfg\" width=\"100%\">&nbsp;</td></tr></table>";
}
else {
$output .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"95%\" align=\"center\"><tr><td class=\"pollfg\" width=\"". $width ."%\">&nbsp;</td><td class=\"pollbg\" width=\"". (100 - $width) ."%\">&nbsp;</td></tr></table>";
}
$output .= "<div class=\"poll-text\">$value</div>";
$output .= "<div style=\"float:left; width:". $width ."%; height: 1em;\" class=\"poll-foreground\"></div>";
$output .= "<div style=\"float:left; width:". (100 - $width) ."%; height: 1em;\" class=\"poll-background\"></div>";
$output .= "<div align=\"right\"> $percentage%". (!$block ? " (". format_plural($node->chvotes[$key], "1 vote", "%count votes") .")" : "") ."</div>";
}
}
}
......
......@@ -326,7 +326,7 @@ function statistics_admin() {
/* Displays the various admin tables */
function statistics_admin_count_table($dbfield, $dbrows) {
$result = db_query_range("SELECT statistics.nid, statistics.daycount, statistics.totalcount, statistics.timestamp, node.title FROM statistics LEFT JOIN node USING (nid) WHERE statistics.%s <> '0' ORDER BY statistics.%s DESC", $dbfield, $dbfield, 0, $dbrows);
$result = db_query_range("SELECT s.nid, s.daycount, s.totalcount, s.timestamp, n.title FROM statistics s LEFT JOIN node n USING (nid) WHERE s.%s <> '0' ORDER BY s.%s DESC", $dbfield, $dbfield, 0, $dbrows);
$header = array(t("title"), t("today"), t("all time"), t("last hit"), t("operations"));
......@@ -789,7 +789,7 @@ function statistics_display_online_block() {
/* Display linked title based on field name */
function statistics_title_list($dbfield, $dbrows) {
/* valid dbfields: totalcount, daycount, timestamp */
return db_query_range("SELECT statistics.nid, node.title, u.uid, u.name FROM statistics LEFT JOIN node ON statistics.nid = node.nid LEFT JOIN users u ON node.uid = u.uid WHERE %s <> '0' AND node.status = 1 ORDER BY %s DESC", "statistics.". $dbfield, "statistics.". $dbfield, 0, $dbrows);
return db_query_range("SELECT s.nid, n.title, u.uid, u.name FROM statistics s LEFT JOIN node n ON s.nid = n.nid LEFT JOIN users u ON n.uid = u.uid WHERE %s <> '0' AND n.status = 1 ORDER BY %s DESC", "s.". $dbfield, "s.". $dbfield, 0, $dbrows);
}
......@@ -900,9 +900,12 @@ function statistics_summary($dbfield, $dbrows) {
return $output;
}
// clean up statistics table when node is deleted
function statistics_node_delete($nid) {
db_query("DELETE FROM statistics WHERE nid = '%d'", $nid);
function statistics_nodeapi(&$node, $op, $arg = 0) {
switch ($op) {
case "delete":
// clean up statistics table when node is deleted
db_query("DELETE FROM statistics WHERE nid = '%d'", $node->nid);
}
}
/* internal throttle function - do not call from other modules */
......
......@@ -326,7 +326,7 @@ function statistics_admin() {
/* Displays the various admin tables */
function statistics_admin_count_table($dbfield, $dbrows) {
$result = db_query_range("SELECT statistics.nid, statistics.daycount, statistics.totalcount, statistics.timestamp, node.title FROM statistics LEFT JOIN node USING (nid) WHERE statistics.%s <> '0' ORDER BY statistics.%s DESC", $dbfield, $dbfield, 0, $dbrows);
$result = db_query_range("SELECT s.nid, s.daycount, s.totalcount, s.timestamp, n.title FROM statistics s LEFT JOIN node n USING (nid) WHERE s.%s <> '0' ORDER BY s.%s DESC", $dbfield, $dbfield, 0, $dbrows);
$header = array(t("title"), t("today"), t("all time"), t("last hit"), t("operations"));
......@@ -789,7 +789,7 @@ function statistics_display_online_block() {
/* Display linked title based on field name */
function statistics_title_list($dbfield, $dbrows) {
/* valid dbfields: totalcount, daycount, timestamp */
return db_query_range("SELECT statistics.nid, node.title, u.uid, u.name FROM statistics LEFT JOIN node ON statistics.nid = node.nid LEFT JOIN users u ON node.uid = u.uid WHERE %s <> '0' AND node.status = 1 ORDER BY %s DESC", "statistics.". $dbfield, "statistics.". $dbfield, 0, $dbrows);
return db_query_range("SELECT s.nid, n.title, u.uid, u.name FROM statistics s LEFT JOIN node n ON s.nid = n.nid LEFT JOIN users u ON n.uid = u.uid WHERE %s <> '0' AND n.status = 1 ORDER BY %s DESC", "s.". $dbfield, "s.". $dbfield, 0, $dbrows);
}
......@@ -900,9 +900,12 @@ function statistics_summary($dbfield, $dbrows) {
return $output;
}
// clean up statistics table when node is deleted
function statistics_node_delete($nid) {
db_query("DELETE FROM statistics WHERE nid = '%d'", $nid);
function statistics_nodeapi(&$node, $op, $arg = 0) {
switch ($op) {
case "delete":
// clean up statistics table when node is deleted
db_query("DELETE FROM statistics WHERE nid = '%d'", $node->nid);
}
}
/* internal throttle function - do not call from other modules */
......
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