You are here

public function purl_domain::rewrite in Persistent URL 7

Same name and namespace in other branches
  1. 6 includes/purl_domain.inc \purl_domain::rewrite()

Responsible for rewriting outgoing links. Note: it's this functions job to make sure it doesn't alter a link that has already been treated.

This must also check $options['purl']['disabled'] and $options['purl']['remove']. The _purl_skip() method is helpful for this.

Parameters

$path: string, by-reference the path to modify.

$options: See url() docs

$element: The element to add to the path.

Overrides purl_processor::rewrite

File

includes/purl_domain.inc, line 50

Class

purl_domain
Full domain handling.

Code

public function rewrite(&$path, &$options, $element) {
  $options['absolute'] = TRUE;
  if ($base_url = $this
    ->base_url()) {
    if (!_purl_skip($element, $options)) {
      $base = parse_url($base_url);
      $base_path = !empty($base['path']) ? $base['path'] : "";
      $options['base_url'] = "{$base['scheme']}://{$element->value}{$base_path}";
    }
    else {
      $options['base_url'] = $base_url;
    }
  }
}