You are here

function simplenews_html_to_text in Simplenews 6.2

Same name and namespace in other branches
  1. 5 simplenews.module \simplenews_html_to_text()
  2. 6 simplenews.module \simplenews_html_to_text()
  3. 7.2 includes/simplenews.mail.inc \simplenews_html_to_text()
  4. 7 includes/simplenews.mail.inc \simplenews_html_to_text()

HTML to text conversion for HTML and special characters.

Converts some special HTMLcharacters in addition to drupal_html_to_text()

Parameters

string $text Source text with HTML and special characters:

boolean $inline_hyperlinks: TRUE: URLs will be placed inline. FALSE: URLs will be converted to numbered reference list.

Return value

string Target text with HTML and special characters replaced

2 calls to simplenews_html_to_text()
simplenews_mail in ./simplenews.module
Implementation of hook_mail().
simplenews_mail_mail in includes/simplenews.mail.inc
Send a node to an email address.

File

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

Code

function simplenews_html_to_text($text, $inline_hyperlinks = TRUE) {

  // By replacing <a> tag by only its URL the URLs will be placed inline
  // in the email body and are not converted to a numbered reference list
  // by drupal_html_to_text().
  // URL are converted to absolute URL as drupal_html_to_text() would have.
  if ($inline_hyperlinks) {
    $pattern = '@<a[^>]+?href="([^"]*)"[^>]*?>(.+?)</a>@is';
    $text = preg_replace_callback($pattern, '_simplenews_absolute_mail_urls', $text);
  }

  // Replace some special characters before performing the drupal standard conversion.
  $preg = _simplenews_html_replace();
  $text = preg_replace(array_keys($preg), array_values($preg), $text);

  // Perform standard drupal html to text conversion.
  return drupal_html_to_text($text);
}