Branch: Tag:

2011-05-28

2011-05-28 13:26:09 by Martin Stjernholm <mast@lysator.liu.se>

Moved the state decode step to a separate function.

Rev: server/base_server/wizard.pike:1.172

2:   // Copyright © 1997 - 2009, Roxen IS.   //   // Wizard generator - // $Id: wizard.pike,v 1.171 2011/04/06 21:21:29 mast Exp $ + // $Id: wizard.pike,v 1.172 2011/05/28 13:26:09 mast Exp $      /* wizard_automaton operation (old behavior if it isn't defined):   
806:      #define PAGE(X) ((string)(((int)v->_page)+(X)))    - mapping|string wizard_for(RequestID id,string cancel,mixed ... args) + mapping(string:array) wizard_get_state (RequestID id) + //! Decodes the wizard state and incorporates it into + //! id->real_variables, letting existing variables override those from + //! the wizard state. Returns the wizard state without overrides.   { -  string data; -  int offset = 1; -  string wiz_name = "page_"; +  mapping(string:array) s = id->misc->wizard_state; +  if (s) return s;    -  mapping s; -  { +     string state_str;   #ifdef USE_WIZARD_COOKIE    state_str = id->real_variables->_page && id->cookies->WizardState;
840:    s->cancel_url = s->done_url = ({referrer});    }    } +  +  mapping(string:array) vars = id->real_variables; +  foreach(vars; string q; array var) +  if (!vars[q]) +  vars[q] = var; +  +  return id->misc->wizard_state = s;   }    -  + mapping|string wizard_for(RequestID id,string cancel,mixed ... args) + { +  string data; +  int offset = 1; +  string wiz_name = "page_"; +  +  mapping(string:array) s = wizard_get_state (id); +     if(id->real_variables->cancel || id->real_variables["cancel.x"])    return wizard_cancel_exit (s, cancel, id);    -  mapping å = id->real_variables; -  foreach(indices(s), string q) -  å[q] = å[q]||s[q]; -  +     // Handle double posting of variables in select override widgets    foreach(Array.uniq(id->real_variables->__select_override_vars || ({ }) ),    string override_combo) {