summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2005-08-01 05:14:05 +0000
committerDries Buytaert <dries@buytaert.net>2005-08-01 05:14:05 +0000
commit7625a4e91ab81b52f5cd74cabe5b0e0324ef8bb4 (patch)
tree255aa1aab3de018eeb60d5756522e7726c7dbe10 /includes
parent22479d876173f5e1704cbafabba667450ecf2512 (diff)
downloadbrdo-7625a4e91ab81b52f5cd74cabe5b0e0324ef8bb4.tar.gz
brdo-7625a4e91ab81b52f5cd74cabe5b0e0324ef8bb4.tar.bz2
- Patch #27737 by Gerhard: format_name($object) -> theme('username', $object).
Usernames can now be themed; eg. an icon/avatar could be added. TODO: update contributed modules + update the migration docs.
Diffstat (limited to 'includes')
-rw-r--r--includes/common.inc47
-rw-r--r--includes/theme.inc51
2 files changed, 49 insertions, 49 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 8a85e0d71..684112c61 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -965,53 +965,6 @@ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NUL
}
/**
- * Format a username.
- *
- * @param $object
- * The user object to format, usually returned from user_load().
- * @return
- * A string containing an HTML link to the user's page if the passed object
- * suggests that this is a site user. Otherwise, only the username is returned.
- */
-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 = truncate_utf8($object->name, 15) .'...';
- }
- else {
- $name = $object->name;
- }
-
- if (user_access('access user profiles')) {
- $output = l($name, 'user/'. $object->uid, array('title' => t('View user profile.')));
- }
- else {
- $output = $name;
- }
- }
- else if ($object->name) {
- // Sometimes modules display content composed by people who are
- // not registered members of the site (e.g. mailing list or news
- // aggregator modules). This clause enables modules to display
- // the true author of the content.
- if ($object->homepage) {
- $output = '<a href="'. $object->homepage .'">'. $object->name .'</a>';
- }
- else {
- $output = $object->name;
- }
-
- $output .= ' ('. t('not verified') .')';
- }
- else {
- $output = variable_get('anonymous', 'Anonymous');
- }
-
- return $output;
-}
-/**
* @} End of "defgroup format".
*/
diff --git a/includes/theme.inc b/includes/theme.inc
index da3e846a7..501d80715 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -580,10 +580,10 @@ function theme_node($node, $teaser = FALSE, $page = FALSE) {
}
if ($page == 0) {
- $output = '<h2 class="title">'. check_plain($node->title) .'</h2> by '. format_name($node);
+ $output = '<h2 class="title">'. check_plain($node->title) .'</h2> by '. theme('username', $node);
}
else {
- $output = 'by '. format_name($node);
+ $output = 'by '. theme('username', $node);
}
if (count($terms)) {
@@ -994,6 +994,53 @@ function theme_confirm($question, $path, $description = NULL, $yes = NULL, $no =
return form($output, 'post', NULL, array('class' => 'confirmation'));
}
+/**
+ * Format a username.
+ *
+ * @param $object
+ * The user object to format, usually returned from user_load().
+ * @return
+ * A string containing an HTML link to the user's page if the passed object
+ * suggests that this is a site user. Otherwise, only the username is returned.
+ */
+function theme_username($object) {
+
+ if ($object->uid && $object->name) {
+ // Shorten the name when it is too long or it will break many tables.
+ if (drupal_strlen($object->name) > 20) {
+ $name = drupal_substr($object->name, 0, 15) .'...';
+ }
+ else {
+ $name = $object->name;
+ }
+
+ if (user_access('access user profiles')) {
+ $output = l($name, 'user/'. $object->uid, array('title' => t('View user profile.')));
+ }
+ else {
+ $output = $name;
+ }
+ }
+ else if ($object->name) {
+ // Sometimes modules display content composed by people who are
+ // not registered members of the site (e.g. mailing list or news
+ // aggregator modules). This clause enables modules to display
+ // the true author of the content.
+ if ($object->homepage) {
+ $output = '<a href="'. $object->homepage .'">'. $object->name .'</a>';
+ }
+ else {
+ $output = $object->name;
+ }
+
+ $output .= ' ('. t('not verified') .')';
+ }
+ else {
+ $output = variable_get('anonymous', 'Anonymous');
+ }
+
+ return $output;
+}
/**
* @} End of "defgroup themeable".