You are here

function _simplenews_absolute_mail_urls in Simplenews 6

Same name and namespace in other branches
  1. 6.2 includes/simplenews.mail.inc \_simplenews_absolute_mail_urls()
  2. 7.2 includes/simplenews.mail.inc \_simplenews_absolute_mail_urls()
  3. 7 includes/simplenews.mail.inc \_simplenews_absolute_mail_urls()

Helper function for simplenews_html_to_text().

Replaces URLs with abolute URLs.

1 string reference to '_simplenews_absolute_mail_urls'
simplenews_html_to_text in ./simplenews.module
HTML to text conversion for HTML and special characters.

File

./simplenews.module, line 2135
Simplnews node handling, sent email, newsletter block and general hooks

Code

function _simplenews_absolute_mail_urls($match) {
  global $base_url, $base_path;
  static $regexp;
  $url = $label = '';
  if ($match) {
    if (empty($regexp)) {
      $regexp = '@^' . preg_quote($base_path, '@') . '@';
    }
    list(, $url, $label) = $match;
    $url = strpos($url, '://') ? $url : preg_replace($regexp, $base_url . '/', $url);

    // If the link is formed by Drupal's URL filter, we only return the URL.
    // The URL filter generates a label out of the original URL.
    if (strpos($label, '...') === strlen($label) - 3) {

      // Remove ellipsis from end of label.
      $label = substr($label, 0, strlen($label) - 3);
    }
    if (strpos($url, $label) !== FALSE) {
      return $url;
    }
    return $label . ' ' . $url;
  }
}