diff --git a/tweetbutton.admin.inc b/tweetbutton.admin.inc index 5d13484..afa8393 100644 --- a/tweetbutton.admin.inc +++ b/tweetbutton.admin.inc @@ -1,16 +1,15 @@ 'fieldset', - '#title' => t('Default settings for tweetbutton'), + '#title' => t('Choose your button. Customize it'), ); - + $form['button']['tweetbutton_button'] = array( '#type' => 'select', '#options' => array( @@ -21,35 +20,18 @@ function tweetbutton_admin_settings() { '#default_value' => variable_get('tweetbutton_button', 'vertical'), '#id' => 'tweetbutton-button', ); - + + $form['button']['tweetbutton_tweet_text'] = array( '#type' => 'textfield', '#title' => t('Tweet Text'), '#default_value' => variable_get('tweetbutton_tweet_text'), - '#description' => t('Tweet text to use as a default text, if no values are passed, leave this to blank to use page title as tweet text.') ); $form['button']['tokens'] = array( '#token_types' => array('node'), '#theme' => 'token_tree', - ); - - $form['button']['tweetbutton_size'] = array( - '#title' => t('Tweetbutton size'), - '#type' => 'select', - '#options' => array( - 'medium' => t('Medium'), - 'large' => t('Large'), - ), - '#default_value' => variable_get('tweetbutton_size'), - ); - - $form['button']['tweetbutton_hashtags'] = array( - '#title' => t('Hashtags'), - '#type' => 'textfield', - '#default_value' => variable_get('tweetbutton_hashtags'), - '#description' => t('Comma separated hashtags to be used in every tweet'), - ); + ); $form['button']['tweetbutton_language'] = array( '#title' => t('Language'), @@ -65,75 +47,73 @@ function tweetbutton_admin_settings() { ), '#default_value' => variable_get('tweetbutton_language'), ); - - if (module_exists('shorten')) { - $services = array(); - $services[0] = t('Use t.co twitter default url shortener'); - $all_services = module_invoke_all('shorten_service'); - foreach (array_keys($all_services) as $value) { - $services[$value] = $value; - } - - $form['button']['tweetbutton_shorten_service'] = array( - '#title' => t('Shorten service to use to add custom url'), - '#type' => 'select', - '#options' => $services, - '#default_value' => variable_get('tweetbutton_shorten_service', 0), - ); - } - - $form['button']['follow'] = array( + + $form['follow'] = array( '#type' => 'fieldset', '#title' => t('Recommend people to follow'), ); - - $form['button']['follow']['tweetbutton_account'] = array( + + $form['follow']['tweetbutton_account'] = array( '#type' => 'textfield', '#title' => t('Twitter account to follow'), - '#description' => t('This user will be @mentioned in the suggested. Will be used as default if tweetbutton fields author twitter account is not set'), + '#description' => t('This user will be @mentioned in the suggested'), '#default_value' => variable_get('tweetbutton_account'), '#id' => 'tweetbutton-account', ); - - $form['button']['follow']['tweetbutton_rel_account_name'] = array( + + $form['follow']['tweetbutton_rel_account_name'] = array( '#type' => 'textfield', '#title' => t('Related Account'), '#default_value' => variable_get('tweetbutton_rel_account_name'), - '#description' => t('This should be site default twitter account'), ); - - $form['button']['follow']['tweetbutton_rel_account_description'] = array( + + $form['follow']['tweetbutton_rel_account_description'] = array( '#type' => 'textfield', '#title' => t('Related Account Description'), '#default_value' => variable_get('tweetbutton_rel_account_description'), ); - $form['follow_button'] = array( - '#type' => 'fieldset', - '#title' => t('Follow button settings'), - ); + return system_settings_form($form); +} - $form['follow_button']['tweetbutton_follow_show_count'] = array( - '#type' => 'checkbox', - '#title' => t('Show follow count'), - '#default_value' => variable_get('tweetbutton_follow_show_count', TRUE), +function tweetbutton_node_settings() { + $form = array(); + + $node_types = node_type_get_types(); + foreach($node_types as $node_type) { + $types[$node_type->type] = $node_type->name; + } + + $form['tweetbutton_node_types'] = array( + '#type' => 'checkboxes', + '#title' => t('Node Types'), + '#options' => $types, + '#default_value' => variable_get('tweetbutton_node_types', array('article')), ); - - $form['follow_button']['tweetbutton_follow_screen_name'] = array( - '#type' => 'textfield', - '#title' => t('Screen name to follow'), - '#default_value' => variable_get('tweetbutton_follow_screen_name'), + + $options = array(); + $entity_info = entity_get_info('node'); + $view_modes = $entity_info['view modes']; + foreach($view_modes as $name => $info) { + $options[$name] = $info['label']; + } + + $options['links'] = t('Node links'); + + $form['tweetbutton_node_location'] = array( + '#type' => 'checkboxes', + '#title' => t('Locations'), + '#options' => $options, + '#default_value' => variable_get('tweetbutton_node_location', array('full')), ); - - $form['follow_button']['tweetbutton_follow_size'] = array( - '#title' => t('Tweetbutton size'), - '#type' => 'select', - '#options' => array( - 'medium' => t('Medium'), - 'large' => t('Large'), - ), - '#default_value' => variable_get('tweetbutton_follow_size'), + + + $form['tweetbutton_node_weight'] = array( + '#type' => 'weight', + '#title' => t('Weight'), + '#default_value' => variable_get('tweetbutton_node_weight', -5), + '#description' => t('Heavier weight will sink button to bottom on node view'), ); - + return system_settings_form($form); -} +} \ No newline at end of file diff --git a/tweetbutton.info b/tweetbutton.info index a918c40..491a4b4 100644 --- a/tweetbutton.info +++ b/tweetbutton.info @@ -1,5 +1,5 @@ name = Tweetbutton -description = Add tweet button to your website without having to leave the page +description = Add tweet button to your website without having to leave the page core = 7.x dependencies[] = token -configure = admin/config/services/tweetbutton +configure = admin/config/services/tweetbutton \ No newline at end of file diff --git a/tweetbutton.install b/tweetbutton.install index 75b2344..10cddba 100644 --- a/tweetbutton.install +++ b/tweetbutton.install @@ -1,8 +1,7 @@ array( 'type' => 'varchar', - 'length' => 32, + 'length' => 32, + 'not null' => FALSE, + ), + 'count' => array( + 'type' => 'int', 'not null' => FALSE, + 'sortable' => TRUE ), ); break; @@ -24,14 +28,13 @@ function tweetbutton_field_schema($field) { return array( 'columns' => $columns, 'indexes' => array( - 'account' => array('account'), - 'text' => array('text'), + 'count' => array('count'), ), ); } /** - * Implements hook_uninstall(). + * Implementation of hook_uninstall() */ function tweetbutton_uninstall() { variable_del('tweetbutton_button'); @@ -43,10 +46,5 @@ function tweetbutton_uninstall() { variable_del('tweetbutton_rel_account_description'); variable_del('tweetbutton_node_weight'); variable_del('tweetbutton_node_types'); - variable_del('tweetbutton_node_location'); - variable_del('tweetbutton_shorten_service'); - variable_del('tweetbutton_follow_show_count'); - variable_del('tweetbutton_follow_screen_name'); - variable_del('tweetbutton_follow_size'); -} - + variable_del('tweetbutton_node_location'); +} \ No newline at end of file diff --git a/tweetbutton.module b/tweetbutton.module index 7ec1891..314777b 100644 --- a/tweetbutton.module +++ b/tweetbutton.module @@ -1,29 +1,14 @@ ' . t('About') . ''; - $output = '

' . t('This button allows your website to let people share content on Twitter without having to leave the page. Promote strategic Twitter accounts at the same time while driving traffic to your website. These are the general configuration options for the button.') . '

'; - $output .= '

' . t('To add tweetbutton you have to create a tweetbutton field and add it to your content (node, taxonomy, user).') . '

'; - return $output; - } -} - -/** - * Implements hook_field_info(). + * Implementation of hook_field_info() */ function tweetbutton_field_info() { return array( 'tweetbutton' => array( 'label' => 'Tweetbutton', 'description' => 'Creates a tweetbutton field', - 'instance_settings' => array( 'tweet_text' => '', 'author_twitter' => ''), + 'instance_settings' => array( 'tweet_text', 'author_twitter'), 'default_widget' => 'tweetbutton', 'default_formatter' => 'tweetbutton_formatter_button_horizontal', ), @@ -31,20 +16,20 @@ function tweetbutton_field_info() { } /** - * Implements hook_field_is_empty(). + * Implementation of hook_field_is_empty() */ function tweetbutton_field_is_empty($item, $field) { return FALSE; } /** - * Implements hook_field_instance_settings_form(). + * Implementation of hook_field_settings_form */ -function tweetbutton_field_instance_settings_form($field, $instance) { - $settings = $instance['settings']; - +function tweetbutton_field_settings_form($field, $instance, $has_data) { + $settings = $field['settings']; + $form = array(); - + $form['tweet_text'] = array( '#type' => 'textfield', '#title' => t('Tweet text'), @@ -58,24 +43,17 @@ function tweetbutton_field_instance_settings_form($field, $instance) { '#default_value' => isset($settings['author_twitter'])? $settings['author_twitter']: variable_get('tweetbutton_account'), '#description' => t('This user will be @mentioned in the suggested'), ); - - if ($instance['entity_type'] == 'taxonomy_term') { - $token_type = 'term'; - } - else { - $token_type = $instance['entity_type']; - } - + $form['tokens'] = array( - '#token_types' => array($token_type), + '#token_types' => array($instance['entity_type']), '#theme' => 'token_tree', ); - + return $form; } /** - * Implements hook_field_widget_info(). + * Implementation of hook_field_widget_info() */ function tweetbutton_field_widget_info() { return array( @@ -91,111 +69,68 @@ function tweetbutton_field_widget_info() { } /** - * Implements hook_field_widget_form(). + * Implementation of hook_field_widget_form() */ function tweetbutton_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) { - $default_author = isset($instance['settings']['author_twitter'])? $instance['settings']['author_twitter']: ''; - $default_text = isset($instance['settings']['tweet_text'])? $instance['settings']['tweet_text']: ''; - - $element['account'] = array( + $element['text'] = array( '#type' => 'textfield', - '#default_value' => !empty($items[$delta]['account'])? $items[$delta]['account']: $default_author, + '#default_value' => isset($field['settings']['author_twitter'])? $field['settings']['author_twitter']: '', '#title' => t('Author twitter account'), '#description' => t('Leave blank to use global twitter account.'), '#maxlength' => 128, '#access' => user_access('use tweetbutton field'), ); - - $element['text'] = array( + + $element['account'] = array( '#type' => 'textfield', - '#default_value' => !empty($items[$delta]['text'])? $items[$delta]['text']: $default_text, + '#default_value' => isset($field['settings']['tweet_text'])? $field['settings']['tweet_text']: '', '#title' => t('Tweet text'), - '#description' => t('Leave blank to use content title as tweet text'), + '#description' => t('Leave blank to use page title as tweet text'), '#maxlength' => 32, '#access' => user_access('use tweetbutton field'), ); - + return $element; } /** - * Implements hook_field_presave(). + * Implementation of hook_field_presave() */ function tweetbutton_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) { if ($field['type'] == 'tweetbutton') { foreach ($items as $delta => $item) { $data = array($entity_type => $entity); - $option = array('clear' => TRUE); - $items[$delta]['text'] = !empty($items[$delta]['text'])? token_replace($items[$delta]['text'], $data, $option): $entity->title; - $items[$delta]['account'] = !empty($items[$delta]['account'])? token_replace($items[$delta]['account'], $data, $option): ''; + $items[$delta]['text'] = !empty($items[$delta]['text'])? token_replace($items[$delta]['text'], $data): ''; + $items[$delta]['account'] = !empty($items[$delta]['account'])? token_replace($items[$delta]['account'], $data): ''; } } } - /** - * Implements hook_field_formatter_info(). + * Implementation of hook_field_formatter_info() */ function tweetbutton_field_formatter_info() { return array( 'tweetbutton_formatter_button_vertical' => array( 'label' => t('Tweetbutton style vertical'), - 'field types' => array('tweetbutton'), - 'settings' => array( - 'size' => 'medium', - ), + 'field_types' => array('tweetbutton'), ), 'tweetbutton_formatter_button_horizontal' => array( 'label' => t('Tweetbutton style horizontal'), - 'field types' => array('tweetbutton'), - 'settings' => array( - 'size' => 'medium', - ), + 'field_types' => array('tweetbutton'), ), 'tweetbutton_formatter_button_none' => array( 'label' => t('Tweetbutton style none'), - 'field types' => array('tweetbutton'), - 'settings' => array( - 'size' => 'medium', - ), + 'field_types' => array('tweetbutton'), ), ); } /** - * Implements hook_field_formatter_settings_form(). - */ -function tweetbutton_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) { - $display = $instance['display'][$view_mode]; - $settings = $display['settings']; - - $element['size'] = array( - '#type' => 'select', - '#title' => t('Tweetbutton size'), - '#options' => array('medium' => t('Medium'), 'large' => t('Large')), - '#default_value' => $settings['size'] - ); - - return $element; -} - -/** - * Implements hook_field_formatter_settings_summary(). - */ -function tweetbutton_field_formatter_settings_summary($field, $instance, $view_mode) { - $display = $instance['display'][$view_mode]; - $settings = $display['settings']; - $options = array('medium' => t('Medium'), 'large' => t('Large')); - $title = $options[$settings['size']]; - return t('Size: !title', array('!title' => $title)); -} - -/** * Implements hook_field_formatter_view(). */ -function tweetbutton_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, &$items, $display) { - $settings = $display['settings']; - +function tweetbutton_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { + $delta = 0; switch ($display['type']) { case 'tweetbutton_formatter_button_vertical': @@ -209,32 +144,37 @@ function tweetbutton_field_formatter_view($entity_type, $entity, $field, $instan break; } - if (empty($items)) { - $items[$delta] = array( - 'text' => '', - 'account' => '' - ); - } - - $uri = entity_uri($entity_type, $entity); $element[$delta] = array( - '#theme' => 'tweetbutton_tweet_display', - '#options' => array( - 'size' => $settings['size'], - 'type' => $button_type, - 'account' => $items[$delta]['account'], - 'tweet_text' => $items[$delta]['text'], - 'url' => url($uri['path'], array('absolute' => TRUE)), - ), - '#entity' => $entity, - '#entity_type' => $entity_type, - ); - return $element; + '#theme' => 'tweetbutton_display', + '#options' => array( + 'type' => $button_type, + ), + '#tweet_text' => $items[$delta]['text'], + ); } /** - * Implements hook_menu(). + * Implementation of hook_help() */ +function tweetbutton_help($path, $arg) { + $output = NULL; + switch($path) { + case 'admin/help#tweetbutton': + $output = 'This button allows your website to let people share content on Twitter without having to leave the page. Promote strategic Twitter accounts at the same time while driving traffic to your website.'; + break; + case 'admin/config/services/tweetbutton': + $output = '

' . t('This button allows your website to let people share content on Twitter without having to leave the page. Promote strategic Twitter accounts at the same time while driving traffic to your website. These are the general configuration options for the button. Make sure to check the Node Settings to set where the button will appear.') . '

'; + break; + case 'admin/config/services/tweetbutton/node': + $output = '

' . t('Select the node types and location on which the Tweet Button will appear.') . '

'; + break; + } + return $output; +} + +/** + * Implementation of hook_menu() + */ function tweetbutton_menu() { $items = array(); @@ -248,40 +188,44 @@ function tweetbutton_menu() { 'type' => MENU_NORMAL_ITEM, ); + $items['admin/config/services/tweetbutton/settings'] = array( + 'title' => 'General Settings', + 'description' => 'Change the look and behavior of the Tweet Button.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('tweetbutton_admin_settings'), + 'access arguments' => array('administer tweetbutton'), + 'file' => 'tweetbutton.admin.inc', + 'weight' => 0, + 'type' => MENU_DEFAULT_LOCAL_TASK, + ); + + $items['admin/config/services/tweetbutton/node'] = array( + 'title' => 'Node Settings', + 'description' => 'Configure how the Tweet Button interacts with nodes.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('tweetbutton_node_settings'), + 'access arguments' => array('administer tweetbutton'), + 'file' => 'tweetbutton.admin.inc', + 'weight' => 1, + 'type' => MENU_LOCAL_TASK, + ); + return $items; } /** - * Implements hook_theme(). + * Implementation of hook_theme() */ function tweetbutton_theme() { return array( - 'tweetbutton_tweet_display' => array( - 'variables' => array('entity' => NULL, 'entity_type' => NULL, 'options' => array()), - ), - 'tweetbutton_follow_display' => array( - 'variables' => array('options' => array(), 'screen_name' => ''), - ), - 'tweetbutton_hashtag_display' => array( - 'variables' => array('options' => array(), 'hashtag' => ''), + 'tweetbutton_display' => array( + 'variables' => array('object' => NULL, 'options' => array()), ), ); } - -/** - * Implements of hook_cron(). - */ -function tweetbutton_cron() { - // @TODO: Fetch count of each page where tweetbutton is on and add it to column 'count' in field - // Will be useful in sorting page based on no of tweets and add views support - if (!variable_get('tweetbutton_get_count', FALSE)) { - return; - } -} - /** - * Implements hook_permission(). + * Implementation of hook_permission() */ function tweetbutton_permission() { return array( @@ -298,84 +242,91 @@ function tweetbutton_permission() { } /** - * Implements hook_block_info(). + * Implementation of hook_node_view() + */ +function tweetbutton_node_view($node, $view_mode) { + if (in_array($node->type, variable_get('tweetbutton_node_types', array('article')), TRUE) + && user_access('access tweetbutton')) { + if (in_array($view_mode, variable_get('tweetbutton_node_location', array('full')), TRUE)) { + $node->content['tweetbutton'] = array( + '#object' => $node, + '#weight' => variable_get('tweetbutton_node_weight', -5), + '#theme' => 'tweetbutton_display__' . $node->type, + ); + } + + if (in_array('links', variable_get('tweetbutton_node_location', array('full')), TRUE)) { + $node->content['links']['#links']['node_tweetbutton_link'] = array( + 'title' => theme('tweetbutton_display__' . $node->type, array('object' => $node, 'options' => array('type' => 'horizontal'))), + 'html' => TRUE, + ); + } + } +} + +/** + * Implementation of hook_block_info() */ function tweetbutton_block_info() { - $blocks['tweetbutton_tweet'] = array( - 'info' => t('Tweetbutton tweet'), - ); - $blocks['tweetbutton_follow'] = array( - 'info' => t('Tweetbutton follow'), - ); + $blocks['tweetbutton'] = array( + 'info' => t('Tweetbutton'), + 'weight' => 0, + ); + return $blocks; } /** - * Implements hook_block_configure(). + * Implementation of hook_block_configure */ function tweetbutton_block_view($delta = '') { - if ($delta == 'tweetbutton_tweet') { - $block['subject'] = t('Tweetbutton tweet'); - $block['content'] = theme('tweetbutton_tweet_display'); - return $block; - } - elseif ($delta == 'tweetbutton_follow') { - $block['subject'] = t('Tweetbutton follow'); - $block['content'] = theme('tweetbutton_follow_display'); - return $block; + if ($delta == 'tweetbutton') { + $block['subject'] = t('Tweetbutton'); + $block['content'] = theme('tweetbutton_display', array('options' => array('text' => ''))); + return $block; } } /** - * Helper function to build the required tweet attributes. - * + * Helper function to build the required tweet attributes + * @param $object + * Entity object can either be (node, user, taxonomy) * @param $options * Context specific options - * @return + * @return * List of attributes to be rendered for twitter tweetbutton */ -function tweetbutton_tweet_get_attributes($options = array()) { +function tweetbutton_get_attributes($object = NULL, $options = array()) { global $language; - + $entity_type = empty($options['entity_type'])? 'node': $options['entity_type']; + $default_option = array( 'type' => variable_get('tweetbutton_button', 'vertical'), - 'tweet_text' => variable_get('tweetbutton_tweet_text'), + 'text' => variable_get('tweetbutton_tweet_text'), 'language' => variable_get('tweetbutton_language'), 'account' => variable_get('tweetbutton_account'), 'rel_account' => variable_get('tweetbutton_rel_account_name'), 'rel_desc' => variable_get('tweetbutton_rel_account_description'), - 'size' => variable_get('tweetbutton_size', 'medium') ); - + if (empty($options['url'])) { - $options['url'] = url($_GET['q'], array('absolute' => TRUE)); - } - - if (empty($options['count_url'])) { - $options['count_url'] = $options['url']; - } - - if (module_exists('shorten') && ($service = variable_get('tweetbutton_shorten_service'))) { - $url = shorten_url($options['url'], $service); - // if www => http:// replacement if enabled - if (variable_get('shorten_www', TRUE)) { - if (strpos($url, 'www.') === 0) { - $url = drupal_substr($url, 4); - $url = 'http://' . $url; - } + if (empty($object)) { + $options['url'] = url($_GET['q'], array('absolute' => TRUE)); + } + else { + $uri = entity_uri($entity_type, $object); + $options['url'] = url($uri['path'], array('absolute' => TRUE)); } - $options['url'] = $url; } $options += $default_option; - + $attributes = array( - 'data-size' => $options['size'], 'data-count' => $options['type'], 'data-via' => $options['account'], 'data-related' => $options['rel_account'] . ':' . $options['rel_desc'], - 'data-text' => $options['tweet_text'], - 'data-counturl'=> $options['count_url'], + 'data-text' => !empty($options['text'])? token_replace($options['text'], array($entity_type => $object)): '', + 'data-counturl'=> $options['url'], 'data-url' => $options['url'], 'data-lang' => $options['language'] == 'auto' ? $language->language : $options['language'], 'class' => 'twitter-share-button', @@ -385,92 +336,16 @@ function tweetbutton_tweet_get_attributes($options = array()) { } -function theme_tweetbutton_tweet_display($variables) { - $script_url = url('http://platform.twitter.com/widgets.js', array('external' => TRUE, 'https' => TRUE)); - drupal_add_js($script_url, array('type' => 'external', 'scope' => 'footer')); - $options = $variables['options']; - $attributes = tweetbutton_tweet_get_attributes($options); - - $tweetbutton_label = isset($options['tweetbutton_label'])? $options['tweetbutton_label']: t('Tweet'); - $tweet_link = l($tweetbutton_label, 'http://twitter.com/share', array('attributes' => $attributes, 'external' => TRUE, 'https' => TRUE)); - $link = '
' . $tweet_link . '
'; - - return $link; -} - - -function tweetbutton_follow_get_attributes($options) { - global $language; - $default_options = array( - 'show_count' => variable_get('tweetbutton_follow_show_count', TRUE), - 'show_screen_name' => variable_get('tweetbutton_follow_screen_name'), - 'size' => variable_get('tweetbutton_follow_size'), - 'language' => variable_get('tweetbutton_language'), - ); - - $options += $default_options; - - $attributes = array( - 'data-show-count' => $options['show_count'], - 'data-show-screen-name' => $options['show_screen_name'], - 'data-size' => $options['size'], - 'data-lang' => $options['language'] == 'auto' ? $language->language : $options['language'], - 'class' => 'twitter-follow-button', - ); - return $attributes; -} - -function theme_tweetbutton_follow_display($variables) { - $script_url = url('http://platform.twitter.com/widgets.js', array('external' => TRUE, 'https' => TRUE)); - drupal_add_js($script_url, array('type' => 'external', 'scope' => 'footer')); - - $options = $variables['options']; - $screen_name = $variables['screen_name']; - if (empty($screen_name)) { - $screen_name = variable_get('tweetbutton_follow_screen_name'); - } - $follow_user_text = isset($options['tweetbutton_label'])? $options['tweetbutton_label']: t('Follow !screen_name', array('!screen_name' => $screen_name)); - - $twitter_account_link = 'http://twitter.com/' . $screen_name; - - $attributes = tweetbutton_follow_get_attributes($options); - - $follow_link = l($follow_user_text, $twitter_account_link,array('attributes' => $attributes, 'external' => TRUE, 'https' => TRUE)); - $link = '
' . $follow_link . '
'; - return $link; -} - -function tweetbutton_hashtag_get_attributes($options) { - global $language; - $default_options = array( - 'rel_account' => variable_get('tweetbutton_account'), - ); - - $options += $default_options; - - $attributes = array( - 'data-related' => $options['rel_account'], - 'data-lang' => $options['language'] == 'auto'? $language->language: $options['language'], - 'class' => 'twitter-hashtag-button', - ); -} - -function theme_tweetbutton_hashtag_display($variables) { +function theme_tweetbutton_display($variables) { $script_url = url('http://platform.twitter.com/widgets.js', array('external' => TRUE)); drupal_add_js($script_url, array('type' => 'external', 'scope' => 'footer')); - + + $object = $variables['object']; $options = $variables['options']; - $attributes = tweetbutton_hashtag_get_attributes($options); - $query = array(); - if (!empty($options['tweet_text'])) { - $query['tweet_text'] = $options['tweet_text']; - } - - if (!empty($variables['hashtag'])) { - $query['button_hashtag'] = $variables['hashtag']; - } - - $hash_link = l($hash_text, 'http://twitter.com/intent/tweet', array('query' => $query, 'attributes' => $attributes, 'external' => TRUE, 'https' => TRUE)); - return '
' . $hash_link . '
'; -} + $attributes = tweetbutton_get_attributes($object, $options); + + $tweet_link = l(t('Tweet'), 'http://twitter.com/share', array('attributes' => $attributes, 'external' => TRUE)); + $link = '
' . $tweet_link . '
'; + return $link; +} \ No newline at end of file