check_markup

Хочешь помочь с переводом? Это очень просто и быстро. Лишь зарегистрируйся, и можешь тут же начать переводить.

modules/filter/filter.module, строка 428

Версии
5 – 6
check_markup($text, $format = FILTER_FORMAT_DEFAULT, $check = TRUE)

Фильтрует текст с помощью выбранного формата ввода.

Параметры

$text Исходный текст.

$format Идентификатор формата ввода, которым нужно отфильтровать текст (FILTER_FORMAT_DEFAULT — фильтр по-умолчанию).

$check Производить ли проверку доступа пользователя к формату ввода (filter_access()). Примечание: будьте бдительны при установке этого параметра в TRUE. То, что корректно отображается у вас, может не отобразится у людей с меньшими правами.

▾ 7 функции вызывают check_markup()

block_block in modules/block/block.module
Реализация hook_block().
comment_nodeapi in modules/comment/comment.module
Реализация hook_nodeapi().
node_prepare in modules/node/node.module
Применяет фильтры и создает стандартные элементы нод.
profile_view_field in modules/profile/profile.module
theme_comment_view in modules/comment/comment.module
Темизировать блок с единичным комментарием
user_comment in modules/user/user.module
Реализация hook_comment().
_comment_form_submit in modules/comment/comment.module
Prepare a comment for submission.

Код

<?php
function check_markup($text, $format = FILTER_FORMAT_DEFAULT, $check = TRUE) {
  // When $check = TRUE, do an access check on $format.
  if (isset($text) && (!$check || filter_access($format))) {
    $format = filter_resolve_format($format);

    // Check for a cached version of this piece of text.
    $cache_id = $format .':'. md5($text);
    if ($cached = cache_get($cache_id, 'cache_filter')) {
      return $cached->data;
    }

    // See if caching is allowed for this format.
    $cache = filter_format_allowcache($format);

    // 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);
    }

    // Store in cache with a minimum expiration time of 1 day.
    if ($cache) {
      cache_set($cache_id, $text, 'cache_filter', time() + (60 * 60 * 24));
    }
  }
  else {
    $text = t('n/a');
  }

  return $text;
}
?>

Пользовательские комментарии

Пример применения (вставка текста ноды в блок):

<?php
$node=node_load(192);
print check_markup($node->body, $node->format, FALSE);
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

Вход в систему