? sites/localwork Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.991 diff -u -p -r1.991 common.inc --- includes/common.inc 18 Sep 2009 00:04:21 -0000 1.991 +++ includes/common.inc 18 Sep 2009 09:38:16 -0000 @@ -4602,7 +4602,7 @@ function drupal_common_theme() { 'arguments' => array('region' => NULL), ), 'username' => array( - 'arguments' => array('object' => NULL), + 'arguments' => array('object' => NULL, 'options' => array()), ), 'progress_bar' => array( 'arguments' => array('percent' => NULL, 'message' => NULL), Index: includes/theme.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/theme.inc,v retrieving revision 1.525 diff -u -p -r1.525 theme.inc --- includes/theme.inc 15 Sep 2009 20:03:18 -0000 1.525 +++ includes/theme.inc 18 Sep 2009 09:38:16 -0000 @@ -1870,6 +1870,13 @@ function theme_more_link($url, $title) { * @see theme_username(). */ function template_preprocess_username(&$variables) { + // Merge in default options. + $variables['options'] += array( + 'plain' => FALSE, + 'link' => TRUE, + 'shorten' => TRUE, + ); + $account = $variables['object']; // Create a new empty object to populate with standardized data. $variables['object'] = new stdClass; @@ -1895,7 +1902,7 @@ function template_preprocess_username(&$ $variables['object']->profile_access = user_access('access user profiles'); $variables['object']->link_attributes = array(); // Populate link path and attributes if appropriate. - if ($variables['object']->uid && $variables['object']->profile_access) { + if ($variables['options']['link'] && $variables['object']->uid && $variables['object']->profile_access) { // We are linking to a local user. $variables['object']->link_attributes = array('title' => t('View user profile.')); $variables['object']->link_path = 'user/' . $variables['object']->uid; @@ -1909,12 +1916,6 @@ function template_preprocess_username(&$ $variables['object']->link_options['html'] = TRUE; // Set a default class. $variables['object']->attributes = array('class' => array('username')); - // Shorten the name when it is too long or it will break many tables. - if (drupal_strlen($variables['object']->name) > 20) { - $variables['object']->name = drupal_substr($variables['object']->name, 0, 15) . '...'; - } - // Make sure name is safe for use in the theme function. - $variables['object']->name = check_plain($variables['object']->name); } /** @@ -1923,12 +1924,20 @@ function template_preprocess_username(&$ * @see theme_username(). */ function template_process_username(&$variables) { + // Make sure name is safe for use in the theme function. + $variables['object']->name = check_plain($variables['object']->name); + // Finalize the link_options array for passing to the l() function. // This is done in the process phase so that attributes may be added by // modules or the theme during the preprocess phase. if (isset($variables['object']->link_path)) { $variables['object']->link_options['attributes'] = $variables['object']->link_attributes + $variables['object']->attributes; } + + // Shorten the name when it is too long or it will break many tables. + if ($variables['options']['shorten'] && !$variables['options']['plain'] && drupal_strlen($variables['object']->name) > 20) { + $variables['object']->name = drupal_substr($variables['object']->name, 0, 15) . '...'; + } } /** @@ -1938,6 +1947,16 @@ function template_process_username(&$var * The user object to format, which has been processed to provide safe and * standarized elements. The object keys 'name', and 'extra' are safe strings * that can be used directly. + * @param $options + * An associative array of additional options, with the following keys: + * 'plain' (default FALSE) + * Whether to force the output as plain text format. Useful for + * centralize username style handling. + * 'link' (default TRUE) + * Whether to format name as hyperlink to user profile. + * 'shorten' (default TRUE) + * Whether to limit the length of the name, to fit in user tables. + * Modules may introduce additional options by implementing preprocess functions. * * @return * A string containing an HTML link to the user's page if the passed object @@ -1946,8 +1965,11 @@ function template_process_username(&$var * @see template_preprocess_username() * @see template_process_username() */ -function theme_username($object) { - if (isset($object->link_path)) { +function theme_username($object, $options) { + if ($options['plain']) { + $output = $object->name; + } + else if (isset($object->link_path)) { // We have a link path, so we should generate a link using l(). // Additional classes may be added as array elements like // $object->link_options['attributes']['class'][] = 'myclass'; Index: modules/blog/blog.module =================================================================== RCS file: /cvs/drupal/drupal/modules/blog/blog.module,v retrieving revision 1.335 diff -u -p -r1.335 blog.module --- modules/blog/blog.module 29 Aug 2009 05:46:02 -0000 1.335 +++ modules/blog/blog.module 18 Sep 2009 09:38:16 -0000 @@ -27,7 +27,7 @@ function blog_user_view($account) { $account->content['summary']['blog'] = array( '#type' => 'user_profile_item', '#title' => t('Blog'), - '#markup' => l(t('View recent blog entries'), "blog/$account->uid", array('attributes' => array('title' => t("Read !username's latest blog entries.", array('!username' => $account->name))))), + '#markup' => l(t('View recent blog entries'), "blog/$account->uid", array('attributes' => array('title' => t("Read !username's latest blog entries.", array('!username' => theme('username', $account, array('link' => FALSE, 'shorten' => FALSE)))))), array('html' => TRUE)), '#attributes' => array('class' => array('blog')), ); } @@ -60,7 +60,7 @@ function blog_form($node, $form_state) { function blog_view($node, $build_mode) { if ((bool)menu_get_object()) { // Breadcrumb navigation. - drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t('Blogs'), 'blog'), l(t("!name's blog", array('!name' => $node->name)), 'blog/' . $node->uid))); + drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t('Blogs'), 'blog'), l(t("!name's blog", array('!name' => theme('username', $node, array('shorten' => FALSE, 'link' => FALSE)))), 'blog/' . $node->uid, array('html' => TRUE)))); } return $node; } @@ -72,9 +72,10 @@ function blog_node_view($node, $build_mo if ($build_mode != 'rss') { if ($node->type == 'blog' && arg(0) != 'blog' || arg(1) != $node->uid) { $links['blog_usernames_blog'] = array( - 'title' => t("!username's blog", array('!username' => $node->name)), + 'title' => t("!username's blog", array('!username' => theme('username', $node, array('link' => FALSE, 'shorten' => FALSE)))), 'href' => "blog/$node->uid", - 'attributes' => array('title' => t("Read !username's latest blog entries.", array('!username' => $node->name))), + 'attributes' => array('title' => t("Read !username's latest blog entries.", array('!username' => theme('username', $node, array('plain' => TRUE))))), + 'html' => TRUE, ); $node->content['links']['blog'] = array( '#theme' => 'links', Index: modules/blog/blog.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/blog/blog.pages.inc,v retrieving revision 1.22 diff -u -p -r1.22 blog.pages.inc --- modules/blog/blog.pages.inc 10 Aug 2009 22:39:24 -0000 1.22 +++ modules/blog/blog.pages.inc 18 Sep 2009 09:38:16 -0000 @@ -12,7 +12,7 @@ function blog_page_user($account) { global $user; - drupal_set_title($title = t("@name's blog", array('@name' => $account->name)), PASS_THROUGH); + drupal_set_title($title = t("@name's blog", array('@name' => theme('username', $account, array('plain' => TRUE)))), PASS_THROUGH); $items = array(); @@ -123,7 +123,7 @@ function blog_feed_user($account) { ->execute() ->fetchCol(); - $channel['title'] = t("!name's blog", array('!name' => $account->name)); + $channel['title'] = t("!name's blog", array('!name' => theme('username', $account, array('plain' => TRUE)))); $channel['link'] = url('blog/' . $account->uid, array('absolute' => TRUE)); node_feed($nids, $channel); Index: modules/blog/blog.test =================================================================== RCS file: /cvs/drupal/drupal/modules/blog/blog.test,v retrieving revision 1.18 diff -u -p -r1.18 blog.test --- modules/blog/blog.test 22 Aug 2009 00:58:52 -0000 1.18 +++ modules/blog/blog.test 18 Sep 2009 09:38:16 -0000 @@ -38,7 +38,7 @@ class BlogTestCase extends DrupalWebTest $this->drupalGet('blog/' . $this->big_user->uid); $this->assertResponse(200); - $this->assertTitle(t("@name's blog", array('@name' => $this->big_user->name)) . ' | Drupal', t('Blog title was displayed')); + $this->assertTitle(t("@name's blog", array('@name' => theme('username', $this->big_user, array('plain' => TRUE)))) . ' | Drupal', t('Blog title was displayed')); $this->assertText(t('You are not allowed to post a new blog entry.'), t('No new entries can be posted without the right permission')); } @@ -50,8 +50,8 @@ class BlogTestCase extends DrupalWebTest $this->drupalGet('blog/' . $this->own_user->uid); $this->assertResponse(200); - $this->assertTitle(t("@name's blog", array('@name' => $this->own_user->name)) . ' | Drupal', t('Blog title was displayed')); - $this->assertText(t('!author has not created any blog entries.', array('!author' => $this->own_user->name)), t('Users blog displayed with no entries')); + $this->assertTitle(t("@name's blog", array('@name' => theme('username', $this->own_user, array('plain' => TRUE)))) . ' | Drupal', t('Blog title was displayed')); + $this->assertText(t('!author has not created any blog entries.', array('!author' => theme('username', $this->own_user))), t('Users blog displayed with no entries')); } /** @@ -139,7 +139,8 @@ class BlogTestCase extends DrupalWebTest $this->drupalGet('node/' . $node->nid); $this->assertResponse(200); $this->assertTitle($node->title . ' | Drupal', t('Blog node was displayed')); - $this->assertText(t('Home ' . $crumb . ' Blogs ' . $crumb . ' @name' . $quote . 's blog', array('@name' => $node_user->name)), t('Breadcrumbs were displayed')); + $bc = t('Home ' . $crumb . ' Blogs ' . $crumb . ' @name' . $quote . 's blog', array('@name' => theme('username', $node_user, array('link' => FALSE, 'shorten' => FALSE)))); + $this->assertText($bc, t('Breadcrumbs were displayed ')); // View blog edit node. $this->drupalGet('node/' . $node->nid . '/edit'); @@ -180,7 +181,7 @@ class BlogTestCase extends DrupalWebTest // Confirm the recent blog entries link goes to the user's blog page. $this->clickLink('View recent blog entries'); - $this->assertTitle(t("@name's blog | Drupal", array('@name' => $user->name)), t('View recent blog entries link target was correct')); + $this->assertTitle(t("@name's blog | Drupal", array('@name' => theme('username', $user, array('plain' => TRUE)))), t('View recent blog entries link target was correct')); // Confirm a blog page was displayed. $this->drupalGet('blog'); @@ -191,7 +192,7 @@ class BlogTestCase extends DrupalWebTest // Confirm a blog page was displayed per user. $this->drupalGet('blog/' . $user->uid); - $this->assertTitle(t("@name's blog | Drupal", array('@name' => $user->name)), t('User blog node was displayed')); + $this->assertTitle(t("@name's blog | Drupal", array('@name' => theme('username', $user, array('plain' => TRUE)))), t('User blog node was displayed')); // Confirm a blog feed was displayed. $this->drupalGet('blog/feed'); @@ -199,6 +200,6 @@ class BlogTestCase extends DrupalWebTest // Confirm a blog feed was displayed per user. $this->drupalGet('blog/' . $user->uid . '/feed'); - $this->assertTitle(t("@name's blog", array('@name' => $user->name)), t('User blog feed was displayed')); + $this->assertTitle(t("@name's blog", array('@name' => theme('username', $user, array('plain' => TRUE)))), t('User blog feed was displayed')); } } Index: modules/contact/contact.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/contact/contact.pages.inc,v retrieving revision 1.24 diff -u -p -r1.24 contact.pages.inc --- modules/contact/contact.pages.inc 18 Sep 2009 00:12:46 -0000 1.24 +++ modules/contact/contact.pages.inc 18 Sep 2009 09:38:16 -0000 @@ -54,7 +54,7 @@ function contact_site_form() { '#type' => 'textfield', '#title' => t('Your name'), '#maxlength' => 255, - '#default_value' => $user->uid ? $user->name : '', + '#default_value' => $user->uid ? theme('username', $user, array('plain' => TRUE)) : '', '#required' => TRUE, ); $form['mail'] = array( @@ -161,7 +161,7 @@ function contact_personal_page($account) $output = t("You cannot send more than %number messages per hour. Please try again later.", array('%number' => variable_get('contact_hourly_threshold', 3))); } else { - drupal_set_title($account->name); + drupal_set_title(theme('username', $account, array('plain' => TRUE))); $output = drupal_get_form('contact_personal_form', $account); } Index: modules/openid/openid.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/openid/openid.pages.inc,v retrieving revision 1.21 diff -u -p -r1.21 openid.pages.inc --- modules/openid/openid.pages.inc 18 Sep 2009 00:12:47 -0000 1.21 +++ modules/openid/openid.pages.inc 18 Sep 2009 09:38:16 -0000 @@ -28,7 +28,7 @@ function openid_authentication_page() { * Menu callback; Manage OpenID identities for the specified user. */ function openid_user_identities($account) { - drupal_set_title($account->name); + drupal_set_title(theme('username', $account, array('plain' => TRUE))); drupal_add_css(drupal_get_path('module', 'openid') . '/openid.css'); // Check to see if we got a response Index: modules/tracker/tracker.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/tracker/tracker.pages.inc,v retrieving revision 1.25 diff -u -p -r1.25 tracker.pages.inc --- modules/tracker/tracker.pages.inc 5 Sep 2009 15:05:05 -0000 1.25 +++ modules/tracker/tracker.pages.inc 18 Sep 2009 09:38:16 -0000 @@ -19,7 +19,7 @@ function tracker_page($account = NULL, $ // When viewed from user/%user/track, display the name of the user // as page title -- the tab title remains Track so this needs to be done // here and not in the menu definition. - drupal_set_title($account->name); + drupal_set_title(theme('username', $account, array('plain' => TRUE))); } } else { Index: modules/user/user.module =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.module,v retrieving revision 1.1046 diff -u -p -r1.1046 user.module --- modules/user/user.module 18 Sep 2009 00:12:48 -0000 1.1046 +++ modules/user/user.module 18 Sep 2009 09:38:16 -0000 @@ -817,7 +817,7 @@ function user_search_execute($keys = NUL ->limit(15) ->execute(); foreach ($result as $account) { - $find[] = array('title' => $account->name . ' (' . $account->mail . ')', 'link' => url('user/' . $account->uid, array('absolute' => TRUE))); + $find[] = array('title' => theme('username', $account, array('plain' => TRUE)) . ' (' . $account->mail . ')', 'link' => url('user/' . $account->uid, array('absolute' => TRUE))); } return $find; }