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';
$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,
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);
}
'#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',