You are here

function domain_theme_form in Domain Access 7.3

Same name and namespace in other branches
  1. 7.2 domain_theme/domain_theme.admin.inc \domain_theme_form()

Form callback to set theme per domain.

Parameters

$domain: The $domain object created by domain_lookup().

Return value

An HTML form.

1 string reference to 'domain_theme_form'
domain_theme_page in domain_theme/domain_theme.admin.inc
The domain theme page callback router.

File

domain_theme/domain_theme.admin.inc, line 47
Include file to handle theme configuration screen

Code

function domain_theme_form($form, &$form_state, $domain) {
  $form = array();

  // Get the current $theme for this domain, if available.
  $theme = domain_theme_lookup($domain['domain_id']);
  if ($theme['theme']) {
    $default = $theme['theme'];
  }
  else {
    $default = variable_get('theme_default', 'bartik');
    drupal_set_message(t('No theme has been set for this domain. It will use the default theme settings.'), 'status', FALSE);
  }

  // Message to users.
  $form['intro'] = array(
    '#markup' => t('<p>Select the default theme for this domain. You may only select themes <a href="!url">activated for all sites</a>.</p>', array(
      '!url' => url('admin/appearance'),
    )) . theme_domain_theme_reset(array(
      'domain' => $domain,
    )),
  );

  // Which domain are we editing?
  $form['domain_id'] = array(
    '#type' => 'value',
    '#value' => $domain['domain_id'],
  );
  $themes = system_rebuild_theme_data();
  $form['theme'] = array(
    '#tree' => TRUE,
    '#description' => t('To enable additional themes, <a href="!url">configure them globally</a>', array(
      '!url' => url('admin/appearance'),
    )),
  );
  foreach ($themes as $key => $theme) {
    if ($theme->status) {
      $form['theme'][$key] = array(
        '#type' => 'radio',
        '#return_value' => $key,
        '#parents' => array(
          'theme',
        ),
        '#default_value' => $key == $default ? $key : FALSE,
      );
    }
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Set domain theme'),
  );
  return $form;
}