Révision 64156087
Ajouté par Assos Assos il y a plus de 7 ans
drupal7/sites/all/modules/panels/panels.module | ||
---|---|---|
1 | 1 |
<?php |
2 | 2 |
|
3 | 3 |
/** |
4 |
* @file panels.module |
|
5 |
* |
|
4 |
* @file |
|
6 | 5 |
* Core functionality for the Panels engine. |
7 | 6 |
*/ |
8 | 7 |
|
... | ... | |
23 | 22 |
define('PANELS_VERSION', '7.x-3.8'); |
24 | 23 |
|
25 | 24 |
|
26 |
define('PANELS_TITLE_FIXED', 0); // Hide title use to be true/false. So false remains old behavior. |
|
27 |
define('PANELS_TITLE_NONE', 1); // And true meant no title. |
|
28 |
define('PANELS_TITLE_PANE', 2); // And this is the new behavior, where the title field will pick from a pane. |
|
25 |
// Hide title use to be TRUE/FALSE. So FALSE remains old behavior. |
|
26 |
define('PANELS_TITLE_FIXED', 0); |
|
27 |
// And TRUE meant no title. |
|
28 |
define('PANELS_TITLE_NONE', 1); |
|
29 |
// And this is the new behavior, where the title field will pick from a pane. |
|
30 |
define('PANELS_TITLE_PANE', 2); |
|
29 | 31 |
|
30 | 32 |
/** |
31 | 33 |
* Returns the API version of Panels. This didn't exist in 1. |
32 | 34 |
* |
33 | 35 |
* @todo -- this should work more like the CTools API version. |
34 | 36 |
* |
35 |
* @return An array with the major and minor versions |
|
37 |
* @return array |
|
38 |
* An array with the major and minor versions |
|
36 | 39 |
*/ |
37 | 40 |
function panels_api_version() { |
38 | 41 |
return array(3, 1); |
39 | 42 |
} |
40 | 43 |
|
41 |
// -------------------------------------------------------------------------- |
|
42 |
// Core Drupal hook implementations |
|
43 |
|
|
44 | 44 |
/** |
45 |
* Implementation of hook_theme()
|
|
45 |
* Implements hook_theme().
|
|
46 | 46 |
*/ |
47 | 47 |
function panels_theme() { |
48 | 48 |
// Safety: go away if CTools is not at an appropriate version. |
... | ... | |
52 | 52 |
|
53 | 53 |
$theme = array(); |
54 | 54 |
$theme['panels_layout_link'] = array( |
55 |
'variables' => array('title' => NULL, 'id' => NULL, 'image' => NULL, 'link' => NULL, 'class' => NULL), |
|
55 |
'variables' => array( |
|
56 |
'title' => NULL, |
|
57 |
'id' => NULL, |
|
58 |
'image' => NULL, |
|
59 |
'link' => NULL, |
|
60 |
'class' => NULL, |
|
61 |
), |
|
56 | 62 |
); |
57 | 63 |
$theme['panels_layout_icon'] = array( |
58 |
'variables' => array('id' => NULL, 'image' => NULL, 'title' => NULL), |
|
64 |
'variables' => array( |
|
65 |
'id' => NULL, |
|
66 |
'image' => NULL, |
|
67 |
'title' => NULL, |
|
68 |
), |
|
59 | 69 |
); |
60 | 70 |
$theme['panels_pane'] = array( |
61 |
'variables' => array('content' => array(), 'pane' => array(), 'display' => array()), |
|
71 |
'variables' => array( |
|
72 |
'content' => array(), |
|
73 |
'pane' => array(), |
|
74 |
'display' => array(), |
|
75 |
), |
|
62 | 76 |
'path' => drupal_get_path('module', 'panels') . '/templates', |
63 | 77 |
'template' => 'panels-pane', |
64 | 78 |
); |
... | ... | |
92 | 106 |
); |
93 | 107 |
|
94 | 108 |
$theme['panels_add_content_modal'] = array( |
95 |
'variables' => array('renderer' => NULL, 'categories' => array(), 'region' => NULL, 'category' => NULL, 'column_count' => 2), |
|
109 |
'variables' => array( |
|
110 |
'renderer' => NULL, |
|
111 |
'categories' => array(), |
|
112 |
'region' => NULL, |
|
113 |
'category' => NULL, |
|
114 |
'column_count' => 2, |
|
115 |
), |
|
96 | 116 |
'path' => drupal_get_path('module', 'panels') . '/templates', |
97 | 117 |
'file' => '../includes/add-content.inc', |
98 | 118 |
'template' => 'panels-add-content-modal', |
99 | 119 |
); |
100 | 120 |
|
101 | 121 |
$theme['panels_add_content_link'] = array( |
102 |
'variables' => array('renderer' => NULL, 'region' => NULL, 'content_type' => NULL), |
|
122 |
'variables' => array( |
|
123 |
'renderer' => NULL, |
|
124 |
'region' => NULL, |
|
125 |
'content_type' => NULL, |
|
126 |
), |
|
103 | 127 |
'path' => drupal_get_path('module', 'panels') . '/templates', |
104 | 128 |
'file' => '../includes/add-content.inc', |
105 | 129 |
'template' => 'panels-add-content-link', |
106 | 130 |
); |
107 | 131 |
|
108 |
// We don't need layout and style themes in maintenance mode. |
|
109 |
// Disabling this: See http://drupal.org/node/979912 for information. |
|
110 |
// if (defined('MAINTENANCE_MODE')) { |
|
111 |
// return $theme; |
|
112 |
// } |
|
113 |
|
|
114 | 132 |
// Register layout and style themes on behalf of all of these items. |
115 | 133 |
ctools_include('plugins', 'panels'); |
116 | 134 |
|
... | ... | |
121 | 139 |
foreach (array('theme', 'admin theme') as $callback) { |
122 | 140 |
if (!empty($data[$callback])) { |
123 | 141 |
$theme[$data[$callback]] = array( |
124 |
'variables' => array('css_id' => NULL, 'content' => NULL, 'settings' => NULL, 'display' => NULL, 'layout' => NULL, 'renderer' => NULL), |
|
142 |
'variables' => array( |
|
143 |
'css_id' => NULL, |
|
144 |
'content' => NULL, |
|
145 |
'settings' => NULL, |
|
146 |
'display' => NULL, |
|
147 |
'layout' => NULL, |
|
148 |
'renderer' => NULL, |
|
149 |
), |
|
125 | 150 |
'path' => $data['path'], |
126 | 151 |
'file' => $data['file'], |
127 | 152 |
); |
128 | 153 |
|
129 |
// if no theme function exists, assume template.
|
|
154 |
// If no theme function exists, assume template.
|
|
130 | 155 |
if (!function_exists("theme_$data[theme]")) { |
131 | 156 |
$theme[$data[$callback]]['template'] = str_replace('_', '-', $data[$callback]); |
132 |
$theme[$data[$callback]]['file'] = $data['file']; // for preprocess. |
|
157 |
// For preprocess. |
|
158 |
$theme[$data[$callback]]['file'] = $data['file']; |
|
133 | 159 |
} |
134 | 160 |
} |
135 | 161 |
} |
... | ... | |
139 | 165 |
foreach ($styles as $name => $data) { |
140 | 166 |
if (!empty($data['render pane'])) { |
141 | 167 |
$theme[$data['render pane']] = array( |
142 |
'variables' => array('content' => NULL, 'pane' => NULL, 'display' => NULL, 'style' => NULL, 'settings' => NULL), |
|
168 |
'variables' => array( |
|
169 |
'content' => NULL, |
|
170 |
'pane' => NULL, |
|
171 |
'display' => NULL, |
|
172 |
'style' => NULL, |
|
173 |
'settings' => NULL, |
|
174 |
), |
|
143 | 175 |
'path' => $data['path'], |
144 | 176 |
'file' => $data['file'], |
145 | 177 |
); |
146 | 178 |
} |
147 | 179 |
if (!empty($data['render region'])) { |
148 | 180 |
$theme[$data['render region']] = array( |
149 |
'variables' => array('display' => NULL, 'owner_id' => NULL, 'panes' => NULL, 'settings' => NULL, 'region_id' => NULL, 'style' => NULL), |
|
181 |
'variables' => array( |
|
182 |
'display' => NULL, |
|
183 |
'owner_id' => NULL, |
|
184 |
'panes' => NULL, |
|
185 |
'settings' => NULL, |
|
186 |
'region_id' => NULL, |
|
187 |
'style' => NULL, |
|
188 |
), |
|
150 | 189 |
'path' => $data['path'], |
151 | 190 |
'file' => $data['file'], |
152 | 191 |
); |
... | ... | |
156 | 195 |
if (is_array($data['hook theme'])) { |
157 | 196 |
$theme += $data['hook theme']; |
158 | 197 |
} |
159 |
else if (function_exists($data['hook theme'])) {
|
|
198 |
elseif (function_exists($data['hook theme'])) { |
|
160 | 199 |
$data['hook theme']($theme, $data); |
161 | 200 |
} |
162 | 201 |
} |
163 | 202 |
} |
164 |
|
|
165 | 203 |
return $theme; |
166 | 204 |
} |
167 | 205 |
|
168 | 206 |
/** |
169 |
* Implementation of hook_menu
|
|
207 |
* Implements hook_menu().
|
|
170 | 208 |
*/ |
171 | 209 |
function panels_menu() { |
172 | 210 |
// Safety: go away if CTools is not at an appropriate version. |
... | ... | |
234 | 272 |
if (is_array($data['hook menu'])) { |
235 | 273 |
$items += $data['hook menu']; |
236 | 274 |
} |
237 |
else if (function_exists($data['hook menu'])) {
|
|
275 |
elseif (function_exists($data['hook menu'])) { |
|
238 | 276 |
$data['hook menu']($items, $data); |
239 | 277 |
} |
240 | 278 |
} |
241 | 279 |
} |
242 |
|
|
243 |
|
|
244 | 280 |
return $items; |
245 | 281 |
} |
246 | 282 |
|
... | ... | |
261 | 297 |
} |
262 | 298 |
|
263 | 299 |
/** |
264 |
* Implementation of hook_init()
|
|
300 |
* Implements hook_init().
|
|
265 | 301 |
*/ |
266 | 302 |
function panels_init() { |
267 | 303 |
// Safety: go away if CTools is not at an appropriate version. |
... | ... | |
276 | 312 |
} |
277 | 313 |
|
278 | 314 |
/** |
279 |
* Implementation of hook_permission().
|
|
315 |
* Implements hook_permission().
|
|
280 | 316 |
* |
281 | 317 |
* @todo Almost all of these need to be moved into pipelines. |
282 | 318 |
*/ |
... | ... | |
286 | 322 |
'title' => t("Use Panels Dashboard"), |
287 | 323 |
'description' => t('Allows a user to access the <a href="@url">Panels Dashboard</a>.', array('@url' => url('admin/structure/panels'))), |
288 | 324 |
), |
289 |
'view pane admin links' => array( // @todo |
|
325 |
// @todo |
|
326 |
'view pane admin links' => array( |
|
290 | 327 |
'title' => t("View administrative links on Panel panes"), |
291 |
'description' => t(""),
|
|
328 |
'description' => "",
|
|
292 | 329 |
), |
293 |
'administer pane access' => array( // @todo should we really have a global perm for this, or should it be moved into a pipeline question? |
|
330 |
// @todo should we really have a global perm for this, or should it be moved into a pipeline question? |
|
331 |
'administer pane access' => array( |
|
294 | 332 |
'title' => t("Configure access settings on Panel panes"), |
295 | 333 |
'description' => t("Access rules (often also called visibility rules) can be configured on a per-pane basis. This permission allows users to configure those settings."), |
296 | 334 |
), |
... | ... | |
309 | 347 |
), |
310 | 348 |
'administer advanced pane settings' => array( |
311 | 349 |
'title' => t("Configure advanced settings on Panel panes"), |
312 |
'description' => t(""),
|
|
350 |
'description' => "",
|
|
313 | 351 |
), |
314 | 352 |
'administer panels layouts' => array( |
315 | 353 |
'title' => t("Administer Panels layouts"), |
... | ... | |
355 | 393 |
} |
356 | 394 |
} |
357 | 395 |
|
358 |
// --------------------------------------------------------------------------- |
|
359 |
// CTools hook implementations |
|
360 |
// |
|
361 |
// These aren't core Drupal hooks but they are just as important. |
|
396 |
/** |
|
397 |
* CTools hook implementations. |
|
398 |
* |
|
399 |
* These aren't core Drupal hooks but they are just as important. |
|
400 |
*/ |
|
362 | 401 |
|
363 | 402 |
/** |
364 |
* Implementation of hook_ctools_plugin_directory() to let the system know |
|
365 |
* we implement task and task_handler plugins. |
|
403 |
* Implements hook_ctools_plugin_directory(). |
|
366 | 404 |
*/ |
367 | 405 |
function panels_ctools_plugin_directory($module, $plugin) { |
406 |
// To let the system know we implement task and task_handler plugins. |
|
368 | 407 |
// Safety: go away if CTools is not at an appropriate version. |
369 | 408 |
if (!module_invoke('ctools', 'api_version', PANELS_REQUIRED_CTOOLS_API)) { |
370 | 409 |
return; |
... | ... | |
373 | 412 |
// We don't support the 'ctools' 'cache' plugin and pretending to causes |
374 | 413 |
// errors when they're in use. |
375 | 414 |
if ($module == 'ctools' && $plugin == 'cache') { |
415 |
// If we did we'd make a plugin/ctools_cache or something. |
|
376 | 416 |
return; |
377 |
// if we did we'd make a plugin/ctools_cache or something. |
|
378 | 417 |
} |
379 | 418 |
|
380 | 419 |
if ($module == 'page_manager' || $module == 'panels' || $module == 'ctools' || $module == 'stylizer') { |
... | ... | |
383 | 422 |
if ($module == 'ctools' && $plugin == 'cache') { |
384 | 423 |
return; |
385 | 424 |
} |
386 |
|
|
387 | 425 |
return 'plugins/' . $plugin; |
388 | 426 |
} |
389 | 427 |
} |
... | ... | |
397 | 435 |
function panels_ctools_plugin_type() { |
398 | 436 |
return array( |
399 | 437 |
'layouts' => array( |
400 |
'load themes' => TRUE, // Can define layouts in themes |
|
438 |
// We can define layouts in themes. |
|
439 |
'load themes' => TRUE, |
|
401 | 440 |
'process' => 'panels_layout_process', |
402 | 441 |
'child plugins' => TRUE, |
403 | 442 |
), |
... | ... | |
425 | 464 |
} |
426 | 465 |
|
427 | 466 |
/** |
428 |
* Implementation of hook_ctools_plugin_api(). |
|
429 |
* |
|
430 |
* Inform CTools about version information for various plugins implemented by |
|
431 |
* Panels. |
|
432 |
* |
|
433 |
* @param string $owner |
|
434 |
* The system name of the module owning the API about which information is |
|
435 |
* being requested. |
|
436 |
* @param string $api |
|
437 |
* The name of the API about which information is being requested. |
|
467 |
* Implements hook_ctools_plugin_api(). |
|
438 | 468 |
*/ |
439 | 469 |
function panels_ctools_plugin_api($owner, $api) { |
470 |
// Inform CTools about version information for various plugins implemented by |
|
471 |
// panels. |
|
440 | 472 |
if ($owner == 'panels' && $api == 'styles') { |
441 | 473 |
// As of 6.x-3.6, Panels has a slightly new system for style plugins. |
442 | 474 |
return array('version' => 2.0); |
... | ... | |
451 | 483 |
} |
452 | 484 |
|
453 | 485 |
/** |
454 |
* Implementation of hook_views_api().
|
|
486 |
* Implements hook_views_api().
|
|
455 | 487 |
*/ |
456 | 488 |
function panels_views_api() { |
457 | 489 |
return array( |
... | ... | |
468 | 500 |
* parameters to a style plugin in a hybrid environment of both new and old |
469 | 501 |
* plugins. |
470 | 502 |
* |
471 |
* @see _ctools_process_data() |
|
472 |
* |
|
473 | 503 |
* @param array $plugin |
474 | 504 |
* The style plugin that is being processed. |
475 | 505 |
* @param array $info |
476 | 506 |
* The style plugin type info array. |
507 |
* |
|
508 |
* @see _ctools_process_data() |
|
477 | 509 |
*/ |
478 | 510 |
function panels_plugin_styles_process(&$plugin, $info) { |
479 | 511 |
$plugin += array( |
... | ... | |
492 | 524 |
'region' => array( |
493 | 525 |
'title' => t('Panel region'), |
494 | 526 |
'preview' => 'panels_stylizer_region_preview', |
495 |
'theme variables' => array('settings' => NULL, 'class' => NULL, 'content' => NULL), |
|
527 |
'theme variables' => array( |
|
528 |
'settings' => NULL, |
|
529 |
'class' => NULL, |
|
530 |
'content' => NULL, |
|
531 |
), |
|
496 | 532 |
), |
497 | 533 |
'pane' => array( |
498 | 534 |
'title' => t('Panel pane'), |
499 | 535 |
'preview' => 'panels_stylizer_pane_preview', |
500 |
'theme variables' => array('settings' => NULL, 'content' => NULL, 'pane' => NULL, 'display' => NULL), |
|
536 |
'theme variables' => array( |
|
537 |
'settings' => NULL, |
|
538 |
'content' => NULL, |
|
539 |
'pane' => NULL, |
|
540 |
'display' => NULL, |
|
541 |
), |
|
501 | 542 |
), |
502 | 543 |
); |
503 | 544 |
} |
504 | 545 |
|
546 |
/** |
|
547 |
* Generates Lorem Ipsum. |
|
548 |
* |
|
549 |
* @return string |
|
550 |
* Lorem ipsum string. |
|
551 |
*/ |
|
505 | 552 |
function panels_stylizer_lipsum() { |
506 |
return " |
|
507 |
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus at velit dolor. Donec egestas tellus sit amet urna rhoncus adipiscing. Proin nec porttitor sem. Maecenas aliquam, purus nec tempus dignissim, nulla arcu aliquam diam, non tincidunt massa ante vel dolor. Aliquam sapien sapien, tincidunt id tristique at, pretium sagittis libero.</p> |
|
508 |
|
|
509 |
<p>Nulla facilisi. Curabitur lacinia, tellus sed tristique consequat, diam lorem scelerisque felis, at dictum purus augue facilisis lorem. Duis pharetra dignissim rutrum. Curabitur ac elit id dui dapibus tincidunt. Nulla eget sem quam, non eleifend eros. Cras porttitor tempus lectus ac scelerisque. Curabitur vehicula bibendum lorem, vitae ornare ligula venenatis ut.</p> |
|
510 |
"; |
|
553 |
return <<<LIPSUM |
|
554 |
<p> |
|
555 |
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus at |
|
556 |
velit dolor. Donec egestas tellus sit amet urna rhoncus adipiscing. Proin |
|
557 |
nec porttitor sem. Maecenas aliquam, purus nec tempus dignissim, nulla arcu |
|
558 |
aliquam diam, non tincidunt massa ante vel dolor. Aliquam sapien sapien, |
|
559 |
tincidunt id tristique at, pretium sagittis libero. |
|
560 |
</p> |
|
561 |
<p> |
|
562 |
Nulla facilisi. Curabitur lacinia, tellus sed tristique consequat, diam |
|
563 |
lorem scelerisque felis, at dictum purus augue facilisis lorem. Duis |
|
564 |
pharetra dignissim rutrum. Curabitur ac elit id dui dapibus tincidunt. |
|
565 |
Nulla eget sem quam, non eleifend eros. Cras porttitor tempus lectus ac |
|
566 |
scelerisque. Curabitur vehicula bibendum lorem, vitae ornare ligula |
|
567 |
venenatis ut. |
|
568 |
</p> |
|
569 |
LIPSUM; |
|
511 | 570 |
} |
512 | 571 |
|
513 | 572 |
/** |
... | ... | |
515 | 574 |
*/ |
516 | 575 |
function panels_stylizer_region_preview($plugin, $settings) { |
517 | 576 |
ctools_stylizer_add_css($plugin, $settings); |
518 |
return theme($plugin['theme'], array('settings' => $settings, 'class' => ctools_stylizer_get_css_class($plugin, $settings), 'content' => panels_stylizer_lipsum())); |
|
577 |
return theme( |
|
578 |
$plugin['theme'], |
|
579 |
array( |
|
580 |
'settings' => $settings, |
|
581 |
'class' => ctools_stylizer_get_css_class($plugin, $settings), |
|
582 |
'content' => panels_stylizer_lipsum(), |
|
583 |
) |
|
584 |
); |
|
519 | 585 |
} |
520 | 586 |
|
521 | 587 |
/** |
... | ... | |
525 | 591 |
ctools_stylizer_add_css($plugin, $settings); |
526 | 592 |
$pane = new stdClass(); |
527 | 593 |
|
528 |
$content = new stdClass; |
|
594 |
$content = new stdClass();
|
|
529 | 595 |
$content->title = t('Lorem ipsum'); |
530 | 596 |
$content->content = panels_stylizer_lipsum(); |
531 | 597 |
$content->type = 'dummy'; |
... | ... | |
536 | 602 |
$display = new panels_display(); |
537 | 603 |
|
538 | 604 |
if (!empty($plugin['theme'])) { |
539 |
return theme($plugin['theme'], array('settings' => $settings, 'content' => $content, 'pane' => $pane, 'display' => $display)); |
|
605 |
return theme( |
|
606 |
$plugin['theme'], |
|
607 |
array( |
|
608 |
'settings' => $settings, |
|
609 |
'content' => $content, |
|
610 |
'pane' => $pane, |
|
611 |
'display' => $display, |
|
612 |
) |
|
613 |
); |
|
540 | 614 |
} |
541 | 615 |
else { |
542 |
return theme('panels_pane', array('content' => $content, 'pane' => $pane, 'display' => $display)); |
|
616 |
return theme( |
|
617 |
'panels_pane', |
|
618 |
array( |
|
619 |
'content' => $content, |
|
620 |
'pane' => $pane, |
|
621 |
'display' => $display, |
|
622 |
) |
|
623 |
); |
|
543 | 624 |
} |
544 | 625 |
} |
545 | 626 |
|
546 |
// --------------------------------------------------------------------------- |
|
547 |
// Panels display editing |
|
627 |
/** |
|
628 |
* Panels display editing. |
|
629 |
*/ |
|
548 | 630 |
|
549 | 631 |
/** |
550 |
* @defgroup mainapi Functions comprising the main panels API |
|
551 |
* @{ |
|
632 |
* @defgroup mainapi Functions comprising the main panels API. |
|
552 | 633 |
*/ |
553 | 634 |
|
554 | 635 |
/** |
555 | 636 |
* Main API entry point to edit a panel display. |
556 | 637 |
* |
557 |
* Sample implementations utiltizing the the complex $destination behavior can be found |
|
558 |
* in panels_page_edit_content() and, in a separate contrib module, OG Blueprints |
|
559 |
* (http://drupal.org/project/og_blueprints), og_blueprints_blueprint_edit(). |
|
638 |
* Sample implementations utiltizing the the complex $destination behavior can |
|
639 |
* be found in panels_page_edit_content() and, in a separate contrib module, |
|
640 |
* OG Blueprints (http://drupal.org/project/og_blueprints), |
|
641 |
* og_blueprints_blueprint_edit(). |
|
560 | 642 |
* |
561 |
* @ingroup mainapi |
|
643 |
* @param object $display |
|
644 |
* Instanceof panels_display. |
|
645 |
* |
|
646 |
* A fully loaded panels $display object, as returned from |
|
647 |
* panels_load_display(). Merely passing a did is NOT sufficient. |
|
648 |
* Note that 'fully loaded' means the $display must already be loaded with |
|
649 |
* any contexts the caller wishes to have set for the display. |
|
650 |
* @param mixed $destination |
|
651 |
* The redirect destination that the user should be taken to on form |
|
652 |
* submission or cancellation. With panels_edit, $destination has complex |
|
653 |
* effects on the return values of panels_edit() once the form has been |
|
654 |
* submitted. See the explanation of the return value below to understand the |
|
655 |
* different types of values returned by panels_edit() at different stages of |
|
656 |
* FAPI. Under most circumstances, simply passing in drupal_get_destination() |
|
657 |
* is all that's necessary. |
|
658 |
* @param array $content_types |
|
659 |
* An associative array of allowed content types, typically as returned from |
|
660 |
* panels_common_get_allowed_types(). Note that context partially governs |
|
661 |
* available content types, so you will want to create any relevant contexts |
|
662 |
* using panels_create_context() or panels_create_context_empty() to make sure |
|
663 |
* all the appropriate content types are available. |
|
664 |
* |
|
665 |
* @return mixed |
|
666 |
* Because the functions called by panels_edit() invoke the form API, |
|
667 |
* this function returns different values depending on the stage of form |
|
668 |
* submission we're at. In Drupal 5, the phase of form submission is indicated |
|
669 |
* by the contents of $_POST['op']. Here is what you'll get at different |
|
670 |
* stages: |
|
671 |
* - If !$_POST['op']: then we're on on the initial passthrough and the |
|
672 |
* form is being rendered, so it's the $form itself that's being |
|
673 |
* returned. Because negative margins, a common CSS technique, bork the |
|
674 |
* display editor's ajax drag-and-drop, it's important that the $output |
|
675 |
* be printed, not returned. Use this syntax in the caller function: |
|
676 |
* print theme('page', panels_edit($display, $destination, $content_types), FALSE); |
|
677 |
* - If $_POST['op'] == t('Cancel'): form submission has been cancelled. |
|
678 |
* If empty($destination) == FALSE, then there is no return value and the |
|
679 |
* panels API takes care of redirecting to $destination. |
|
680 |
* If empty($destination) == TRUE, then there's still no return value, |
|
681 |
* but the caller function has to take care of form redirection. |
|
682 |
* - If $_POST['op'] == ('Save'): the form has been submitted successfully |
|
683 |
* and has run through panels_edit_display_submit(). |
|
684 |
* $output depends on the value of $destination: |
|
685 |
* - If empty($destination) == TRUE: $output contains the modified $display |
|
686 |
* object, and no redirection will occur. This option is useful if the |
|
687 |
* caller needs to perform additional operations on or with the modified |
|
688 |
* $display before the page request is complete. Using hook_form_alter() |
|
689 |
* to add an additional submit handler is typically the preferred method |
|
690 |
* for something like this, but there are certain use cases where that is |
|
691 |
* infeasible and $destination = NULL should be used instead. If this |
|
692 |
* method is employed, the caller will need to handle form redirection. |
|
693 |
* Note that having $_REQUEST['destination'] set, whether via |
|
694 |
* drupal_get_destination() or some other method, will NOT interfere with |
|
695 |
* this functionality; consequently, you can use drupal_get_destination() |
|
696 |
* to safely store your desired redirect in the caller function, then |
|
697 |
* simply use drupal_goto() once panels_edit() has done its business. |
|
698 |
* - If empty($destination) == FALSE: the form will redirect to the URL |
|
699 |
* string given in $destination and NO value will be returned. |
|
562 | 700 |
* |
563 |
* @param object $display instanceof panels_display \n |
|
564 |
* A fully loaded panels $display object, as returned from panels_load_display(). |
|
565 |
* Merely passing a did is NOT sufficient. \n |
|
566 |
* Note that 'fully loaded' means the $display must already be loaded with any contexts |
|
567 |
* the caller wishes to have set for the display. |
|
568 |
* @param mixed $destination \n |
|
569 |
* The redirect destination that the user should be taken to on form submission or |
|
570 |
* cancellation. With panels_edit, $destination has complex effects on the return |
|
571 |
* values of panels_edit() once the form has been submitted. See the explanation of |
|
572 |
* the return value below to understand the different types of values returned by panels_edit() |
|
573 |
* at different stages of FAPI. Under most circumstances, simply passing in |
|
574 |
* drupal_get_destination() is all that's necessary. |
|
575 |
* @param array $content_types \n |
|
576 |
* An associative array of allowed content types, typically as returned from |
|
577 |
* panels_common_get_allowed_types(). Note that context partially governs available content types, |
|
578 |
* so you will want to create any relevant contexts using panels_create_context() or |
|
579 |
* panels_create_context_empty() to make sure all the appropriate content types are available. |
|
580 |
* |
|
581 |
* @return |
|
582 |
* Because the functions called by panels_edit() invoke the form API, this function |
|
583 |
* returns different values depending on the stage of form submission we're at. In Drupal 5, |
|
584 |
* the phase of form submission is indicated by the contents of $_POST['op']. Here's what you'll |
|
585 |
* get at different stages: |
|
586 |
* -# If !$_POST['op']: then we're on on the initial passthrough and the form is being |
|
587 |
* rendered, so it's the $form itself that's being returned. Because negative margins, |
|
588 |
* a common CSS technique, bork the display editor's ajax drag-and-drop, it's important |
|
589 |
* that the $output be printed, not returned. Use this syntax in the caller function: \n |
|
590 |
* print theme('page', panels_edit($display, $destination, $content_types), FALSE); \n |
|
591 |
* -# If $_POST['op'] == t('Cancel'): form submission has been cancelled. If empty($destination) == FALSE, |
|
592 |
* then there is no return value and the panels API takes care of redirecting to $destination. |
|
593 |
* If empty($destination) == TRUE, then there's still no return value, but the caller function |
|
594 |
* has to take care of form redirection. |
|
595 |
* -# If $_POST['op'] == ('Save'): the form has been submitted successfully and has run through |
|
596 |
* panels_edit_display_submit(). $output depends on the value of $destination: |
|
597 |
* - If empty($destination) == TRUE: $output contains the modified $display |
|
598 |
* object, and no redirection will occur. This option is useful if the caller |
|
599 |
* needs to perform additional operations on or with the modified $display before |
|
600 |
* the page request is complete. Using hook_form_alter() to add an additional submit |
|
601 |
* handler is typically the preferred method for something like this, but there |
|
602 |
* are certain use cases where that is infeasible and $destination = NULL should |
|
603 |
* be used instead. If this method is employed, the caller will need to handle form |
|
604 |
* redirection. Note that having $_REQUEST['destination'] set, whether via |
|
605 |
* drupal_get_destination() or some other method, will NOT interfere with this |
|
606 |
* functionality; consequently, you can use drupal_get_destination() to safely store |
|
607 |
* your desired redirect in the caller function, then simply use drupal_goto() once |
|
608 |
* panels_edit() has done its business. |
|
609 |
* - If empty($destination) == FALSE: the form will redirect to the URL string |
|
610 |
* given in $destination and NO value will be returned. |
|
701 |
* @ingroup mainapi |
|
611 | 702 |
*/ |
612 | 703 |
function panels_edit($display, $destination = NULL, $content_types = NULL, $title = FALSE) { |
613 | 704 |
ctools_include('display-edit', 'panels'); |
... | ... | |
619 | 710 |
/** |
620 | 711 |
* API entry point for selecting a layout for a given display. |
621 | 712 |
* |
622 |
* Layout selection is nothing more than a list of radio items encompassing the available
|
|
623 |
* layouts for this display, as defined by .inc files in the panels/layouts subdirectory.
|
|
624 |
* The only real complexity occurs when a user attempts to change the layout of a display
|
|
625 |
* that has some content in it. |
|
713 |
* Layout selection is nothing more than a list of radio items encompassing the |
|
714 |
* available layouts for this display, as defined by .inc files in the
|
|
715 |
* panels/layouts subdirectory. The only real complexity occurs when a user
|
|
716 |
* attempts to change the layout of a display that has some content in it.
|
|
626 | 717 |
* |
627 |
* @param object $display instanceof panels_display \n
|
|
628 |
* A fully loaded panels $display object, as returned from panels_load_display().
|
|
629 |
* Merely passing a did is NOT sufficient. |
|
718 |
* @param object $display |
|
719 |
* A fully loaded panels $display object, as returned from
|
|
720 |
* panels_load_display(). Merely passing a did is NOT sufficient.
|
|
630 | 721 |
* @param string $finish |
631 |
* A string that will be used for the text of the form submission button. If no value is provided, |
|
632 |
* then the form submission button will default to t('Save'). |
|
722 |
* A string that will be used for the text of the form submission button. If |
|
723 |
* no value is provided, then the form submission button will default to |
|
724 |
* t('Save'). |
|
633 | 725 |
* @param mixed $destination |
634 |
* Basic usage is a string containing the URL that the form should redirect to upon submission.
|
|
635 |
* For a discussion of advanced usages, see panels_edit(). |
|
726 |
* Basic usage is a string containing the URL that the form should redirect to
|
|
727 |
* upon submission. For a discussion of advanced usages, see panels_edit().
|
|
636 | 728 |
* @param mixed $allowed_layouts |
637 |
* Allowed layouts has three different behaviors that depend on which of three value types |
|
638 |
* are passed in by the caller: |
|
639 |
* #- if $allowed_layouts instanceof panels_allowed_layouts (includes subclasses): the most |
|
640 |
* complex use of the API. The caller is passing in a loaded panels_allowed_layouts object |
|
641 |
* that the client module previously created and stored somewhere using a custom storage |
|
642 |
* mechanism. |
|
643 |
* #- if is_string($allowed_layouts): the string will be used in a call to variable_get() which |
|
644 |
* will call the $allowed_layouts . '_allowed_layouts' var. If the data was stored properly |
|
645 |
* in the system var, the $allowed_layouts object will be unserialized and recreated. |
|
646 |
* @see panels_common_set_allowed_layouts() |
|
647 |
* #- if is_null($allowed_layouts): the default behavior, which also provides backwards |
|
648 |
* compatibility for implementations of the Panels2 API written before beta4. In this case, |
|
649 |
* a dummy panels_allowed_layouts object is created which does not restrict any layouts. |
|
650 |
* Subsequent behavior is indistinguishable from pre-beta4 behavior. |
|
651 |
* |
|
652 |
* @return |
|
653 |
* Can return nothing, or a modified $display object, or a redirection string; return values for the |
|
654 |
* panels_edit* family of functions are quite complex. See panels_edit() for detailed discussion. |
|
729 |
* Allowed layouts has three different behaviors that depend on which of three |
|
730 |
* value types are passed in by the caller: |
|
731 |
* #- if $allowed_layouts instanceof panels_allowed_layouts |
|
732 |
* (includes subclasses): the most complex use of the API. The caller is |
|
733 |
* passing in a loaded panels_allowed_layouts object that the client |
|
734 |
* module previously created and stored somewhere using a custom storage |
|
735 |
* mechanism. |
|
736 |
* #- if is_string($allowed_layouts): the string will be used in a call to |
|
737 |
* variable_get() which will call the |
|
738 |
* $allowed_layouts . '_allowed_layouts' var. If the data was stored |
|
739 |
* properly in the system var, the $allowed_layouts object will be |
|
740 |
* unserialized and recreated. |
|
741 |
* #- if is_null($allowed_layouts): the default behavior, which also |
|
742 |
* provides backwards compatibility for implementations of the Panels2 |
|
743 |
* API written before beta4. In this case, a dummy panels_allowed_layouts |
|
744 |
* object is created which does not restrict any layouts. Subsequent |
|
745 |
* behavior is indistinguishable from pre-beta4 behavior. |
|
746 |
* |
|
747 |
* @return mixed |
|
748 |
* Can return nothing, or a modified $display object, or a redirection string; |
|
749 |
* return values for the panels_edit* family of functions are quite complex. |
|
750 |
* See panels_edit() for detailed discussion. |
|
751 |
* |
|
655 | 752 |
* @see panels_edit() |
753 |
* @see panels_common_set_allowed_layouts() |
|
656 | 754 |
*/ |
657 | 755 |
function panels_edit_layout($display, $finish, $destination = NULL, $allowed_layouts = NULL) { |
658 | 756 |
ctools_include('display-layout', 'panels'); |
... | ... | |
660 | 758 |
return _panels_edit_layout($display, $finish, $destination, $allowed_layouts); |
661 | 759 |
} |
662 | 760 |
|
663 |
// --------------------------------------------------------------------------- |
|
664 |
// Panels database functions |
|
761 |
/** |
|
762 |
* Panels database functions. |
|
763 |
*/ |
|
665 | 764 |
|
666 | 765 |
/** |
667 |
* Forms the basis of a panel display |
|
766 |
* Forms the basis of a panel display.
|
|
668 | 767 |
*/ |
669 | 768 |
class panels_display { |
670 |
var $args = array(); |
|
671 |
var $content = array(); |
|
672 |
var $panels = array(); |
|
673 |
var $incoming_content = NULL; |
|
674 |
var $css_id = NULL; |
|
675 |
var $context = array(); |
|
676 |
var $did = 'new'; |
|
677 |
var $renderer = 'standard'; |
|
678 |
|
|
679 |
function add_pane(&$pane, $location = NULL) { |
|
769 |
public $args = array(); |
|
770 |
public $content = array(); |
|
771 |
public $panels = array(); |
|
772 |
public $incoming_content = NULL; |
|
773 |
public $css_id = NULL; |
|
774 |
public $context = array(); |
|
775 |
public $did = 'new'; |
|
776 |
public $renderer = 'standard'; |
|
777 |
|
|
778 |
/** |
|
779 |
* Add a pane. |
|
780 |
*/ |
|
781 |
public function add_pane(&$pane, $location = NULL) { |
|
680 | 782 |
// If no location specified, use what's set in the pane. |
681 | 783 |
if (empty($location)) { |
682 | 784 |
$location = $pane->panel; |
... | ... | |
690 | 792 |
$pane->uuid = ctools_uuid_generate(); |
691 | 793 |
$pane->pid = 'new-' . $pane->uuid; |
692 | 794 |
|
693 |
// Add the pane to the approprate spots. |
|
795 |
// Add the pane to the appropriate spots.
|
|
694 | 796 |
$this->content[$pane->pid] = &$pane; |
695 | 797 |
$this->panels[$location][] = $pane->pid; |
696 | 798 |
} |
697 | 799 |
|
698 |
function duplicate_pane($pid, $location = FALSE) { |
|
800 |
/** |
|
801 |
* Duplicate a pane. |
|
802 |
*/ |
|
803 |
public function duplicate_pane($pid, $location = FALSE) { |
|
699 | 804 |
$pane = $this->clone_pane($pid); |
700 | 805 |
$this->add_pane($pane, $location); |
701 | 806 |
} |
702 | 807 |
|
703 |
function clone_pane($pid) { |
|
704 |
$pane = clone $this->content[$pid]; |
|
705 |
$pane->uuid = ctools_uuid_generate(); |
|
706 |
return $pane; |
|
707 |
} |
|
708 |
|
|
709 | 808 |
/** |
710 | 809 |
* Get the title from a display. |
711 | 810 |
* |
712 | 811 |
* The display must have already been rendered, or the setting to set the |
713 | 812 |
* display's title from a pane's title will not have worked. |
714 | 813 |
* |
715 |
* @return |
|
716 |
* The title to use. If NULL, this means to let any default title that may be in use
|
|
717 |
* pass through. i.e, do not actually set the title. |
|
814 |
* @return mixed
|
|
815 |
* The title to use. If NULL, this means to let any default title that may |
|
816 |
* be in use pass through. i.e, do not actually set the title.
|
|
718 | 817 |
*/ |
719 |
function get_title() { |
|
818 |
public function get_title() {
|
|
720 | 819 |
switch ($this->hide_title) { |
721 | 820 |
case PANELS_TITLE_NONE: |
722 | 821 |
return ''; |
... | ... | |
725 | 824 |
return isset($this->stored_pane_title) ? $this->stored_pane_title : ''; |
726 | 825 |
|
727 | 826 |
case PANELS_TITLE_FIXED: |
728 |
case FALSE; // For old exported panels that are not in the database. |
|
827 |
case FALSE; |
|
828 |
// For old exported panels that are not in the database. |
|
729 | 829 |
if (!empty($this->title)) { |
730 | 830 |
return filter_xss_admin(ctools_context_keyword_substitute($this->title, array(), $this->context)); |
731 | 831 |
} |
... | ... | |
743 | 843 |
* An instantiated display renderer object, or the name of a display |
744 | 844 |
* renderer plugin+class to be fetched. Defaults to NULL. When NULL, the |
745 | 845 |
* predesignated display renderer will be used. |
846 |
* |
|
847 |
* @return mixed |
|
848 |
* NULL or output of render function. |
|
746 | 849 |
*/ |
747 |
function render($renderer = NULL) { |
|
850 |
public function render($renderer = NULL) {
|
|
748 | 851 |
$layout = panels_get_layout($this->layout); |
749 | 852 |
if (!$layout) { |
750 | 853 |
return NULL; |
... | ... | |
788 | 891 |
* @return bool |
789 | 892 |
* TRUE if access is granted; otherwise FALSE. |
790 | 893 |
*/ |
791 |
function access($op, $account = NULL) { |
|
894 |
public function access($op, $account = NULL) {
|
|
792 | 895 |
global $user; |
793 | 896 |
|
794 | 897 |
if (!$account) { |
... | ... | |
825 | 928 |
|
826 | 929 |
return $access_callback($this->storage_type, $this->storage_id, $op, $account); |
827 | 930 |
} |
931 |
|
|
828 | 932 |
} |
829 | 933 |
|
830 | 934 |
/** |
831 |
* }@ End of 'defgroup mainapi', although other functions are specifically added later
|
|
935 |
* End of 'defgroup mainapi', although other functions are specifically added later.
|
|
832 | 936 |
*/ |
833 | 937 |
|
834 | 938 |
/** |
... | ... | |
869 | 973 |
* Helper function primarily for for panels_load_display(). |
870 | 974 |
* |
871 | 975 |
* @param array $dids |
872 |
* An indexed array of dids to be loaded from the database. |
|
976 |
* An indexed array of dids to be loaded from the database.
|
|
873 | 977 |
* |
874 |
* @return $displays
|
|
875 |
* An array of displays, keyed by their display dids. |
|
978 |
* @return array
|
|
979 |
* An array of displays, keyed by their display dids.
|
|
876 | 980 |
* |
877 | 981 |
* @todo schema API can drasticly simplify this code. |
878 | 982 |
*/ |
... | ... | |
882 | 986 |
return $displays; |
883 | 987 |
} |
884 | 988 |
|
885 |
$result = db_query("SELECT * FROM {panels_display} WHERE did IN (:dids)", array(':dids' => $dids)); |
|
989 |
$result = db_query( |
|
990 |
"SELECT * FROM {panels_display} WHERE did IN (:dids)", |
|
991 |
array(':dids' => $dids) |
|
992 |
); |
|
886 | 993 |
|
887 | 994 |
ctools_include('export'); |
888 | 995 |
foreach ($result as $obj) { |
... | ... | |
890 | 997 |
// Modify the hide_title field to go from a bool to an int if necessary. |
891 | 998 |
} |
892 | 999 |
|
893 |
$result = db_query("SELECT * FROM {panels_pane} WHERE did IN (:dids) ORDER BY did, panel, position", array(':dids' => $dids)); |
|
1000 |
$result = db_query( |
|
1001 |
"SELECT * FROM {panels_pane} WHERE did IN (:dids) ORDER BY did, panel, position", |
|
1002 |
array(':dids' => $dids) |
|
1003 |
); |
|
894 | 1004 |
foreach ($result as $obj) { |
895 | 1005 |
$pane = ctools_export_unpack_object('panels_pane', $obj); |
896 | 1006 |
|
897 | 1007 |
$displays[$pane->did]->panels[$pane->panel][] = $pane->pid; |
898 | 1008 |
$displays[$pane->did]->content[$pane->pid] = $pane; |
899 | 1009 |
} |
900 |
|
|
901 | 1010 |
return $displays; |
902 | 1011 |
} |
903 | 1012 |
|
904 | 1013 |
/** |
905 | 1014 |
* Load a single display. |
906 | 1015 |
* |
907 |
* @ingroup mainapi |
|
908 |
* |
|
909 | 1016 |
* @param int $did |
910 |
* The display id (did) of the display to be loaded. |
|
1017 |
* The display id (did) of the display to be loaded.
|
|
911 | 1018 |
* |
912 |
* @return object $display instanceof panels_display \n
|
|
913 |
* Returns a partially-loaded panels_display object. $display objects returned from
|
|
914 |
* from this function have only the following data: |
|
1019 |
* @return object $display |
|
1020 |
* Returns a partially-loaded panels_display object. $display objects returned
|
|
1021 |
* from this function have only the following data:
|
|
915 | 1022 |
* - $display->did (the display id) |
916 | 1023 |
* - $display->name (the 'name' of the display, where applicable - it often isn't) |
917 | 1024 |
* - $display->layout (a string with the system name of the display's layout) |
... | ... | |
923 | 1030 |
* - $display->cache (any relevant data from panels_simple_cache) |
924 | 1031 |
* - $display->args |
925 | 1032 |
* - $display->incoming_content |
1033 |
* While all of these members are defined, $display->context is NEVER defined in the returned $display; |
|
1034 |
* it must be set using one of the ctools_context_create() functions. |
|
926 | 1035 |
* |
927 |
* While all of these members are defined, $display->context is NEVER defined in the returned $display; |
|
928 |
* it must be set using one of the ctools_context_create() functions. |
|
1036 |
* @ingroup mainapi |
|
929 | 1037 |
*/ |
930 | 1038 |
function panels_load_display($did) { |
931 | 1039 |
$displays = panels_load_displays(array($did)); |
... | ... | |
937 | 1045 |
/** |
938 | 1046 |
* Save a display object. |
939 | 1047 |
* |
940 |
* @ingroup mainapi |
|
941 |
* |
|
942 | 1048 |
* Note that a new $display only receives a real did once it is run through |
943 | 1049 |
* this function, and likewise for the pid of any new pane. |
944 | 1050 |
* |
... | ... | |
947 | 1053 |
* universally-unique identifier (which is stored permanently in the 'uuid' |
948 | 1054 |
* field). This format is also used in place of the real pid for exports. |
949 | 1055 |
* |
950 |
* @param object $display instanceof panels_display \n
|
|
951 |
* The display object to be saved. Passed by reference so the caller need not use
|
|
952 |
* the return value for any reason except convenience. |
|
1056 |
* @param object $display |
|
1057 |
* The display object to be saved. Passed by reference so the caller need not
|
|
1058 |
* use the return value for any reason except convenience.
|
|
953 | 1059 |
* |
954 |
* @return object $display instanceof panels_display \n |
|
1060 |
* @return object $display |
|
1061 |
* This display panel display object to return. |
|
1062 |
* |
|
1063 |
* @ingroup mainapi |
|
955 | 1064 |
*/ |
956 | 1065 |
function panels_save_display(&$display) { |
957 | 1066 |
$update = (isset($display->did) && is_numeric($display->did)) ? array('did') : array(); |
... | ... | |
962 | 1071 |
|
963 | 1072 |
$pids = array(); |
964 | 1073 |
if ($update) { |
965 |
// Get a list of all panes currently in the database for this display so we can know if there |
|
966 |
// are panes that need to be deleted. (i.e, aren't currently in our list of panes). |
|
967 |
$result = db_query("SELECT pid FROM {panels_pane} WHERE did = :did", array(':did' => $display->did)); |
|
1074 |
// Get a list of all panes currently in the database for this display so we |
|
1075 |
// can know if there are panes that need to be deleted. (i.e, aren't |
|
1076 |
// currently in our list of panes). |
|
1077 |
$result = db_query( |
|
1078 |
"SELECT pid FROM {panels_pane} WHERE did = :did", |
|
1079 |
array(':did' => $display->did) |
|
1080 |
); |
|
968 | 1081 |
foreach ($result as $pane) { |
969 | 1082 |
$pids[$pane->pid] = $pane->pid; |
970 | 1083 |
} |
971 | 1084 |
} |
972 | 1085 |
|
973 |
// update all the panes
|
|
1086 |
// Update all the panes.
|
|
974 | 1087 |
ctools_include('plugins', 'panels'); |
975 | 1088 |
ctools_include('content'); |
976 | 1089 |
|
... | ... | |
1007 | 1120 |
// Remove the old new-* entry from the displays content. |
1008 | 1121 |
unset($display->content[$pid]); |
1009 | 1122 |
|
1010 |
// and put it back so our pids and positions can be used.
|
|
1123 |
// Put it back so our pids and positions can be used.
|
|
1011 | 1124 |
$display->content[$pane->pid] = $pane; |
1012 | 1125 |
|
1013 | 1126 |
// If the title pane was one of our panes that just got its ID changed, |
... | ... | |
1019 | 1132 |
// because it was needed to get the did. Chicken, egg, more chicken. |
1020 | 1133 |
db_update('panels_display') |
1021 | 1134 |
->fields(array( |
1022 |
'title_pane' => $pane->pid |
|
1135 |
'title_pane' => $pane->pid,
|
|
1023 | 1136 |
)) |
1024 | 1137 |
->condition('did', $display->did) |
1025 | 1138 |
->execute(); |
... | ... | |
1049 | 1162 |
// Allow other modules to take action when a display is saved. |
1050 | 1163 |
module_invoke_all('panels_display_save', $display); |
1051 | 1164 |
|
1052 |
// Log the change to watchdog, using the same style as node.module |
|
1165 |
// Log the change to watchdog, using the same style as node.module.
|
|
1053 | 1166 |
$watchdog_args = array('%did' => $display->did); |
1054 | 1167 |
if (!empty($display->title)) { |
1055 | 1168 |
$watchdog_args['%title'] = $display->title; |
... | ... | |
1059 | 1172 |
watchdog('content', 'Panels: saved display with id %did', $watchdog_args, WATCHDOG_NOTICE); |
1060 | 1173 |
} |
1061 | 1174 |
|
1062 |
// to be nice, even tho we have a reference.
|
|
1175 |
// To be nice, even though we have a reference.
|
|
1063 | 1176 |
return $display; |
1064 | 1177 |
} |
1065 | 1178 |
|
... | ... | |
1089 | 1202 |
* Only once panels_save_display() is called on the code version of $display |
1090 | 1203 |
* will the exported display be written to the database and permanently saved. |
1091 | 1204 |
* |
1092 |
* @see panels_page_export() or _panels_page_fetch_display() for sample implementations. |
|
1093 |
* |
|
1094 |
* @ingroup mainapi |
|
1095 |
* |
|
1096 |
* @param object $display instanceof panels_display \n |
|
1097 |
* This export function does no loading of additional data about the provided |
|
1098 |
* display. Consequently, the caller should make sure that all the desired data |
|
1099 |
* has been loaded into the $display before calling this function. |
|
1205 |
* @param object $display |
|
1206 |
* This export function does no loading of additional data about the provided |
|
1207 |
* display. Consequently, the caller should make sure that all the desired |
|
1208 |
* data has been loaded into the $display before calling this function. |
|
1100 | 1209 |
* @param string $prefix |
1101 |
* A string prefix that is prepended to each line of exported code. This is primarily |
|
1102 |
* used for prepending a double space when exporting so that the code indents and lines up nicely. |
|
1210 |
* A string prefix that is prepended to each line of exported code. This is |
|
1211 |
* primarily used for prepending a double space when exporting so that the |
|
1212 |
* code indents and lines up nicely. |
|
1103 | 1213 |
* |
1104 | 1214 |
* @return string $output |
1105 |
* The passed-in $display expressed as code, ready to be imported. Import by running |
|
1106 |
* eval($output) in the caller function; doing so will create a new $display variable |
|
1107 |
* with all the exported values. Note that if you have already defined a $display variable in |
|
1108 |
* the same scope as where you eval(), your existing $display variable WILL be overwritten. |
|
1215 |
* The passed-in $display expressed as code, ready to be imported. Import by |
|
1216 |
* running eval($output) in the caller function; doing so will create a new |
|
1217 |
* $display variable with all the exported values. Note that if you have |
|
1218 |
* already defined a $display variable in the same scope as where you eval(), |
|
1219 |
* your existing $display variable WILL be overwritten. |
|
1220 |
* |
|
1221 |
* @see panels_page_export() or _panels_page_fetch_display() for samples. |
|
1222 |
* |
|
1223 |
* @ingroup mainapi |
|
1109 | 1224 |
*/ |
1110 | 1225 |
function panels_export_display($display, $prefix = '') { |
1111 | 1226 |
ctools_include('export'); |
... | ... | |
1139 | 1254 |
if (!isset($region_counters[$pane->panel])) { |
1140 | 1255 |
$region_counters[$pane->panel] = 0; |
1141 | 1256 |
} |
1142 |
$output .= $prefix . '$display->panels[\'' . $pane->panel . '\'][' . $region_counters[$pane->panel]++ .'] = \'' . $pane->pid . "';\n"; |
|
1257 |
$output .= $prefix . '$display->panels[\'' . $pane->panel . '\'][' . $region_counters[$pane->panel]++ . '] = \'' . $pane->pid . "';\n";
|
|
1143 | 1258 |
} |
1144 | 1259 |
} |
1145 | 1260 |
$output .= $prefix . '$display->hide_title = '; |
... | ... | |
1147 | 1262 |
case PANELS_TITLE_FIXED: |
1148 | 1263 |
$output .= 'PANELS_TITLE_FIXED'; |
1149 | 1264 |
break; |
1265 |
|
|
1150 | 1266 |
case PANELS_TITLE_NONE: |
1151 | 1267 |
$output .= 'PANELS_TITLE_NONE'; |
1152 | 1268 |
break; |
1269 |
|
|
1153 | 1270 |
case PANELS_TITLE_PANE: |
1154 | 1271 |
$output .= 'PANELS_TITLE_PANE'; |
1155 | 1272 |
break; |
... | ... | |
1161 | 1278 |
} |
1162 | 1279 |
|
1163 | 1280 |
/** |
1281 |
* Panels Render Display. |
|
1282 |
* |
|
1164 | 1283 |
* Render a display by loading the content into an appropriate |
1165 | 1284 |
* array and then passing through to panels_render_layout. |
1166 | 1285 |
* |
1167 | 1286 |
* if $incoming_content is NULL, default content will be applied. Use |
1168 | 1287 |
* an empty string to indicate no content. |
1288 |
* |
|
1169 | 1289 |
* @ingroup hook_invocations |
1170 | 1290 |
*/ |
1171 | 1291 |
function panels_render_display(&$display, $renderer = NULL) { |
... | ... | |
1176 | 1296 |
if ($form_context = ctools_context_get_form($display->context)) { |
1177 | 1297 |
$form_context->form['#theme'] = 'panels_render_display_form'; |
1178 | 1298 |
if (empty($form_context->form['#theme_wrappers']) || !in_array('form', $form_context->form['#theme_wrappers'])) { |
1179 |
$form_context['#theme_wrappers'][] = 'form'; |
|
1299 |
$form_context->form['#theme_wrappers'][] = 'form';
|
|
1180 | 1300 |
} |
1181 | 1301 |
$form_context->form['#display'] = &$display; |
1182 | 1302 |
return $form_context->form; |
... | ... | |
1197 | 1317 |
return $vars['element']['#display']->render(); |
1198 | 1318 |
} |
1199 | 1319 |
|
1200 |
// @layout |
|
1320 |
/** |
|
1321 |
* Panels layout icon function. |
|
1322 |
*/ |
|
1201 | 1323 |
function panels_print_layout_icon($id, $layout, $title = NULL) { |
1202 | 1324 |
ctools_add_css('panels_admin', 'panels'); |
1203 | 1325 |
$file = $layout['path'] . '/' . $layout['icon']; |
1204 |
return theme('panels_layout_icon', array('id' => $id, 'image' => theme('image', array('path' => $file, 'alt' => strip_tags($layout['title']), 'title' => strip_tags($layout['description']))), 'title' => $title)); |
|
1326 |
return theme( |
|
1327 |
'panels_layout_icon', |
|
1328 |
array( |
|
1329 |
'id' => $id, |
|
1330 |
'image' => theme( |
|
1331 |
'image', |
|
1332 |
array( |
|
1333 |
'path' => $file, |
|
1334 |
'alt' => strip_tags($layout['title']), |
|
1335 |
'title' => strip_tags($layout['description']), |
|
1336 |
) |
|
1337 |
), |
|
1338 |
'title' => $title, |
|
1339 |
) |
|
1340 |
); |
|
1205 | 1341 |
} |
1206 | 1342 |
|
1207 | 1343 |
/** |
1208 |
* Theme the layout icon image |
|
1209 |
* @layout
|
|
1344 |
* Theme the layout icon image.
|
|
1345 |
* |
|
1210 | 1346 |
* @todo move to theme.inc |
1211 | 1347 |
*/ |
1212 | 1348 |
function theme_panels_layout_icon($vars) { |
... | ... | |
1224 | 1360 |
} |
1225 | 1361 |
|
1226 | 1362 |
/** |
1227 |
* Theme the layout link image |
|
1363 |
* Theme the layout link image. |
|
1364 |
* |
|
1228 | 1365 |
* @layout |
1229 | 1366 |
* |
1230 | 1367 |
* @todo Why isn't this a template at this point? |
1231 | 1368 |
* @todo Why does this take 4 arguments but only makes use of two? |
1232 | 1369 |
*/ |
1233 | 1370 |
function theme_panels_layout_link($vars) { |
1234 |
$title = $vars['title']; |
|
1235 |
$image = $vars['image']; |
|
1236 |
$class = $vars['class']; |
|
1237 |
|
|
1238 |
$output = '<div class="' . implode(' ', $class) . '">'; |
|
1371 |
$output = '<div class="' . implode(' ', $vars['class']) . '">'; |
|
1239 | 1372 |
$output .= $vars['image']; |
1240 | 1373 |
$output .= '<div>' . $vars['title'] . '</div>'; |
1241 | 1374 |
$output .= '</div>'; |
... | ... | |
1244 | 1377 |
|
1245 | 1378 |
/** |
1246 | 1379 |
* Print the layout link. Sends out to a theme function. |
1380 |
* |
|
1247 | 1381 |
* @layout |
1248 | 1382 |
*/ |
1249 | 1383 |
function panels_print_layout_link($id, $layout, $link, $options = array(), $current_layout = FALSE) { |
... | ... | |
1251 | 1385 |
unset($options['query']['q']); |
1252 | 1386 |
} |
1253 | 1387 |
|
1254 |
// Setup classes for layout link, including current-layout information |
|
1388 |
// Setup classes for layout link, including current-layout information.
|
|
1255 | 1389 |
$class = array('layout-link'); |
1256 | 1390 |
if ($current_layout == $id) { |
1257 | 1391 |
$options['attributes']['class'][] = 'current-layout-link'; |
... | ... | |
1260 | 1394 |
|
1261 | 1395 |
ctools_add_css('panels_admin', 'panels'); |
1262 | 1396 |
$file = $layout['path'] . '/' . $layout['icon']; |
1263 |
$image = l(theme('image', array('path' => $file)), $link, array('html' => true) + $options); |
|
1397 |
$image = l( |
|
1398 |
theme('image', array('path' => $file)), |
|
1399 |
$link, |
|
1400 |
array('html' => TRUE) + $options |
|
1401 |
); |
|
1264 | 1402 |
$title = l($layout['title'], $link, $options); |
1265 |
return theme('panels_layout_link', array('title' => $title, 'image' => $image, 'class' => $class)); |
|
1403 |
return theme( |
|
1404 |
'panels_layout_link', |
|
1405 |
array( |
|
1406 |
'title' => $title, |
|
1407 |
'image' => $image, |
|
1408 |
'class' => $class, |
|
1409 |
) |
|
1410 |
); |
|
1266 | 1411 |
} |
1267 | 1412 |
|
1268 | 1413 |
|
1269 | 1414 |
/** |
1415 |
* Panels Get legacy state. |
|
1416 |
* |
|
1270 | 1417 |
* Gateway to the PanelsLegacyState class/object, which does all legacy state |
1271 | 1418 |
* checks and provides information about the cause of legacy states as needed. |
1272 | 1419 |
* |
1273 | 1420 |
* @return PanelsLegacyState $legacy |
1421 |
* Returns a legacy panels state. |
|
1274 | 1422 |
*/ |
1275 | 1423 |
function panels_get_legacy_state() { |
1276 | 1424 |
static $legacy = NULL; |
... | ... | |
1325 | 1473 |
); |
1326 | 1474 |
unset($content->content['#contextual_links']); |
1327 | 1475 |
|
1328 |
// Add content to $element array |
|
1476 |
// Add content to $element array.
|
|
1329 | 1477 |
if (is_array($content->content)) { |
1330 | 1478 |
$element['#element'] = $content->content; |
1331 | 1479 |
} |
1332 | 1480 |
|
1333 | 1481 |
$element = contextual_pre_render_links($element); |
1334 |
if(!empty($element['#links'])) { |
|
1482 |
if (!empty($element['#links'])) {
|
|
1335 | 1483 |
$links += $element['#links']; |
1336 | 1484 |
} |
1337 | 1485 |
} |
... | ... | |
1352 | 1500 |
} |
1353 | 1501 |
} |
1354 | 1502 |
|
1355 |
// basic classes
|
|
1503 |
// Basic classes.
|
|
1356 | 1504 |
$vars['classes_array'][] = 'panel-pane'; |
1357 | 1505 |
$vars['id'] = ''; |
1358 | 1506 |
|
1359 |
// Add some usable classes based on type/subtype |
|
1507 |
// Add some usable classes based on type/subtype.
|
|
1360 | 1508 |
ctools_include('cleanstring'); |
1361 |
$type_class = $content->type ? 'pane-'. ctools_cleanstring($content->type, array('lower case' => TRUE)) : ''; |
|
1362 |
$subtype_class = $content->subtype ? 'pane-'. ctools_cleanstring($content->subtype, array('lower case' => TRUE)) : ''; |
|
1509 |
$type_class = $content->type ? 'pane-' . ctools_cleanstring($content->type, array('lower case' => TRUE)) : '';
|
|
1510 |
$subtype_class = $content->subtype ? 'pane-' . ctools_cleanstring($content->subtype, array('lower case' => TRUE)) : '';
|
|
1363 | 1511 |
|
1364 | 1512 |
// Sometimes type and subtype are the same. Avoid redundant classes. |
1365 | 1513 |
$vars['classes_array'][] = $type_class; |
... | ... | |
1403 | 1551 |
$vars['more'] = l($content->more['title'], $content->more['href'], $content->more); |
1404 | 1552 |
} |
1405 | 1553 |
|
1554 |
if (!empty($content->attributes)) { |
|
1555 |
$vars['attributes_array'] = array_merge($vars['attributes_array'], $content->attributes); |
|
1556 |
} |
|
1557 |
|
|
1406 | 1558 |
$vars['content'] = !empty($content->content) ? $content->content : ''; |
1407 | 1559 |
|
1408 | 1560 |
} |
... | ... | |
1483 | 1635 |
} |
1484 | 1636 |
} |
1485 | 1637 |
|
1486 |
// --------------------------------------------------------------------------
|
|
1487 |
// Panels caching functions and callbacks
|
|
1488 |
//
|
|
1489 |
// When editing displays and the like, Panels has a caching system that relies
|
|
1490 |
// on a callback to determine where to get the actual cache.
|
|
1491 |
|
|
1492 |
// @todo This system needs to be better documented so that it can be
|
|
1493 |
// better used.
|
|
1638 |
/**
|
|
1639 |
* Panels caching functions and callbacks.
|
|
1640 |
*
|
|
1641 |
* When editing displays and the like, Panels has a caching system that relies
|
|
1642 |
* on a callback to determine where to get the actual cache.
|
|
1643 |
* |
|
1644 |
* @todo This system needs to be better documented so that it can be better used.
|
|
1645 |
*/
|
|
1494 | 1646 |
|
1495 | 1647 |
/** |
1496 | 1648 |
* Get an object from cache. |
1497 | 1649 |
*/ |
1498 | 1650 |
function panels_cache_get($obj, $did, $skip_cache = FALSE) { |
1499 | 1651 |
ctools_include('object-cache'); |
1500 |
// we often store contexts in cache, so let's just make sure we can load |
|
1501 |
// them. |
|
1652 |
// We often store contexts in cache, so let's just make sure we can load them. |
|
1502 | 1653 |
ctools_include('context'); |
1503 | 1654 |
return ctools_object_cache_get($obj, 'panels_display:' . $did, $skip_cache); |
1504 | 1655 |
} |
... | ... | |
1544 | 1695 |
} |
1545 | 1696 |
|
1546 | 1697 |
/** |
1698 |
* Panels Editor Cache Get. |
|
1699 |
* |
|
1547 | 1700 |
* Method to allow modules to provide their own caching mechanism for the |
1548 | 1701 |
* display editor. |
1549 | 1702 |
*/ |
... | ... | |
1553 | 1706 |
return module_invoke($module, 'panels_cache_get', $argument); |
1554 | 1707 |
} |
1555 | 1708 |
|
1556 |
// Fall back to our normal method:
|
|
1709 |
// Fall back to our normal method.
|
|
1557 | 1710 |
return panels_cache_get('display', $cache_key); |
1558 | 1711 |
} |
1559 | 1712 |
|
1560 | 1713 |
/** |
1714 |
* Panels Editor Cache Set. |
|
1715 |
* |
|
1561 | 1716 |
* Method to allow modules to provide their own caching mechanism for the |
1562 | 1717 |
* display editor. |
1563 | 1718 |
*/ |
... | ... | |
1568 | 1723 |
return module_invoke($module, 'panels_cache_set', $argument, $cache); |
1569 | 1724 |
} |
1570 | 1725 |
|
1571 |
// Fall back to our normal method:
|
|
1726 |
// Fall back to our normal method.
|
|
1572 | 1727 |
return panels_cache_set('display', $cache_key, $cache); |
1573 | 1728 |
} |
1574 | 1729 |
|
1575 | 1730 |
/** |
1731 |
* Panels Editor Cache Save. |
|
1732 |
* |
|
1576 | 1733 |
* Method to allow modules to provide their own mechanism to write the |
1577 | 1734 |
* cache used in the display editor. |
1578 | 1735 |
*/ |
... | ... | |
1585 | 1742 |
} |
1586 | 1743 |
} |
1587 | 1744 |
|
1588 |
// Fall back to our normal method:
|
|
1745 |
// Fall back to our normal method.
|
|
1589 | 1746 |
return panels_save_display($cache->display); |
1590 | 1747 |
} |
1591 | 1748 |
|
1592 | 1749 |
/** |
1750 |
* Panels Editor Cache Clear. |
|
1751 |
* |
|
1593 | 1752 |
* Method to allow modules to provide their own mechanism to clear the |
1594 | 1753 |
* cache used in the display editor. |
1595 | 1754 |
*/ |
... | ... | |
1602 | 1761 |
} |
1603 | 1762 |
} |
1604 | 1763 |
|
1605 |
// Fall back to our normal method:
|
|
1764 |
// Fall back to our normal method.
|
|
1606 | 1765 |
return panels_cache_clear('display', $cache_key); |
1607 | 1766 |
} |
1608 | 1767 |
|
... | ... | |
1624 | 1783 |
|
1625 | 1784 |
// Normal panel display editing has no locks, so we do nothing if there is |
1626 | 1785 |
// no fallback. |
1627 |
return; |
|
1628 | 1786 |
} |
1629 | 1787 |
|
1630 |
// -------------------------------------------------------------------------- |
|
1631 |
// Callbacks on behalf of the panel_context plugin. |
|
1632 |
// |
|
1633 |
// The panel_context plugin lets Panels be used in page manager. These |
|
1634 |
// callbacks allow the display editing system to use the page manager |
|
1635 |
// cache rather than the default display cache. They are routed by the cache |
|
1636 |
// key via panels_edit_cache_* functions. |
|
1788 |
/** |
|
1789 |
* Callbacks on behalf of the panel_context plugin. |
|
1790 |
* |
|
1791 |
* The panel_context plugin lets Panels be used in page manager. These |
|
1792 |
* callbacks allow the display editing system to use the page manager |
|
1793 |
* cache rather than the default display cache. They are routed by the cache |
|
1794 |
* key via panels_edit_cache_* functions. |
|
1795 |
*/ |
|
1637 | 1796 |
|
1638 | 1797 |
/** |
1639 | 1798 |
* Get display edit cache on behalf of panel context. |
... | ... | |
1645 | 1804 |
ctools_include('common', 'panels'); |
1646 | 1805 |
ctools_include('context'); |
1647 | 1806 |
ctools_include('context-task-handler'); |
1648 |
// this loads the panel context inc even if we don't use the plugin.
|
|
1807 |
// This loads the panel context inc even if we don't use the plugin.
|
|
1649 | 1808 |
$plugin = page_manager_get_task_handler('panel_context'); |
1650 | 1809 |
|
1651 | 1810 |
list($task_name, $handler_name, $args, $q) = explode('::', $key, 4); |
... | ... | |
1663 | 1822 |
$cache = new stdClass(); |
1664 | 1823 |
|
1665 | 1824 |
$task = page_manager_get_task($page->task_id); |
1666 |
//ctools_context_handler_get_all_contexts($page->task, $page->subtask, $handler); |
|
1667 | 1825 |
$arguments = array(); |
1668 | 1826 |
if ($args) { |
1669 | 1827 |
$arguments = explode('\\', $args); |
... | ... | |
1734 | 1892 |
ctools_object_cache_clear_all('page_manager_page', $page->task_name); |
1735 | 1893 |
} |
1736 | 1894 |
|
1737 |
// -------------------------------------------------------------------------- |
|
1738 |
// Callbacks on behalf of the panels page wizards |
|
1739 |
// |
|
1740 |
// The page wizards are a pluggable set of 'wizards' to make it easy to create |
|
1741 |
// specific types of pages based upon whatever someone felt like putting |
|
1742 |
// together. Since they will very often have content editing, we provide |
|
1743 |
// a generic mechanism to allow them to store their editing cache in the |
|
1744 |
// wizard cache. |
|
1745 |
// |
|
1746 |
// For them to use this mechanism, they just need to use: |
|
1747 |
// $cache = panels_edit_cache_get('panels_page_wizard:' . $plugin['name']); |
|
1895 |
/** |
|
1896 |
* Callbacks on behalf of the panels page wizards. |
|
1897 |
* |
|
1898 |
* The page wizards are a pluggable set of 'wizards' to make it easy to create |
|
1899 |
* specific types of pages based upon whatever someone felt like putting |
|
1900 |
* together. Since they will very often have content editing, we provide |
|
1901 |
* a generic mechanism to allow them to store their editing cache in the |
|
1902 |
* wizard cache. |
|
1903 |
* |
|
1904 |
* For them to use this mechanism, they just need to use: |
|
1905 |
* $cache = panels_edit_cache_get('panels_page_wizard:' . $plugin['name']);. |
|
1906 |
*/ |
|
1748 | 1907 |
|
1749 | 1908 |
/** |
1750 |
* Get display edit cache for the panels mini export UI |
|
1909 |
* Get display edit cache for the panels mini export UI.
|
|
1751 | 1910 |
* |
1752 | 1911 |
* The key is the second half of the key in this form: |
1753 | 1912 |
* panels_page_wizard:TASK_NAME:HANDLER_NAME; |
... | ... | |
1807 | 1966 |
} |
1808 | 1967 |
} |
1809 | 1968 |
|
1810 |
// -------------------------------------------------------------------------- |
|
1811 |
// General utility functions |
|
1969 |
/** |
|
1970 |
* General utility functions. |
|
1971 |
*/ |
|
1812 | 1972 |
|
1813 | 1973 |
/** |
1814 | 1974 |
* Perform a drupal_goto on a destination that may be an array like url(). |
... | ... | |
1818 | 1978 |
return drupal_goto($destination); |
1819 | 1979 |
} |
1820 | 1980 |
else { |
1821 |
// Prevent notices by adding defaults |
|
1981 |
// Prevent notices by adding defaults.
|
|
1822 | 1982 |
$destination += array( |
1823 | 1983 |
'query' => NULL, |
1824 | 1984 |
'fragment' => NULL, |
1825 | 1985 |
'http_response_code' => NULL, |
1826 | 1986 |
); |
1827 | 1987 |
|
1828 |
return drupal_goto($destination['path'], $destination['query'], $destination['fragment'], $destination['http_response_code']); |
|
1988 |
return drupal_goto( |
|
1989 |
$destination['path'], |
|
1990 |
$destination['query'], |
|
1991 |
$destination['fragment'], |
|
1992 |
$destination['http_response_code'] |
|
1993 |
); |
|
1829 | 1994 |
} |
1830 | 1995 |
} |
1831 | 1996 |
|
1832 | 1997 |
|
1833 | 1998 |
/** |
1834 |
* For external use: Given a layout ID and a $content array, return the |
|
1835 |
* panel display. |
|
1999 |
* For external use: Given a layout ID and $content array, return panel display. |
|
1836 | 2000 |
* |
1837 | 2001 |
* The content array is filled in based upon the content available in the |
1838 |
* layout. If it's a two column with a content array defined like |
|
2002 |
* layout. If it's a two column with a content array defined like.
|
|
1839 | 2003 |
* @code |
1840 | 2004 |
* array( |
1841 | 2005 |
* 'left' => t('Left side'), |
1842 | 2006 |
* 'right' => t('Right side') |
1843 | 2007 |
* ), |
1844 |
* @endcode |
|
1845 | 2008 |
* |
1846 | 2009 |
* Then the $content array should be |
1847 | 2010 |
* @code |
... | ... | |
1849 | 2012 |
* 'left' => $output_left, |
1850 | 2013 |
* 'right' => $output_right, |
1851 | 2014 |
* ) |
1852 |
* @endcode |
|
1853 | 2015 |
* |
1854 | 2016 |
* The output within each panel region can be either a single rendered |
1855 | 2017 |
* HTML string or an array of rendered HTML strings as though they were |
... | ... | |
1863 | 2025 |
$display->layout = is_array($layout) ? $layout['name'] : $layout; |
1864 | 2026 |
$display->content = $content; |
1865 | 2027 |
|
1866 |
// Get our simple renderer |
|
2028 |
// Get our simple renderer.
|
|
1867 | 2029 |
$renderer = panels_get_renderer_handler('simple', $display); |
1868 | 2030 |
$renderer->meta_location = $meta; |
1869 | 2031 |
|
... | ... | |
1879 | 2041 |
|
1880 | 2042 |
/** |
1881 | 2043 |
* Implements hook_get_pane_links_alter(). |
1882 |
* |
|
1883 |
* add links to the Panels pane dropdown menu. |
|
1884 | 2044 |
*/ |
1885 | 2045 |
function panels_get_pane_links_alter(&$links, $pane, $content_type) { |
1886 |
if ($pane->type === "block"){ |
|
2046 |
// Add links to the Panels pane dropdown menu. |
|
2047 |
if ($pane->type === "block") { |
|
1887 | 2048 |
$prefixed_name = $pane->subtype; |
1888 | 2049 |
|
1889 |
// breakup the subtype string into parts.
|
|
2050 |
// Breakup the subtype string into parts.
|
|
1890 | 2051 |
$exploded_subtype = explode('-', $pane->subtype); |
1891 | 2052 |
|
1892 |
// get the first part of the string.
|
|
2053 |
// Get the first part of the string.
|
|
1893 | 2054 |
$subtype_prefix = $exploded_subtype[0]; |
1894 | 2055 |
|
1895 |
// get the first part of the string and add a hyphen.
|
|
2056 |
// Get the first part of the string and add a hyphen.
|
|
1896 | 2057 |
$subtype_prefix_hyphen = $exploded_subtype[0] . '-'; |
1897 | 2058 |
|
1898 |
// remove the prefix block- to get the name.
|
|
1899 |
$name_of_block = ltrim( $prefixed_name, $subtype_prefix_hyphen);
|
|
2059 |
// Remove the prefix block- to get the name.
|
|
2060 |
$name_of_block = ltrim($prefixed_name, $subtype_prefix_hyphen); |
|
1900 | 2061 |
|
1901 |
// check for user added menus created at /admin/structure/menu/add
|
|
1902 |
// menus of that type have a subtype that is prefixed with menu-menu- |
|
1903 |
if (substr($prefixed_name, 0, 10) === "menu-menu-"){ |
|
1904 |
// remove the first prefix menu- from menu-menu- to get the name.
|
|
2062 |
// Check for user added menus created at /admin/structure/menu/add
|
|
2063 |
// menus of that type have a subtype that is prefixed with menu-menu-.
|
|
2064 |
if (substr($prefixed_name, 0, 10) === "menu-menu-") {
|
|
2065 |
// Remove the first prefix menu- from menu-menu- to get the name.
|
|
1905 | 2066 |
$name_of_block = substr($prefixed_name, 5); |
1906 | 2067 |
|
1907 | 2068 |
$links['top'][] = array( |
... | ... | |
1917 | 2078 |
); |
1918 | 2079 |
} |
1919 | 2080 |
|
1920 |
// check for module provided menu blocks like Devels or Features |
|
1921 |
// menus of that type have a subtype that is prefixed with menu- |
Formats disponibles : Unified diff
Weekly update of contrib modules