function domain_theme_form_alter in Domain Access 5
Same name and namespace in other branches
- 6.2 domain_theme/domain_theme.admin.inc \domain_theme_form_alter()
- 7.3 domain_theme/domain_theme.module \domain_theme_form_alter()
- 7.2 domain_theme/domain_theme.module \domain_theme_form_alter()
Implement hook_form_alter()
File
- domain_theme/
domain_theme_form.inc, line 13 - Include file to handle theme configration screen.
Code
function domain_theme_form_alter($form_id, &$form) {
if ($form_id == 'system_themes') {
// The domain_goto() function assures that we are on the right domain.
global $_domain;
// 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'];
}
// 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 use the default
if ($key == $theme['theme']) {
$form['theme_default']['#default_value'] = variable_get('theme_default', 'garland');
}
unset($form[$key]);
unset($form['status']['#options'][$key]);
unset($form['theme_default']['#options'][$key]);
}
else {
$form['status']['#disabled'] = TRUE;
}
}
// 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. Theme-specific settings must be configured at <a href="!url">the system theme settings page</a>.</p>', array(
'!url' => url('admin/build/themes'),
)),
);
// Which domain are we editing?
$form['domain_id'] = array(
'#type' => 'value',
'#value' => $_domain['domain_id'],
);
// Our submit handlers.
$form['#submit']['domain_theme_submit'] = array();
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Set domain theme'),
);
}
}