-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathckan.admin.inc
executable file
·125 lines (105 loc) · 3.17 KB
/
ckan.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
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
<?php
/**
* Implements settings form
*/
function ckan_admin_settings_form($form_state) {
$arrvoc=getallvocabularies();
$form['url'] = array(
'#title' => t('Url'),
'#type' => 'textfield',
'#default_value' => variable_get('ckan_url'),
'#required' => TRUE,
);
$form['apikey'] = array(
'#title' => t('Api key'),
'#type' => 'textfield',
'#default_value' => variable_get('ckan_api'),
);
$form['tags'] = array(
'#type' => 'select',
'#title' => t('List of vocabularies'),
'#options' => $arrvoc,
'#required' => TRUE,
'#default_value' => variable_get('ckan_tagsvocab')
);
$form['frequence'] = array(
'#type' => 'select',
'#title' => t('frequence'),
'#options' => $arrvoc,
'#default_value' => variable_get('ckan_frequencevocab')
);
$form['qualite'] = array(
'#type' => 'select',
'#title' => t('qualite'),
'#options' => $arrvoc,
'#default_value' => variable_get('ckan_qualitevocab')
);
$form['granularite'] = array(
'#type' => 'select',
'#title' => t('granualite'),
'#options' => $arrvoc,
'#default_value' => variable_get('ckan_granularitevocab')
);
/* $form['categorie'] = array(
'#type' => 'select',
'#title' => t('categorie'),
'#options' => $arrvoc,
'#default_value' => variable_get('ckan_categorievocab')
);*/
$form['concept'] = array(
'#type' => 'select',
'#title' => t('concept'),
'#options' => $arrvoc,
'#default_value' => variable_get('ckan_conceptvocab')
);
$form['geo'] = array(
'#type' => 'select',
'#title' => t('Geographical granularity'),
'#options' => $arrvoc,
'#default_value' => variable_get('ckan_geographicvocab')
);
$form['licence'] = array(
'#type' => 'select',
'#title' => t('Licence'),
'#options' => $arrvoc,
'#default_value' => variable_get('ckan_licencevocab')
);
$form['#submit'][] = 'ckan_admin_settings_form_submit';
return system_settings_form($form);
}
function getallvocabularies(){
$query = db_select('taxonomy_vocabulary',"l")->fields('l', array('vid','name'));
$result = $query->execute();
foreach($result as $r)$arrvoc[$r->vid]=$r->name;
return $arrvoc;
}
/**
* Implements _form_validate().
*/
function ckan_admin_settings_form_validate($form, &$form_state) {
}
/**
* Implements _form_submit().
*/
function ckan_admin_settings_form_submit($form, &$form_state) {
$url=$form_state['values']['url'];
variable_set('ckan_url', $url);
$apikey=$form_state['values']['apikey'];
variable_set('ckan_api', $apikey);
$tags=$form_state['values']['tags'];
variable_set('ckan_tagsvocab', $tags);
$frequence=$form_state['values']['frequence'];
variable_set('ckan_frequencevocab', $frequence);
$concept=$form_state['values']['concept'];
variable_set('ckan_conceptvocab', $concept);
//$categorie=$form_state['values']['categorie'];
//variable_set('ckan_categorievocab', $categorie);
$qualite=$form_state['values']['qualite'];
variable_set('ckan_qualitevocab', $qualite);
$granularite=$form_state['values']['granularite'];
variable_set('ckan_granularitevocab', $granularite);
$geo=$form_state['values']['geo'];
variable_set('ckan_geographicvocab', $geo);
$geo=$form_state['values']['licence'];
variable_set('ckan_licencevocab', $geo);
}