| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hdsApp::MakeNavbarJS | (hzChain&,hdsLang*,unsigned int,) |
Declared in file: hzDissemino.h
Defined in file : hdsScript.cpp
Function Logic:
Function body:
hzEcode hdsApp::MakeNavbarJS (hzChain& Z, hdsLang* pLang, unsigned int access)
{
_hzfunc("hdsApp::MakeNavbarJS") ;
hzList<hzString>::Iter si ;
hdsPage* pPage ;
uint32_t* counts ;
hzString subject ;
hzString S ;
uint32_t x ;
uint32_t nLo ;
uint32_t nHi ;
bool doComma ;
if (!pLang)
pLang = m_pDfltLang ;
if (!pLang)
Fatal("No language supplied\n") ;
Z.Clear() ;
counts = new uint32_t[m_lstPgSubjects.Count()] ;
for (si = m_lstPgSubjects, x = 0; si.Valid() ; x++, si++)
{
subject = si.Element() ;
counts[x] = 0;
nLo = m_mapSubj2Res.First(subject) ;
if (nLo < 0)
continue ;
nHi = m_mapSubj2Res.Last(subject) ;
for (; nLo <&eq; nHi ; nLo++)
{
pPage = m_mapSubj2Res.GetObj(nLo) ;
if (pPage->m_resAccess == ACCESS_PUBLIC || access == ACCESS_ADMIN
|| (pPage->m_resAccess == ACCESS_NOBODY && !access)
|| ((access & ACCESS_MASK) & pPage->m_resAccess))
{
m_pLog->Out("For access=%08x: Page %s (subj %s), acc=%08x\n", access, *pPage->m_Title, *pPage->m_Subj, pPage->m_resAccess) ;
counts[x] += 1;
}
}
}
/*
** for (x = 0 ; x < m_mapSubj2Res.Count() ; x++)
** {
** pSubj = m_vecPgSubjects[x] ;
**
** m_pLog->Log("NOTE: Subject [%s] has %d pages\n", *pSubj->subject, pSubj->pglist.Count()) ;
**
** counts[x] = 0 ;
** if (!pSubj->pglist.Count())
** continue ;
**
** for (y = 0 ; y < pSubj->pglist.Count() ; y++)
** {
** pPage = pSubj->pglist[y] ;
**
** // Only count if the page has correct access
** if (pPage->m_resAccess == ACCESS_PUBLIC || access == ACCESS_ADMIN
** || (pPage->m_resAccess == ACCESS_NOBODY && !access)
** || ((access & ACCESS_MASK) & pPage->m_resAccess))
** {
** m_pLog->Out("For access=%08x: Page %s (subj %s), acc=%08x\n", access, *pPage->m_Title, *pPage->m_Subj, pPage->m_resAccess) ;
** counts[x] += 1 ;
** }
** }
** }
** */
Z.Clear() ;
Z <<
"var pdmX = new Array();\npdmX = ["
;
doComma = false ;
for (si = m_lstPgSubjects, x = 0; si.Valid() ; x++, si++)
{
if (!counts[x])
continue ;
subject = si.Element() ;
nLo = m_mapSubj2Res.First(subject) ;
if (nLo < 0)
continue ;
nHi = m_mapSubj2Res.Last(subject) ;
pPage = m_mapSubj2Res.GetObj(nLo) ;
if (doComma)
Z << ",\n" ;
if (nLo == nHi)
Z.Printf("[%d,"%s","%s"]" , x, *subject, *pPage->m_Url) ;
else
Z.Printf("[%d,"%s",""]" , x, *subject) ;
doComma = true ;
}
Z << "];\n" ;
Z <<
"var subX = new Array();\nsubX = ["
;
doComma = false ;
for (si = m_lstPgSubjects, x = 0; si.Valid() ; x++, si++)
{
if (!counts[x])
continue ;
subject = si.Element() ;
nLo = m_mapSubj2Res.First(subject) ;
if (nLo < 0)
continue ;
nHi = m_mapSubj2Res.Last(subject) ;
for (; nLo <&eq; nHi ; nLo++)
{
pPage = m_mapSubj2Res.GetObj(nLo) ;
if (pPage->m_resAccess == ACCESS_PUBLIC || access == ACCESS_ADMIN
|| (pPage->m_resAccess == ACCESS_NOBODY && !access)
|| ((access & ACCESS_MASK) & pPage->m_resAccess))
{
if (doComma)
Z << ",\n" ;
Z.Printf("[%d,"%s","%s"]" , x, *pPage->m_Title, *pPage->m_Url) ;
doComma = true ;
}
}
}
/*
** for (x = 0 ; x < m_vecPgSubjects.Count() ; x++)
** {
** if (!counts[x])
** continue ;
**
** pSubj = m_vecPgSubjects[x] ;
**
** if (!pSubj->pglist.Count())
** continue ;
**
** for (y = 0 ; y < pSubj->pglist.Count() ; y++)
** {
** pPage = pSubj->pglist[y] ;
**
** if (pLang->m_MiscStrings.Exists(pPage->m_RID)) langTitl = pLang->m_MiscStrings[pPage->m_RID] ;
** else if (m_pDfltLang->m_MiscStrings.Exists(pPage->m_RID)) langTitl = m_pDfltLang->m_MiscStrings[pPage->m_RID] ;
** else
** langTitl = pPage->m_Title ;
**
** if (pPage->m_resAccess == ACCESS_PUBLIC || access == ACCESS_ADMIN
** || (pPage->m_resAccess == ACCESS_NOBODY && !access)
** || ((access & ACCESS_MASK) & pPage->m_resAccess))
** {
** if (doComma)
** Z << ",\n" ;
** //Z.AddByte(CHAR_COMMA) ;
** Z.Printf("[%d,\"%s\",\"%s\"]", x, *langTitl, *pPage->m_Url) ;
** doComma = true ;
** }
** }
** }
** */
Z << "];\n" ;
threadLog("Set script as\n") ;
threadLog(Z) ;
threadLog("End script\n") ;
delete [] counts ;
return E_OK ;
}