You are here

function _subscriptions_content_format_text in Subscriptions 6

Same name and namespace in other branches
  1. 5.2 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 665
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 (!empty($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);
  }
  if (!variable_get('subscriptions_allow_html_node_output', 0)) {
    $text = drupal_html_to_text($text);
  }
  return trim($text);
}