summaryrefslogtreecommitdiffstats
path: root/theme-settings.php
blob: 78edb555e1992e95b5736b9ad366499a8a320825 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
/**
 * @file
 * Functionality for the admin form of the theme.
 */

$path_rijkshuisstijl = drupal_get_path('theme', 'rijkshuisstijl');
  include_once './' . $path_rijkshuisstijl . '/functions/misc.php';

/**
 * Implements hook_form_system_theme_settings_alter().
 */
function rijkshuisstijl_form_system_theme_settings_alter(&$form, $form_state) {
  // Add some stylesheets for the theme settings.
  drupal_add_css(drupal_get_path('theme', 'rijkshuisstijl') . '/styles/theme-settings.css', array(
    'group' => CSS_THEME,
    'weight' => 115,
    'preprocess' => FALSE,
  ));

  // Disable some required display toggles.
  $form['theme_settings']['toggle_logo']['#disabled'] = TRUE;

  // Override the logo path form element with our own logo form element.
  $form['logo']['settings']['logo_path'] = array(
    '#type' => 'select',
    '#title' => t('Custom logo'),
    '#options' => _rijkshuisstijl_defined_logos(),
    '#default_value' => theme_get_setting('logo_path'),
    '#description' => t('Select a custom logo for a specific government agency.'),
  );
  // Remove the logo upload form from the display.
  $form['logo']['settings']['logo_upload']['#access'] = FALSE;

  $form['titlebar'] = array(
    '#type' => 'fieldset',
    '#title' => t('Titlebar settings'),
    '#weight' => -20,
  );

  $form['titlebar']['default_titlebar'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use the default site title and slogan in the titlebar.'),
    '#default_value' => theme_get_setting('default_titlebar', 'rijkshuisstijl'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );

  $form['titlebar']['settings'] = array(
    '#type' => 'container',
    '#states' => array(
      // Hide the titlebar settings when using the default logo.
      'invisible' => array(
        'input[name="default_titlebar"]' => array('checked' => TRUE),
      ),
    ),
  );

  $form['titlebar']['settings']['titlebar_title'] = array(
    '#type' => 'textfield',
    '#title' => t('Custom titlebar title'),
    '#default_value' => theme_get_setting('titlebar_title', 'rijkshuisstijl'),
    '#size' => 60,
    '#maxlength' => 128,
    '#description' => t("Override the titlebar's title with a custom title."),
  );

  $form['titlebar']['settings']['titlebar_slogan'] = array(
    '#type' => 'textfield',
    '#title' => t('Custom titlebar slogan'),
    '#default_value' => theme_get_setting('titlebar_slogan', 'rijkshuisstijl'),
    '#size' => 60,
    '#maxlength' => 128,
    '#description' => t("Override the titlebar's slogan with a custom slogan."),
  );

  $form['color'] = array(
    '#type' => 'fieldset',
    '#title' => t('Color settings'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#weight' => -19,
  );

  $colours = _rijkshuisstijl_defined_colours();
  $colours_assoc = array();
  foreach (_rijkshuisstijl_defined_colours() as $index => $colour) {
    $colours_assoc[$colour] = _rijkshuisstijl_format_color_swatch($colour);
  }

  $form['color']['color_swatch'] = array(
    '#type' => 'radios',
    '#title' => t('Color swatches'),
    '#options' => $colours_assoc,
    '#default_value' => theme_get_setting('color_swatch', 'rijkshuisstijl'),
  );

  $form['system'] = array(
    '#type' => 'fieldset',
    '#title' => t('System settings'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#weight' => -18,
  );

  $form['system']['system_type'] = array(
    '#type' => 'radios',
    '#title' => t('Type'),
    '#default_value' => theme_get_setting('system_type', 'rijkshuisstijl'),
    '#options' => array(
      // @todo This should be defined somewhere else.
      'internet' => 'Internet',
      'intranet' => 'Intranet / External Application',
      'application' => 'Internal Application',
    ),
    // @todo Should the colors be influenced?
    '#description' => t('The choice of %system influenced the layout, the available colors and other theme settings.', array(
      '%system' => 'system',
    )),
  );

  $form['internet_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Internet Settings'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#states' => array(
      'visible' => array(
        ':input[name="system_type"]' => array('value' => 'internet'),
      ),
    ),
    '#weight' => -17,
  );

  $form['internet_settings']['system_width'] = array(
    '#type' => 'radios',
    '#title' => t('Width And Column Behaviour'),
    '#default_value' => theme_get_setting('system_width'),
    '#options' => drupal_map_assoc(array('default', 'wide', 'wider', 'liquid')),
    '#description' => t('Select the behaviour for the sizing of columns.'),
  );
}