function domain_view in Domain Access 5
Same name and namespace in other branches
- 6.2 domain.admin.inc \domain_view()
- 7.2 domain.admin.inc \domain_view()
The main administration page, a list of active domains.
Return value
A sortable table of active domain records, or an error message.
File
- ./
domain_admin.inc, line 17 - Administration functions for the domain module.
Code
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) and is always
at the top of the list below.</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();
$domains[] = domain_default();
// 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, 24);
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(), NULL, NULL, TRUE);
if ($domain['domain_id'] == 0) {
$actions = l(t('Default settings'), 'admin/build/domain/settings');
// Grab any extra elements defined by other modules. If so, allow configuration.
if (module_exists('domain_conf')) {
$extra = array();
$extra = domain_conf_api();
if (!empty($extra)) {
$actions .= ' | ' . l(t('settings'), 'admin/build/domain/conf/0');
}
}
}
else {
$actions = l(t('edit'), 'admin/build/domain/edit/' . $domain['domain_id']);
// Add advanced settings from other modules.
$items = array();
$items = module_invoke_all('domainlinks', $domain);
if (!empty($items)) {
foreach ($items as $item) {
$actions .= ' | ' . l($item['title'], $item['path']);
}
}
$actions .= ' | ' . l(t('delete'), 'admin/build/domain/delete/' . $domain['domain_id']);
}
// Set the valid flag.
$domain['valid'] == 1 ? $valid = t('Active') : ($valid = t('Inactive'));
$row = array(
$domain['domain_id'],
$domain['subdomain'] == $_domain['subdomain'] ? '<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[] = $actions;
$rows[] = $row;
}
if (!empty($rows)) {
$output .= theme_table($header, $rows);
$output .= theme('pager', NULL, 24, 0);
return $output;
}
else {
return t('No domains have been configured.');
}
}