function _pathfilter_process_internal in Path Filter 6.2
Same name and namespace in other branches
- 5.2 pathfilter.module \_pathfilter_process_internal()
- 5 pathfilter.module \_pathfilter_process_internal()
- 6 pathfilter.module \_pathfilter_process_internal()
- 7 pathfilter.module \_pathfilter_process_internal()
1 call to _pathfilter_process_internal()
File
- ./
pathfilter.module, line 120 - 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($format, $convert_to_alias, $matches) {
$absolute = variable_get('pathfilter_link_absolute_' . $format, 1) ? TRUE : FALSE;
$link = '';
// 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];
$language = $languages[i18n_node_get_lang($nid)];
$link = url($matches[3], array(
'query' => $matches[4],
'fragment' => $matches[5],
'absolute' => $absolute,
'alias' => !$convert_to_alias,
'language' => $language,
));
}
}
$link = $link ? $link : url($matches[3], array(
'query' => !empty($matches[4]) ? $matches[4] : '',
'fragment' => !empty($matches[5]) ? $matches[5] : '',
'absolute' => $absolute,
'alias' => !$convert_to_alias,
));
return $matches[1] . $link . $matches[1];
}