### 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 1 May 2008 19:29:19 -0000 @@ -17,13 +17,20 @@ // tweets. $user->feed = 'http://twitter.com/statuses/user_timeline/'.$user->userid . '.rss'; $items = activitystream_feed_streamapi($user); - foreach ($items as $tweet) { - $userid = $user->userid . ':'; - $tweet['title'] = preg_replace('/^'.$userid.' /', '', $tweet['title']); - $tweet['body'] = activitystream_twitter_makelinks($tweet['body']); - $newitems[] = $tweet; + if($items) { + foreach ($items as $tweet) { + $userid = $user->userid . ':'; + /** + * http://drupal.org/node/245662#comment-810733 + */ + $raw_title = preg_replace('/^'.$userid.' /', '', $tweet['title']); + $tweet['title'] = activitystream_twitter_word_trim($raw_title, TRUE); + $tweet['body'] = activitystream_twitter_makelinks($tweet['body']); + $newitems[] = $tweet; + } + return $newitems; } - return $newitems; + return false; } @@ -78,3 +85,52 @@ return $text; } +/* + * Implement an admin form hook. Modules should build a form + * using an array that mirrors the Drupal form API. activitystream.module + * will add the form elements to the admin settings page. + * To avoid collisions with other activitystream module's forms + * use your module's name as the form array's key. + */ +function activitystream_twitter_activitystream_admin() { + $form['activitystream_twitter'] = array( + '#type' => 'fieldset', + '#title' => t("Twitter"), + '#description' => t("Twitter settings."), + '#weight' => 1, + '#collapsible' => TRUE, + '#collapsed' => TRUE + ); + $form['activitystream_twitter']['activitystream_twitter_wordcount'] = array( + '#type' => 'textfield', + '#title' => t('Display word count'), + '#description' => t('Maximum number of words that will be displayed per tweet.'), + '#default_value' => variable_get('activitystream_twitter_wordcount', 10), + '#required' => FALSE + ); + return $form; +} + +/** + * 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, $ellipsis = FALSE){ + $words = explode(' ', $string); + $count = variable_get('activitystream_twitter_wordcount', 10); + 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 Index: activitystream_feed/activitystream_feed.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/activitystream/activitystream_feed/activitystream_feed.module,v retrieving revision 1.1.2.1 diff -u -r1.1.2.1 activitystream_feed.module --- activitystream_feed/activitystream_feed.module 10 Apr 2008 15:37:23 -0000 1.1.2.1 +++ activitystream_feed/activitystream_feed.module 1 May 2008 19:29:19 -0000 @@ -20,7 +20,10 @@ $feed->set_useragent('Drupal Activity Streams'); // Set this so that SimplePie will cache the favicon //$feed->set_favicon_handler('tmp'); - $feed->init(); + if(!$feed->init()) { + watchdog('activitystream', $feed->error, WATCHDOG_ERROR); + return false; + } $favicon = str_replace('?=i','/', $feed->get_favicon()); $arrFeed = $feed->get_items();