Commit 5ad51999 authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

#212126 report by salvis, patch by myself: allow clearing of...

#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
parent ea79c66c
......@@ -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,9 +430,15 @@ 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 ($reset) {
// Reset internal URL list.
$urls = array();
}
else {
if (empty($regexp)) {
$regexp = '@^'. preg_quote($base_path, '@') .'@';
}
......@@ -441,6 +448,7 @@ function _drupal_html_to_mail_urls($match = NULL) {
$urls[] = strpos($url, '://') ? $url : preg_replace($regexp, $base_url .'/', $url);
return $label .' ['. count($urls) .']';
}
}
return $urls;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment