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

- Patch #60910 by doq: clean up the statistics.module's link handling. Show...

- Patch #60910 by doq: clean up the statistics.module's link handling.  Show clean URLs when available.
parent dcc64e37
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -185,7 +185,7 @@ function statistics_node_tracker() { ...@@ -185,7 +185,7 @@ function statistics_node_tracker() {
while ($log = db_fetch_object($result)) { while ($log = db_fetch_object($result)) {
$rows[] = array( $rows[] = array(
array('data' => format_date($log->timestamp, 'small'), 'class' => 'nowrap'), array('data' => format_date($log->timestamp, 'small'), 'class' => 'nowrap'),
l(_statistics_column_width($log->url), $log->url), _statistics_link($log->url),
theme('username', $log), theme('username', $log),
l(t('details'), "admin/logs/access/$log->aid")); l(t('details'), "admin/logs/access/$log->aid"));
} }
...@@ -325,7 +325,7 @@ function statistics_top_referrers() { ...@@ -325,7 +325,7 @@ function statistics_top_referrers() {
$result = pager_query($query, 30, 0, $query_cnt, $_SERVER['HTTP_HOST']); $result = pager_query($query, 30, 0, $query_cnt, $_SERVER['HTTP_HOST']);
while ($referrer = db_fetch_object($result)) { while ($referrer = db_fetch_object($result)) {
$rows[] = array($referrer->hits, '<a href="'. check_url($referrer->url) .'">'. check_plain(_statistics_column_width($referrer->url)) .'</a>', t('%time ago', array('%time' => format_interval(time() - $referrer->last)))); $rows[] = array($referrer->hits, _statistics_link($referrer->url), t('%time ago', array('%time' => format_interval(time() - $referrer->last))));
} }
$output = theme('table', $header, $rows); $output = theme('table', $header, $rows);
...@@ -468,14 +468,16 @@ function statistics_block($op = 'list', $delta = 0, $edit = array()) { ...@@ -468,14 +468,16 @@ function statistics_block($op = 'list', $delta = 0, $edit = array()) {
* It is possible to adjust the width of columns generated by the * It is possible to adjust the width of columns generated by the
* statistics module. * statistics module.
*/ */
function _statistics_column_width($column, $width = 35) { function _statistics_link($path, $width = 35) {
return (strlen($column) > $width ? substr($column, 0, $width) . '...' : $column); $title = drupal_get_path_alias($path);
$title = truncate_utf8($title, $width, FALSE, TRUE);
return l($title, $path);
} }
function _statistics_format_item($title, $link) { function _statistics_format_item($title, $path) {
$link = ($link ? $link : '/'); $path = ($path ? $path : '/');
$output = ($title ? "$title<br />" : ''); $output = ($title ? "$title<br />" : '');
$output .= l(_statistics_column_width($link), $link); $output .= _statistics_link($path);
return $output; return $output;
} }
......
...@@ -185,7 +185,7 @@ function statistics_node_tracker() { ...@@ -185,7 +185,7 @@ function statistics_node_tracker() {
while ($log = db_fetch_object($result)) { while ($log = db_fetch_object($result)) {
$rows[] = array( $rows[] = array(
array('data' => format_date($log->timestamp, 'small'), 'class' => 'nowrap'), array('data' => format_date($log->timestamp, 'small'), 'class' => 'nowrap'),
l(_statistics_column_width($log->url), $log->url), _statistics_link($log->url),
theme('username', $log), theme('username', $log),
l(t('details'), "admin/logs/access/$log->aid")); l(t('details'), "admin/logs/access/$log->aid"));
} }
...@@ -325,7 +325,7 @@ function statistics_top_referrers() { ...@@ -325,7 +325,7 @@ function statistics_top_referrers() {
$result = pager_query($query, 30, 0, $query_cnt, $_SERVER['HTTP_HOST']); $result = pager_query($query, 30, 0, $query_cnt, $_SERVER['HTTP_HOST']);
while ($referrer = db_fetch_object($result)) { while ($referrer = db_fetch_object($result)) {
$rows[] = array($referrer->hits, '<a href="'. check_url($referrer->url) .'">'. check_plain(_statistics_column_width($referrer->url)) .'</a>', t('%time ago', array('%time' => format_interval(time() - $referrer->last)))); $rows[] = array($referrer->hits, _statistics_link($referrer->url), t('%time ago', array('%time' => format_interval(time() - $referrer->last))));
} }
$output = theme('table', $header, $rows); $output = theme('table', $header, $rows);
...@@ -468,14 +468,16 @@ function statistics_block($op = 'list', $delta = 0, $edit = array()) { ...@@ -468,14 +468,16 @@ function statistics_block($op = 'list', $delta = 0, $edit = array()) {
* It is possible to adjust the width of columns generated by the * It is possible to adjust the width of columns generated by the
* statistics module. * statistics module.
*/ */
function _statistics_column_width($column, $width = 35) { function _statistics_link($path, $width = 35) {
return (strlen($column) > $width ? substr($column, 0, $width) . '...' : $column); $title = drupal_get_path_alias($path);
$title = truncate_utf8($title, $width, FALSE, TRUE);
return l($title, $path);
} }
function _statistics_format_item($title, $link) { function _statistics_format_item($title, $path) {
$link = ($link ? $link : '/'); $path = ($path ? $path : '/');
$output = ($title ? "$title<br />" : ''); $output = ($title ? "$title<br />" : '');
$output .= l(_statistics_column_width($link), $link); $output .= _statistics_link($path);
return $output; return $output;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment