--- addtoany.module.orig	2009-04-11 17:55:02.000000000 -0400
+++ addtoany.module	2009-08-23 17:51:32.000000000 -0400
@@ -29,7 +29,7 @@ function addtoany_link($type, $node = NU
            
   if ($type === 'node' && $show && user_access('view addtoany')) {
     $links['addtoany'] = array(
-        'title' => _addtoany_create_button($node, $teaser),
+        'title' => _addtoany_create_saveshare_button($node, $teaser),
         'html' => TRUE,
       );
   }
@@ -54,7 +54,7 @@ function addtoany_nodeapi(&$node, $op, $
         
         if ($show && user_access('view addtoany')) {
           $node->content['addtoany'] = array(
-            '#value' => _addtoany_create_button($node, FALSE),
+            '#value' => _addtoany_create_saveshare_button($node, FALSE),
             '#weight' => $weight,
           );
         }
@@ -81,65 +81,123 @@ function addtoany_menu() {
   return $items;
 }
 
+
 /**
  * Implementation of hook_block().
  */
-function addtoany_block($op = 'list', $delta = 0) {
-  if ($op == 'list') {
-    $blocks[0]['info'] = t('AddToAny button');
-    return $blocks;
-  }
-  else if ($op == 'view' && user_access('view addtoany')) {
-    $block['subject'] = t('AddToAny');
-    $block['content'] = _addtoany_create_button();
-    return $block;
+function addtoany_block($op = 'list', $delta = 0, $edit = array()) {
+
+  global $base_path;
+  $button_img = '<img src="' . $base_path . drupal_get_path('module', 'addtoany') . '/images/%s" width="%d" height="%d" />';
+  
+  $subscribe_button_options = array(
+  	'favicon.png|16|16' => sprintf($button_img, 'favicon.png', 16, 16),
+  	'subscribe_16_16.gif|16|16' => sprintf($button_img, 'subscribe_16_16.gif', 16, 16),
+  	'subscribe_106_16.gif|106|16' => sprintf($button_img, 'subscribe_106_16.gif', 106, 16),
+  	'subscribe_120_16.gif|120|16' => sprintf($button_img, 'subscribe_120_16.gif', 120, 16),
+  	'subscribe_171_16.gif|171|16' => sprintf($button_img, 'subscribe_171_16.gif', 171, 16),
+  	'subscribe_256_24.png|256|24' => sprintf($button_img, 'subscribe_256_24.png', 256, 24),
+  	'custom'				=> 'Custom button',
+  );
+  
+  // get link name from the front page setting of the Page Title module if enabled and is set, else use site name
+  if (module_exists(page_title)) { 
+    $feedname = variable_get('page_title_front', variable_get('site_name', ''));
+  } else { 
+    $feedname = variable_get('site_name', '');
+  }
+   
+  switch ($op) {
+    case 'list':
+      $blocks[0]['info'] = t('AddToAny Share/Save button');
+      $blocks[1]['info'] = t('AddToAny Subscribe button');
+      return $blocks;
+
+    case 'configure':
+      $form = array();
+      switch ($delta) {
+        case 1:
+         $form['addtoany_subscribe_block_feed_name'] = array(
+           '#type'          => 'textfield',
+           '#title'         => t('Feed Name'),
+           '#default_value' => variable_get('addtoany_subscribe_block_feed_name', $feedname),
+           '#description'   => t('Name of the feed to use for the subscribe link.'),
+         );
+         $form['addtoany_subscribe_block_feed_url'] = array(
+           '#type'          => 'textfield',
+           '#title'         => t('Feed URL'),
+           '#default_value' => variable_get('addtoany_subscribe_block_feed_url', url(substr($base_path, 0, -2), array('absolute' => 1)).'rss.xml'),
+           '#description'   => t('URL to the feed of your choosing. Example: http://example.com/rss.xml'),
+         );
+         $form['addtoany_subscribe_block_image'] = array(
+           '#type' 		 => 'radios',
+           '#title' 		 => t('Link Button'),
+           '#default_value' => variable_get('addtoany_subscribe_block_image', 'subscribe_106_16.gif'),
+           '#options' 		 => $subscribe_button_options,
+         );
+         $form['addtoany_subscribe_block_custom_image'] = array(
+           '#type'          => 'textfield',
+           '#title'         => t('Custom button URL'),
+           '#default_value' => variable_get('addtoany_subscribe_block_custom_image', ''),
+           '#description'   => t('URL to the button image of your choosing. Example: http://example.com/share.png<br>Many pre-made buttons can be found at the <a href="http://www.flickr.com/groups/addtoany_buttons/pool/">AddToAny button pool</a>.'),
+         );
+         $form['addtoany_subscribe_block_image_attributes'] = array(
+           '#type'          => 'textfield',
+           '#title'         => t('Button image HTML attributes'),
+           '#default_value' => variable_get('addtoany_subscribe_block_image_attributes', 'alt="Subscibe"'),
+           '#description'   => t('Extra HTML attributes for img tag. Example: alt=""'),
+         );
+         $form['addtoany_subscribe_block_additional_js'] = array(
+           '#type'          => 'textarea',
+           '#title'         => t('Additional script'),
+           '#default_value' => variable_get('addtoany_subscribe_block_additional_js', ''),
+           '#description'   => t('You can set special JavaScript variables for the Subscribe menu. Advanced users might want to check out Add to Any\'s <a href="http://www.addtoany.com/buttons/api/">JavaScript API</a> and <a href="http://www.addtoany.com/buttons/customize/link_tracking">Link Tracking</a> pages.'),
+         );
+         $form['addtoany_subscribe_block_dropdown_disabled'] = array(
+           '#type'          => 'checkbox',
+           '#title'         => t('Disable dropdown'),
+           '#default_value' => variable_get('addtoany_subscribe_block_dropdown_disabled', '0'),
+           '#description'   => t('You can disable the drop-down and use a pop-up window instead.'),
+         );                
+      }
+      return $form;
+      
+    case 'save':
+      switch ($delta) {
+        case 1:
+          variable_set('addtoany_subscribe_block_feed_name', $edit['addtoany_subscribe_block_feed_name']);
+          variable_set('addtoany_subscribe_block_feed_url', $edit['addtoany_subscribe_block_feed_url']);
+          variable_set('addtoany_subscribe_block_image', $edit['addtoany_subscribe_block_image']);
+          variable_set('addtoany_subscribe_block_custom_image', $edit['addtoany_subscribe_block_custom_image']);
+          variable_set('addtoany_subscribe_block_image_attributes', $edit['addtoany_subscribe_block_image_attributes']);
+          variable_set('addtoany_subscribe_block_additional_js', $edit['addtoany_subscribe_block_additional_js']);
+          variable_set('addtoany_subscribe_block_dropdown_disabled', $edit['addtoany_subscribe_block_dropdown_disabled']);        
+      }
+      return;
+      
+    case 'view':
+      switch ($delta) {
+        case 0:
+          $block['subject'] = t('Share/Save');
+          $block['content'] = _addtoany_create_saveshare_button(menu_get_object());
+        break;
+        case 1:
+          $block['subject'] = t('Subscribe');
+          $block['content'] = _addtoany_create_subscribe_button();
+        break;
+      }  
+      return $block;
   }
 }
 
-/**
- * Implementation of hook_footer().  Would use drupal_add_js, but external scripts are not well supported
- *
- * @return
- *   String containing JavaScript code for the drop-down
- */
-function addtoany_footer($main = 0) {
-	global $_addtoany_script;
-	return $_addtoany_script;
-}
-
-function _addtoany_create_script($node = NULL) {
-
-	// Drop-down disabled?
-	if(variable_get('addtoany_dropdown_disabled', '0')) return;
-
-	global $_addtoany_script, $_addtoany_script_init;
-	
-	if ( ! $_addtoany_script_init)
-		$_addtoany_script = '<script type="text/javascript">';
-	else
-		$_addtoany_script .= '<script type="text/javascript">';
-		
-	$_addtoany_script .= 'a2a_linkname="'. addslashes($node->title) .'";a2a_linkurl="'. url('node/'. $node->nid, array('absolute' => 1) ) .'";';
-	
-	if ( ! $_addtoany_script_init) {
-		$_addtoany_script .= variable_get('addtoany_additional_js', '');
-		$_addtoany_script .= '</script><script type="text/javascript" src="http://static.addtoany.com/menu/page.js"></script>';
-	} else {
-		$_addtoany_script .= 'a2a_init("page");</script>';
-	}
-	
-	$_addtoany_script_init = TRUE;
-	
-	return $_addtoany_script;
-}
 
 /**
- * Internal function to generate code for AddToAny button
+ * Internal function to generate code for AddToAny save/share button
  *
  * @return
  *   String containing html code for the button
  */
-function _addtoany_create_button($node=NULL, $teaser = FALSE) {
+function _addtoany_create_saveshare_button($node=NULL, $teaser = FALSE) {
   global $_addtoany_counter, $base_path;
   
   $_addtoany_counter++;
@@ -147,7 +205,7 @@ function _addtoany_create_button($node=N
       drupal_add_css((drupal_get_path('module', 'addtoany') .'/addtoany.css'));
   }
   
-  _addtoany_create_script($node);
+
 
   $disable_dropdown = variable_get('addtoany_dropdown_disabled', '0');
   
@@ -166,15 +224,78 @@ function _addtoany_create_button($node=N
   }
      
   return ( sprintf('
-      <a%s href="http://www.addtoany.com/share_save?linkurl=%s&amp;linkname=%s"><img src="%s"%s%s %s/></a>
+      <a%s href="http://www.addtoany.com/share_save?linkname=%s&amp;linkurl=%s"><img src="%s"%s%s %s/></a>
+      <script type="text/javascript">a2a_linkname="%s";a2a_linkurl="%s";%s</script>
+      <script type="text/javascript" src="http://static.addtoany.com/menu/page.js"></script>
       ',
 	  $disable_dropdown ? '' : ' class="a2a_dd"',
+	  rawurlencode($node->title),
 	  rawurlencode(url('node/'. $node->nid, array('absolute' => 1) )),
-      rawurlencode($node->title),
       $button_image,
       $button_width,
       $button_height,
-      variable_get('addtoany_image_attributes', 'alt="Share/Save"')
+      variable_get('addtoany_image_attributes', 'alt="Share/Save"'),
+      addslashes($node->title),
+      url('node/'. $node->nid, array('absolute' => 1) ),
+      variable_get('addtoany_additional_js', '')
+  ));
+
+}
+
+
+/**
+ * Internal function to generate code for AddToAny subscribe button
+ *
+ * @return
+ *   String containing html code for the button
+ */
+function _addtoany_create_subscribe_button() {
+  global $base_path; $site_name;
+  
+  $disable_dropdown = variable_get('addtoany_subscribe_block_dropdown_disabled', '0');
+  
+  $button_setting = variable_get('addtoany_subscribe_block_image', 'subscribe_106_16.gif');
+  
+  // get link name from the front page setting of the Page Title module if enabled and is set, else use site name
+  if (module_exists(page_title)) { 
+    $feedname = variable_get('page_title_front', variable_get('site_name', ''));
+  } else { 
+    $feedname = variable_get('site_name', '');
+  }
+  
+  if (variable_get('addtoany_subscribe_block_feed_url', '')) {
+    $feed = variable_get('addtoany_subscribe_block_feed_url', url(substr($base_path, 0, -2), array('absolute' => 1)).'rss.xml');
+  } else {
+    $feed = url(substr($base_path,0,-1) . 'rss.xml', array('absolute' => 1));
+  }
+  
+  if ($button_setting == "custom") {
+  	$button_image 		= variable_get('addtoany_subscribe_block_custom_image', '');
+  	$button_width    	= '';
+	$button_height		= ''; 
+  } else {
+	  $button 			= explode('|', $button_setting);
+	  $button_filename 	= $button[0];
+	  $button_width    	= ' width="' . $button[1] . '"';
+	  $button_height	= ' height="' . $button[2] . '"';
+	  $button_image 	= $base_path . drupal_get_path('module', 'addtoany') . '/images/' . $button_filename;
+  }
+     
+  return ( sprintf('
+      <a%s href="http://www.addtoany.com/subscribe?linkname=%s&amp;linkurl=%s"><img src="%s"%s%s %s/></a>
+      <script type="text/javascript">a2a_linkname="%s";a2a_linkurl="%s";%s</script>
+      <script type="text/javascript" src="http://static.addtoany.com/menu/feed.js"></script>
+      ',
+	  $disable_dropdown ? '' : ' class="a2a_dd"',
+	  rawurlencode(variable_get('addtoany_subscribe_block_feed_name', $feedname)),
+	  rawurlencode($feed),
+      $button_image,
+      $button_width,
+      $button_height,
+      variable_get('addtoany_subscribe_block_image_attributes', 'alt="Subscribe"'),
+      addslashes(variable_get('addtoany_subscribe_block_feed_name', $feedname)),
+      $feed,
+      variable_get('addtoany_subscribe_block_additional_js', '')
   ));
 
 }
