You are here

function hosting_alias_automatic_aliases in Hosting 5

Same name and namespace in other branches
  1. 6.2 alias/hosting_alias.module \hosting_alias_automatic_aliases()
  2. 7.4 alias/hosting_alias.module \hosting_alias_automatic_aliases()
  3. 7.3 alias/hosting_alias.module \hosting_alias_automatic_aliases()

Generate a default set of aliases for the site

1 call to hosting_alias_automatic_aliases()
hosting_alias_insert in alias/hosting_alias.module

File

alias/hosting_alias.module, line 202

Code

function hosting_alias_automatic_aliases($url) {
  $alias = array();
  if ($sub = variable_get('hosting_alias_subdomain', FALSE)) {
    if (!preg_match("/\\.{$sub}\$/", $url)) {
      $alias[] = str_replace(array(
        '-',
        '.',
      ), array(
        '--',
        '-',
      ), $url) . "." . trim($sub, ".");
    }
  }
  if (!preg_match('/^www\\./', $url) && variable_get('hosting_alias_automatic_www', FALSE)) {
    $alias[] = "www." . $url;
  }
  elseif (preg_match('/^www\\./', $url) && variable_get('hosting_alias_automatic_no_www', FALSE)) {
    $alias[] = str_replace("www.", "", $url);
  }
  return $alias;
}