You are here

function messaging_text_render in Messaging 6.4

Same name and namespace in other branches
  1. 5 messaging.module \messaging_text_render()
  2. 6 messaging.module \messaging_text_render()
  3. 6.2 messaging.module \messaging_text_render()
  4. 6.3 messaging.module \messaging_text_render()

Composes message from different parts, recursively and applies filter

Filter is applied now only once

Parameters

$text: Simple string or array of message parts It may have named elements like #prefix and #text or it may be single strings to render straight forward

$glue: Text to glue all lines together

$filter: Input format to apply to the results

1 call to messaging_text_render()
Messaging_Method::text_render in includes/messaging_method.class.inc
Composes message from different parts, recursively and applies filter

File

includes/text.inc, line 154
Drupal Messaging Framework - Text filtering functions

Code

function messaging_text_render($text, $glue = '', $format = NULL, $filter = NULL) {
  $output = '';
  if (is_array($text)) {
    if (isset($text['#prefix'])) {
      $output .= $text['#prefix'] . $glue;
      unset($text['#prefix']);
    }
    if (isset($text['#text'])) {
      $output .= $text['#text'];
      return $output;
    }
    foreach (element_children($text) as $key) {

      // The filter is not passed along
      $text[$key] = messaging_text_render($text[$key], $glue);
    }
    $output .= implode($glue, $text);
  }
  else {
    $output .= $text;
  }

  // The format and the final filter are applied now only once
  if (!empty($format)) {
    $output = messaging_text_check_markup($output, $format);
  }
  if (!empty($filter)) {
    $output = messaging_text_filter($output, $filter);
  }
  return $output;
}