--- ed_readmore5/ed_readmore.module +++ ed_readmore6/ed_readmore.module @@ -1,33 +1,6 @@ " . $link . ""; + $read_more = ''. $link .''; if ($inlineflag) { // deal with broken strrpos on php4 if (_ed_readmore_is_php4()) { @@ -51,11 +24,13 @@ // substr_replace ( mixed string, string replacement, int start [, int length] ) // this is lame - need to look for any tag allowed by the current filter $marker_to_insert_at = '
'; - - $final_p_pos = $find_last($thing, $marker_to_insert_at); // php4 gotcha - will search only for first char of marker! (supports only single char search) - if (!($final_p_pos ===FALSE)) { + + // php4 gotcha - will search only for first char of marker! (supports only single char search) + $final_p_pos = $find_last($thing, $marker_to_insert_at); + if (!($final_p_pos === FALSE)) { $thing = substr_replace($thing, $read_more, $final_p_pos, 0); // account for length of string - } else { + } + else { $thing .= $read_more; // not found, so just append it } } @@ -66,21 +41,27 @@ } -/** - * - * Fix "read more" flag - * From the most excellent angry donuts site: http://www.angrydonuts.com/the_nuisance_of_the_read_more_fl - * From author: Note that I'm using a lot of arguments to l() -- I'm telling it to provide an 'absolute' - * path, because these teasers often go out to RSS, and providing an absolute path is much, much safer. - */ + function ed_readmore_nodeapi(&$node, $op, $teaser, $page) { - $enabled = variable_get('ed_readmore_readmore_tweak', ED_READMORE_READMORE_TWEAK_DEFAULT); - $inlineflag = variable_get('ed_readmore_readmore_inline', ED_READMORE_READMORE_INLINE_DEFAULT); - $readmore_url = l(variable_get('ed_readmore_text', t(ED_READMORE_TEXT_DEFAULT)), "node/$node->nid", NULL, NULL, NULL, TRUE, TRUE); + $enabled = variable_get('ed_readmore_readmore_tweak', 1); + $inlineflag = variable_get('ed_readmore_readmore_inline', 1); + $strong = variable_get('ed_readmore_readmore_strong', 1); + + if ($strong) { + $strong_l = ''; + $strong_r = ''; + } + else { + $strong_l = ''; + $strong_r = ''; + } + + $options = array('html' => true); + $readmore_url = l($strong_l .' '. t(variable_get('ed_readmore_text', ED_READMORE_TEXT_DEFAULT)) .' »'. $strong_r, "node/$node->nid", $options); if ($enabled) { if ($op == 'rss item') { $item_length = variable_get('feed_item_length', 'teaser'); // from node.module node_feed() code - switch($item_length) { + switch ($item_length) { case 'teaser': if (strlen($node->teaser) < strlen($node->body)) { $node->teaser = _ed_readmore_place_readmore_link($node->teaser, $readmore_url, $inlineflag); @@ -89,49 +70,48 @@ } return; } - + 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); + $node->content['body']['#value'] = _ed_readmore_place_readmore_link($node->content['body']['#value'], $readmore_url, $inlineflag); } } } } -################################################### -# -# DESCRIPTION: -# This function returns the last occurance of a string, -# rather than the last occurance of a single character like -# strrpos does. It also supports an offset from where to -# start the searching in the haystack string. -# -# ARGS: -# $haystack (required) -- the string to search upon -# $needle (required) -- the string you are looking for -# $offset (optional) -- the offset to start from -# -# RETURN VALS: -# returns integer on success -# returns false on failure to find the string at all -# -# lifted from http://us3.php.net/manual/en/function.strrpos.php#67559 -# -################################################### +/* + * + * DESCRIPTION: + * This function returns the last occurance of a string, rather than the last occurance + * of a single character like strrpos does. It also supports an offset from where to + * start the searching in the haystack string. + * + * ARGS: + * $haystack (required) -- the string to search upon + * $needle (required) -- the string you are looking for + * $offset (optional) -- the offset to start from + * + * RETURN VALS: + * returns integer on success + * returns false on failure to find the string at all + * + * lifted from http://us3.php.net/manual/en/function.strrpos.php#67559 + */ + function _ed_readmore_strrpos_string($haystack, $needle, $offset = 0) { - if(trim($haystack) != "" && trim($needle) != "" && $offset <= strlen($haystack)) { + 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, $needle, $last_pos)) !== false) { $found = true; $last_pos = $curr_pos + 1; } - if($found) { + if ($found) { return $last_pos - 1; } else { @@ -155,16 +135,15 @@ * Implementation of hook_menu */ function ed_readmore_menu() { - $items[] = array( - 'path' => 'admin/settings/ed_readmore', - 'title' => t('Read More Tweak'), - 'description' => t('Relocate the teaser "read more" link from links section?'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('ed_readmore_admin_settings'), - 'access' => user_access('administer site configuration'), - 'type' => MENU_NORMAL_ITEM, - ); - return $items; + $items['admin/settings/ed_readmore'] = array( + 'title' => t('Read More Tweak'), + 'description' => t('Relocate the teaser "read more" link from links section?'), + 'page callback' => 'drupal_get_form', + 'page arguments' => array('ed_readmore_admin_settings'), + 'access arguments' => array('administer site configuration'), + 'type' => MENU_NORMAL_ITEM, + ); + return $items; } @@ -172,48 +151,44 @@ * Displays the settings form */ function ed_readmore_admin_settings() { - $form=array(); - _ed_readmore_get_banner($form); + $form = array(); + $form['readmore'] = array( '#type' => 'fieldset', '#collapsible' => TRUE, '#collapsed' => FALSE, - '#title' => t('Teaser "read more" handling'), + '#title' => t('Teaser "Read more" handling'), ); - $form['readmore']['ed_readmore_readmore_tweak'] = - array('#type' => 'checkbox', - '#title'=> t('Relocate read more link from links section?'), - '#default_value' => variable_get('ed_readmore_readmore_tweak', ED_READMORE_READMORE_TWEAK_DEFAULT), - '#description' => t('Move Read More from links to end of teaser? See AngryDonuts.com for details.'), - '#required'=>FALSE); + $form['readmore']['ed_readmore_readmore_tweak'] = + array('#type' => 'checkbox', + '#title' => t('Relocate Read more link from links section?'), + '#default_value' => variable_get('ed_readmore_readmore_tweak', 1), + '#description' => t('Move Read More from links to end of teaser? See AngryDonuts.com for details.'), + '#required' => FALSE); - $form['readmore']['ed_readmore_readmore_inline'] = - array('#type' => 'checkbox', - '#title'=> t('Put read more inline in teaser?'), - '#default_value' => variable_get('ed_readmore_readmore_inline', ED_READMORE_READMORE_INLINE_DEFAULT), - '#description' => t('If relocation is enabled, and this option is set, place "read more" text on last line of teaser text using a <span> element.'), - '#required'=>FALSE); + $form['readmore']['ed_readmore_readmore_inline'] = + array('#type' => 'checkbox', + '#title' => t('Put Read more inline in teaser?'), + '#default_value' => variable_get('ed_readmore_readmore_inline', 1), + '#description' => t('If relocation is enabled, and this option is set, place "read more" text on last line of teaser text using a <span> element.'), + '#required' => FALSE); - $form['readmore']['ed_readmore_text'] = - array('#type' => 'textfield', - '#title'=> t('The "read more" text to display in the teaser'), - '#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_text'] = + array('#type' => 'textfield', + '#title' => t('The "read more" text to display in the teaser'), + '#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_readmore_strong'] = + array('#type' => 'checkbox', + '#title' => t('bold this text'), + '#default_value' => variable_get('ed_readmore_readmore_strong', 1), + '#required' => FALSE); return system_settings_form($form); } -/** - * Get settings 'banner' - */ -function _ed_readmore_get_banner(&$form) { - $name = 'ed_readmore-d5'; - $d = '
';
- $form['module_banner'] = array('#type' => 'markup',
- '#value' => '');
-}
-