| 1 |
<?php
|
| 2 |
// $Id: themesettingsapi.admin.inc,v 1.1 2007/11/25 18:25:58 johnalbin Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Extends the custom theme settings API in Drupal 6.
|
| 7 |
*
|
| 8 |
* @author John Albin Wilkins (JohnAlbin) <john at albin dot net>
|
| 9 |
* @link http://www.albin.net
|
| 10 |
*/
|
| 11 |
|
| 12 |
/**
|
| 13 |
* Implementation of hook_form_alter().
|
| 14 |
*
|
| 15 |
* @param &array $form
|
| 16 |
* @param array $form_state
|
| 17 |
* @param string $form_id
|
| 18 |
* @return void
|
| 19 |
*/
|
| 20 |
function themesettingsapi_form_alter(&$form, $form_state, $form_id) {
|
| 21 |
switch ($form_id) {
|
| 22 |
case 'system_theme_settings':
|
| 23 |
// Grab the specific name of the theme settings form
|
| 24 |
$key = $form['var']['#value'];
|
| 25 |
$key = ($key == 'theme_settings') ? '' : preg_replace('/(^theme_|_settings$)/', '', $key);
|
| 26 |
|
| 27 |
// Since we are allowing more settings, make logo and favicon collapsible
|
| 28 |
if (empty($key)) {
|
| 29 |
// Fix for small bug in Drupal core
|
| 30 |
$form['theme_settings']['#prefix'] = '<div class="clear-block">'. $form['theme_settings']['#prefix'];
|
| 31 |
$form['node_info']['#suffix'] = $form['node_info']['#suffix'] .'</div>';
|
| 32 |
if (isset($form['logo'])) {
|
| 33 |
unset($form['logo']['#attributes']['class']);
|
| 34 |
}
|
| 35 |
}
|
| 36 |
if (isset($form['logo'])) {
|
| 37 |
$form['logo']['#collapsible'] = TRUE;
|
| 38 |
$form['logo']['#collapsed'] = $key ? TRUE : FALSE;
|
| 39 |
}
|
| 40 |
if (isset($form['favicon'])) {
|
| 41 |
$form['favicon']['#collapsible'] = TRUE;
|
| 42 |
$form['favicon']['#collapsed'] = $key ? TRUE : FALSE;
|
| 43 |
}
|
| 44 |
|
| 45 |
// If the administration theme is not used, switch themes when displaying the theme settings.
|
| 46 |
if ($key and (variable_get('admin_theme', '0') == '0' or variable_get('theme_settings_admin_theme', '1') == '0')) {
|
| 47 |
global $custom_theme;
|
| 48 |
$custom_theme = $key;
|
| 49 |
init_theme();
|
| 50 |
}
|
| 51 |
break;
|
| 52 |
|
| 53 |
case 'system_admin_theme_settings':
|
| 54 |
// Add a setting to allow theme switching even with an admin theme
|
| 55 |
$form['theme_settings_admin_theme'] = array(
|
| 56 |
'#type' => 'checkbox',
|
| 57 |
'#title' => t('Use administration theme when configuring theme settings'),
|
| 58 |
'#description' => t('If this setting is disabled or if using the "System default" theme, the theme settings pages will be switched to the theme being configured.'),
|
| 59 |
'#default_value' => variable_get('theme_settings_admin_theme', '1'),
|
| 60 |
);
|
| 61 |
|
| 62 |
// Move submit buttons to bottom
|
| 63 |
$form['buttons']['#weight'] = 1;
|
| 64 |
break;
|
| 65 |
}
|
| 66 |
}
|