Roxen.git / server / base_server / wizard.pike

version» Context lines:

Roxen.git/server/base_server/wizard.pike:1:   // This file is part of Roxen WebServer.   // Copyright © 1997 - 2009, Roxen IS.   //   // Wizard generator - // $Id: wizard.pike,v 1.175 2011/06/17 11:28:23 mast Exp $ + // $Id$      /* wizard_automaton operation (old behavior if it isn't defined):       mapping(string:array) wizard_automaton = ([    "foo": ({dispatch, prev_page, next_page, page_name}),    ...    ]);       dispatch: A string redirects the wizard to that page. 0 or the    name of this page continues with it.
Roxen.git/server/base_server/wizard.pike:366:    " onClick='PREFIX_colsel_click(event, 0, \"y\"); return false;'"    " style='position: absolute;"    " cursor: crosshair;"    " z-index: 2'>"    " <img src='/internal-roxen-colsel-mark-y-small'"    " id='PREFIX_mark_y_small'"    " style='position: absolute;"    " cursor: pointer;"    " z-index: 2'>"    " <table border='0' cellspacing='0' cellpadding='4' bgcolor='#ffffff'" +  " class='roxen-color-selector'"    " style='border-top: 1px solid #888888;"    " border-left: 1px solid #888888;"    " border-bottom: 2px solid #888888;"    " border-right: 2px solid #888888'>"    " <tr>"    " <td style='border-right: 1px solid #888888'"    " ><img src='/internal-roxen-colsel-small'"    " width='128' height='128' style='cursor: crosshair'"    " onClick='PREFIX_colsel_click(event, 0); return false;'"    " /></td>"    " <td><img id='PREFIX_colorbar' width='16' height='128'"    " src='/internal-roxen-colorbar-small:" + h + "," + v + ",-1'"    " style='cursor: pointer'"    " onClick='PREFIX_colsel_click(event, 1); return false;'"    " /></td>"    " </tr><tr>"    " <td colspan='2' style='border-top: 1px solid #888888'"    " ><img src='/internal-roxen-pixel-000000'" -  +  " class='black'"    " width='76' height='10' style='cursor: pointer'"    " onClick='PREFIX_colsel_type(\"#000000\", 1);' "    " /><img src='/internal-roxen-pixel-ffffff'" -  +  " class='white'"    " width='76' height='10' style='cursor: pointer'"    " onClick='PREFIX_colsel_type(\"#FFFFFF\", 1);' "    " /></td>"    " </tr>"    " </table>"    "</js-popup>"       // These initializations used to be in the style attributes above    // but MSIE 6.0 failed to recognize them so we execute them explicitly    // instead.
Roxen.git/server/base_server/wizard.pike:719: Inside #if defined(USE_WIZARD_COOKIE)
   // then.    string state_form = "";    id->add_response_header("Set-Cookie",    sprintf("WizardState=%s; path=/",    compress_state(id->real_variables) - "\r\n"));   #else    string state_form = "<input type=\"hidden\" name=\"_state\" value=\""+    compress_state(id->real_variables)+"\" />\n";   #endif    +  string wizard_id = Roxen.get_wizard_id_cookie(id);    res = ("\n<!--Wizard-->\n" -  "<form " + method + ">\n" + +  "<form " + method + ">\n" +  "<input type=\"hidden\" name=\"_roxen_wizard_id\" value=\"" + +  html_encode_string(wizard_id) + "\" />\n" +    (stringp (id->variables->action) ? -  "<input type=\"hidden\" name=\"action\" value=\""+id->variables->action+"\" />\n" : +  "<input type=\"hidden\" name=\"action\" value=\"" + +  html_encode_string(id->variables->action) + "\" />\n" :    "") + -  "<input type=\"hidden\" name=\"_page\" value=\""+page+"\" />\n" +  "<input type=\"hidden\" name=\"_page\" value=\"" + +  html_encode_string(page) + "\" />\n"    +state_form+    "<table bgcolor=\"#000000\" cellpadding=\"1\" border=\"0\" cellspacing=\"0\" width=\"80%\">\n"    " <tr><td><table bgcolor=\"#eeeeee\" cellpadding=\"0\" "    "cellspacing=\"0\" border=\"0\" width=\"100%\">\n"    " <tr><td valign=\"top\"><table width=\"100%\" cellspacing=\"0\" cellpadding=\"5\">\n"    " <tr><td valign=top><font size=\"+2\">"+make_title()+"</font></td>\n"    "<td align=\"right\">"+    (wiz_name=="done"    ?LABEL(completed_label, LOCALE(52, "Completed"))    :page_name || (max_page?LABEL(page_label, LOCALE(53, "Page "))+(pageno+1)+"/"+(max_page+1):""))+
Roxen.git/server/base_server/wizard.pike:850:    }       mapping(string:array) vars = id->real_variables;    foreach(s; string q; array var)    if (!vars[q])    vars[q] = var;       return id->misc->wizard_state = s;   }    + protected void reset_buttons(FakedVariables v) + { +  m_delete (v, "next_page"); +  m_delete (v, "next_page.x"); +  m_delete (v, "next_page.y"); +  m_delete (v, "prev_page"); +  m_delete (v, "prev_page.x"); +  m_delete (v, "prev_page.y"); +  m_delete (v, "ok"); +  m_delete (v, "ok.x"); +  m_delete (v, "ok.y"); + } +    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);
Roxen.git/server/base_server/wizard.pike:887:    }    }    id->real_variables[override_var] = ({ override_value });    }    }       FakedVariables v=id->variables;       int current_page = (int) v->_page;    +  string wizard_id = Roxen.get_wizard_id_cookie(id); +  if (!sizeof(wizard_id || "")) { +  // Create a new cookie. +  // Set the secure flag on the cookie if accessed over https [WS-135]. +  // NB: The cookie is used from Javascript, so it can't have +  // httponly set. +  wizard_id = Roxen.set_wizard_id_cookie(id); +  DEBUGMSG(sprintf("Wizard: Generated new wizard_id: %s\n", wizard_id)); +  } +  if (wizard_id != id->variables["_roxen_wizard_id"]) { +  // Invalid or unset roxen_wizard_id. +  if (current_page) { +  report_warning("Wizard: Invalid wizard_id: %O != %O.\n" +  "Resetting page from %O to 0.\n", +  v["_roxen_wizard_id"], wizard_id, +  current_page); +  } +  // Correct it, and return to page #0. +  id->real_variables["_roxen_wizard_id"] = ({ wizard_id }); +  current_page = 0; +  m_delete(id->real_variables, "_page"); +  m_delete(v, "_page"); +  // Also reset some typical action buttons as a preventive measure. +  reset_buttons(v); +  // FIXME: Do we need to reset any other variables? +  } +     mapping(string:array) automaton = this_object()->wizard_automaton;    function dispatcher;    string oldpage, page_name;    if (automaton && (!v->_page || v->next_page || v["next_page.x"] ||    v->prev_page || v["prev_page.x"] ||    v->ok || v["ok.x"])) {    if (!v->_page && automaton->start) v->_page = "start";    oldpage = v->_page;    if (v->_page) {    array page_state = automaton[v->_page];
Roxen.git/server/base_server/wizard.pike:909:    function|string redirect = page_state[0];    if (functionp (redirect)) {    dispatcher = redirect;    DEBUGMSG (sprintf ("Wizard: Running dispatch function %O for page %s\n",    redirect, v->_page));    redirect = redirect (id, v->_page, @args);    }    if (stringp (redirect) && redirect != v->_page) {    DEBUGMSG ("Wizard: Internal redirect to page " + redirect + "\n");    // Redirect takes precedence over the user choice. -  m_delete (v, "next_page"); -  m_delete (v, "next_page.x"); -  m_delete (v, "next_page.y"); -  m_delete (v, "prev_page"); -  m_delete (v, "prev_page.x"); -  m_delete (v, "prev_page.y"); -  m_delete (v, "ok"); -  m_delete (v, "ok.x"); -  m_delete (v, "ok.y"); +  reset_buttons(v);    v->_page = redirect;    }    }    }       if(v->next_page || v["next_page.x"])    {    function c=this_object()["verify_"+v->_page];    int fail = 0;    if (functionp (c)) {