You are here

function fieldset_helper_state_manager_get_cookie_states in Fieldset helper 6.2

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

Get an associated array for lookup id and the element's state (1 or 0) from $_COOKIE['fieldset_helper_state_manager'].

Parameters

$clear: Optional boolean when set to TRUE will clear any cached cookie states.

1 call to fieldset_helper_state_manager_get_cookie_states()
fieldset_helper_state_manager_get_state in ./fieldset_helper.module
Get fieldset's collapsed state.

File

./fieldset_helper.module, line 350

Code

function fieldset_helper_state_manager_get_cookie_states($clear = FALSE) {
  static $states;
  if (isset($states) && $clear == FALSE) {
    return $states;
  }
  $states = array();
  if (!isset($_COOKIE['fieldset_helper_state_manager'])) {
    return $states;
  }
  else {
    $values = explode('_', $_COOKIE['fieldset_helper_state_manager']);
    foreach ($values as $value) {
      $params = explode('.', $value);
      $states[$params[0]] = $params[1] == '1' ? TRUE : FALSE;
    }
    return $states;
  }
}