-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfieldable_panels_panes.api.php
More file actions
176 lines (165 loc) · 5.01 KB
/
fieldable_panels_panes.api.php
File metadata and controls
176 lines (165 loc) · 5.01 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
/**
* @file
* Hooks provided by the Fieldable Panels Panes module.
*/
/**
* @addtogroup hooks
* @{
*/
/**
* Respond to fieldable panels pane deletion.
*
* @param $panels_pane
* The fieldable panels pane that is being deleted.
*
* @ingroup fieldable_panels_pane_api_hooks
*/
function hook_fieldable_panels_pane_delete($panels_pane) {
db_delete('mytable')
->condition('fpid', $panels_pane->fpid)
->execute();
}
/**
* Respond to creation of a new fieldable panels pane.
*
* @param $panels_pane
* The fieldable that is being created.
*
* @ingroup fieldable_panels_pane_api_hooks
*/
function hook_fieldable_panels_pane_insert($panels_pane) {
db_insert('mytable')
->fields(array(
'fpid' => $panels_pane->fpid,
'vid' => $panels_pane->vid,
))
->execute();
}
/**
* Act on a fieldable panels pane being inserted or updated.
*
* @param $panels_pane
* The fieldable panels pane that is being inserted or updated.
*
* @ingroup fieldable_panels_pane_api_hooks
*/
function hook_fieldable_panels_pane_presave($panels_pane) {
// @todo: Needs example.
}
/**
* Respond to updates to a fieldable panels pane.
*
* @param $panels_pane
* The fieldable panels pane that is being updated.
*
* @ingroup fieldable_panels_pane_api_hooks
*/
function hook_fieldable_panels_pane_update($panels_pane) {
db_update('mytable')
->fields(array('fpid' => $panels_pane->fpid))
->condition('vid', $panels_pane->vid)
->execute();
}
/**
* Act on a fieldable panels pane that is being assembled before rendering.
*
* @param $panels_pane
* The fieldable panels pane that is being assembled for rendering.
* @param $view_mode
* The $view_mode parameter.
* @param $langcode
* The language code used for rendering.
*
* @see hook_entity_view()
*
* @ingroup fieldable_panels_pane_api_hooks
*/
function hook_fieldable_panels_pane_view($panels_pane, $view_mode, $langcode) {
$panels_pane->content['my_additional_field'] = array(
'#markup' => $additional_field,
'#weight' => 10,
'#theme' => 'mymodule_my_additional_field',
);
}
/**
* All the list of CTools plugin specs for FPP objects to be modified.
*
* @param array $types
* All of the CTools plugin specifications for these FPP objects.
* @param string $bundle
* The FPP bundle.
* @param array $entities
* All of the FPP entities for this bundle indexed by their CTools subtype,
* e.g. fpid:123, vid:123, uuid:123.
*/
function hook_fieldable_panels_panes_content_types_alter(&$types, $bundle, $entities) {
foreach ($types as $name => &$type) {
$type['icon'] = 'icon_funnyface.png';
}
}
/**
* Allow other modules to control access to Fieldable Panels Pane objects.
*
* @param string $op
* The operation to be performed.
* @param $entity
* The fieldable panels pane that is being accessed.
* @param $account
* The user account whose access should be checked.
*
* @return TRUE|FALSE|NULL
* Returns TRUE to allow access, FALSE to deny, or NULL to pass the access
* decision off to the next hook or the module itself.
*
* @ingroup fieldable_panels_pane_api_hooks
*/
function hook_fieldable_panels_panes_access($op, $entity = NULL, $account = NULL) {
// Example implementation which restricts access to edit reusable panes.
if ($op == 'update' && !empty($entity) && $entity->reusable && !user_access('administer fieldable panels panes')) {
return FALSE;
}
return NULL;
}
/**
* Allow other modules to modify access to the Fieldable Panels Pane CTools content type.
*
* @param boolean $return
* Value to determine if edit access is granted to FPP entity.
* @param array $content_type
* The CTools content type plugin.
* @param array $subtype
* The individual FPP entity being evaluated for edit access.
* @param array $view_mode
* The view mode of the FPP entity being evaluated for edit access.
*
*/
function hook_fieldable_panels_pane_content_type_edit_form_access_alter(&$return, $content_type, $subtype, $view_mode) {
// For button and quote FPP bundles, deny edit access from Panels.
if ($subtype['bundle'] == 'button' || $subtype['bundle'] == 'quote') {
$return = FALSE;
}
}
/**
* Allow other modules to modify the Fieldable Panels Pane CTools content type.
*
* @param array $content_type
* The individual content type to be returned.
* @param string $subtype_id
* The subtype id of the fieldable panel pane being altered for render.
* @param array $plugin
* The CTools content type plugin.
*
*/
function hook_fieldable_panels_pane_content_type_alter(&$content_type, $subtype_id, $plugin) {
// For button FPP bundles, always show the latest revision.
if ($content_type['bundle'] == 'button' && substr( $subtype_id, 0, 4 ) === "vid:") {
$vid = substr($subtype_id, strpos($subtype_id, ":") + 1);
$fpid = db_query('SELECT f.fpid FROM {fieldable_panels_panes} f WHERE f.vid = :vid', array(':vid' => $vid))->fetchField();
$content_type['name'] = 'fpid:' . $fpid;
$content_type['entity_id'] = 'fpid:' . $fpid;
}
}
/**
* @} End of "addtogroup hooks".
*/