You are here

function messaging_text_check_markup in Messaging 6.4

This is a fast version of check_markup

The differences with regular check_markup are:

  • It uses a static cache instead of querying the database
  • It doesn't check for permissions

Parameters

$text:

$format:

See also

check_markup()

2 calls to messaging_text_check_markup()
messaging_template_text_replace in messaging_template/messaging_template.module
Do token replacement.
messaging_text_render in includes/text.inc
Composes message from different parts, recursively and applies filter

File

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

Code

function messaging_text_check_markup($text, $format = FILTER_FORMAT_DEFAULT) {
  $cache =& messaging_static(__FUNCTION__);

  // When $check = TRUE, do an access check on $format.
  if (isset($text)) {
    $format = filter_resolve_format($format);

    // Check for a cached version of this piece of text.
    $cache_id = $format . ':' . md5($text);
    if (!isset($cache[$cache_id])) {

      // Convert all Windows and Mac newlines to a single newline,
      // so filters only need to deal with one possibility.
      $text = str_replace(array(
        "\r\n",
        "\r",
      ), "\n", $text);

      // Get a complete list of filters, ordered properly.
      $filters = filter_list_format($format);

      // Give filters the chance to escape HTML-like data such as code or formulas.
      foreach ($filters as $filter) {
        $text = module_invoke($filter->module, 'filter', 'prepare', $filter->delta, $format, $text, $cache_id);
      }

      // Perform filtering.
      foreach ($filters as $filter) {
        $text = module_invoke($filter->module, 'filter', 'process', $filter->delta, $format, $text, $cache_id);
      }
      $cache[$cache_id] = $text;
    }
    return $cache[$cache_id];
  }
  else {
    $text = t('n/a');
  }
  return $text;
}