You are here

function spaces_dashboard_admin_region_form in Spaces 6.3

Same name and namespace in other branches
  1. 7.3 spaces_dashboard/spaces_dashboard.admin.inc \spaces_dashboard_admin_region_form()
  2. 7 spaces_dashboard/spaces_dashboard.admin.inc \spaces_dashboard_admin_region_form()

Allow administrators to select which regions and layouts are available in dashboards.

1 string reference to 'spaces_dashboard_admin_region_form'
spaces_dashboard_menu in spaces_dashboard/spaces_dashboard.module
Implementation of hook_menu()

File

spaces_dashboard/spaces_dashboard.admin.inc, line 79

Code

function spaces_dashboard_admin_region_form($form_state) {
  $theme_key = variable_get('theme_default', 'garland');
  $layouts = module_exists('context_layouts') ? context_layouts_get_layouts($theme_key) : array();
  if (empty($layouts)) {
    $layouts['default'] = array(
      'title' => t('Default'),
      'description' => t('Default layout'),
      'regions' => array_keys(system_region_list($theme_key)),
    );
  }
  $region_labels = system_region_list($theme_key);
  $form = array();
  $form['spaces_dashboard_layouts'] = array(
    '#tree' => TRUE,
  );
  $form['spaces_dashboard_regions'] = array(
    '#tree' => TRUE,
  );
  $default_layouts = variable_get('spaces_dashboard_layouts', array());
  $default_regions = variable_get('spaces_dashboard_regions', array());
  foreach ($layouts as $k => $v) {
    if (!empty($v['regions'])) {
      $form['spaces_dashboard_layouts'][$k] = array(
        '#type' => 'checkbox',
        '#title' => isset($v['name']) ? $v['name'] : $k,
        '#description' => isset($v['description']) ? $v['description'] : NULL,
        '#default_value' => isset($default_layouts[$k]) ? $default_layouts[$k] : TRUE,
      );
      foreach ($v['regions'] as $region) {
        $form['spaces_dashboard_regions'][$k][$region] = array(
          '#type' => 'checkbox',
          '#title' => check_plain($region_labels[$region]),
          '#grouping' => isset($v['name']) ? check_plain($v['name']) : $k,
          '#grouping_id' => $k,
          '#default_value' => isset($default_regions[$k][$region]) ? $default_regions[$k][$region] : TRUE,
        );
      }
    }
  }
  $form = system_settings_form($form);
  $form['#theme'] = 'spaces_dashboard_admin_region_form';
  return $form;
}