check_markup
modules/filter/filter.module, строка 762
- Версии
- 5 – 6
check_markup($text, $format = FILTER_FORMAT_DEFAULT, $check = TRUE)
Фильтрует текст с помощью выбранного формата ввода.
Параметры
$text
Исходный текст.
$format
Идентификатор формата ввода, которым нужно отфильтровать текст (FILTER_FORMAT_DEFAULT — фильтр по-умолчанию).
$check
Производить ли проверку доступа пользователя к формату ввода (filter_access()
). Примечание: будьте бдительны при установке этого параметра в TRUE
. То, что корректно отображается у вас, может не отобразится у людей с меньшими правами.
Код
<?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.
$id = $format .':'. md5($text);
if ($cached = cache_get($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);
}
// Perform filtering.
foreach ($filters as $filter) {
$text = module_invoke($filter->module, 'filter', 'process', $filter->delta, $format, $text);
}
// Store in cache with a minimum expiration time of 1 day.
if ($cache) {
cache_set($id, 'cache_filter', $text, time() + (60 * 60 * 24));
}
}
else {
$text = t('n/a');
}
return $text;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии