You are here

function ds_fieldgroups in Display Suite 6.2

Same name and namespace in other branches
  1. 6.3 includes/ds.groups.inc \ds_fieldgroups()
  2. 6 includes/ds.groups.inc \ds_fieldgroups()

Fieldgroups overview.

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

File

includes/ds.groups.inc, line 11
Manage fieldgroups.

Code

function ds_fieldgroups($module) {
  $output = '';
  $action = check_plain(arg(6));
  $fieldgroup = check_plain(arg(7));
  drupal_add_js(drupal_get_path('module', 'ds') . '/js/fields.js');

  // Get API information.
  $api_info = ds_api_info($module);

  // Extra info.
  $extra = array();

  // Get fields.
  $db_fields = variable_get($module . '_fields', array());

  // Delete form.
  if (in_array($fieldgroup, array_keys($db_fields)) && $action == 'delete') {
    $output .= drupal_get_form('ds_fieldgroup_delete_form', $module, $fieldgroup);
  }
  elseif (in_array($fieldgroup, array_keys($db_fields)) && $action == 'edit') {
    $output .= drupal_get_form('ds_fieldgroup_form', $module, $fieldgroup, $db_fields[$fieldgroup]);
  }
  else {
    $rows = array();
    foreach ($db_fields as $key => $value) {
      if ($value['type'] == DS_FIELD_TYPE_GROUP) {
        $row = array();
        $row[] = l($value['title'], DS_PATH_MODULES . '/' . $module . '/fieldgroups/edit/' . $key);
        $row[] = $key;
        $operations = l(t('Edit'), DS_PATH_MODULES . '/' . $module . '/fieldgroups/edit/' . $key);
        $operations .= ' - ' . l(t('Delete'), DS_PATH_MODULES . '/' . $module . '/fieldgroups/delete/' . $key);
        $row[] = $operations;
        $rows[] = $row;
      }
    }
    if (!empty($rows)) {
      $header = array(
        t('Title'),
        t('Key'),
        t('Operations'),
      );
      $output .= '<p>' . t('This is a list of fieldgroups defined via the UI.') . '</p>';
      $output .= theme('table', $header, $rows);
    }
    else {
      $output .= '<p>' . t('You have not defined any custom fieldgroups.') . '</p>';
    }

    // Additional modules support.
    if ($module == 'nd') {
      $output .= '<p>' . t('<strong>Additional modules</strong><br />These fieldgroups are independant from the fieldgroups module that comes with the CCK package.<br />You can also output fieldgroups as tabs if you have the <a href="!url_tabs">tabs</a> module enabled.<br />It\'s not necessary to have the fieldgroup and/or <a href="!url_cck_tabs">CCK fieldgroup tabs</a> modules enabled.', array(
        '!url_tabs' => 'http://drupal.org/project/tabs',
        '!url_cck_tabs' => 'http://drupal.org/project/cck_fieldgroup_tabs',
      )) . '</p>';
    }
    else {
      $output .= '<p>' . t('<strong>Additional modules</strong><br />You can also output fieldgroups as tabs if you have the <a href="!url_tabs">tabs</a> module enabled.', array(
        '!url_tabs' => 'http://drupal.org/project/tabs',
        '!url_cck_tabs' => 'http://drupal.org/project/cck_fieldgroup_tabs',
      )) . '</p>';
    }

    // New fieldgroup form.
    $output .= drupal_get_form('ds_fieldgroup_form', $module, $fieldgroup);
  }
  return $output;
}