-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdolpp.module
136 lines (120 loc) · 3.61 KB
/
dolpp.module
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
<?php
/**
* Implementation of hook_openlayers_behaviors().
*
* This is a ctools plugins hook.
*/
function dolpp_openlayers_behaviors() {
return array(
'dolpp_behavior_query' => array(
'title' => t('OL++ Query'),
'description' => t('Adds info boxes on maps clicks.'),
'type' => 'layer',
'path' => drupal_get_path('module', 'dolpp') .'/behaviors',
'file' => 'dolpp_behavior_query.inc',
'behavior' => array(
'class' => 'dolpp_behavior_query',
'parent' => 'openlayers_behavior',
),
),
'dolpp_behavior_legend' => array(
'title' => t('OL++ Legend'),
'description' => t('Adds map legend.'),
'type' => 'layer',
'path' => drupal_get_path('module', 'dolpp') .'/behaviors',
'file' => 'dolpp_behavior_legend.inc',
'behavior' => array(
'class' => 'dolpp_behavior_legend',
'parent' => 'openlayers_behavior',
),
),
'dolpp_behavior_highlight_features' => array(
'title' => t('OL++ Features highlighting'),
'description' => t('Adds feature highlighting.'),
'type' => 'layer',
'path' => drupal_get_path('module', 'dolpp') .'/behaviors',
'file' => 'dolpp_behavior_highlight_features.inc',
'behavior' => array(
'class' => 'dolpp_behavior_highlight_features',
'parent' => 'openlayers_behavior',
),
),
);
}
/**
* Implementation of hook_form_alter().
*
* This is a ctools plugins hook.
*/
function dolpp_form_openlayers_ui_layers_form_alter(&$form, &$form_state) {
$layer_type = $form['layer']['data']['layer_type']['#value'];
// We'll only act upon WMS layers for now
if ( $layer_type != "openlayers_layer_type_wms" ) return;
$olddata = $form['#parameters'][2]->data;
$form['layer']['data']['params']['queryable'] = array (
'#type' => 'checkbox',
'#title' => t('Queryable'),
'#description' => t('Check if this layer supports GetFeatureInfo calls.'),
'#default_value' => isset($olddata['params']['queryable']) ? $olddata['params']['queryable'] : FALSE,
);
$form['layer']['data']['params']['hasLegend'] = array (
'#type' => 'checkbox',
'#title' => t('Has legend'),
'#description' => t('Check if this layer supports a legend.'),
'#default_value' => isset($olddata['params']['hasLegend']) ? $olddata['params']['hasLegend'] : FALSE,
);
}
/**
* Implementation of hook_block().
*/
function dolpp_block($op, $delta = 0) {
switch ($op) {
case 'list':
$blocks = array('dolpplegend' => array('info' => t('OL++ Legend')));
return $blocks;
case 'view':
switch ($delta) {
case 'dolpplegend':
return array(
'subject' => t('Layer legend'),
'content' => theme('dolpp_legend')
);
}
}
}
/**
* Implementation of hook_theme().
*/
function dolpp_theme() {
return array(
'dolpp_legend' => array(
'arguments' => array(),
),
);
}
/*
* Implementation of theme function for legend block
*/
function theme_dolpp_legend() {
return '<div id="dolpp-legend"></div>';
}
/**
* Implementation of hook_ctools_plugin_directory
*/
function dolpp_ctools_plugin_directory($module, $plugin) {
if ($module == 'openlayers' && $plugin == 'style_plugin') {
return 'plugins/style_plugin';
}
}
/**
* Implementation of hook_ctools_plugin_api().
*/
function dolpp_ctools_plugin_api($module, $api) {
// Define plugins for OpenLayers plugins api
if ($module == "openlayers") {
switch ($api) {
case 'openlayers_styles':
return array('version' => 1);
}
}
}