Révision 136a805a
Ajouté par Assos Assos il y a plus de 7 ans
drupal7/sites/all/modules/panels/panels_ipe/plugins/display_renderers/panels_renderer_ipe.class.php | ||
---|---|---|
7 | 7 |
// The IPE operates in normal render mode, not admin mode. |
8 | 8 |
var $admin = FALSE; |
9 | 9 |
|
10 |
// Whether or not the user has access. |
|
11 |
var $access = NULL; |
|
12 |
|
|
13 |
function invoke_panels_ipe_access() { |
|
14 |
if (user_access('bypass access in place editing')) { |
|
15 |
return TRUE; |
|
16 |
} |
|
17 |
// Modules can return TRUE, FALSE or NULL, for allowed, disallowed, |
|
18 |
// or don't care - respectively. On the first FALSE, we deny access, |
|
19 |
// otherwise allow. |
|
20 |
foreach (module_invoke_all('panels_ipe_access', $this->display) as $result) { |
|
21 |
if ($result === FALSE) { |
|
22 |
return FALSE; |
|
23 |
} |
|
24 |
} |
|
25 |
return TRUE; |
|
26 |
} |
|
27 |
|
|
28 |
function access() { |
|
29 |
if (is_null($this->access)) { |
|
30 |
$this->access = $this->invoke_panels_ipe_access(); |
|
31 |
} |
|
32 |
return $this->access; |
|
33 |
} |
|
34 |
|
|
10 | 35 |
function render() { |
11 | 36 |
$output = parent::render(); |
12 |
return "<div id='panels-ipe-display-{$this->clean_key}' class='panels-ipe-display-container'>$output</div>"; |
|
37 |
if ($this->access()) { |
|
38 |
return "<div id='panels-ipe-display-{$this->clean_key}' class='panels-ipe-display-container'>$output</div>"; |
|
39 |
} |
|
40 |
return $output; |
|
13 | 41 |
} |
14 | 42 |
|
15 | 43 |
function add_meta() { |
44 |
if (!$this->access()) { |
|
45 |
return parent::add_meta(); |
|
46 |
} |
|
47 |
|
|
16 | 48 |
ctools_include('display-edit', 'panels'); |
17 | 49 |
ctools_include('content'); |
18 | 50 |
|
... | ... | |
42 | 74 |
'#suffix' => '</div>', |
43 | 75 |
); |
44 | 76 |
|
45 |
panels_ipe_toolbar_add_button($this->clean_key, 'panels-ipe-startedit', $button);
|
|
77 |
panels_ipe_toolbar_add_button($this->display->cache_key, 'panels-ipe-startedit', $button);
|
|
46 | 78 |
|
47 | 79 |
// @todo this actually should be an IPE setting instead. |
48 | 80 |
if (user_access('change layouts in place editing')) { |
... | ... | |
63 | 95 |
'#suffix' => '</div>', |
64 | 96 |
); |
65 | 97 |
|
66 |
panels_ipe_toolbar_add_button($this->clean_key, 'panels-ipe-change-layout', $button);
|
|
98 |
panels_ipe_toolbar_add_button($this->display->cache_key, 'panels-ipe-change-layout', $button);
|
|
67 | 99 |
} |
68 | 100 |
|
69 | 101 |
ctools_include('ajax'); |
... | ... | |
72 | 104 |
|
73 | 105 |
ctools_add_css('panels_dnd', 'panels'); |
74 | 106 |
ctools_add_css('panels_admin', 'panels'); |
107 |
ctools_add_js('panels-base', 'panels'); |
|
75 | 108 |
ctools_add_js('panels_ipe', 'panels_ipe'); |
76 | 109 |
ctools_add_css('panels_ipe', 'panels_ipe'); |
77 | 110 |
|
... | ... | |
95 | 128 |
if (empty($output)) { |
96 | 129 |
return; |
97 | 130 |
} |
131 |
if (!$this->access()) { |
|
132 |
return $output; |
|
133 |
} |
|
98 | 134 |
|
99 | 135 |
// If there are region locks, add them. |
100 | 136 |
if (!empty($pane->locks['type']) && $pane->locks['type'] == 'regions') { |
... | ... | |
137 | 173 |
} |
138 | 174 |
|
139 | 175 |
function prepare_panes($panes) { |
176 |
if (!$this->access()) { |
|
177 |
return parent::prepare_panes($panes); |
|
178 |
} |
|
179 |
|
|
140 | 180 |
// Set to admin mode just for this to ensure all panes are represented. |
141 | 181 |
$this->admin = TRUE; |
142 | 182 |
$panes = parent::prepare_panes($panes); |
... | ... | |
144 | 184 |
} |
145 | 185 |
|
146 | 186 |
function render_pane_content(&$pane) { |
187 |
if (!$this->access()) { |
|
188 |
return parent::render_pane_content($pane); |
|
189 |
} |
|
190 |
|
|
147 | 191 |
if (!empty($pane->shown) && panels_pane_access($pane, $this->display)) { |
148 | 192 |
$content = parent::render_pane_content($pane); |
149 | 193 |
} |
... | ... | |
174 | 218 |
* @param $panes |
175 | 219 |
*/ |
176 | 220 |
function render_region($region_id, $panes) { |
221 |
if (!$this->access()) { |
|
222 |
return parent::render_region($region_id, $panes); |
|
223 |
} |
|
224 |
|
|
177 | 225 |
// Generate this region's 'empty' placeholder pane from the IPE plugin. |
178 | 226 |
$empty_ph = theme('panels_ipe_placeholder_pane', array('region_id' => $region_id, 'region_title' => $this->plugins['layout']['regions'][$region_id])); |
179 | 227 |
|
... | ... | |
211 | 259 |
// Break the lock. |
212 | 260 |
panels_edit_cache_break_lock($this->cache); |
213 | 261 |
} |
262 |
} |
|
263 |
|
|
264 |
function get_panels_storage_op_for_ajax($method) { |
|
265 |
switch ($method) { |
|
266 |
case 'ajax_unlock_ipe': |
|
267 |
case 'ajax_save_form': |
|
268 |
return 'update'; |
|
269 |
case 'ajax_change_layout': |
|
270 |
case 'ajax_set_layout': |
|
271 |
return 'change layout'; |
|
272 |
} |
|
273 |
|
|
274 |
return parent::get_panels_storage_op_for_ajax($method); |
|
214 | 275 |
} |
215 | 276 |
|
216 | 277 |
/** |
... | ... | |
322 | 383 |
// Filter out builders |
323 | 384 |
$layouts = array_filter($layouts, '_panels_builder_filter'); |
324 | 385 |
|
386 |
// Let other modules filter the layouts. |
|
387 |
drupal_alter('panels_layouts_available', $layouts); |
|
388 |
|
|
325 | 389 |
// Define the current layout |
326 | 390 |
$current_layout = $this->plugins['layout']['name']; |
327 | 391 |
|
Formats disponibles : Unified diff
Weekly update of contrib modules