You are here

function messaging_text_render in Messaging 6.2

Same name and namespace in other branches
  1. 5 messaging.module \messaging_text_render()
  2. 6.4 includes/text.inc \messaging_text_render()
  3. 6 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_message_render in ./messaging.module
Renders full message with header and body

File

./messaging.module, line 739

Code

function messaging_text_render($text, $glue = '', $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 filter is applied now only once
  if ($filter) {
    $output = check_markup($output, $filter, FALSE);
  }
  return $output;
}