summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--addthis_displays/addthis_displays.addthis.inc3
-rw-r--r--classes/AddThis.php20
-rw-r--r--includes/addthis.admin.inc27
3 files changed, 48 insertions, 2 deletions
diff --git a/addthis_displays/addthis_displays.addthis.inc b/addthis_displays/addthis_displays.addthis.inc
index 03ae376..87ac624 100644
--- a/addthis_displays/addthis_displays.addthis.inc
+++ b/addthis_displays/addthis_displays.addthis.inc
@@ -68,7 +68,8 @@ function addthis_displays_addthis_display_markup__addthis_basic_toolbox($options
break;
case 'tweet':
$items[$service]['#attributes'] += array(
- 'tw:count' => ($orientation ? 'horizontal' : 'vertical')
+ 'tw:count' => ($orientation ? 'horizontal' : 'vertical'),
+ 'tw:via' => AddThis::getInstance()->getTwitterVia(),
);
break;
}
diff --git a/classes/AddThis.php b/classes/AddThis.php
index 45e2800..4a84ca2 100644
--- a/classes/AddThis.php
+++ b/classes/AddThis.php
@@ -47,6 +47,12 @@ class AddThis {
const WIDGET_JS_URL_KEY = 'addthis_widget_js_url';
const WIDGET_JS_ASYNC = 'addthis_widget_async';
+ // Twitter
+ const TWITTER_VIA_KEY = 'addthis_twitter_via';
+ const TWITTER_VIA_DEFAULT = 'AddThis';
+ const TWITTER_TEMPLATE_KEY = 'addthis_twitter_template';
+ const TWITTER_TEMPLATE_DEFAULT = '{{title}} {{url}} via @AddThis';
+
// External resources
const DEFAULT_BOOKMARK_URL = 'http://www.addthis.com/bookmark.php?v=250';
const DEFAULT_SERVICES_CSS_URL = 'http://cache.addthiscdn.com/icons/v1/sprites/services.css';
@@ -251,9 +257,13 @@ class AddThis {
$configuration['data_ga_social'] = $this->isGoogleAnalyticsSocialTrackingEnabled();
}
}
+ $configuration['templates']['twitter'] = $this->getTwitterTemplate();
drupal_alter('addthis_configuration', $configuration);
- $configurationOptionsJavascript = 'var addthis_config = ' . drupal_json_encode($configuration);
+ $templates = array('templates' => $configuration['templates']);
+ unset($configuration['templates']);
+ $configurationOptionsJavascript = 'var addthis_config = ' . drupal_json_encode($configuration) . "\n";
+ $configurationOptionsJavascript .= 'var addthis_share = ' . drupal_json_encode($templates);
}
drupal_add_js(
$configurationOptionsJavascript,
@@ -351,6 +361,14 @@ class AddThis {
return (boolean) variable_get(self::COMPLIANT_508_KEY, FALSE);
}
+ public function getTwitterVia() {
+ return variable_get(self::TWITTER_VIA_KEY, self::TWITTER_VIA_DEFAULT);
+ }
+
+ public function getTwitterTemplate() {
+ return variable_get(self::TWITTER_TEMPLATE_KEY, self::TWITTER_TEMPLATE_DEFAULT);
+ }
+
public function isClickbackTrackingEnabled() {
return (boolean) variable_get(self::CLICKBACK_TRACKING_ENABLED_KEY, FALSE);
}
diff --git a/includes/addthis.admin.inc b/includes/addthis.admin.inc
index be84034..c9e132b 100644
--- a/includes/addthis.admin.inc
+++ b/includes/addthis.admin.inc
@@ -198,6 +198,33 @@ function addthis_admin_settings_form($form_state) {
'#columns' => 3,
);
+ // Third party settings.
+ $form['third_party_fieldset'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Third party settings'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
+ $form['third_party_fieldset']['twitter_service'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Twitter'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
+ $form['third_party_fieldset']['twitter_service'][AddThis::TWITTER_VIA_KEY] = array(
+ '#type' => 'textfield',
+ '#title' => t('Send via'),
+ '#description' => t('When sending a tweet this is the screen name of the user to attribute the Tweet to. (Relates to Tweet Button)'),
+ '#default_value' => AddThis::getInstance()->getTwitterVia(),
+ '#size' => 15,
+ );
+ $form['third_party_fieldset']['twitter_service'][AddThis::TWITTER_TEMPLATE_KEY] = array(
+ '#type' => 'textfield',
+ '#title' => t('Template text'),
+ '#description' => t('The {{title}} and {{url}} are replaced from the Twitter Button.'),
+ '#default_value' => AddThis::getInstance()->getTwitterTemplate(),
+ );
+
// Service URL's settings.
$form['service_urls_fieldset'] = array(
'#type' => 'fieldset',