1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * @file |
---|
5 | * Contains helper functions for the Panels page wizards. |
---|
6 | */ |
---|
7 | function panels_page_wizard_add_layout(&$form, &$form_state) { |
---|
8 | $form_state['allowed_layouts'] = 'panels_page'; |
---|
9 | $form_state['display'] = $form_state['cache']->display; |
---|
10 | |
---|
11 | // Tell the Panels form not to display buttons. |
---|
12 | $form_state['no buttons'] = TRUE; |
---|
13 | |
---|
14 | // Change the #id of the form so the CSS applies properly. |
---|
15 | $form['#id'] = 'panels-choose-layout'; |
---|
16 | |
---|
17 | $form['layout_prefix'] = array( |
---|
18 | '#value' => '<fieldset><legend>' . t('Layout') . '</legend>', |
---|
19 | ); |
---|
20 | |
---|
21 | ctools_include('common', 'panels'); |
---|
22 | ctools_include('display-layout', 'panels'); |
---|
23 | ctools_include('plugins', 'panels'); |
---|
24 | |
---|
25 | $form = array_merge($form, panels_choose_layout($form_state)); |
---|
26 | |
---|
27 | $form['layout_suffix'] = array( |
---|
28 | '#value' => '</fieldset>', |
---|
29 | ); |
---|
30 | } |
---|
31 | |
---|
32 | function panels_page_wizard_add_content(&$form, &$form_state) { |
---|
33 | ctools_include('ajax'); |
---|
34 | ctools_include('plugins', 'panels'); |
---|
35 | ctools_include('common', 'panels'); |
---|
36 | ctools_include('display-edit', 'panels'); |
---|
37 | |
---|
38 | // Panels provides this caching mechanism to make it easy to use the |
---|
39 | // wizard to cache the display. |
---|
40 | |
---|
41 | $cache = panels_edit_cache_get('panels_page_wizard:node_override'); |
---|
42 | |
---|
43 | $form_state['renderer'] = panels_get_renderer_handler('editor', $cache->display); |
---|
44 | $form_state['renderer']->cache = &$cache; |
---|
45 | |
---|
46 | $form_state['display'] = &$cache->display; |
---|
47 | $form_state['content_types'] = $cache->content_types; |
---|
48 | // Tell the Panels form not to display buttons. |
---|
49 | $form_state['no buttons'] = TRUE; |
---|
50 | $form_state['display_title'] = !empty($cache->display_title); |
---|
51 | |
---|
52 | $form = array_merge($form, panels_edit_display_form($form_state)); |
---|
53 | // Make sure the theme will work since our form id is different. |
---|
54 | $form['#theme'] = 'panels_edit_display_form'; |
---|
55 | } |
---|
56 | |
---|
57 | function panels_page_wizard_add_content_submit(&$form, &$form_state) { |
---|
58 | // Call the normal panels edit form submit to make sure values are stored |
---|
59 | // on the display |
---|
60 | panels_edit_display_form_submit($form, $form_state); |
---|
61 | $cache = &$form_state['cache']; |
---|
62 | |
---|
63 | // Copy the "being edited" cached display to the "actual" cached display. |
---|
64 | $cache->display = &$form_state['display']; |
---|
65 | unset($cache->display_cache); |
---|
66 | } |
---|
67 | |
---|