Serve an master article. These are articles in that a partial page is served by AJAX but they are an in-built feature of Dissemino rather than defined as a part of the application configs. At present the only example of AJAX in the master section is the Data Model Editing regime. Here, there is a host page and a navigation tree listing all data enums, classes and class members, and repositories in the current application data model. An article containing a form exists for each of the following:- 1) Addition of a new enum or displaying/editing an existing enum. The enum values are listed in a table with an blank row and an add button for adding new values. The values have a checkbox for setting them active/inactive and there is a checkbox for setting the enum as a whole to active/inactive. The URL of the blank article/form for adding a new enum is /master_dme_enum with no further arguments. This will be extended by -enum_name for an existing enum. 2) Addition of a new class or displaying/editing an existing class. The class members are listed in a table showing the data type and other parameters. The table cannot be edited in-situ. The class members, which can themselves be classes, are edited by clicking on the member name. The URL of the blank article/form for adding a new class is /master_dme_class and for an existing class this will be extended by -N where N is the class number. 3) Addition of a new class member or the editing of an existing one. This included the ability to set the member ative/inactive. The URL of the blank is /master_dme_mbr and for an existing member this will be extended by -N where N is the member number. Note it is not necessary to have a class id and a member id. 4) Addition of a new respository or the editing of an existing one. This must name a single host class.
| Return Type | Function name | Arguments |
|---|---|---|
| void | hdsApp::MasterArticle | (hzHttpEvent*,) |
Declared in file: hzDissemino.h
Defined in file : hdsMaster.cpp
Function Logic:
Function body:
void hdsApp::MasterArticle (hzHttpEvent* pE)
{
// Serve an master article. These are articles in that a partial page is served by AJAX but they are an in-built feature of Dissemino rather than defined as
// a part of the application configs. At present the only example of AJAX in the master section is the Data Model Editing regime. Here, there is a host page
// and a navigation tree listing all data enums, classes and class members, and repositories in the current application data model. An article containing a
// form exists for each of the following:-
//
// 1) Addition of a new enum or displaying/editing an existing enum. The enum values are listed in a table with an blank row and an add button for adding
// new values. The values have a checkbox for setting them active/inactive and there is a checkbox for setting the enum as a whole to active/inactive.
// The URL of the blank article/form for adding a new enum is /master_dme_enum with no further arguments. This will be extended by -enum_name for an
// existing enum.
//
// 2) Addition of a new class or displaying/editing an existing class. The class members are listed in a table showing the data type and other parameters.
// The table cannot be edited in-situ. The class members, which can themselves be classes, are edited by clicking on the member name. The URL of the
// blank article/form for adding a new class is /master_dme_class and for an existing class this will be extended by -N where N is the class number.
//
// 3) Addition of a new class member or the editing of an existing one. This included the ability to set the member ative/inactive. The URL of the blank
// is /master_dme_mbr and for an existing member this will be extended by -N where N is the member number. Note it is not necessary to have a class id and
// a member id.
//
// 4) Addition of a new respository or the editing of an existing one. This must name a single host class.
_hzfunc("hdsApp::MasterArticle") ;
const hdbEnum* pEnum = 0; // Data Enum
const hdbClass* pClass = 0; // Class
const hdbMember* pMbr = 0; // Class member
const hdbObjRepos* pRepos = 0; // Repository
hzChain Z ; // For building partial HTML output
hdsInfo* pInfo ; // Session
const char* pRes ; // Requested resource
const char* i ; // Requested resource iterator
hzString entName ; // Name of enum/class/member/repos
hzString argA ; // 1st argument (e.g. lang subdir or article group name)
hzString argB ; // 2nd argument (e.g. article name)
hzString S ; // Temp string
uint32_t numId ; // Numeric id
uint32_t mbrNo ; // Member number
uint32_t n ; // Loop iterator
pInfo = (hdsInfo*) pE->Session() ;
// No HTTP session?
if (!pInfo)
{
threadLog("Forbiden\n") ;
pE->SendAjaxResult(HTTPMSG_FORBIDDEN, "No Access") ;
return ;
}
pRes = pE->GetResource() ;
if (memcmp(pRes, "/masterAction", 13))
{
// Not a web-master option so illegal
threadLog("No such path\n") ;
pE->SendAjaxResult(HTTPMSG_NOTFOUND, "No such path") ;
return ;
}
if (!pE->QueryLen())
{
threadLog("Called with no arguments\n") ;
pE->SendAjaxResult(HTTPMSG_NOTFOUND, "No such path") ;
return ;
}
argA = pE->m_mapStrings.GetKey(0);
argB = pE->m_mapStrings.GetObj(0);
if (argA == "editfile")
{
_masterCfgEdit(pE, argB) ;
return ;
}
// This may be a webmaster command unrelated to the data object model
// if (!memcmp(pRes + 8, "A.0", 4)) { _masterCfgList(pE) ; return ; }
// if (!memcmp(pRes + 8, "A.1", 4)) { _masterResList(pE) ; return ; }
// if (!memcmp(pRes + 8, "A.2", 4)) { _masterVisList(pE) ; return ; }
// if (!memcmp(pRes + 8, "A.3", 4)) { _masterDomain(pE) ; return ; }
// if (!memcmp(pRes + 8, "A.4", 4)) { _masterEmaddr(pE) ; return ; }
// if (!memcmp(pRes + 8, "A.5", 4)) { _masterStrFix(pE) ; return ; }
// if (!memcmp(pRes + 8, "A.6", 4)) { _masterStrGen(pE) ; return ; }
// if (!memcmp(pRes + 8, "A.7", 4)) { _masterBanned(pE) ; return ; }
// if (!memcmp(pRes + 8, "A.8", 4)) { _masterMemstat(pE) ; return ; }
// if (!memcmp(pRes + 8, "A.9", 4)) { _masterUSL(pE) ; return ; }
// if (!memcmp(pRes + 8, "A.10", 5)) { _masterFileList(pE) ; return ; }
// if (!memcmp(pRes + 8, "A.11", 5)) { _masterFileEdit(pE) ; return ; }
// URL not of the form /master_dme- ?
if (memcmp(pRes, "/master_dme-", 12))
{
threadLog("No such path\n") ;
pE->SendAjaxResult(HTTPMSG_NOTFOUND, "No such path") ;
return ;
}
// Invalid URL?
if (pRes[12]!=''E''&&pRes[12]!=''C''&&pRes[12]!=''M''&&pRes[12]!=''R'')
{
threadLog("No such path\n") ;
pE->SendAjaxResult(HTTPMSG_NOTFOUND, "No such path") ;
return ;
}
// DERIVE ENTITY. A is general article (not related to Data Object Model), E is enum, C is class, M is class member, R is repository.
if (pRes[13]==CHAR_PERIOD)
{
switch (pRes[12])
{
case ''E'': if (IsPosint(numId, pRes + 14))
// pEnum = m_ADP.mapEnums.GetObj(numId) ;
pEnum = m_ADP.GetDataEnum(numId) ;
if (pEnum)
entName = pEnum->txtType() ;
break ;
case ''C'': if (IsPosint(numId, pRes + 14))
{
for (n = 0; n < m_ADP.CountDataClass() ; n++)
{
pClass = m_ADP.GetDataClass(n) ;
if (pClass->ClassId() == numId)
{
entName = pClass->txtType() ;
break ;
}
}
if (!entName)
pClass = 0;
}
case ''M'': if (IsPosint(numId, pRes + 14))
{
for (n = 0; n < m_ADP.CountDataClass() ; n++)
{
pClass = m_ADP.GetDataClass(n) ;
if (pClass->ClassId() == numId)
{
entName = pClass->txtType() ;
break ;
}
}
if (!entName)
pClass = 0;
// pClass = m_ADP.mapClasses.GetObj(numId-1) ;
if (pClass)
{
for (i = pRes + 14;*i && *i != CHAR_PERIOD ; i++) ;
if (*i == CHAR_PERIOD)
{
if (IsPosint(numId, i+1))
pMbr = pClass->GetMember(numId) ;
}
}
}
if (pMbr)
{ entName = pClass->txtType() ; entName += "::" ; entName += pMbr->strName() ; }
case ''R'': if (IsPosint(numId, pRes + 14))
pRepos = m_ADP.GetObjRepos(numId) ;
if (pRepos)
entName = pRepos->strName() ;
}
}
// CREATE HTML
Z.Printf("<form method=\"POST\" action=\"%s\">\n", pRes) ;
Z << "<table width=\"100%\" align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"main\">\n" ;
// Deal with non-data model requests
switch (pRes[9])
{
case ''E'':
Z <<
"<tr><td align=\"center\">Enum Editor</td></tr>\n<tr><td height=\"20\"> </td></tr>\n</table>\n<table width=\"100%\" align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"main\">\n"
;
Z.Printf("<tr height=\"25\"><td>Name: </td><td><input type=\"text\" name=\"username_master\" size=\"40\" maxlen=\"40\" value=\"%s\"/></td></tr>\n", *entName) ;
Z <<
"</table>\n<table width=\"100%\" align=\"center\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\" class=\"main\">\n"
;
for (n = 0; n < pEnum->Count() ; n++)
{
S = pEnum->GetStr(n) ;
Z.Printf("<tr><td>%d</td><td>%s</td></tr>\n", n+1,*S) ;
}
break ;
case ''C'':
Z <<
"<tr><td align=\"center\">Class Editor</td></tr>\n<tr><td height=\"20\"> </td></tr>\n</table>\n<table width=\"100%\" align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"main\">\n"
;
Z.Printf("<tr height=\"25\"><td>Name: </td><td><input type=\"text\" name=\"username_master\" size=\"40\" maxlen=\"40\" value=\"%s\"/></td></tr>\n", *entName) ;
Z <<
"</table>\n<table width=\"100%\" align=\"center\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\" class=\"main\">\n<tr>\n <th>Posn</th>\n <th>Name</th>\n <th>Data type</th>\n <th>MinP</th>\n <th>MaxP</th>\n <th>Description</th>\n</tr>\n"
;
for (mbrNo = 0; mbrNo < pClass->MbrCount() ; mbrNo++)
{
pMbr = pClass->GetMember(mbrNo) ;
Z << "<tr>" ;
Z.Printf("<td align=\"right\">%d</td>", mbrNo) ;
Z.Printf("<td><a href=\"#\" onclick=\"loadArticle('/master_dme-M.%d.%d');\">%s</a></td>", pClass->ClassId(), mbrNo, pMbr->txtName()) ;
Z.Printf("<td>%s</td>", pMbr->Datatype()->txtType()) ;
Z.Printf("<td>%s</td>", PopCtl2Txt(pMbr->PopCtl())) ;
Z.Printf("<td>%s</td>", pMbr->txtDesc()) ;
Z << "</tr>" ;
}
break ;
case ''M'':
if (pMbr)
Z.Printf("<tr><td align=\"center\">%s::%s</td></tr>\n", pClass->txtType(), pMbr->txtName()) ;
else
Z << "<tr><td align=\"center\">Class Member Editor</td></tr>\n" ;
Z <<
"<tr><td height=\"60\"> </td></tr>\n</table>\n<table width=\"66%\" align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"main\">\n"
;
Z <<
"<tr height=\"25\"><td>Name: </td><td><input type=\"text\" name=\"username_master\" size=\"40\" maxlen=\"40\"/></td></tr>\n<tr height=\"25\"><td>Type: </td><td><input type=\"select\" name=\"password_master\" size=\"40\" maxlen=\"40\"/></td></tr>\n<tr height=\"25\"><td>Min Value: </td><td><input type=\"select\" name=\"password_master\" size=\"40\" maxlen=\"40\"/></td></tr>\n<tr height=\"25\"><td>Max Value: </td><td><input type=\"select\" name=\"password_master\" size=\"40\" maxlen=\"40\"/></td></tr>\n<tr height=\"25\"><td>Compusory: </td><td><input type=\"select\" name=\"password_master\" size=\"40\" maxlen=\"40\"/></td></tr>\n<tr height=\"25\"><td>Multiple: </td><td><input type=\"select\" name=\"password_master\" size=\"40\" maxlen=\"40\"/></td></tr>\n"
;
break ;
case ''R'': if (pRes[10]==CHAR_PERIOD)
{
if (IsPosint(numId, pRes + 11))
pRepos = m_ADP.GetObjRepos(numId) ;
}
break ;
}
Z <<
"</table>\n</form>\n"
;
// Send result
if (entName)
pE->SetHdr("x-title", entName) ;
else
pE->SetHdr("x-title", pRes) ;
pE->SendRawChain(HTTPMSG_OK, HMTYPE_TXT_HTML, Z, 0,false) ;
}