You are here

function theme_domain_alias_block in Domain Access 7.2

Same name and namespace in other branches
  1. 6.2 domain_alias/domain_alias.module \theme_domain_alias_block()
  2. 7.3 domain_alias/domain_alias.module \theme_domain_alias_block()

Theme element for the Domain Alias switcher block.

Parameters

$domains: The array of active domains defined by domain_domains().

Return value

HTML output.

2 theme calls to theme_domain_alias_block()
domain_alias_block in domain_alias/domain_alias.module
Implements hook_block().
domain_alias_block_view in domain_alias/domain_alias.module
Implements hook_block_view().

File

domain_alias/domain_alias.module, line 395
Interface for advanced domain matching for Domain Access.

Code

function theme_domain_alias_block($variables) {
  $_domain = domain_get_domain();
  $domains = $variables['domains'];
  $output = '';
  $items = array();
  $msg = FALSE;
  $i = 0;
  $active = NULL;
  foreach ($domains as $domain) {
    if ($domain['valid']) {
      $title = $domain['sitename'];
      $allow = TRUE;
    }
    else {
      $title = $domain['sitename'] . ' *';
      $allow = FALSE;
      if (user_access('access inactive domains')) {
        $msg = TRUE;
        $allow = TRUE;
      }
    }
    if ($allow) {
      if ($domain['domain_id'] == $_domain['domain_id']) {
        $title = '<strong>' . $title . '</strong>';
      }
      $items[$i]['data'] = l($title, domain_get_uri($domain), array(
        'absolute' => TRUE,
        'html' => TRUE,
      ));
      if (!empty($domain['aliases'])) {
        $request = array_reverse(explode('.', $_domain['subdomain']));
        if (isset($_domain['active_alias_id'])) {
          $active = $_domain['active_alias_id'];
        }
        foreach ($domain['aliases'] as $alias_id => $alias) {
          $items[$i]['children'][] = _domain_alias_link($alias, $domain, $request, $active);
        }
      }
      $i++;
    }
  }
  $output .= theme('item_list', array(
    'items' => $items,
  ));
  if ($msg) {
    $output .= t('<em>* Inactive domain.</em>');
  }
  return $output;
}