### Eclipse Workspace Patch 1.0 #P activitystream Index: activitystream_twitter/activitystream_twitter.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/activitystream/activitystream_twitter/activitystream_twitter.module,v retrieving revision 1.1.2.4 diff -u -r1.1.2.4 activitystream_twitter.module --- activitystream_twitter/activitystream_twitter.module 10 Apr 2008 15:37:23 -0000 1.1.2.4 +++ activitystream_twitter/activitystream_twitter.module 29 Apr 2008 06:15:43 -0000 @@ -19,7 +19,11 @@ $items = activitystream_feed_streamapi($user); foreach ($items as $tweet) { $userid = $user->userid . ':'; - $tweet['title'] = preg_replace('/^'.$userid.' /', '', $tweet['title']); + /** + * http://drupal.org/node/245662#comment-810733 + */ + $raw_title = preg_replace('/^'.$userid.' /', '', $tweet['title']); + $tweet['title'] = activitystream_twitter_word_trim($raw_title, 10, TRUE); $tweet['body'] = activitystream_twitter_makelinks($tweet['body']); $newitems[] = $tweet; } @@ -78,3 +82,25 @@ return $text; } +/** + * This trims the node title to 10 words and appends an ellipses (three dots, the html entity doens't work correctly in node title, like any other html). + * see http://drupal.org/node/245662#comment-810733 + * @param string $string + * @param int $count + * @param bool $ellipsis + * @return string + */ +function activitystream_twitter_word_trim($string, $count, $ellipsis = FALSE){ + $words = explode(' ', $string); + if (count($words) > $count){ + array_splice($words, $count); + $string = implode(' ', $words); + if (is_string($ellipsis)){ + $string .= $ellipsis; + } + elseif ($ellipsis){ + $string .= '...'; + } + } + return $string; +} \ No newline at end of file