page-wizard.inc 2.5 KB

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