Index: twitter.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/twitter/twitter.module,v retrieving revision 1.3.2.12 diff -u -p -r1.3.2.12 twitter.module --- twitter.module 9 Apr 2009 14:34:26 -0000 1.3.2.12 +++ twitter.module 19 Apr 2009 03:22:23 -0000 @@ -96,10 +96,26 @@ function twitter_form_alter(&$form, $for ); $form['twitter'] += $twitter_form; $form['twitter']['status']['#default_value'] = variable_get('twitter_default_format', 'New post: !title !tinyurl'); - $form['twitter']['status']['#description'] = t('The given text will be posted to twitter.com. You can use !url, !url-alias, !tinyurl, !title and !user as replacement text.'); + $form['twitter']['status']['#description'] = t('The given text will be posted to twitter.com. You can use !url, !url-alias, !tinyurl, !title, !type, !terms and !user as replacement text.'); } } +/* + * Get taxonomy terms for this node, to pass as string of hash tags. + */ +function twitter_get_node_term_list($node) { + if (!empty($node->taxonomy)) { + taxonomy_node_save($node, $node->taxonomy); + unset($node->taxonomy); + } + $terms = taxonomy_node_get_terms($node); + $output = array(); + foreach($terms as $tid => $term) { + $output[] = preg_replace('/\s/',"","#{$term->name}"); + } + return implode(' ', $output); +} + /** * Implementation of hook_nodeapi(). * @@ -118,6 +134,8 @@ function twitter_nodeapi(&$node, $op, $a $replacements = array('!title' => $node->title, '!url' => url('node/'. $node->nid, array('absolute' => TRUE, 'alias' => TRUE)), '!url-alias' => url('node/'. $node->nid, array('absolute' => TRUE)), + '!type' => node_get_types('name', $node, FALSE), + '!terms' => twitter_get_node_term_list($node), '!user' => $node->name); // Only generate the shortened URL if it's going to be used. No sense // burning through TinyURLs without a good reason.