From e9148b9180bdba54f8bc99c36a68791a7b291dc2 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 29 Dec 2002 16:40:08 +0000 Subject: - Usability improvement: made the access log, referrer logs and popular post tables use the new table rendering functions. - Usability improvement: a couple of strings could not be translated. --- modules/statistics.module | 47 ++++++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 27 deletions(-) (limited to 'modules/statistics.module') diff --git a/modules/statistics.module b/modules/statistics.module index 0d0922e0f..632b0bc5d 100644 --- a/modules/statistics.module +++ b/modules/statistics.module @@ -119,8 +119,8 @@ function statistics_link($type, $node = 0, $main = 0) { menu_add("help", "admin.php?mod=statistics&op=help", "More information about the statistics.", NULL, "site monitoring", 6); // block configuration: - menu_add("configure 'top nodes' block", "admin.php?mod=statistics&op=top+nodes+block", "Configure the 'top nodes block'", $help["top nodes block"], "block management"); - menu_add("configure 'who is online' block", "admin.php?mod=statistics&op=whos+online+block", "Configure the 'top nodes block'", $help["who is online block"], "block management"); + menu_add("configure 'top nodes' block", "admin.php?mod=statistics&op=top+nodes+block", "Configure the 'top nodes block'", $help["top nodes block"], "block management", 2); + menu_add("configure 'who is online' block", "admin.php?mod=statistics&op=whos+online+block", "Configure the 'top nodes block'", $help["who is online block"], "block management", 2); } return $links ? $links : array(); @@ -324,20 +324,18 @@ function statistics_admin() { function statistics_admin_count_table($dbfield, $dbrows) { $result = db_query("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 LIMIT %s", $dbfield, $dbfield, $dbrows); - $output = "\n"; + $header = array(t("title"), t("today"), t("all time"), t("last hit"), t("operations")); while ($nid = db_fetch_array($result)) { - $output .= ""; + $rows[] = array(l($nid["title"], array("id" => $nid["nid"]), "node", "", array("title" => t("View this posting."))), $nid["daycount"], $nid["totalcount"], format_date($nid["timestamp"], "small"), la("view referrers", array("mod" => "statistics", "op" => "referrers", "nid" => $nid["nid"], "title" => "$nid[title]"))); } - $output .= "
". t("title") ."". t("today") ."". t("all time") ."". t("last hit") ."". t("referrers") ."
". l($nid["title"], array("id" => $nid["nid"]), "node", "", array("title" => t("View this posting."))) ."". $nid["daycount"] ."". $nid["totalcount"] ."". format_date($nid["timestamp"], "small") ."
"; - $output .= la("view", array("mod" => "statistics", "op" => "referrers", "nid" => $nid["nid"], "title" => "$nid[title]")); - $output .= "
\n"; - return $output; + return table($header, $rows); } function statistics_admin_accesslog_table($type, $id) { + /* overview limit */ $limit0 = 50; /* detail limit */ @@ -357,38 +355,35 @@ function statistics_admin_accesslog_table($type, $id) { else if ($type == 2) { /* retrieve recent access logs for node $id */ $result = db_query("SELECT nid, url, hostname, uid, timestamp FROM accesslog WHERE nid = '%s' ORDER BY timestamp DESC LIMIT %s", $id, $limit1); - } else if ($type == 3) { /* retrieve recent access logs for hostname $id */ $result = db_query("SELECT nid, url, hostname, uid, timestamp FROM accesslog WHERE hostname = '%s' ORDER BY timestamp DESC LIMIT %s", $id, $limit1); - } else { /* retrieve all recent access logs */ $result = db_query("SELECT nid, url, hostname, uid, timestamp FROM accesslog ORDER BY timestamp DESC LIMIT %s", $limit0); } - $output = "\n"; + $header = array(t("timestamp"), t("title"), t("user"), t("hostname"), t("referrer")); while ($log = db_fetch_array($result)) { if (!$node = node_load(array("nid" => $log["nid"]))) { $node->nid = 0; } $user = user_load(array("uid" => $log["uid"])); - $output .= ""; + $url = "". (strlen($log["url"]) > 28 ? substr($log["url"], 0, 28) . '...' : $log["url"]) .""; } else { - $output .= "n/a"; + $url = message_na(); } + $rows[] = array(array("data" => format_date($log["timestamp"], "small"), "nowrap" => "nowrap"), ($node->nid ? la($node->title, array("mod" => "statistics", "op" => "log", "nid" => $node->nid), "") : message_na()), ($user->name ? la((strlen($user->name) > 18 ? substr($user->name, 0, 18) . '...' : $user->name), array("mod" => "statistics", "op" => "log", "uid" => $user->uid), "") : message_na()), ($log["hostname"] ? la($log["hostname"], array("mod" => "statistics", "op" => "log", "hostname" => $log["hostname"]), "") : message_na()), $url); } - $output .= "
". t("timestamp") ."". t("title") ."". t("user") ."". t("hostname") ."". t("referrer") ."
". format_date($log["timestamp"], "small") ."". ($node->nid ? la($node->title, array("mod" => "statistics", "op" => "log", "nid" => $node->nid), "") : "n/a") ."". ($user->name ? la((strlen($user->name) > 18 ? substr($user->name, 0, 18) . '...' : $user->name), array("mod" => "statistics", "op" => "log", "uid" => $user->uid), "") : "n/a") ."". ($log["hostname"] ? la($log["hostname"], array("mod" => "statistics", "op" => "log", "hostname" => $log["hostname"]), "") : "n/a") .""; + if ($log["url"]) { - $output .= "". (strlen($log["url"]) > 28 ? substr($log["url"], 0, 28) . '...' : $log["url"]) ."
"; - - return $output; + return table($header, $rows); } @@ -431,15 +426,14 @@ function statistics_recent_refer($nid = 0) { $output = "

". t("Most recent %describe referrers", array("%describe" => $describe)) ."

"; } - $output .= "\n"; - $output .= " \n"; + $header = array(t("URL"), t("date")); while ($referrer = db_fetch_array($result)) { - $output .= ""; + $rows[] = array("". substr(check_output($referrer["url"]), 0, 100) ."", format_date($referrer["timestamp"], "small")); } - $output .= "
URLdate
". substr(check_output($referrer["url"]), 0, 100) ."". format_date($referrer["timestamp"], "small") ."
\n"; - return $output; + $output .= table($header, $rows); + return $output; } @@ -484,12 +478,12 @@ function statistics_top_refer($nid = 0) { $result = db_query($query); - $output .= "\n"; - $output .= " \n"; + $header = array(t("URL"), t("count")); while ($referrer = db_fetch_array($result)) { - $output .= ""; + $rows[] = array("". substr(check_output($referrer["url"]), 0, 100) ."", $referrer["count"]); } - $output .= "
". t("URL") ."". t("count") ."
". substr(check_output($referrer["url"]), 0, 100) ."". $referrer["count"] ."
\n"; + + $output .= table($header, $rows); return $output; @@ -901,7 +895,6 @@ function statistics_summary($dbfield, $dbrows) { } return $output; - } // clean up statistics table when node is deleted -- cgit v1.2.3