function _pathfilter_process in Path Filter 7
Same name and namespace in other branches
- 5.2 pathfilter.module \_pathfilter_process()
- 5 pathfilter.module \_pathfilter_process()
- 6.2 pathfilter.module \_pathfilter_process()
- 6 pathfilter.module \_pathfilter_process()
1 call to _pathfilter_process()
- _pathfilter_replace_internal in ./
pathfilter.module - Replaces the internal: and files: in elements with the url for it
1 string reference to '_pathfilter_process'
- pathfilter_filter_info in ./
pathfilter.module - Implements hook_filter_info().
File
- ./
pathfilter.module, line 50 - This filter takes internal Drupal paths in double quotes, written as e.g. "internal:node/99", and replaces them with the appropriate absolute http URL using Drupal's url() function [1]. E.g. for a site located at http://example.com/mysite
Code
function _pathfilter_process($text, $filter, $format, $langcode, $cache, $cache_id) {
$patterns = array();
$replacement = array();
$patterns[] = '/(["\'])(internal):([^"#\\?\']+)\\??([^"#\']+)?#?([^"\']+)?\\1/';
$patterns[] = '/(["\'])(files):([^"\']+)\\1/';
$func = "_pathfilter_process_handler";
// use the 'currying' technique to allow us to pass the format into
// the callback function.
$callback = _pathfilter_curry($func, 2);
return preg_replace_callback($patterns, $callback($filter->settings), $text);
}