-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathec_mapeditor.api.php
More file actions
125 lines (115 loc) · 3.42 KB
/
ec_mapeditor.api.php
File metadata and controls
125 lines (115 loc) · 3.42 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
<?php
/**
* @file
* Documentation for EC mapeditor API.
*/
/**
* @addtogroup hooks
* @{
*/
/**
* Declares a map layer.
*
* Registers the map layer sub module. Defines the name of the map layer type,
* which custom form elements it wants to add to the map and a custom
* JavaScript that can be passed to the Webtools map. The form elements can be
* defined by EC mapeditor layer or other custom layer modules by
* implementing hook_map_form_elements().
*/
function hook_layer_info() {
return array(
'user_layer' => array(
'form_elements' => array(
'popup',
'clustering',
'icon',
'user_picture_icon',
),
'custom_js' => base_path(),
),
);
}
/**
* Declares additional form elements for the map layer form.
*
* Defines custom map layer form elements for a custom map layer. These elements
* are added to the form via hook_layer_info().
*/
function hook_map_form_elements() {
$form_elements = array();
// Defines is username is shown when hovering a marker on the map.
$form_elements['user_picture_icon'] = array(
'#type' => 'container',
'#weight' => 15,
'use_user_picture_icon' => array(
'#type' => 'checkbox',
'#title' => t('Use the user icture as marker icon on the map'),
),
'image_style' => array(
'#type' => 'select',
'#options' => _user_layer_get_image_styles(),
'#title' => t('Image style for the user picture marker icon'),
),
);
return $form_elements;
}
/**
* Alters to content of a map layer.
*
* Lets map layer sub modules changes the content of the map layer. For
* example for adding the map features.
*/
function hook_layer_content_alter(&$content, $wrapper, $entity) {
// Fetches map data from user layer.
if ($entity->type == 'user_layer') {
$settings = drupal_json_decode($wrapper->settings->value());
$users = _user_layer_fetch_users();
if ($users) {
$layers[] = array(
'layer_settings' => $settings,
'label' => $wrapper->title->value(),
'users' => $users,
'id' => _ec_mapeditor_layer_id($wrapper->title->value()),
);
$content['#attached']['js'][] = array(
'data' => array(
'user_layers' => $layers,
),
'type' => 'setting',
);
return $content;
}
}
}
/**
* Alters the map layer settings.
*
* Allows custom map layer modules to change the map layer settings. It can be
* used for example to add more settings to the map layer settings. These
* settings are saved when submitting the map layer via an inline entity form.
* See MapLayerInlineEntityFormController->entityFormSubmit().
*/
function hook_map_layer_settings_alter(&$settings, $map_layer) {
if ($map_layer->type == 'user_layer') {
$settings['user_picture_icon'] = $map_layer->user_picture_icon;
}
return $settings;
}
/**
* Alters the map layer settings.
*
* Allows custom map layer modules to change the map layer settings. It can be
* used for example to add more settings to the map layer settings. These
* settings are saved when submitting the map layer via a stand alone form. See
* ec_mapeditor_layer_form_submit().
*/
function hook_stand_alone_map_layer_settings_alter(&$settings, $form_state) {
if ($form_state['map_layer']->type == 'user_layer') {
$values = $form_state['values'];
$settings['user_picture_icon'] = $values['user_picture_icon'];
}
return $settings;
}
/**
* @} End of "addtogroup hooks".
*/