From 4d16c7c65bdd9833b6e6852c49f029ab003f8e2e Mon Sep 17 00:00:00 2001
From: Dries Buytaert <dries@buytaert.net>
Date: Fri, 22 Aug 2003 21:35:25 +0000
Subject: [PATCH] Implemented more suggestions by Keith:

- Made sure the 'Topic' title is only shown above the topics, not the icons.

- Automatically shorten the username when it is too long.  I implemented this
  as part of format_name() and could therefore nuke some code in the
  statistics module.  This is change is somewhat experimental and I'm willing
  to revert or change this if a number of people aren't too happy with this
  behavior.

- Left align the dates and authors: makes it easier/faster to scan.

- Made the little tablesort arrows clickable.
---
 includes/common.inc                  | 16 ++++++++++++++--
 includes/tablesort.inc               |  2 +-
 misc/drupal.css                      |  4 +++-
 modules/forum.module                 |  3 ++-
 modules/forum/forum.module           |  3 ++-
 modules/statistics.module            |  3 +--
 modules/statistics/statistics.module |  3 +--
 7 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/includes/common.inc b/includes/common.inc
index 60a383603f6a..e5c23fcabceb 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -822,11 +822,23 @@ function format_date($timestamp, $type = "medium", $format = "") {
 function format_name($object) {
 
   if ($object->uid && $object->name) {
+    /*
+    ** Shorten the name when it is too long or it will break many
+    ** tables.
+    */
+
+    if (strlen($object->name) > 20) {
+      $name = substr($object->name, 0, 15) ."...";
+    }
+    else {
+      $name = $object->name;
+    }
+
     if (arg(0) == "admin") {
-      $output = l($object->name, "admin/user/edit/$object->uid", array("title" => t("Administer user profile.")));
+      $output = l($name, "admin/user/edit/$object->uid", array("title" => t("Administer user profile.")));
     }
     else {
-      $output = l($object->name, "user/view/$object->uid", array("title" => t("View user profile.")));
+      $output = l($name, "user/view/$object->uid", array("title" => t("View user profile.")));
     }
   }
   else if ($object->name) {
diff --git a/includes/tablesort.inc b/includes/tablesort.inc
index 184176114f97..8b7fdd2a6420 100644
--- a/includes/tablesort.inc
+++ b/includes/tablesort.inc
@@ -31,7 +31,7 @@ function tablesort($cell, $header) {
     $cell["class"] = "cell-highlight";
     $image = "&nbsp;<img src=\"". $theme->image("arrow-". $ts["sort"]. ".gif"). "\"></img>";
   }
-  $cell["data"] = l($cell["data"], $_GET["q"], array(), "sort=". $ts["sort"]. "&order=". urlencode($cell["data"]). $ts["query_string"]). $image;
+  $cell["data"] = l($cell["data"] . $image, $_GET["q"], array(), "sort=". $ts["sort"]. "&order=". urlencode($cell["data"]). $ts["query_string"]);
   return $cell;
 }
 
diff --git a/misc/drupal.css b/misc/drupal.css
index 1a0299520e25..062510d820d9 100644
--- a/misc/drupal.css
+++ b/misc/drupal.css
@@ -128,9 +128,11 @@ th {
   margin: 0.5em;
 }
 #forum td.created, #forum td.posts, #forum td.topics, #forum td.last-reply, #forum td.replies, #forum td.pager {
-  text-align: center;
   white-space: nowrap;
 }
+#forum td.posts, #forum td.topics, #forum td.replies, #forum td.pager {
+  text-align: center;
+}
 .item-list .icon {
   color: #555;
   float: right;
diff --git a/modules/forum.module b/modules/forum.module
index a8a05d1b8230..a1220f8e2eb6 100644
--- a/modules/forum.module
+++ b/modules/forum.module
@@ -321,7 +321,8 @@ function forum_get_topics($tid, $sortby, $forum_per_page) {
   global $user, $forum_topic_list_header;
 
   $forum_topic_list_header = array(
-      array("data" => t("Topic"), "field" => "n.title", "colspan" => "2"),
+      array("data" => "&nbsp;"),
+      array("data" => t("Topic"), "field" => "n.title"),
       array("data" => t("Replies"),"field" => "num_comments"),
       array("data" => t("Created"), "field" => "n.created"),
       array("data" => t("Last reply"), "field" => "date_sort", "sort" => "desc"),
diff --git a/modules/forum/forum.module b/modules/forum/forum.module
index a8a05d1b8230..a1220f8e2eb6 100644
--- a/modules/forum/forum.module
+++ b/modules/forum/forum.module
@@ -321,7 +321,8 @@ function forum_get_topics($tid, $sortby, $forum_per_page) {
   global $user, $forum_topic_list_header;
 
   $forum_topic_list_header = array(
-      array("data" => t("Topic"), "field" => "n.title", "colspan" => "2"),
+      array("data" => "&nbsp;"),
+      array("data" => t("Topic"), "field" => "n.title"),
       array("data" => t("Replies"),"field" => "num_comments"),
       array("data" => t("Created"), "field" => "n.created"),
       array("data" => t("Last reply"), "field" => "date_sort", "sort" => "desc"),
diff --git a/modules/statistics.module b/modules/statistics.module
index 8a83afcb9505..69948922c62c 100644
--- a/modules/statistics.module
+++ b/modules/statistics.module
@@ -637,12 +637,11 @@ function statistics_display_online_block() {
       if (user_access("access userlist") && $users) {
         /* Display a list of currently online users */
         $max_users = variable_get("statistics_block_online_max_cnt", 10);
-        $max_name_len = variable_get("statistics_block_online_max_len", 15);
         $uid = reset($user_list);
         while (($uid) && ($max_users)) {
           $user = user_load(array("uid" => $uid));
           /* When displaying name, be sure it's not more than defined max length */
-          $items[] = l((strlen($user->name) > $max_name_len ? substr($user->name, 0, $max_name_len) ."..." : $user->name), "user/view/$user->uid");
+          $items[] = format_name($user);
           $uid = next($user_list);
           /*
           ** When $max_users reaches zero, we break out even if there are
diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module
index 8a83afcb9505..69948922c62c 100644
--- a/modules/statistics/statistics.module
+++ b/modules/statistics/statistics.module
@@ -637,12 +637,11 @@ function statistics_display_online_block() {
       if (user_access("access userlist") && $users) {
         /* Display a list of currently online users */
         $max_users = variable_get("statistics_block_online_max_cnt", 10);
-        $max_name_len = variable_get("statistics_block_online_max_len", 15);
         $uid = reset($user_list);
         while (($uid) && ($max_users)) {
           $user = user_load(array("uid" => $uid));
           /* When displaying name, be sure it's not more than defined max length */
-          $items[] = l((strlen($user->name) > $max_name_len ? substr($user->name, 0, $max_name_len) ."..." : $user->name), "user/view/$user->uid");
+          $items[] = format_name($user);
           $uid = next($user_list);
           /*
           ** When $max_users reaches zero, we break out even if there are
-- 
GitLab