function domain_theme_form_system_themes_form_alter in Domain Access 6.2
Implement hook_form_alter().
Since we have this in an include file, it is only called by our module's invocation of this form.
File
- domain_theme/
domain_theme.admin.inc, line 46 - Include file to handle theme configration screen
Code
function domain_theme_form_system_themes_form_alter(&$form, &$form_state) {
$domain_id = arg(4);
$domain = domain_load($domain_id);
if ($domain == -1) {
return drupal_access_denied();
}
// Get the current $theme for this domain, if available.
$theme = domain_theme_lookup($domain['domain_id']);
if ($theme['theme']) {
$form['theme_default']['#default_value'] = $theme['theme'];
}
else {
$form['theme_default']['#default_value'] = '';
if (empty($_POST)) {
drupal_set_message(t('No theme has been set for this domain.'));
}
}
// Unset options that are not allowed.
$available = $form['status']['#options'];
$allowed = $form['status']['#default_value'];
foreach ($available as $key => $value) {
if (!in_array($key, $allowed)) {
// If the theme was disabled, then we have to set a new default
if ($key == $theme['theme']) {
$form['theme_default']['#default_value'] = '';
if (empty($_POST)) {
drupal_set_message(t('The chosen theme is no longer available for this domain.'), 'status', FALSE);
}
}
unset($form[$key]);
unset($form['status']['#options'][$key]);
unset($form['theme_default']['#options'][$key]);
}
else {
$form['status']['#disabled'] = TRUE;
}
if (isset($form[$key]) && isset($form[$key]['operations'])) {
$form[$key]['operations'] = array(
'#value' => l(t('configure'), 'admin/build/domain/theme/' . $key . '/' . $domain['domain_id'] . '/theme-settings'),
);
}
}
// Use our own submit buttons.
$unset = array(
'buttons',
'#submit',
);
foreach ($unset as $key) {
unset($form[$key]);
}
// Message to users.
$form['intro'] = array(
'#value' => t('<p>Select the default theme for this domain.</p>'),
);
// Which domain are we editing?
$form['domain_id'] = array(
'#type' => 'value',
'#value' => $domain['domain_id'],
);
// Our submit handlers.
$form['#submit'][] = 'domain_theme_submit';
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Set domain theme'),
);
}