You are here

function _subscriptions_content_format_text in Subscriptions 5.2

Same name and namespace in other branches
  1. 6 subscriptions_content.module \_subscriptions_content_format_text()

Convert text with formatting into plain text.

2 calls to _subscriptions_content_format_text()
_subscriptions_content_format_comments in ./subscriptions_content.module
Given a comment template returns a formatted text of comments for given node.
_subscriptions_content_node_mailvars in ./subscriptions_content.module
Fill given array of mailvars with given node values.

File

./subscriptions_content.module, line 715
Subscriptions to content events

Code

function _subscriptions_content_format_text($text, $format = NULL) {
  static $have_img_assist;
  if (!isset($have_img_assist)) {
    $have_img_assist = module_exists('img_assist');
  }
  if ($have_img_assist) {
    foreach (img_assist_get_macros($text) as $unexpanded_macro => $macro) {
      $expanded_macro = img_assist_render_image($macro);
      if (preg_match('/<img src="([^"]*)".*title="([^"]*)"/', $expanded_macro, $matches)) {
        $text = str_replace($unexpanded_macro, " [<a href=\"{$matches[1]}\">{$matches[2]}</a>] ", $text);
      }
    }
  }
  if (isset($format)) {
    $text = check_markup($text, $format, FALSE);
  }
  static $have_HTML_to_text;
  if (!isset($have_HTML_to_text)) {
    $have_HTML_to_text = substr(VERSION, 0, 1) > 5 || module_exists('html_to_text');
  }
  if ($have_HTML_to_text) {
    $text = drupal_html_to_text($text);
  }
  return trim($text);
}