497d85f0a8f8ca48592955b0edd40468305a5be3
tdreszer
  Tue Sep 27 17:08:37 2011 -0700
Major rework of subCfg module to no longer rely upon removing name at initialization.
diff --git src/lib/cheapcgi.c src/lib/cheapcgi.c
index 6389564..8aa6be2 100644
--- src/lib/cheapcgi.c
+++ src/lib/cheapcgi.c
@@ -1213,61 +1213,62 @@
                                         char *command)
 /* Make radio type button with onClick command.
  *  A group of radio buttons should have the
  * same name but different values.   The default selection should be
  * sent with checked on. */
 {
 printf("<INPUT TYPE=RADIO NAME=\"%s\" VALUE=\"%s\" %s %s>",
         name, value, command, (checked ? "CHECKED" : ""));
 }
 
 char *cgiBooleanShadowPrefix()
 /* Prefix for shadow variable set with boolean variables. */
 {
 return "boolshad.";
 }
+#define BOOLSHAD_EXTRA "class='cbShadow'"
 
 boolean cgiBooleanDefined(char *name)
 /* Return TRUE if boolean variable is defined (by
  * checking for shadow. */
 {
 char buf[256];
 safef(buf, sizeof(buf), "%s%s", cgiBooleanShadowPrefix(), name);
 return cgiVarExists(buf);
 }
 
 static void cgiMakeCheckBox2Bool(char *name, boolean checked, boolean enabled, char *id, char *moreHtml)
 /* Make check box - designed to be called by the variously overloaded
  * cgiMakeCheckBox functions, and should NOT be called directly.
  * moreHtml: optional additional html like javascript call or mouseover msg (may be NULL)
  * id: button id (may be NULL)
  * Also make a shadow hidden variable and support 2 boolean states:
  *    checked/unchecked and enabled/disabled. */
 {
 char buf[256], idBuf[256];
 
 if(id)
     safef(idBuf, sizeof(idBuf), " id=\"%s\"", id);
 else
     idBuf[0] = 0;
 
 printf("<INPUT TYPE=CHECKBOX NAME=\"%s\"%s VALUE=on %s%s%s>", name, idBuf,
     (moreHtml ? moreHtml : ""),
     (checked ? " CHECKED" : ""),
     (enabled ? "" : " DISABLED"));
 safef(buf, sizeof(buf), "%s%s", cgiBooleanShadowPrefix(), name);
-cgiMakeHiddenVar(buf, ( enabled ? "0" : (checked ? "-1" : "-2")));
+cgiMakeHiddenVarWithExtra(buf, ( enabled ? "0" : (checked ? "-1" : "-2")),BOOLSHAD_EXTRA);
 }
 
 void cgiMakeCheckBoxUtil(char *name, boolean checked, char *msg, char *id)
 /* Make check box - can be called directly, though it was originally meant
  * as the common code for all lower level checkbox routines.
  * However, it's util functionality has been taken over by
  * cgiMakeCheckBoxWithIdAndOptionalHtml() */
 {
 char buf[256];
 
 if(msg)
     safef(buf, sizeof(buf), "TITLE=\"%s\"", msg);
 else
     buf[0] = 0;
 
@@ -1295,64 +1296,63 @@
 /* Make check box with javascript. */
 {
 cgiMakeCheckBox2Bool(name,checked,TRUE,NULL,javascript);
 }
 
 void cgiMakeCheckBoxIdAndJS(char *name, boolean checked, char *id, char *javascript)
 /* Make check box with ID and javascript. */
 {
 cgiMakeCheckBox2Bool(name,checked,TRUE,id,javascript);
 }
 
 void cgiMakeCheckBoxFourWay(char *name, boolean checked, boolean enabled, char *id, char *classes, char *moreHtml)
 /* Make check box - with fourWay functionality (checked/unchecked by enabled/disabled)
  * Also makes a shadow hidden variable that supports the 2 boolean states. */
 {
-char shadName[256], extra[256];
+char shadName[256];
 
 printf("<INPUT TYPE=CHECKBOX NAME='%s'", name);
 if(id)
     printf(" id='%s'", id);
 if(checked)
     printf(" CHECKED");
 if(!enabled)
     {
     if (findWordByDelimiter("disabled",' ', classes) == NULL) // fauxDisabled ?
         printf(" DISABLED");
     }
 if(classes)
     printf(" class='%s'",classes);
 if(moreHtml)
     printf(" %s",moreHtml);
 printf(">");
 
 // The hidden var needs to hold the 4way state
 safef(shadName, sizeof(shadName), "%s%s", cgiBooleanShadowPrefix(), name);
-safef(extra, sizeof(extra), "class='fourWay'");
-cgiMakeHiddenVarWithExtra(shadName, ( enabled ? "0" : (checked ? "-1" : "-2")),extra); // Doesn't need enabled/checked!
+cgiMakeHiddenVarWithExtra(shadName, ( enabled ? "0" : (checked ? "-1" : "-2")),BOOLSHAD_EXTRA); // Doesn't need enabled/checked!
 }
 
 
 void cgiMakeHiddenBoolean(char *name, boolean on)
 /* Make hidden boolean variable. Also make a shadow hidden variable so we
  * can distinguish between variable not present and
  * variable set to false. */
 {
 char buf[256];
 cgiMakeHiddenVar(name, on ? "on" : "off");
 safef(buf, sizeof(buf), "%s%s", cgiBooleanShadowPrefix(), name);
-cgiMakeHiddenVar(buf, "1");
+cgiMakeHiddenVarWithExtra(buf, "1",BOOLSHAD_EXTRA);  // shouldn't this be "0" or "off" ?   Probably any non-"on" will work.
 }
 
 void cgiMakeTextArea(char *varName, char *initialVal, int rowCount, int columnCount)
 /* Make a text area with area rowCount X columnCount and with text: intialVal */
 {
 cgiMakeTextAreaDisableable(varName, initialVal, rowCount, columnCount, FALSE);
 }
 
 void cgiMakeTextAreaDisableable(char *varName, char *initialVal, int rowCount, int columnCount, boolean disabled)
 /* Make a text area that can be disabled. The rea has rowCount X
  * columnCount and with text: intialVal */
 {
 printf("<TEXTAREA NAME=\"%s\" ROWS=%d COLS=%d %s>%s</TEXTAREA>", varName,
        rowCount, columnCount, disabled ? "DISABLED" : "",
        (initialVal != NULL ? initialVal : ""));