summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--addthis.admin.inc116
-rw-r--r--addthis.module129
2 files changed, 124 insertions, 121 deletions
diff --git a/addthis.admin.inc b/addthis.admin.inc
new file mode 100644
index 0000000..d98082d
--- /dev/null
+++ b/addthis.admin.inc
@@ -0,0 +1,116 @@
+<?php
+
+/**
+ * Administration settings form.
+ *
+ * @return
+ * The completed form definition.
+ */
+function addthis_admin_settings() {
+ $form = array();
+
+ $form['addthis_general_settings'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('General settings'),
+ );
+ $form['addthis_general_settings']['addthis_username'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Username'),
+ '#default_value' => variable_get('addthis_username', 'my-username'),
+ '#description' => t('Your username for <a href="http://www.addthis.com/">addthis.com</a>. Example: my-username'),
+ );
+ $form['addthis_general_settings']['addthis_display_in_links'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Display on node pages'),
+ '#default_value' => variable_get('addthis_display_in_links', '0'),
+ '#description' => t('Display an AddThis button always on a node page\'s links section.'),
+ );
+ $form['addthis_general_settings']['addthis_display_in_teasers'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Display in node teasers'),
+ '#default_value' => variable_get('addthis_display_in_teasers', '0'),
+ '#description' => t('Display an AddThis button in the node teasers.'),
+ );
+
+ $form['addthis_button_settings'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Button image settings'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
+ $form['addthis_button_settings']['addthis_image'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Button image url'),
+ '#default_value' => variable_get('addthis_image', 'http://s9.addthis.com/button1-share.gif'),
+ '#description' => t('URL for small image in the button. Example: http://s9.addthis.com/button1-share.gif'),
+ );
+ $form['addthis_button_settings']['addthis_image_width'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Button image width'),
+ '#default_value' => variable_get('addthis_image_width', '125'),
+ '#description' => t('Width for button image. Example: 125'),
+ );
+ $form['addthis_button_settings']['addthis_image_height'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Button image height'),
+ '#default_value' => variable_get('addthis_image_height', '16'),
+ '#description' => t('Height for button image. Example: 16'),
+ );
+ $form['addthis_button_settings']['addthis_image_attributes'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Button image HTML attributes'),
+ '#default_value' => variable_get('addthis_image_attributes', 'alt=""'),
+ '#description' => t('Extra HTML attributes for img tag. Example: alt=""'),
+ );
+
+ $form['addthis_widget_settings'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Widget settings'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
+ $form['addthis_widget_settings']['addthis_logo'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Logo url'),
+ '#default_value' => variable_get('addthis_logo', 'http://www.addthis.com/images/yourlogo.png'),
+ '#description' => t('The logo to display on the popup window (about 200x50 pixels). The popup window is show when the user selects the \'More\' choice. Example: http://www.your-website.com/img/mylogo.gif'),
+ );
+ $form['addthis_widget_settings']['addthis_logo_background'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Logo background color'),
+ '#default_value' => variable_get('addthis_logo_background', 'EFEFFF'),
+ '#description' => t('The color to use as a background around the logo in the popup. Example: EFEFEF'),
+ );
+ $form['addthis_widget_settings']['addthis_logo_color'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Logo text color'),
+ '#default_value' => variable_get('addthis_logo_color', '666699'),
+ '#description' => t('The color to use for the text next to the logo in the popup. Example: 666666'),
+ );
+ $form['addthis_widget_settings']['addthis_brand'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Brand text'),
+ '#default_value' => variable_get('addthis_brand', 'Your Site'),
+ '#description' => t('The brand name to display in the drop-down (top right). Example: My Website'),
+ );
+ $form['addthis_widget_settings']['addthis_options'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Options'),
+ '#default_value' => variable_get('addthis_options', 'favorites, email, digg, delicious, myspace, facebook, google, live, more'),
+ '#description' => t('A comma-separated ordered list of options to include in the drop-down. Example: favorites, email, digg, delicious, more<br/>Currently supported options:<br/>
+ delicious, digg, email, favorites, facebook, fark, furl, google, live, myweb, myspace, newsvine, reddit, slashdot, stumbleupon, technorati, twitter, more'),
+ );
+ $form['addthis_widget_settings']['addthis_offset_top'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Offset top'),
+ '#default_value' => variable_get('addthis_offset_top', '2'),
+ '#description' => t('Vertical offset for the drop-down window (in pixels). Example: 2'),
+ );
+ $form['addthis_widget_settings']['addthis_offset_left'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Offset top'),
+ '#default_value' => variable_get('addthis_offset_left', '2'),
+ '#description' => t('Horizontal offset for the drop-down window (in pixels). Example: 2'),
+ );
+ return system_settings_form($form);
+} \ No newline at end of file
diff --git a/addthis.module b/addthis.module
index f01c3ec..0ecb1f4 100644
--- a/addthis.module
+++ b/addthis.module
@@ -21,11 +21,13 @@ function addthis_perm() {
function addthis_link($type, $node=NULL, $teaser = FALSE) {
$links = array();
- if ($type == 'node' && user_access('view addthis') && $teaser ? variable_get('addthis_display_in_teasers', '0') : variable_get('addthis_display_in_links', '0') ) {
- $links['addthis'] = array(
- 'title' => _addthis_create_button($node, $teaser),
- 'html' => TRUE,
- );
+ if ($type === 'node' && user_access('view addthis')) {
+ if (! $teaser || variable_get('addthis_display_in_teasers', '0')) {
+ $links['addthis'] = array(
+ 'title' => _addthis_create_button($node, $teaser),
+ 'html' => TRUE,
+ );
+ }
}
return $links;
@@ -42,127 +44,12 @@ function addthis_menu() {
'page callback' => 'drupal_get_form',
'page arguments' => array('addthis_admin_settings'),
'access arguments' => array('administer addthis'),
+ 'file' => 'addthis.admin.inc',
);
return $items;
}
-
-/**
- * Administration settings form.
- *
- * @return
- * The completed form definition.
- */
-function addthis_admin_settings() {
- $form = array();
-
- $form['addthis_general_settings'] = array(
- '#type' => 'fieldset',
- '#title' => t('General settings'),
- );
- $form['addthis_general_settings']['addthis_username'] = array(
- '#type' => 'textfield',
- '#title' => t('Username'),
- '#default_value' => variable_get('addthis_username', 'my-username'),
- '#description' => t('Your username for <a href="http://www.addthis.com/">addthis.com</a>. Example: my-username'),
- );
- $form['addthis_general_settings']['addthis_display_in_links'] = array(
- '#type' => 'checkbox',
- '#title' => t('Display on node pages'),
- '#default_value' => variable_get('addthis_display_in_links', '0'),
- '#description' => t('Display an AddThis button always on a node page\'s links section.'),
- );
- $form['addthis_general_settings']['addthis_display_in_teasers'] = array(
- '#type' => 'checkbox',
- '#title' => t('Display in node teasers'),
- '#default_value' => variable_get('addthis_display_in_teasers', '0'),
- '#description' => t('Display an AddThis button in the node teasers.'),
- );
-
- $form['addthis_button_settings'] = array(
- '#type' => 'fieldset',
- '#title' => t('Button image settings'),
- '#collapsible' => TRUE,
- '#collapsed' => TRUE,
- );
- $form['addthis_button_settings']['addthis_image'] = array(
- '#type' => 'textfield',
- '#title' => t('Button image url'),
- '#default_value' => variable_get('addthis_image', 'http://s9.addthis.com/button1-share.gif'),
- '#description' => t('URL for small image in the button. Example: http://s9.addthis.com/button1-share.gif'),
- );
- $form['addthis_button_settings']['addthis_image_width'] = array(
- '#type' => 'textfield',
- '#title' => t('Button image width'),
- '#default_value' => variable_get('addthis_image_width', '125'),
- '#description' => t('Width for button image. Example: 125'),
- );
- $form['addthis_button_settings']['addthis_image_height'] = array(
- '#type' => 'textfield',
- '#title' => t('Button image height'),
- '#default_value' => variable_get('addthis_image_height', '16'),
- '#description' => t('Height for button image. Example: 16'),
- );
- $form['addthis_button_settings']['addthis_image_attributes'] = array(
- '#type' => 'textfield',
- '#title' => t('Button image HTML attributes'),
- '#default_value' => variable_get('addthis_image_attributes', 'alt=""'),
- '#description' => t('Extra HTML attributes for img tag. Example: alt=""'),
- );
-
- $form['addthis_widget_settings'] = array(
- '#type' => 'fieldset',
- '#title' => t('Widget settings'),
- '#collapsible' => TRUE,
- '#collapsed' => TRUE,
- );
- $form['addthis_widget_settings']['addthis_logo'] = array(
- '#type' => 'textfield',
- '#title' => t('Logo url'),
- '#default_value' => variable_get('addthis_logo', 'http://www.addthis.com/images/yourlogo.png'),
- '#description' => t('The logo to display on the popup window (about 200x50 pixels). The popup window is show when the user selects the \'More\' choice. Example: http://www.your-website.com/img/mylogo.gif'),
- );
- $form['addthis_widget_settings']['addthis_logo_background'] = array(
- '#type' => 'textfield',
- '#title' => t('Logo background color'),
- '#default_value' => variable_get('addthis_logo_background', 'EFEFFF'),
- '#description' => t('The color to use as a background around the logo in the popup. Example: EFEFEF'),
- );
- $form['addthis_widget_settings']['addthis_logo_color'] = array(
- '#type' => 'textfield',
- '#title' => t('Logo text color'),
- '#default_value' => variable_get('addthis_logo_color', '666699'),
- '#description' => t('The color to use for the text next to the logo in the popup. Example: 666666'),
- );
- $form['addthis_widget_settings']['addthis_brand'] = array(
- '#type' => 'textfield',
- '#title' => t('Brand text'),
- '#default_value' => variable_get('addthis_brand', 'Your Site'),
- '#description' => t('The brand name to display in the drop-down (top right). Example: My Website'),
- );
- $form['addthis_widget_settings']['addthis_options'] = array(
- '#type' => 'textfield',
- '#title' => t('Options'),
- '#default_value' => variable_get('addthis_options', 'favorites, email, digg, delicious, myspace, facebook, google, live, more'),
- '#description' => t('A comma-separated ordered list of options to include in the drop-down. Example: favorites, email, digg, delicious, more<br/>Currently supported options:<br/>
- delicious, digg, email, favorites, facebook, fark, furl, google, live, myweb, myspace, newsvine, reddit, slashdot, stumbleupon, technorati, twitter, more'),
- );
- $form['addthis_widget_settings']['addthis_offset_top'] = array(
- '#type' => 'textfield',
- '#title' => t('Offset top'),
- '#default_value' => variable_get('addthis_offset_top', '2'),
- '#description' => t('Vertical offset for the drop-down window (in pixels). Example: 2'),
- );
- $form['addthis_widget_settings']['addthis_offset_left'] = array(
- '#type' => 'textfield',
- '#title' => t('Offset top'),
- '#default_value' => variable_get('addthis_offset_left', '2'),
- '#description' => t('Horizontal offset for the drop-down window (in pixels). Example: 2'),
- );
- return system_settings_form($form);
-}
-
/**
* Implementation of hook_block().
*/