--- ed_readmore.module.orig	2008-10-03 02:45:45.000000000 -0400
+++ ed_readmore.module	2008-10-03 03:04:08.000000000 -0400
@@ -24,7 +24,8 @@
    * Conversion from 5.x to 6.x done by Exodus Development and tomaszx (tomaszx provided initial conversion and patches -- thanks!)
    */
 
-define('ED_READMORE_TEXT_DEFAULT', 'Read more');
+define('ED_READMORE_TEXT_DEFAULT', 'read more &raquo;');
+define('ED_READMORE_TITLE_DEFAULT', 'Read the whole posting.');
 
 /**
  * Place the teaser in the correct location in $thing
@@ -36,12 +37,15 @@ define('ED_READMORE_TEXT_DEFAULT', 'Read
 function _ed_readmore_place_readmore_link($thing, $link, $inlineflag) {
   $read_more = '<span class="read-more">'. $link .'</span>';
   if ($inlineflag) {
+    // (only if is inline) it must be prefixes with a nonbreaking space: &nbsp;
+    $read_more = '&nbsp;' . $read_more;
+
     // deal with broken strrpos on php4
     if (_ed_readmore_is_php4()) {
       $find_last = '_ed_readmore_strrpos_string';
     }
     else {
-      $find_last = 'strrpos';
+      $find_last = 'strripos';
     }
     // int strrpos ( string haystack, string needle [, int offset] )
     // substr_replace ( mixed string, string replacement, int start [, int length] )
@@ -78,21 +82,22 @@ function ed_readmore_nodeapi(&$node, $op
     $strong_l = '';
     $strong_r = '';
   }
-  $link_text = $strong_l . t(variable_get('ed_readmore_text', ED_READMORE_TEXT_DEFAULT)) . $strong_r;
-  $options = array('html' => true);
-  $readmore_url = l($link_text, "node/$node->nid", $options);
+
+  $link_text = variable_get('ed_readmore_text', t(ED_READMORE_TEXT_DEFAULT));
+  $link_text = $strong_l . str_replace(' ', '&nbsp;', $link_text) . $strong_r; // prevent line break into the readmore link
+  $link_title = variable_get('ed_readmore_title', ED_READMORE_TITLE_DEFAULT);
+
+  // $readmore_url is used for regular node teaser
+  $readmore_url = l($link_text, "node/$node->nid", array('attributes' => array('title' => $link_title), 'html' => TRUE));
+  // $readmore_url_rss is used for RSS teasers...
+  $readmore_url_rss = l($link_text, "node/$node->nid", array('attributes' => array('title' => $link_title, 'target' => '_blank'), 'absolute' => TRUE, 'html' => TRUE));
   if ($enabled) {
     if ($op == 'rss item') {
-      // Since this is an RSS item, we need an absolute URL.
-      // And, while we're at it, we make it a _blank target as does node.module node_feed() function.
-      $options['absolute'] =  true;
-      $options['attributes'] =  array('target' => '_blank');
-      $readmore_url = l($link_text, "node/$node->nid", $options);
       $item_length = variable_get('feed_item_length', 'teaser'); // from node.module node_feed() code
       switch ($item_length) {
         case 'teaser':
           if (strlen($node->teaser) < strlen($node->body)) {
-            $node->teaser = _ed_readmore_place_readmore_link($node->teaser, $readmore_url, $inlineflag);
+            $node->teaser = _ed_readmore_place_readmore_link($node->teaser, $readmore_url_rss, $inlineflag);
           }
           break;
       }
@@ -101,16 +106,19 @@ function ed_readmore_nodeapi(&$node, $op
 
     if ($op == 'view' ) {
       if ($teaser && $node->readmore) {
-        $node->readmore = false;
-        //
-        // since we are blowing away some of the implicit info ($node->readmore) let's remember that this was a teaser
-        $node->is_teaser = TRUE;
         $node->content['body']['#value'] = _ed_readmore_place_readmore_link($node->content['body']['#value'], $readmore_url, $inlineflag);
       }
     }
   }
 }
 
+function ed_readmore_link_alter($node, &$links) {
+  $remove = variable_get('ed_readmore_remove', TRUE);
+  if ($remove) {
+    unset($links['node_read_more']);
+  }
+}
+
 /*
   *
   * DESCRIPTION:
@@ -135,7 +143,7 @@ function _ed_readmore_strrpos_string($ha
   if (trim($haystack) != "" && trim($needle) != "" && $offset <= strlen($haystack)) {
     $last_pos = $offset;
     $found = false;
-    while (($curr_pos = strpos($haystack, $needle, $last_pos)) !== false) {
+    while (($curr_pos = strpos($haystack, strtolower($needle), $last_pos)) !== false) {
       $found = true;
       $last_pos = $curr_pos + 1;
     }
@@ -189,11 +197,18 @@ function ed_readmore_admin_settings() {
 
   $form['readmore']['ed_readmore_readmore_tweak'] =
     array('#type' => 'checkbox',
-          '#title' =>  t('Relocate <strong>Read more</strong> link from links section?'),
+          '#title'=> t('Add <strong>read more</strong> link to the end of teaser?'),
           '#default_value' => variable_get('ed_readmore_readmore_tweak', 1),
-          '#description' => t('Move Read More from links to end of teaser?  See <a target="_blank" href="http://www.angrydonuts.com/the_nuisance_of_the_read_more_fl">AngryDonuts.com</a> for details.'),
+          '#description' => t('Add a <strong>read more</strong> link to the end of teaser.  See <a target="_blank" href="http://www.angrydonuts.com/the_nuisance_of_the_read_more_fl">AngryDonuts.com</a> for details.'),
           '#required' => FALSE);
 
+  $form['readmore']['ed_readmore_remove'] =
+    array('#type' => 'checkbox',
+          '#title'=> t('Remove <strong>read more</strong> link from links section?'),
+          '#default_value' => variable_get('ed_readmore_remove', TRUE),
+          '#description' => t('Also remove the "read more" link from node links.'),
+          '#required'=>FALSE);
+
   $form['readmore']['ed_readmore_readmore_inline'] =
     array('#type' => 'checkbox',
           '#title' =>  t('Put <strong>Read more</strong> inline in teaser?'),
@@ -207,6 +222,12 @@ function ed_readmore_admin_settings() {
           '#default_value' => variable_get('ed_readmore_text', t(ED_READMORE_TEXT_DEFAULT)),
           '#description' => t('Enter the text you wish to display in the read more link.  May contain HTML.'),
           '#required' => TRUE);
+  $form['readmore']['ed_readmore_title'] =
+    array('#type' => 'textfield',
+          '#title'=> t('The title for the "read more" link'),
+          '#default_value' => variable_get('ed_readmore_title', ED_READMORE_TITLE_DEFAULT),
+          '#description' => t('Enter the text you wish to be used as title in the "read more" link. You should give this text in english. The module will localize this text when is displayed.'),
+          '#required' => FALSE);
 
   $form['readmore']['ed_readmore_readmore_strong'] =
     array('#type' => 'checkbox',
