preset_settings.inc
5.3 KB
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
143
144
145
146
147
148
149
150
<?php
function drupalexp_preset_settings_form_alter(&$form){
drupal_add_js(drupal_get_path('theme','drupalexp').'/admin/js/farbtastic.js');
drupal_add_js(drupal_get_path('theme','drupalexp').'/admin/js/presets.js');
drupal_add_css(drupal_get_path('theme','drupalexp').'/admin/css/farbtastic.css');
$theme = drupalexp_get_theme();
$presets = $theme->presets;
if(empty($presets)){
$presets = array(
'drupalexp_presets' => array(
array(
'key' => 'preset1',
'base_color' => '#0072b9',
'text_color' => '#494949',
'link_color' => '#027ac6',
'link_hover_color' => '#027ac6',
'heading_color' => '#2385c2',
),
array(
'key' => 'preset2',
'base_color' => '#464849',
'text_color' => '#494949',
'link_color' => '#2f416f',
'link_hover_color' => '#2f416f',
'heading_color' => '#2a2b2d',
),
array(
'key' => 'preset3',
'base_color' => '#55c0e2',
'text_color' => '#696969',
'link_color' => '#000000',
'link_hover_color' => '#000000',
'heading_color' => '#085360',
),
array(
'key' => 'preset4',
'base_color' => '#d5b048',
'text_color' => '#494949',
'link_color' => '#6c420e',
'link_hover_color' => '#6c420e',
'heading_color' => '#331900',
),
array(
'key' => 'preset5',
'base_color' => '#3f3f3f',
'text_color' => '#000000',
'link_color' => '#336699',
'link_hover_color' => '#336699',
'heading_color' => '#6598cb',
),
array(
'key' => 'preset6',
'base_color' => '#d0cb9a',
'text_color' => '#494949',
'link_color' => '#917803',
'link_hover_color' => '#917803',
'heading_color' => '#efde01',
)
)
);
}else{
$presets = array(
'drupalexp_presets' => $presets,
);
}
drupal_add_js($presets,'setting');
$preset_options = array();
foreach($presets['drupalexp_presets'] as $k=>$p){
$p = (array)$p;
$preset_options[] = $p['key'];
}
$form['preset_settings'] = array(
'#type' => 'fieldset',
'#title' => 'Presets',
'#group' => 'drupalexp_settings',
'#weight' => 1
);
$form['preset_settings']['drupalexp_presets'] = array(
'#type' => 'hidden',
'#default_value' => theme_get_setting('drupalexp_presets'),
);
$form['preset_settings']['drupalexp_default_preset'] = array(
'#type' => 'select',
'#title' => 'Default preset',
'#options' => $preset_options,
'#default_value' => $theme->get('drupalexp_default_preset'),
'#description' => 'Check to set this preset is default',
);
$form['preset_settings']['drupalexp_presets_settings'] = array(
'#type' => 'fieldset',
'#title' => 'Preset settings',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['preset_settings']['drupalexp_presets_settings']['drupalexp_presets_list'] = array(
'#type' => 'select',
'#title' => 'Presets',
'#default_value' => $theme->preset,
'#options' => $preset_options,
);
$default_preset = (array)$presets['drupalexp_presets'][0];
$form['preset_settings']['drupalexp_presets_settings']['drupalexp_preset_key'] = array(
'#type' => 'textfield',
'#title' => 'Preset name',
'#default_value' => $default_preset['key'],
'#description' => 'The css file generated based on this name. e.g: style-[preset_name].css',
'#attributes' => array('data-property'=>'key','class'=>array('preset-option')),
);
$form['preset_settings']['drupalexp_presets_settings']['drupalexp_base_color'] = array(
'#type' => 'textfield',
'#title' => 'Base color',
'#default_value' => $default_preset['base_color'],
'#attributes' => array('data-property'=>'base_color','class'=>array('color','preset-option')),
);
$form['preset_settings']['drupalexp_presets_settings']['drupalexp_base_color_opposite'] = array(
'#type' => 'textfield',
'#title' => 'Opposite Base color',
'#default_value' => isset($default_preset['base_color_opposite'])?$default_preset['base_color_opposite']:$default_preset['base_color'],
'#attributes' => array('data-property'=>'base_color_opposite','class'=>array('color','preset-option')),
);
$form['preset_settings']['drupalexp_presets_settings']['drupalexp_link_color'] = array(
'#type' => 'textfield',
'#title' => 'Link color',
'#default_value' => $default_preset['link_color'],
'#attributes' => array('data-property'=>'link_color','class'=>array('color','preset-option')),
);
$form['preset_settings']['drupalexp_presets_settings']['drupalexp_link_hover_color'] = array(
'#type' => 'textfield',
'#title' => 'Link hover color',
'#default_value' => $default_preset['link_hover_color'],
'#attributes' => array('data-property'=>'link_hover_color','class'=>array('color','preset-option')),
);
$form['preset_settings']['drupalexp_presets_settings']['drupalexp_text_color'] = array(
'#type' => 'textfield',
'#title' => 'Text color',
'#default_value' => $default_preset['text_color'],
'#attributes' => array('data-property'=>'text_color','class'=>array('color','preset-option')),
);
$form['preset_settings']['drupalexp_presets_settings']['drupalexp_heading_color'] = array(
'#type' => 'textfield',
'#title' => 'Headding color',
'#default_value' => $default_preset['heading_color'],
'#attributes' => array('data-property'=>'heading_color','class'=>array('color','preset-option')),
);
$form['preset_settings']['drupalexp_presets_settings']['drupalexp_link_picker'] = array(
'#markup' => '<div id="placeholder"></div>',
);
}