You are here

function panelizer_change_layout_wizard in Panelizer 7.2

Same name and namespace in other branches
  1. 7.3 includes/common.inc \panelizer_change_layout_wizard()

Panelizer layout change form. If there is no content this will be a 'choose' layout form. If there is content it will be a 'change' layout form.

Parameters

$form_state: The initial form state array to be used by the wizard. This *must* contain:

  • 'display': The display whose layout should be changed.
  • 'wizard path': The Drupal path where this wizard lives, so it knows where to redirect to. Note that the layout chosen will be appended to this path for the second step, so the page callback for this wizard needs to make sure to pass that through when teh function is called.

This can also contain:

  • 'allowed_layouts' => The key to the allowed layouts array to use.
  • 'finish' => The text to use on the save button.

$step: The wizard step that must be passed through. It should be in the %step portion of the path.

$layout: A layout that is chosen in the first step. It is passed through the URL so that no caching is needed. The caller needs to be sure to extract this from the URL.

Return value

While the return value is render array, if $form_state['complete'] is true, then$form_state['display'] can be saved by the caller and redirection chosen. If $form_state['cancel'] is true, then the display should not be saved.

2 calls to panelizer_change_layout_wizard()
PanelizerEntityDefault::page_layout in plugins/entity/PanelizerEntityDefault.class.php
panelizer_default_layout_page in includes/admin.inc
Pass through to the panels layout editor.

File

includes/common.inc, line 310
Contains common forms and routines that different object types use.

Code

function panelizer_change_layout_wizard(&$form_state, $step = 'choose', $layout = NULL) {
  ctools_include('common', 'panels');

  // Add defaults to the form state sent in.
  $form_state += array(
    'finish' => t('Save'),
    'allowed_layouts' => '',
    'no_redirect' => TRUE,
    'no buttons' => TRUE,
    'layout' => $layout,
  );
  $form_info = array(
    'id' => 'panelizer_change_layout_wizard',
    'finish text' => $form_state['finish'],
    'path' => $form_state['wizard path'],
    'show back' => TRUE,
    'order' => array(
      'choose' => t('Choose layout'),
    ),
    'forms' => array(
      'choose' => array(
        'form id' => 'panelizer_choose_layout_form',
      ),
      'move' => array(
        'form id' => 'panelizer_move_content_form',
      ),
    ),
  );
  if (!empty($form_state['display']->content)) {
    $form_info['order']['move'] = t('Move content');
  }
  ctools_include('common', 'panels');
  ctools_include('display-layout', 'panels');
  ctools_include('plugins', 'panels');
  ctools_include('wizard');
  $output = ctools_wizard_multistep_form($form_info, $step, $form_state);
  if (!empty($form_state['complete'])) {
    $form_state['display']->layout = $form_state['layout'];
  }
  return $output;
}