You are here

function fieldset_helper_state_manager_get_state in Fieldset helper 7.2

Same name and namespace in other branches
  1. 6.2 fieldset_helper.module \fieldset_helper_state_manager_get_state()
  2. 6 fieldset_helper.module \fieldset_helper_state_manager_get_state()

Get fieldset's collapsed state.

Parameters

$element_id: The DOM element id.

$default_value: Boolean for default state value

1 call to fieldset_helper_state_manager_get_state()
_fieldset_helper_alter_fieldset in ./fieldset_helper.theme.inc
Alter fieldset element and set default collapsible and collapsed attributes.

File

./fieldset_helper.module, line 364

Code

function fieldset_helper_state_manager_get_state($element_id, $default_value = FALSE) {

  // Always return the default value is state management is disabled for anonymous.
  if (user_is_anonymous() && variable_get('fieldset_helper_disable_state_anonymous', 0) == 1) {
    return $default_value;
  }

  // Get fieldset states and lookup ids
  $states = fieldset_helper_state_manager_get_cookie_states();
  $lookup_id = fieldset_helper_state_manager_get_lookup_id($element_id);

  // Return collapsed boolean value.
  if (isset($states[$lookup_id])) {
    return $states[$lookup_id] ? TRUE : FALSE;
  }
  else {
    return $default_value ? TRUE : FALSE;
  }
}