1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Contains helper functions for the Panels page wizards.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Add layout form helper for panels page wizards.
|
10 |
|
|
*
|
11 |
|
|
* This is not a proper form, it is meant to be called by a form to add
|
12 |
|
|
* elements to it.
|
13 |
|
|
*/
|
14 |
|
|
function panels_page_wizard_add_layout(&$form, &$form_state) {
|
15 |
|
|
$form_state['allowed_layouts'] = 'panels_page';
|
16 |
|
|
$form_state['display'] = $form_state['wizard cache']->display;
|
17 |
|
|
|
18 |
|
|
// Tell the Panels form not to display buttons.
|
19 |
|
|
$form_state['no buttons'] = TRUE;
|
20 |
|
|
|
21 |
|
|
// Change the #id of the form so the CSS applies properly.
|
22 |
|
|
$form['#id'] = 'panels-choose-layout';
|
23 |
|
|
|
24 |
|
|
$form['layout_prefix'] = array(
|
25 |
|
|
'#value' => '<fieldset><legend>' . t('Layout') . '</legend>',
|
26 |
|
|
);
|
27 |
|
|
|
28 |
|
|
ctools_include('common', 'panels');
|
29 |
|
|
ctools_include('display-layout', 'panels');
|
30 |
|
|
ctools_include('plugins', 'panels');
|
31 |
|
|
|
32 |
|
|
$form = panels_choose_layout($form, $form_state);
|
33 |
|
|
|
34 |
|
|
$form['layout_suffix'] = array(
|
35 |
|
|
'#value' => '</fieldset>',
|
36 |
|
|
);
|
37 |
|
|
|
38 |
|
|
// $form_state['cache'] = FALSE;
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
/**
|
42 |
|
|
* Add content editor form helper for panels page wizards.
|
43 |
|
|
*
|
44 |
|
|
* This is not a proper form, it is meant to be called by a form to add
|
45 |
|
|
* elements to it.
|
46 |
|
|
*/
|
47 |
|
|
function panels_page_wizard_add_content(&$form, &$form_state) {
|
48 |
|
|
ctools_include('ajax');
|
49 |
|
|
ctools_include('plugins', 'panels');
|
50 |
|
|
ctools_include('common', 'panels');
|
51 |
|
|
ctools_include('display-edit', 'panels');
|
52 |
|
|
|
53 |
|
|
// Panels provides this caching mechanism to make it easy to use the
|
54 |
|
|
// wizard to cache the display.
|
55 |
|
|
|
56 |
|
|
$cache = panels_edit_cache_get('panels_page_wizard:' . $form_state['plugin']['name']);
|
57 |
|
|
|
58 |
|
|
$form_state['renderer'] = panels_get_renderer_handler('editor', $cache->display);
|
59 |
|
|
$form_state['renderer']->cache = &$cache;
|
60 |
|
|
|
61 |
|
|
$form_state['display'] = &$cache->display;
|
62 |
|
|
$form_state['content_types'] = $cache->content_types;
|
63 |
|
|
// Tell the Panels form not to display buttons.
|
64 |
|
|
$form_state['no buttons'] = TRUE;
|
65 |
|
|
$form_state['display_title'] = !empty($cache->display_title);
|
66 |
|
|
|
67 |
|
|
$form = panels_edit_display_form($form, $form_state);
|
68 |
|
|
}
|
69 |
|
|
|
70 |
|
|
/**
|
71 |
|
|
* Add content form submit handler
|
72 |
|
|
*
|
73 |
|
|
* This is not a proper submit handler, it is meant to be called by a form's
|
74 |
|
|
* submit handler to handle submission.
|
75 |
|
|
*/
|
76 |
|
|
function panels_page_wizard_add_content_submit(&$form, &$form_state) {
|
77 |
|
|
// Call the normal panels edit form submit to make sure values are stored
|
78 |
|
|
// on the display
|
79 |
|
|
panels_edit_display_form_submit($form, $form_state);
|
80 |
|
|
$cache = &$form_state['wizard cache'];
|
81 |
|
|
|
82 |
|
|
// Copy the "being edited" cached display to the "actual" cached display.
|
83 |
|
|
$cache->display = &$form_state['display'];
|
84 |
|
|
unset($cache->display_cache);
|
85 |
|
|
}
|