110a111,125
> function my_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'), 'colspan' => 6);
111a127,204
>   // 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);
>   }
> 
>   global $user;
>   $sql = 'SELECT d.* FROM {domain} d INNER JOIN domain_editor e ON d.domain_id=e.domain_id WHERE uid = '. $user->uid;
>   $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('data' => t('primary'), 'colspan' => 2);
>       }
>     }
>     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']);
>           }
>           else {
>             $actions[] = '<br />';
>           }
>         }
>       }
>     // 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.
>     $rows[] = array_merge($row, $actions);
>   }
>   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.');
>   }
> }
