You are here

function views_fieldsets_field_options_to_fieldsets_1d in Views fieldsets 7

Same name and namespace in other branches
  1. 7.2 views_fieldsets.module \views_fieldsets_field_options_to_fieldsets_1d()

Helper to make a nice 1D fieldsets array from fields' settings.

3 calls to views_fieldsets_field_options_to_fieldsets_1d()
views_fieldsets_form_views_ui_rearrange_form_alter in ./views_fieldsets.module
Implements hook_form_FORM_ID_alter() for views_ui_rearrange_form().
views_fieldsets_preprocess_views_view_fields__2 in ./views_fieldsets.module
Implements template_preprocess_views_view_fields().
views_fieldsets_views_ui_display_tab_alter in ./views_fieldsets.module
Implements hook_views_ui_display_tab_alter().

File

./views_fieldsets.module, line 203
Hooks, helpers and theming for the Views Fieldsets module.

Code

function views_fieldsets_field_options_to_fieldsets_1d($fields) {

  // Create empty 1D array with `field` => `parent`.
  $fieldsets = $fields ? array_combine(array_keys($fields), array_fill(0, count($fields), '')) : array();

  // Fill `parent` values by iterating through all fields (only the Views Fieldset fields matter).
  foreach ($fields as $field_name => $field) {
    if (isset($field['children'])) {
      foreach ($field['children'] as $child_field_name) {
        $fieldsets[$child_field_name] = $field_name;
      }
    }
  }
  return $fieldsets;
}