You are here

function ds_build_modes in Display Suite 6

Build modes overview.

1 string reference to 'ds_build_modes'
_ds_ui_menu in includes/ds.registry.inc
Return menu items and import default settings.

File

includes/ds.buildmodes.inc, line 11
Manage build modes.

Code

function ds_build_modes($module) {
  $output = '';
  $action = arg(5);
  $build_mode = arg(6);
  $build_modes = variable_get($module . '_build_modes', array());
  $api_info = ds_api_info($module);
  if (!isset($api_info['no_new_build_modes'])) {

    // Delete form.
    if (in_array($build_mode, array_keys($build_modes)) && $action == 'delete') {
      $output .= drupal_get_form('ds_build_mode_delete_form', $module, $build_mode);
    }
    elseif (in_array($build_mode, array_keys($build_modes)) && $action == 'edit') {
      $output .= drupal_get_form('ds_build_mode_form', $module, $build_mode);
    }
    else {
      if (empty($build_modes)) {
        $output .= '<p>' . t('You have not defined any custom build modes.') . '</p>';
      }
      else {
        $output .= '<p>' . t('This is a list of custom build modes defined via the UI.') . '</p>';
        $header = array(
          t('Name'),
          t('Key'),
          t('Operations'),
        );
        $rows = array();
        foreach ($build_modes as $key => $name) {
          $row = array();
          $row[] = check_plain($name);
          $row[] = $key;
          $row[] = l(t('Edit'), 'admin/build/ds/' . $module . '/buildmodes/edit/' . $key) . ' - ' . l(t('Delete'), 'admin/build/ds/' . $module . '/buildmodes/delete/' . $key);
          $rows[] = $row;
        }
        $output .= theme('table', $header, $rows);
      }

      // New build mode form.
      $output .= drupal_get_form('ds_build_mode_form', $module);
    }
  }

  // Matrix form.
  if (isset($api_info['types'])) {
    $types = $api_info['types']();
    $output .= drupal_get_form('ds_buildmodes_matrix_form', $module, $types);
  }
  return $output;
}