You are here

function _pathfilter_process_internal in Path Filter 5

Same name and namespace in other branches
  1. 5.2 pathfilter.module \_pathfilter_process_internal()
  2. 6.2 pathfilter.module \_pathfilter_process_internal()
  3. 6 pathfilter.module \_pathfilter_process_internal()
  4. 7 pathfilter.module \_pathfilter_process_internal()
1 call to _pathfilter_process_internal()
_pathfilter_process in ./pathfilter.module

File

./pathfilter.module, line 117
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, $matches) {
  $absolute = variable_get('pathfilter_link_absolute_' . $format, 1) ? TRUE : FALSE;
  if (module_exists('i18n')) {
    if (preg_match('/(node\\/([0-9]+))$/', $matches[3], $match)) {

      // if we have a drupal node url, ensure we get the translated url alias
      $language = i18n_node_get_lang($match[2]);
      $path = $language ? i18n_path($match[1], $language) : $match[1];
      $link = url($path, $matches[4], $matches[5], $absolute);
    }
  }
  $link = $link ? $link : url($matches[3], $matches[4], $matches[5], $absolute);
  return $matches[1] . $link . $matches[1];
}