You are here

function hosting_alias_automatic_aliases in Hosting 6.2

Same name and namespace in other branches
  1. 5 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 based on the global options.

1 call to hosting_alias_automatic_aliases()
hosting_alias_insert in alias/hosting_alias.module
Save stored aliases for a new site.

File

alias/hosting_alias.module, line 490
Allow sites to have domain aliases that they can be accessed with.

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;
}