You are here

function bigmenu_get_cached_mlids in Big Menu 7

Get the menu items that have already been expanded.

Merge in with the form during its construction.

Parameters

array $form_state: The array of submitted form values.

Return value

array The previously cached mlids, including those from expanded parents.

1 call to bigmenu_get_cached_mlids()
bigmenu_overview_form in ./bigmenu.admin.inc
Overview form for bigmenu.

File

./bigmenu.admin.inc, line 75
Administrative page callbacks for bigmenu module.

Code

function bigmenu_get_cached_mlids($form_state) {
  $cached_mlids = array();
  if (!empty($form_state) && !empty($form_state['rebuild_info']) && !empty($form_state['rebuild_info']['copy'])) {
    $form_build_id = $form_state['rebuild_info']['copy']['#build_id'];
    $cached_form = form_get_cache($form_build_id, $form_state);
    if (!empty($cached_form)) {

      // We have previously expanded one of the menu items,
      // so extract the items that were in the cached form
      // so that we can add them to the form that is being built now.
      foreach ($cached_form as $key => $value) {
        $matches = array();
        if (preg_match('/mlid:([0-9]*)/', $key, $matches)) {
          $cached_mlids[$key] = $value;
        }
      }
    }
  }
  return $cached_mlids;
}