function _pathfilter_process_internal in Path Filter 7
Same name and namespace in other branches
- 5.2 pathfilter.module \_pathfilter_process_internal()
- 5 pathfilter.module \_pathfilter_process_internal()
- 6.2 pathfilter.module \_pathfilter_process_internal()
- 6 pathfilter.module \_pathfilter_process_internal()
1 call to _pathfilter_process_internal()
File
- ./
pathfilter.module, line 104 - 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_internal($settings, $matches) {
$absolute = $settings['link_absolute'];
// Initialize an array to store additional matches to pass into the url function
// we can't access array offsets that aren't defined.
$url_array = array();
if (isset($matches[4])) {
$url_array['query'] = $matches[4];
}
if (isset($matches[5])) {
$url_array['fragment'] = $matches[5];
}
if (isset($absolute)) {
$url_array['absolute'] = $absolute;
}
// If we are going to convert our output to the aliased version ($convert_to_alias is set to TRUE),
// We need to pass 'alias' => true into url to tell it to not pass our URL through
// drupal_get_path_alias() thus keeping our 'node/#' format.
if (module_exists('i18n')) {
if ($path = drupal_get_normal_path($matches[3])) {
if (substr($path, 0, 5) == 'node/') {
$nid = substr($path, 5);
}
}
elseif (preg_match('/(node\\/([0-9]+))$/', $matches[3], $match)) {
$nid = $match[2];
}
if (!empty($nid)) {
$languages = language_list('enabled');
$languages = $languages[1];
if (isset($language)) {
$url_array['language'] = $languages[i18n_node_get_lang($match[2])];
}
$link = url($match[1], $url_array);
}
}
$link = isset($link) ? $link : url($matches[3], $url_array);
return $matches[1] . $link . $matches[1];
}