Skip to content
Snippets Groups Projects
Commit d8113fda authored by Dries Buytaert's avatar Dries Buytaert
Browse files

- Small code improvements.

parent 254233da
No related branches found
No related tags found
No related merge requests found
......@@ -144,13 +144,6 @@ function statistics_menu($may_cache) {
return $items;
}
function _statistics_format_item($title, $link) {
$link = ($link ? $link : '/');
$output = ($title ? "$title<br />" : '');
$output .= l($link, $link);
return $output;
}
function statistics_access_log($aid) {
$result = db_query('SELECT a.*, u.name FROM {accesslog} a LEFT JOIN {users} u ON a.uid = u.uid WHERE aid = %d', $aid);
if ($access = db_fetch_object($result)) {
......@@ -182,7 +175,7 @@ function statistics_node_tracker() {
while ($log = db_fetch_object($result)) {
$rows[] = array(
array('data' => format_date($log->timestamp, 'small'), 'nowrap' => 'nowrap'),
l($log->url, $log->url),
l(_statistics_column_width($log->url), $log->url),
format_name($log),
l(t('details'), "admin/logs/access/$log->aid"));
}
......@@ -322,7 +315,7 @@ function statistics_top_referrers() {
$result = pager_query($query, 30, 0, $query_cnt);
while ($referrer = db_fetch_object($result)) {
$rows[] = array($referrer->hits, '<a href="'. $referrer->url .'">'. _statistics_column_width($referrer->url, '_refer', 65) .'</a>', t('%time ago', array('%time' => format_interval(time() - $referrer->last))));
$rows[] = array($referrer->hits, '<a href="'. $referrer->url .'">'. _statistics_column_width($referrer->url) .'</a>', t('%time ago', array('%time' => format_interval(time() - $referrer->last))));
}
if ($pager = theme('pager', NULL, 30, 0, tablesort_pager())) {
$rows[] = array(array('data' => $pager, 'colspan' => '3'));
......@@ -471,14 +464,17 @@ function statistics_block($op = 'list', $delta = 0, $edit = array()) {
/**
* It is possible to adjust the width of columns generated by the
* statistics module. Currently this has to be done manually, by
* updating the appropriate variable. There are several recognized variables:
* 'statistics_column_width', 'statistics_column_width_refer', and
* 'statistics_column_width_title'
* statistics module.
*/
function _statistics_column_width($column, $type = "", $default = 26) {
$max_width = variable_get("statistics_column_width$type", $default);
return (strlen($column) > $max_width ? substr($column, 0, $max_width) . '...' : $column);
function _statistics_column_width($column, $width = 35) {
return (strlen($column) > $width ? substr($column, 0, $width) . '...' : $column);
}
function _statistics_format_item($title, $link) {
$link = ($link ? $link : '/');
$output = ($title ? "$title<br />" : '');
$output .= l($link, $link);
return $output;
}
/**
......
......@@ -144,13 +144,6 @@ function statistics_menu($may_cache) {
return $items;
}
function _statistics_format_item($title, $link) {
$link = ($link ? $link : '/');
$output = ($title ? "$title<br />" : '');
$output .= l($link, $link);
return $output;
}
function statistics_access_log($aid) {
$result = db_query('SELECT a.*, u.name FROM {accesslog} a LEFT JOIN {users} u ON a.uid = u.uid WHERE aid = %d', $aid);
if ($access = db_fetch_object($result)) {
......@@ -182,7 +175,7 @@ function statistics_node_tracker() {
while ($log = db_fetch_object($result)) {
$rows[] = array(
array('data' => format_date($log->timestamp, 'small'), 'nowrap' => 'nowrap'),
l($log->url, $log->url),
l(_statistics_column_width($log->url), $log->url),
format_name($log),
l(t('details'), "admin/logs/access/$log->aid"));
}
......@@ -322,7 +315,7 @@ function statistics_top_referrers() {
$result = pager_query($query, 30, 0, $query_cnt);
while ($referrer = db_fetch_object($result)) {
$rows[] = array($referrer->hits, '<a href="'. $referrer->url .'">'. _statistics_column_width($referrer->url, '_refer', 65) .'</a>', t('%time ago', array('%time' => format_interval(time() - $referrer->last))));
$rows[] = array($referrer->hits, '<a href="'. $referrer->url .'">'. _statistics_column_width($referrer->url) .'</a>', t('%time ago', array('%time' => format_interval(time() - $referrer->last))));
}
if ($pager = theme('pager', NULL, 30, 0, tablesort_pager())) {
$rows[] = array(array('data' => $pager, 'colspan' => '3'));
......@@ -471,14 +464,17 @@ function statistics_block($op = 'list', $delta = 0, $edit = array()) {
/**
* It is possible to adjust the width of columns generated by the
* statistics module. Currently this has to be done manually, by
* updating the appropriate variable. There are several recognized variables:
* 'statistics_column_width', 'statistics_column_width_refer', and
* 'statistics_column_width_title'
* statistics module.
*/
function _statistics_column_width($column, $type = "", $default = 26) {
$max_width = variable_get("statistics_column_width$type", $default);
return (strlen($column) > $max_width ? substr($column, 0, $max_width) . '...' : $column);
function _statistics_column_width($column, $width = 35) {
return (strlen($column) > $width ? substr($column, 0, $width) . '...' : $column);
}
function _statistics_format_item($title, $link) {
$link = ($link ? $link : '/');
$output = ($title ? "$title<br />" : '');
$output .= l($link, $link);
return $output;
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment