-
Notifications
You must be signed in to change notification settings - Fork 0
/
express_localist_bundle.admin.inc
47 lines (40 loc) · 1.32 KB
/
express_localist_bundle.admin.inc
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
<?php
function express_localist_bundle_config_form($form, &$form_state) {
$form['express_localist_url'] = array(
'#type' => 'textfield',
'#title' => 'Localist URL',
'#description' => 'URL of your Localist Installation.',
'#default_value' => variable_get('express_localist_url', NULL),
);
$options = express_localist_bundle_get_filters();
$form['express_localist_filters'] = array(
'#type' => 'checkboxes',
'#title' => 'Available Filters',
'#description' => 'Choose which Localist filters are available.',
'#default_value' => variable_get('express_localist_filters', array()),
'#options' => $options,
);
// Let system_settings_form_submit run first to variable_set vars.
$form = system_settings_form($form);
return $form;
}
function express_localist_bundle_get_filters() {
$options = array();
$end_point = variable_get('express_localist_url', NULL);
if (!$end_point) {
return array();
}
else {
$end_point .= '/api/2/events/filters';
}
$response = drupal_http_request($end_point);
if ($response->code == '200') {
$options = array();
$categories = array();
$filters = drupal_json_decode($response->data, true);
foreach ($filters as $key => $filter) {
$options[$key] = ucfirst(substr(str_replace('_', ' ', $key), 6));
}
}
return $options;
}