You are here

function _simplenews_absolute_mail_urls in Simplenews 6.2

Same name and namespace in other branches
  1. 6 simplenews.module \_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 absolute URLs.

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

File

includes/simplenews.mail.inc, line 745
Simplenews email send and spool handling

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, '...') === drupal_strlen($label) - 3) {

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