domain_view()The main administration page, a list of active domains.
A sortable table of active domain records, or an error message.
./domain.admin.inc, line 17
<?php
function domain_view() {
global $_domain;
$output = t('<p>The following domains have been created for your site. The currently active domain <b>is shown in boldface</b>. You
may click on a domain to change the currently active domain. Your default domain has an ID of zero (0).</p>');
$header = array(
array('data' => t('Id'), 'field' => 'd.domain_id'),
array('data' => t('Domain'), 'field' => 'd.subdomain'),
array('data' => t('Site name'), 'field' => 'd.sitename'),
array('data' => t('Status'), 'field' => 'd.valid'),
array('data' => t('Scheme'), 'field' => 'd.scheme'),
);
// Get header elements from other modules
$extra = module_invoke_all('domainview', 'header');
$header = array_merge($header, $extra);
$header[] = array('data' => t('Actions'));
// Cannot use domain_domains() here because we need to sort the output.
$domains = array();
$actions = array();
// Get any select sql from other modules.
$select = module_invoke_all('domainview', 'select');
$select_sql = '';
if (!empty($select)) {
$select_sql = ', '. implode(', ', $select);
$select_sql = rtrim($select_sql, ',');
}
// Get any tablesort sql from other modules.
$join = module_invoke_all('domainview', 'join');
$join_sql = '';
if (!empty($join)) {
$join_sql = ' '. implode(' ', $join);
}
$sql = 'SELECT d.*'. $select_sql .' FROM {domain} d'. $join_sql . tablesort_sql($header);
$result = pager_query($sql, variable_get('domain_list_size', DOMAIN_LIST_SIZE));
while ($data = db_fetch_array($result)) {
$domains[] = $data;
}
foreach ($domains as $domain) {
// Let submodules overwrite the defaults, if they wish.
$domain = domain_api($domain);
$link = l($domain['subdomain'], domain_get_uri($domain), array('absolute' => TRUE));
if ($domain['domain_id'] == 0) {
// Grab any extra elements defined by other modules. If so, allow configuration.
$extra = array();
if (module_exists('domain_conf')) {
$extra = domain_conf_api();
}
if (!empty($extra)) {
$actions[] = l(t('settings'), 'admin/build/domain/conf/0');
}
}
else {
$actions = array();
$actions[] = l(t('edit'), 'admin/build/domain/edit/'. $domain['domain_id']);
$actions[] = l(t('delete'), 'admin/build/domain/delete/'. $domain['domain_id']);
}
// Add advanced settings from other modules.
$items = array();
$items = module_invoke_all('domainlinks', $domain);
if (!empty($items)) {
foreach ($items as $item) {
if (!empty($item)) {
$actions[] = l($item['title'], $item['path']);
}
}
}
// Set the valid flag.
($domain['valid'] == 1) ? $valid = t('Active') : $valid = t('Inactive');
$row = array($domain['domain_id'], ($domain['domain_id'] == $_domain['domain_id']) ? '<b>'. $link .'</b>' : $link, filter_xss_admin($domain['sitename']), $valid, $domain['scheme']);
// Let other modules add data.
foreach (module_implements('domainview') as $module) {
$row[] = module_invoke($module, 'domainview', 'data', $domain);
}
// Add the actions.
$row[] = theme('item_list', $actions);
$rows[] = $row;
}
if (!empty($rows)) {
$output .= theme_table($header, $rows);
$output .= theme('pager', NULL, variable_get('domain_list_size', DOMAIN_LIST_SIZE), 0);
return $output;
}
else {
return t('No domains have been configured.');
}
}
?>