* @link http://www.albin.net
*/
/**
* Implementation of hook_form_alter().
*
* @param string $form_id
* @param &array $form
* @return void
*/
function themesettingsapi_form_alter($form_id, &$form) {
switch ($form_id) {
case 'system_theme_settings':
// Grab the specific name of the theme settings form
$key = $form['var']['#value'];
// Since we are allowing more settings, make logo and favicon collapsible
if ($key == 'theme_settings') {
// Fix for small bug in Drupal 5.1
$form['theme_settings']['#prefix'] = '
'.$form['theme_settings']['#prefix'];
$form['node_info']['#suffix'] = $form['node_info']['#suffix'].'
';
if (isset($form['logo'])) {
unset($form['logo']['#attributes']['class']);
}
}
if (isset($form['logo'])) {
$form['logo']['#collapsible'] = TRUE;
$form['logo']['#collapsed'] = FALSE;
}
if (isset($form['favicon'])) {
$form['favicon']['#collapsible'] = TRUE;
$form['favicon']['#collapsed'] = FALSE;
// Fix for small bug in Drupal 5.1
if (isset($form['favicon']['text']['#value'])) {
$form['favicon']['#descripton'] = $form['favicon']['text']['#value'];
unset($form['favicon']['text']);
}
}
// Move submit buttons to bottom
$form['buttons']['#weight'] = 1;
// On template-specific settings pages...
if ($key != 'theme_settings') {
$theme = str_replace(array('theme_', '_settings'), array('', ''), $key);
// Since we are adding more settings, make logo and favicon collapsed
if (isset($form['logo'])) {
$form['logo']['#collapsed'] = TRUE;
}
if (isset($form['favicon'])) {
$form['favicon']['#collapsed'] = TRUE;
}
// Add template-specific settings
$function = $theme .'_settings';
if (function_exists($function)) {
$group = $function();
$group = is_array($group) ? $group : array();
// So we can make a comparison, add the exact same attributes as system_theme_settings()
$group['#type'] = 'fieldset';
$group['#title'] = t('Theme-specific settings');
$group['#description'] = t('These settings only exist for the %theme theme and all the styles based on it.', array('%theme' => $theme));
// If theme-specific settings are already present, don't double insert the settings
if (!isset($form['specific']) or $group !== $form['specific']) {
// Add form elements
$form['template-specific'] = $group;
// Make collapsible, but not collapsed
$form['template-specific']['#collapsible'] = true;
}
}
}
break;
}
}