Export data classes found in the configs as XML fragments that define default forms and form-handlers. This facility is provided as a development aid in order to save time. The output is to file name "classforms.def" in the current directory which should always be the development config directory for the website. The facility is invoked by calling Dissemino with "-forms" supplied as an argument. Dissemino will load the configs, write the classforms.def file and then exit. There will be one form and one form-handler generated for each class found in the configs, including those for which form(s) currently exists. Forms in HTML cannot be nested so in cases where class members are composite (have a data type which is another class), the form produced will contain an extra button for each composite member. The class which a member has as its data type will have to have been declare beforehand (otherwise the configs cannot be read in), and this will have a form and form handler. The ...

Return TypeFunction nameArguments
hzEcodehdsApp::ExportDefaultForm(hzString&,)

Declared in file: hzDissemino.h
Defined in file : hdsResource.cpp

Function Logic:

0:START 1:items pebuf pebuf pebuf pebuf 2:unknown 3:pIncl dfltInclude 4:pClass 5:unknown 6:Return hzerr(E_NOTFOUND,No such class as %s\n,*cname) 7:items bUser 8:unknown 9:bUser 10:items items items 11:unknown 12:items 13:items items items 14:unknown 15:pMem mname items 16:items items items items 17:unknown 18:items 19:items items items 20:unknown 21:items 22:items 23:items items 24:unknown 25:pMem mname pSpec 26:unknown 27:items 28:unknown 29:items 30:items 31:items items items items 32:items items items items 33:unknown 34:items items items 35:unknown 36:pMem mname items 37:items items items items items items items items items items items items items items items items 38:unknown 39:pMem mname items 40:items items items 41:items items items 42:unknown 43:pMem mname items 44:items items items items 45:items 46:unknown 47:items items items 48:unknown 49:items 50:items 51:unknown 52:items 53:items 54:items 55:items 56:Return rc

Function body:

hzEcode hdsApp::ExportDefaultForm (hzString& cname)
{
   //  Export data classes found in the configs as XML fragments that define default forms and form-handlers. This facility is provided as a development aid in
   //  order to save time. The output is to file name "classforms.def" in the current directory which should always be the development config directory for the
   //  website. The facility is invoked by calling Dissemino with "-forms" supplied as an argument. Dissemino will load the configs, write the classforms.def
   //  file and then exit.
   //  
   //  There will be one form and one form-handler generated for each class found in the configs, including those for which form(s) currently exists. Forms in
   //  HTML cannot be nested so in cases where class members are composite (have a data type which is another class), the form produced will contain an extra
   //  button for each composite member. The class which a member has as its data type will have to have been declare beforehand (otherwise the configs cannot
   //  be read in), and this will have a form and form handler. The ...
   _hzfunc("hdsApp::ExportDefaultForm") ;
   ofstream            os ;            //  Output file
   hzChain             Z ;             //  Output chain
   const hdsFldspec*   pSpec ;         //  Field spec
   const hdbMember*    pMem ;          //  Data class member pointer
   const hdbClass*     pClass ;        //  Data class pointer
   hdsBlock*           pIncl ;         //  Pointer to default include block
   hzString            dfltInclude ;   //  Use a <xinclude> block in pages?
   const char*         mname ;         //  Member name
   uint32_t            nM ;            //  Data class member iterator
   bool                bUser ;         //  True is class is a user class
   char                fname[80];      //  Filename
   char                pebuf[4];       //  Percent entity form
   hzEcode             rc = E_OK ;     //  Return code
   m_pLog->Log("Have %d classes and %d repositories\n", m_ADP.CountDataClass(), m_ADP.CountObjRepos()) ;
   pebuf[0]= CHAR_PERCENT ;
   pebuf[1]= ''s'';
   pebuf[2]= '':'';
   pebuf[3]= 0;
   if (m_Includes.Count())
   {
       pIncl = m_Includes.GetObj(0);
       dfltInclude = pIncl->m_Refname ;
   }
   pClass = m_ADP.GetPureClass(cname) ;
   if (!pClass)
       return hzerr(E_NOTFOUND, "No such class as %s\n", *cname) ;
   m_pLog->Log("Doing class %s with %d members\n", *cname, pClass->MbrCount()) ;
   bUser = false ;
   if (m_UserTypes.Exists(cname))
       bUser = true ;
   //  Start the XML output
   Z << "<disseminoInclude>\n" ;
   /*
   **  ** Write out a basic list page for the class
   **      */
   Z.Printf("<xpage path=\"/list_%s\" subject=\"%s\" title=\"List %s\" access=\"any\" bgcolor=\"eeeeee\" ops=\"noindex\">\n",
       *cname, *pClass->m_Category, *cname) ;
   Z << "\t<desc>None</desc>\n" ;
   if (dfltInclude)
       Z.Printf("\t<xblock name=\"%s\"/>\n", *dfltInclude) ;
   Z.AddByte(CHAR_NL) ;
   Z.Printf("\t<xtable repos=\"%s\" criteria=\"all\" rows=\"10000\" width=\"90\" height=\"500\" css=\"main\">\n", *cname) ;
   Z <<
   "\t\t<ifnone><p>Sorry no records ...</p></ifnone>\n\t\t<header>Table header ...</header>\n\t\t<footer>Table footer ...</footer>\n"
                                             ;
   for (nM = 0; nM < pClass->MbrCount() ; nM++)
   {
       pMem = pClass->GetMember(nM) ;
       mname = pMem->txtName() ;
       Z.Printf("\t\t<xcol member=\"%s\" title=\"%s\"/>\n", mname, mname) ;
   }
   Z << "\t</xtable>\n" ;
   Z << "</xpage>\n" ;
   /*
   **  ** Write out a basic host page for the form for the class
   **      */
   Z.Printf("<xpage path=\"/add_%s\" subject=\"%s\" title=\"Add %s\" access=\"any\" bgcolor=\"eeeeee\" ops=\"noindex\">\n", *cname, *pClass->m_Category, *cname) ;
   Z << "\t<desc>None</desc>\n" ;
   if (dfltInclude)
       Z.Printf("\t<xblock name=\"%s\"/>\n", *dfltInclude) ;
   Z.AddByte(CHAR_NL) ;
   Z <<
   "<style>\n.tooltip { position: relative; display: inline-block; border-bottom: 1px dotted black; }\n.tooltip .tooltiptext { visibility: hidden; width: 120px; background-color: black; color: #fff; text-align: center; padding: 5px 0; border-radius: 6px; position: absolute; z-index: 1; }\n.tooltip:hover .tooltiptext { visibility: visible; }\n</style>\n\n"
                  ;
   Z <<
   "\t<table width=\"96%\" align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n\t\t<tr><td height=\"20\"> </td></tr>\n\t\t<tr><td class=\"title\" align=\"center\">Title: Add a "
                                                                << cname << "</td></tr>\n\t\t<tr>\n\t\t<td valign=\"top\" align=\"center\" class=\"main\">\n\t\t<p>\n\t\tUse this form to create an instance of "
                                                 << cname << "\n\t\t</p>\n\t\t</td>\n\t</tr>\n\t<xdiv user=\"public\">\n\t<tr><td height=\"20\"> </td></tr>\n\t<tr>\n\t\t<td height=\"20\" align=\"center\" class=\"main\">\n\t\tPlease be aware that by submitting this form, you are consenting to the use of cookies. Please read our cookie policy to <a href=\"/cookies\">find out more</a>\n\t\t</td>\n\t</tr>\n\t</xdiv>\n\t<tr><td height=\"40\"> </td></tr>\n\t</table>\n\n"
                    ;
   //  Now write out the form itself
   if (bUser)
       Z.Printf("\t<xform name=\"form_reg_%s\" action=\"fhdl_phase1_%s\" class=\"%s\">\n", *cname, *cname, *cname) ;
   else
       Z.Printf("\t<xform name=\"form_add_%s\" action=\"fhdl_add_%s\" class=\"%s\">\n", *cname, *cname, *cname) ;
   Z << "\t<xhide name=\"lastpage\" value=\"%x:referer;\"/>\n\n" ;
   Z << "\t<table width=\"56%\" align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"main\">\n" ;
   for (nM = 0; nM < pClass->MbrCount() ; nM++)
   {
       pMem = pClass->GetMember(nM) ;
       mname = pMem->txtName() ;
       pSpec = pMem->GetSpec() ;
       if (!pSpec)
           { m_pLog->Log("Warning No Field specification for member %s\n", mname) ; continue ; }
       if (pSpec->m_Desc)
           Z.Printf("\t\t<tr height=\"18\"><td class=\"fld\"><div class=\"tooltip\">%s<span class=\"tooltiptext\">%s</span></div>:</td>\t<td><xfield member=\"%s\"",
               *pSpec->m_Title, *pSpec->m_Desc, mname) ;
       else
           Z.Printf("\t\t<tr height=\"18\"><td class=\"fld\">%s:</td>\t<td><xfield member=\"%s\"", *pSpec->m_Title, mname) ;
       Z << "\tdata=\"" ; Z << pebuf ; Z << mname << "\"" ;
       Z << "\tflags=\"req\"/></td></tr>\n" ;
   }
   Z << "\t</table>\n" ;
   //  Write out a rudimentry page footer
   Z <<
   "\t<table width=\"96%\" align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"fld\">\n\t\t<tr height=\"50\"><td align=\"center\"><xbutton show=\"Abort\"/> <xbutton show=\"Submit\"/></td></tr>\n\t\t<tr height=\"50\" bgcolor=\"#CCCCCC\"><td class=\"vb10blue\"><center>Site Name</center></td></tr>\n\t</table>\n"
                  ;
   Z << "\t</xform>\n" ;
   Z << "</xpage>\n\n" ;
   //  Write form-handler for class
   if (bUser)
   {
       //  Write out user registration form-handler. This will be the first form-handler (with name of the form fhdl_classname), with a sendemail step to
       //  conduct email verification and reference to a second form-handler. This second form handler will also be produced and will commit a new user.
       Z.Printf("<formhdl name=\"fhdl_phase1_%s\" form=\"form_reg_%s\" ops=\"cookie\">\n", *cname, *cname) ;
       Z << "\t<procdata>\n" ;
       //  Do the <setvar tags for all the members
       Z << "\t\t<setvar name=\"iniCode\" type=\"uint32_t\" value=\"%x:usecs;\"/>\n" ;
       for (nM = 0; nM < pClass->MbrCount() ; nM++)
       {
           pMem = pClass->GetMember(nM) ;
           mname = pMem->txtName() ;
           Z.Printf("\t\t<setvar name=\"%s\" type=\"%s\" value=\"%ce:%s;\"/>\n", mname, pSpec->m_pType->txtType() , CHAR_PERCENT, mname) ;
       }
       //  Do the send email code thing
       Z.Printf("\t\t<sendemail from=\"%s\" to=\"%ce:email;\" smtpuser=\"%s\" smtppass=\"%s\" subject=\"Membership Application\">\n",
           *m_SmtpAddr, CHAR_PERCENT, *m_SmtpUser, *m_SmtpPass) ;
       Z.Printf("Thank you for registering with %s. Your initial login code is %cs:iniCode;i\n\n", *m_Domain, CHAR_PERCENT) ;
       Z << "The code is good for 1 hour. Enter this code instead of your selected password in the login screen.\n\n" ;
       Z << "This email has been generated by a submission to the Registration form at " ;
       Z << m_Domain ;
       Z << ". If you have recived this in error, please ignore\n" ;
       Z << "\t\t</sendemail>\n" ;
       Z << "\t</procdata>\n" ;
       Z << "\t<error goto=\"/register\"/>\n\n" ;
       Z.Printf("\t<response name=\"form_reg_%s\" bgcolor=\"eeeeee\">\n", *cname) ;
       Z << "\t\t<xblock name=\"gdInclude\"/>\n" ;
       Z.Printf("<xform name=\"formCkCorp1\" action=\"hdlCkCorp\">\n") ;
       Z <<
       "\t<table width=\"96%\" align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n\t\t<tr><td width=5 height=25> </td></tr>\n\t\t<tr><td align=center class=title>Email Verification</td></tr>\n\t\t<tr height=\"250\">\n\t\t<td class=\"main\">\n\t\tThank you %s:fname; %s:lname; for your registration on belhalf of %s:orgname; to the gdpr360 XLS document processing service.\n\t\t</td>\n\t\t</tr>\n\t\t<tr height=\"50\"><td align=\"center\" class=\"fld\">Code:</td><td><xfield fldspec=\"fs_Usec\" var=\"testCode\" flags=\"req\"/></td></tr>\n\t\t<tr height=\"50\"><td align=\"center\"><xbutton show=\"Complete Registration\"/></td></tr>\n\t\t</table>\n\t</xform>\n\t</response>\n</formhdl>\n\n"
                        ;
       Z.Printf("<formhdl name=\"fhdl_phase2_%s\" form=\"form_reg_%s\" ops=\"cookie\">\n", *cname, *cname) ;
       Z <<
       "\t<procdata>\n\t\t<testeq param1=\"%e:testCode;\" param2=\"%s:iniCode;\">\n\t\t\t<error name=\"InvalidCode\" bgcolor=\"eeeeee\">\n\t\t\t\t<xblock name=\"gdInclude\"/>\n\t\t\t\t<xform name=\"formCkCorp2\" action=\"hdlCkCorp\">\n\t\t\t\t\t<table width=\"96%\" align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n\t\t\t\t\t\t<tr><td width=5 height=25> </td></tr>\n\t\t\t\t\t\t<tr><td align=center class=title>Oops! Wrong Code!</td></tr>\n\t\t\t\t\t\t<tr height=\"250\"><td class=\"main\">Please check the email again and type in or cut and paste the code.</td></tr>\n\t\t\t\t\t\t<tr height=\"50\"><td align=\"center\" class=\"fld\">Code:</td><td><xfield fldspec=\"fs_Usec\" var=\"testCode\" flags=\"req\"/></td></tr>\n\t\t\t\t\t\t<tr height=\"50\"><td align=\"center\"><xbutton show=\"Complete Registration\"/></td></tr>\n\t\t\t\t\t</table>\n\t\t\t\t</xform>\n\t\t\t</error>\n\t\t</testeq>\n"
                         ;
       Z.Printf("<addSubscriber class=\"%s\" userName=\"%css:orgname;\" userPass=\"%css:password;\" userEmail=\"%css:email;\">\n",
           *cname, CHAR_PERCENT, CHAR_PERCENT, CHAR_PERCENT) ;
       for (nM = 0; nM < pClass->MbrCount() ; nM++)
       {
           pMem = pClass->GetMember(nM) ;
           mname = pMem->txtName() ;
           Z.Printf("\t\t\t<seteq member=\"%s\" input=\"%cs%s\"/>\n", mname, CHAR_PERCENT, mname) ;
       }
       Z <<
       "\t\t</addSubscriber>\n\t\t<logon user=\"%s:orgname;\"/>\n\t</procdata>\n"
                         ;
       Z <<
       "\t<error name=\"RegistrationError\" bgcolor=\"eeeeee\">\n\t\t<xblock name=\"gdInclude\"/>\n\t\t<div class=\"stdpage\">\n\t\t<table bgcolor=\"#FFDDDD\" width=\"100%\" align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n\t\t<tr><td width=5 height=25> </td></tr>\n\t\t<tr><td align=center class=title>Internal Error</td></tr>\n\t\t<tr height=\"160\"><td> </td></tr>\n\t\t<tr>\n\t\t<td>An Internal error has occured and system administration has been notified. Please try again later.</td>\n\t\t</tr>\n\t\t<tr height=\"160\"><td> </td></tr>\n\t\t<tr height=\"50\"><td align=\"center\"><xbutton show=\"Return to Site\" goto=\"/index.html\"/></td></tr>\n\t\t</table>\n\t\t</div>\n\t</error>\n"
                      ;
       Z <<
       "\t<response name=\"CorpCodeOK\" bgcolor=\"eeeeee\">\n\t\t<xblock name=\"gdInclude\"/>\n\t\t<table width=\"96%\" align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n\t\t\t<tr><td width=5 height=25> </td></tr>\n\t\t\t<tr><td align=center class=title>Registration Complete</td></tr>\n\t\t\t<tr height=\"250\">\n\t\t\t\t<td class=\"main\">\n\t\t\t\tYour registration as %u:orgname; is now complete. You are logged in and may now use the document processing facility.\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr height=\"50\"><td align=\"center\"><xbutton show=\"Continue\" goto=\"/menu\"/></td></tr>\n\t\t</table>\n\t</response>\n</formhdl>\n"
                      ;
   }
   else
   {
       //  Write out standard commit form-handler. (fhdl_classname)
       Z.Printf("<formhdl name=\"fhdl_add_%s\" form=\"form_add_%s\">\n", *cname, *cname) ;
       Z << "\t<procdata>\n" ;
       Z.Printf("<commit class=\"%s\">\n", *cname) ;
       for (nM = 0; nM < pClass->MbrCount() ; nM++)
       {
           pMem = pClass->GetMember(nM) ;
           mname = pMem->txtName() ;
           Z.Printf("<seteq member=\"%s\" input=\"%ce:%s;\"/>\n", mname, CHAR_PERCENT, mname) ;
       }
       Z <<
       "\t\t</commit>\n\t</procdata>\n\n"
                           ;
       Z.Printf("<error goto=\"/add_%s\"/>\n", *cname) ;
       Z.Printf("<response name=\"%s\" bgcolor=\"eeeeee\">\n", *cname) ;
       Z <<
       "\t</response>\n</formhdl>\n"
                      ;
   }
   Z << "</disseminoInclude>\n" ;
   //  Commit the pro-forma page, form and form-handlers to a file called 'classname.forms' This can then be adapted and included in the main XML file for
   //  the site
   if (Z.Size())
   {
       sprintf(fname, "%s/%s.forms", *m_Configdir, *cname) ;
       m_pLog->Log("Writing form of %d bytes to %s\n", Z.Size(), fname) ;
       os.open(fname) ;
       if (os.fail())
           threadLog("Could not open export forms file (classforms.dat)\n") ;
       else
       {
           os << Z ;
           if (os.fail())
               threadLog("Could not write export forms file (classforms.dat)\n") ;
           os.close() ;
       }
       os.clear() ;
   }
   Z.Clear() ;
   return rc ;
}