function _linkchecker_check_markup in Link checker 5.2
Same name and namespace in other branches
- 6.2 linkchecker.module \_linkchecker_check_markup()
- 7 linkchecker.module \_linkchecker_check_markup()
Customized clone of core check_markup() function with additional filter blacklist.
See http://api.drupal.org/api/function/check_markup for API documentation.
3 calls to _linkchecker_check_markup()
- _linkchecker_add_box_links in ./
linkchecker.module - Add box links to database.
- _linkchecker_add_comment_links in ./
linkchecker.module - Add comment links to database.
- _linkchecker_add_node_links in ./
linkchecker.module - Add node links to database.
File
- ./
linkchecker.module, line 1677 - This module periodically check links in given node types, blocks, cck fields, etc.
Code
function _linkchecker_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 = 'linkchecker:' . $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);
// Do not run placeholder or special tag filters used as references
// to nodes like 'weblink' or 'weblinks' node types. If the original
// link node is updated, all links are automatically up-to-date and
// there is no need to notify about the broken link on all nodes having
// a link reference in content. This would only confuse the authors as
// they may also not be able to fix the source node of the reference.
$filters_blacklist = array_keys(array_filter(variable_get('linkchecker_filter_blacklist', explode('|', LINKCHECKER_DEFAULT_FILTER_BLACKLIST))));
// Give filters the chance to escape HTML-like data such as code or formulas.
foreach ($filters as $filter) {
if (!in_array($filter->module . '/' . $filter->delta, $filters_blacklist)) {
$text = module_invoke($filter->module, 'filter', 'prepare', $filter->delta, $format, $text, $cache_id);
}
}
// Perform filtering.
foreach ($filters as $filter) {
if (!in_array($filter->module . '/' . $filter->delta, $filters_blacklist)) {
$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, 'cache_filter', $text, time() + 60 * 60 * 24);
}
}
else {
$text = t('n/a');
}
return $text;
}