diff options
author | Gábor Hojtsy <gabor@hojtsy.hu> | 2008-01-25 17:04:00 +0000 |
---|---|---|
committer | Gábor Hojtsy <gabor@hojtsy.hu> | 2008-01-25 17:04:00 +0000 |
commit | 5ad519996d3798bd12ef930f74f5a82ff8b14032 (patch) | |
tree | 825640d21be3c08a8ae0f922334cbc3c6caa583e | |
parent | ea79c66c033fc835fc404d6ca751189414ae734e (diff) | |
download | brdo-5ad519996d3798bd12ef930f74f5a82ff8b14032.tar.gz brdo-5ad519996d3798bd12ef930f74f5a82ff8b14032.tar.bz2 |
#212126 report by salvis, patch by myself: allow clearing of drupal_html_to_text() URL list, so it can be used multiple times on the page
-rw-r--r-- | includes/mail.inc | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/includes/mail.inc b/includes/mail.inc index 72c7258e6..4234aacab 100644 --- a/includes/mail.inc +++ b/includes/mail.inc @@ -276,6 +276,7 @@ function drupal_html_to_text($string, $allowed_tags = NULL) { // Replace inline <a> tags with the text of link and a footnote. // 'See <a href="http://drupal.org">the Drupal site</a>' becomes // 'See the Drupal site [1]' with the URL included as a footnote. + _drupal_html_to_mail_urls(NULL, TRUE); $pattern = '@(<a[^>]+?href="([^"]*)"[^>]*?>(.+?)</a>)@i'; $string = preg_replace_callback($pattern, '_drupal_html_to_mail_urls', $string); $urls = _drupal_html_to_mail_urls(); @@ -429,17 +430,24 @@ function _drupal_wrap_mail_line(&$line, $key, $values) { * * Keeps track of URLs and replaces them with placeholder tokens. */ -function _drupal_html_to_mail_urls($match = NULL) { +function _drupal_html_to_mail_urls($match = NULL, $reset = FALSE) { global $base_url, $base_path; static $urls = array(), $regexp; - if (empty($regexp)) { - $regexp = '@^'. preg_quote($base_path, '@') .'@'; + + if ($reset) { + // Reset internal URL list. + $urls = array(); } - if ($match) { - list(, , $url, $label) = $match; - // Ensure all URLs are absolute. - $urls[] = strpos($url, '://') ? $url : preg_replace($regexp, $base_url .'/', $url); - return $label .' ['. count($urls) .']'; + else { + if (empty($regexp)) { + $regexp = '@^'. preg_quote($base_path, '@') .'@'; + } + if ($match) { + list(, , $url, $label) = $match; + // Ensure all URLs are absolute. + $urls[] = strpos($url, '://') ? $url : preg_replace($regexp, $base_url .'/', $url); + return $label .' ['. count($urls) .']'; + } } return $urls; } |