You are here

function ds_extras_select_layout_editor in Display Suite 7

Select the editor depending on layout.

Parameters

$entity_type: The name of the entity type.

$bundle_arg: The position of the bundle argument

$view_mode: The name of the view mode.

1 string reference to 'ds_extras_select_layout_editor'
_ds_extras_menu_alter in modules/ds_extras/ds_extras.registry.inc
Implements hook_menu_alter().

File

modules/ds_extras/ds_extras.admin.inc, line 208
Display Suite Extras administrative functions.

Code

function ds_extras_select_layout_editor($entity_type, $bundle_arg, $view_mode) {

  // Extra the bundle name.
  $bundle = field_extract_bundle($entity_type, $bundle_arg);

  // Check layout.
  $layout = ds_get_layout($entity_type, $bundle, $view_mode);

  // Check switch.
  $panels_editor = TRUE;
  if (variable_get('ds_extras_editor_switch')) {
    if ($layout && !isset($layout['settings']['ds_panels'])) {
      $panels_editor = FALSE;
    }
    if (isset($_GET['switch']) && $_GET['switch'] == 'field_ui') {
      $panels_editor = FALSE;
    }
    if (isset($_GET['switch']) && $_GET['switch'] == 'panels') {
      $panels_editor = TRUE;
    }
  }

  // Select the layout editor.
  if ($panels_editor) {
    module_load_include('inc', 'ds_extras', 'ds_extras.panels');
    return ds_panels_field_ui($entity_type, $bundle, $view_mode);
  }
  else {

    // Use drupal_build_form instead of drupal_get_form.
    $form_state = array();
    $arguments = array(
      $entity_type,
      $bundle,
      $view_mode,
    );
    $form_state['build_info']['args'] = $arguments;
    form_load_include($form_state, 'inc', 'field_ui', 'field_ui.admin');
    return drupal_build_form('field_ui_display_overview_form', $form_state);
  }
}