You are here

public function purl_subdomain::rewrite in Persistent URL 7

Same name and namespace in other branches
  1. 6 includes/purl_subdomain.inc \purl_subdomain::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_subdomain.inc, line 48

Class

purl_subdomain
Subdomain prefixing.

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);
      $port = !empty($base['port']) ? ':' . $base['port'] : "";
      $base_path = !empty($base['path']) ? $base['path'] : "";
      $options['base_url'] = "{$base['scheme']}://{$element->value}.{$base['host']}{$port}{$base_path}";
    }
    else {
      $options['base_url'] = $base_url;
    }
  }
}