You are here

public function ctools_export_ui::get_wizard_info in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 plugins/export_ui/ctools_export_ui.class.php \ctools_export_ui::get_wizard_info()

Get the form info for the wizard.

This gets the form info out of the plugin, then adds defaults based on how we want edit forms to work.

Overriding this can allow child UIs to tweak this info for specialized wizards.

Parameters

array $form_state: The already created form state.

2 calls to ctools_export_ui::get_wizard_info()
ctools_export_ui::edit_execute_form_wizard in plugins/export_ui/ctools_export_ui.class.php
Execute the wizard for editing.
stylizer_ui::get_wizard_info in stylizer/plugins/export_ui/stylizer_ui.class.php
Get the form info for the wizard.
1 method overrides ctools_export_ui::get_wizard_info()
stylizer_ui::get_wizard_info in stylizer/plugins/export_ui/stylizer_ui.class.php
Get the form info for the wizard.

File

plugins/export_ui/ctools_export_ui.class.php, line 814

Class

ctools_export_ui
Base class for export UI.

Code

public function get_wizard_info(&$form_state) {
  if (!isset($form_state['step'])) {
    $form_state['step'] = NULL;
  }
  $export_key = $this->plugin['export']['key'];

  // When cloning, the name of the item being cloned is referenced in the
  // path, not the name of this item.
  if ($form_state['form type'] == 'clone') {
    $name = $form_state['original name'];
  }
  else {
    $name = $form_state['item']->{$export_key};
  }
  $form_info = !empty($this->plugin['form info']) ? $this->plugin['form info'] : array();
  $form_info += array(
    'id' => 'ctools_export_ui_edit',
    'path' => ctools_export_ui_plugin_menu_path($this->plugin, $form_state['form type'], $name) . '/%step',
    'show trail' => TRUE,
    'free trail' => TRUE,
    'show back' => $form_state['form type'] == 'add',
    'show return' => FALSE,
    'show cancel' => TRUE,
    'finish callback' => 'ctools_export_ui_wizard_finish',
    'next callback' => 'ctools_export_ui_wizard_next',
    'back callback' => 'ctools_export_ui_wizard_back',
    'cancel callback' => 'ctools_export_ui_wizard_cancel',
    'order' => array(),
    'import order' => array(
      'import' => t('Import code'),
      'settings' => t('Settings'),
    ),
  );

  // Set the order of forms based on the op if we have a specific one.
  if (isset($form_info[$form_state['form type'] . ' order'])) {
    $form_info['order'] = $form_info[$form_state['form type'] . ' order'];
  }

  // We have generic fallback forms we can use if they are not specified,
  // and they automatically delegate back to the UI object. Use these if
  // not specified.
  foreach ($form_info['order'] as $key => $title) {
    if (empty($form_info['forms'][$key])) {
      $form_info['forms'][$key] = array(
        'form id' => 'ctools_export_ui_edit_item_wizard_form',
      );
    }
  }

  // 'free trail' means the wizard can freely go back and form from item
  // via the trail and not with next/back buttons.
  if ($form_state['form type'] == 'add' || $form_state['form type'] == 'import' && empty($form_state['item']->{$export_key})) {
    $form_info['free trail'] = FALSE;
  }
  return $form_info;
}