%
Function getLangFileName(ByVal langName)
Dim langArr
Set langArr = (CreateDictionary())
setArrElement langArr,"English","English"
doAssignmentByRef getLangFileName,ArrayElement(langArr,langName)
Exit Function
End Function
Function GetGlobalData(ByVal name,ByVal defValue)
if not bValue(asp_array_key_exists(name,globalSettings)) then
doAssignmentByRef GetGlobalData,defValue
Exit Function
end if
doAssignmentByRef GetGlobalData,ArrayElement(globalSettings,name)
Exit Function
End Function
Function DisplayMap(ByVal params)
setArrElementN pageObject.googleMapCfg,CreateArray3("mapsData",ArrayElement(params,"id"),"addressField"),IIF(ArrayElement(params,"addressField"),ArrayElement(params,"addressField"),"")
setArrElementN pageObject.googleMapCfg,CreateArray3("mapsData",ArrayElement(params,"id"),"latField"),IIF(ArrayElement(params,"latField"),ArrayElement(params,"latField"),"")
setArrElementN pageObject.googleMapCfg,CreateArray3("mapsData",ArrayElement(params,"id"),"lngField"),IIF(ArrayElement(params,"lngField"),ArrayElement(params,"lngField"),"")
setArrElementN pageObject.googleMapCfg,CreateArray3("mapsData",ArrayElement(params,"id"),"width"),IIF(ArrayElement(params,"width"),ArrayElement(params,"width"),0)
setArrElementN pageObject.googleMapCfg,CreateArray3("mapsData",ArrayElement(params,"id"),"height"),IIF(ArrayElement(params,"height"),ArrayElement(params,"height"),0)
setArrElementN pageObject.googleMapCfg,CreateArray3("mapsData",ArrayElement(params,"id"),"type"),"BIG_MAP"
setArrElementN pageObject.googleMapCfg,CreateArray3("mapsData",ArrayElement(params,"id"),"showCenterLink"),IIF(ArrayElement(params,"showCenterLink"),ArrayElement(params,"showCenterLink"),0)
setArrElementN pageObject.googleMapCfg,CreateArray3("mapsData",ArrayElement(params,"id"),"descField"),IIF(ArrayElement(params,"descField"),ArrayElement(params,"descField"),ArrayElement(ArrayElement(ArrayElement(pageObject.googleMapCfg,"mapsData"),ArrayElement(params,"id")),"addressField"))
if not IsEmpty(ArrayElement(params,"zoom")) then
setArrElementN pageObject.googleMapCfg,CreateArray3("mapsData",ArrayElement(params,"id"),"zoom"),ArrayElement(params,"zoom")
end if
if bValue(ArrayElement(ArrayElement(ArrayElement(pageObject.googleMapCfg,"mapsData"),ArrayElement(params,"id")),"showCenterLink")) then
setArrElementN pageObject.googleMapCfg,CreateArray3("mapsData",ArrayElement(params,"id"),"centerLinkText"),IIF(ArrayElement(params,"centerLinkText"),ArrayElement(params,"centerLinkText"),"")
end if
setArrElementN pageObject.googleMapCfg,CreateArray2("mainMapIds",empty),ArrayElement(params,"id")
if not IsEmpty(ArrayElement(params,"APIkey")) then
setArrElement pageObject.googleMapCfg,"APIcode",ArrayElement(params,"APIkey")
end if
End Function
Function DisplayCAPTCHA()
pageObject.xt.assign_event_p4 pageObject.captchaId,pageObject,"createCaptcha",CreateDictionary()
End Function
Function checkTableName(ByVal shortTName,ByVal var_type)
if not bValue(shortTName) then
checkTableName = false
Exit Function
end if
if IsEqual("customer",shortTName) and (IsFalse(var_type) or not IsFalse(var_type) and IsEqual(var_type,0)) then
checkTableName = true
Exit Function
end if
if IsEqual("courses",shortTName) and (IsFalse(var_type) or not IsFalse(var_type) and IsEqual(var_type,0)) then
checkTableName = true
Exit Function
end if
if IsEqual("siteusers",shortTName) and (IsFalse(var_type) or not IsFalse(var_type) and IsEqual(var_type,0)) then
checkTableName = true
Exit Function
end if
checkTableName = false
Exit Function
End Function
Function GetEditTabs(ByVal table)
doAssignmentByRef GetEditTabs,GetTableData(table,".arrEditTabs",CreateDictionary())
Exit Function
End Function
Function useTabsOnEdit(ByVal table)
if bValue(asp_count(GetEditTabs(table))) then
useTabsOnEdit = true
Exit Function
else
useTabsOnEdit = false
Exit Function
end if
End Function
Function GetAddTabs(ByVal table)
doAssignmentByRef GetAddTabs,GetTableData(table,".arrAddTabs",CreateDictionary())
Exit Function
End Function
Function useTabsOnAdd(ByVal table)
if bValue(asp_count(GetAddTabs(table))) then
useTabsOnAdd = true
Exit Function
else
useTabsOnAdd = false
Exit Function
end if
End Function
Function GetViewTabs(ByVal table)
doAssignmentByRef GetViewTabs,GetTableData(table,".arrViewTabs",CreateDictionary())
Exit Function
End Function
Function useTabsOnView(ByVal table)
if bValue(asp_count(GetViewTabs(table))) then
useTabsOnView = true
Exit Function
else
useTabsOnView = false
Exit Function
end if
End Function
Function GetMasterTablesArr(ByVal tName)
doAssignmentByRef GetMasterTablesArr,ArrayElement(masterTablesData,tName)
Exit Function
End Function
Function GetDetailTablesArr(ByVal tName)
doAssignmentByRef GetDetailTablesArr,ArrayElement(detailsTablesData,tName)
Exit Function
End Function
Function GetDetailKeysByMasterTable(ByVal mTableName,ByVal tName,ByVal default)
Dim strTableName,mTableDataArr
if not bValue(mTableName) then
doAssignmentByRef GetDetailKeysByMasterTable,default
Exit Function
end if
if not bValue(tName) then
doAssignment tName,strTableName
end if
GetCollectionBounds ArrayElement(masterTablesData,tName),i_commonfunctions_loopIdx2,i_commonfunctions_loopMax2
do while i_commonfunctions_loopIdx2<=i_commonfunctions_loopMax2
i_commonfunctions_arrKey2 = GetCollectionKey(ArrayElement(masterTablesData,tName),i_commonfunctions_loopIdx2)
doAssignment mTableDataArr,ArrayElement(ArrayElement(masterTablesData,tName),i_commonfunctions_arrKey2)
if IsEqual(ArrayElement(mTableDataArr,"mDataSourceTable"),mTableName) then
doAssignmentByRef GetDetailKeysByMasterTable,ArrayElement(mTableDataArr,"detailKeys")
Exit Function
end if
i_commonfunctions_loopIdx2=i_commonfunctions_loopIdx2+1
loop
doAssignmentByRef GetDetailKeysByMasterTable,default
Exit Function
End Function
Function GetMasterKeysByDetailTable(ByVal dTableName,ByVal tName,ByVal default)
Dim strTableName,dTableDataArr
if not bValue(dTableName) then
doAssignmentByRef GetMasterKeysByDetailTable,default
Exit Function
end if
if not bValue(tName) then
doAssignment tName,strTableName
end if
GetCollectionBounds ArrayElement(detailsTablesData,tName),i_commonfunctions_loopIdx3,i_commonfunctions_loopMax3
do while i_commonfunctions_loopIdx3<=i_commonfunctions_loopMax3
i_commonfunctions_arrKey3 = GetCollectionKey(ArrayElement(detailsTablesData,tName),i_commonfunctions_loopIdx3)
doAssignment dTableDataArr,ArrayElement(ArrayElement(detailsTablesData,tName),i_commonfunctions_arrKey3)
if IsEqual(ArrayElement(dTableDataArr,"dDataSourceTable"),dTableName) then
doAssignmentByRef GetMasterKeysByDetailTable,ArrayElement(dTableDataArr,"masterKeys")
Exit Function
end if
i_commonfunctions_loopIdx3=i_commonfunctions_loopIdx3+1
loop
doAssignmentByRef GetMasterKeysByDetailTable,default
Exit Function
End Function
Function GetDetailKeysByDetailTable(ByVal dTableName,ByVal tName,ByVal default)
Dim dTableDataArr
GetCollectionBounds ArrayElement(detailsTablesData,tName),i_commonfunctions_loopIdx4,i_commonfunctions_loopMax4
do while i_commonfunctions_loopIdx4<=i_commonfunctions_loopMax4
i_commonfunctions_arrKey4 = GetCollectionKey(ArrayElement(detailsTablesData,tName),i_commonfunctions_loopIdx4)
doAssignment dTableDataArr,ArrayElement(ArrayElement(detailsTablesData,tName),i_commonfunctions_arrKey4)
if IsEqual(ArrayElement(dTableDataArr,"dDataSourceTable"),dTableName) then
doAssignmentByRef GetDetailKeysByDetailTable,ArrayElement(dTableDataArr,"detailKeys")
Exit Function
end if
i_commonfunctions_loopIdx4=i_commonfunctions_loopIdx4+1
loop
doAssignmentByRef GetDetailKeysByDetailTable,default
Exit Function
End Function
Function GetDPType(ByVal dTableName,ByVal tName)
Dim strTableName,dTableDataArr
if not bValue(dTableName) then
GetDPType = false
Exit Function
end if
if not bValue(tName) then
doAssignment tName,strTableName
end if
GetCollectionBounds ArrayElement(detailsTablesData,tName),i_commonfunctions_loopIdx5,i_commonfunctions_loopMax5
do while i_commonfunctions_loopIdx5<=i_commonfunctions_loopMax5
i_commonfunctions_arrKey5 = GetCollectionKey(ArrayElement(detailsTablesData,tName),i_commonfunctions_loopIdx5)
doAssignment dTableDataArr,ArrayElement(ArrayElement(detailsTablesData,tName),i_commonfunctions_arrKey5)
if IsEqual(ArrayElement(dTableDataArr,"dDataSourceTable"),dTableName) then
doAssignmentByRef GetDPType,ArrayElement(dTableDataArr,"previewOnList")
Exit Function
end if
i_commonfunctions_loopIdx5=i_commonfunctions_loopIdx5+1
loop
GetDPType = false
Exit Function
End Function
Function GetFieldByIndex(ByVal index,ByVal table)
Dim value,key
if not bValue(table) then
doAssignment table,strTableName
end if
if not bValue(asp_array_key_exists(table,tables_data)) then
GetFieldByIndex = null
Exit Function
end if
GetCollectionBounds ArrayElement(tables_data,table),i_commonfunctions_loopIdx6,i_commonfunctions_loopMax6
i_commonfunctions_exitLoop6=false
do while i_commonfunctions_loopIdx6<=i_commonfunctions_loopMax6
i_commonfunctions_exitLoop6=false
do
key = GetCollectionKey(ArrayElement(tables_data,table),i_commonfunctions_loopIdx6)
doAssignment value,ArrayElement(ArrayElement(tables_data,table),key)
if not bValue(asp_is_array(value)) or not bValue(asp_array_key_exists("Index",value)) then
exit do
end if
if IsEqual(ArrayElement(value,"Index"),index) and bValue(GetFieldIndex(key,"")) then
doAssignmentByRef GetFieldByIndex,key
Exit Function
end if
loop while false
if i_commonfunctions_exitLoop6 then _
exit do
i_commonfunctions_loopIdx6=i_commonfunctions_loopIdx6+1
loop
GetFieldByIndex = null
Exit Function
End Function
Function Label(ByVal field,ByVal table)
doAssignmentByRef Label,GetFieldData(table,field,"Label",field)
Exit Function
End Function
Function GetFilenameField(ByVal field,ByVal table)
doAssignmentByRef GetFilenameField,GetFieldData(table,field,"Filename","")
Exit Function
End Function
Function GetLinkPrefix(ByVal field,ByVal table)
doAssignmentByRef GetLinkPrefix,GetFieldData(table,field,"LinkPrefix","")
Exit Function
End Function
Function GetFieldType(ByVal field,ByVal table)
doAssignmentByRef GetFieldType,GetFieldData(table,field,"FieldType","")
Exit Function
End Function
Function IsAutoincField(ByVal field,ByVal table)
doAssignmentByRef IsAutoincField,GetFieldData(table,field,"AutoInc",false)
Exit Function
End Function
Function IsUseiBox(ByVal field,ByVal table)
doAssignmentByRef IsUseiBox,GetFieldData(table,field,"UseiBox",false)
Exit Function
End Function
Function GetEditFormat(ByVal field,ByVal table)
doAssignmentByRef GetEditFormat,GetFieldData(table,field,"EditFormat","")
Exit Function
End Function
Function ViewFormat(ByVal field,ByVal table)
doAssignmentByRef ViewFormat,GetFieldData(table,field,"ViewFormat","")
Exit Function
End Function
Function DateEditShowTime(ByVal field,ByVal table)
doAssignmentByRef DateEditShowTime,GetFieldData(table,field,"ShowTime",false)
Exit Function
End Function
Function FastType(ByVal field,ByVal table)
doAssignmentByRef FastType,GetFieldData(table,field,"FastType",false)
Exit Function
End Function
Function LookupControlType(ByVal field,ByVal table)
doAssignmentByRef LookupControlType,GetFieldData(table,field,"LCType",LCT_DROPDOWN)
Exit Function
End Function
Function UseCategory(ByVal field,ByVal table)
doAssignmentByRef UseCategory,GetFieldData(table,field,"UseCategory",false)
Exit Function
End Function
Function Multiselect(ByVal field,ByVal table)
doAssignmentByRef Multiselect,GetFieldData(table,field,"Multiselect",false)
Exit Function
End Function
Function SelectSize(ByVal field,ByVal table)
doAssignmentByRef SelectSize,GetFieldData(table,field,"SelectSize",1)
Exit Function
End Function
Function ShowThumbnail(ByVal field,ByVal table)
doAssignmentByRef ShowThumbnail,GetFieldData(table,field,"ShowThumbnail",false)
Exit Function
End Function
Function GetImageWidth(ByVal field,ByVal table)
doAssignmentByRef GetImageWidth,GetFieldData(table,field,"ImageWidth",0)
Exit Function
End Function
Function GetImageHeight(ByVal field,ByVal table)
doAssignmentByRef GetImageHeight,GetFieldData(table,field,"ImageHeight",0)
Exit Function
End Function
Function GetLWWhere(ByVal field,ByVal table)
if not bValue(table) then
doAssignment table,strTableName
end if
GetLWWhere = ""
Exit Function
End Function
Function GetLookupType(ByVal field,ByVal table)
doAssignmentByRef GetLookupType,GetFieldData(table,field,"LookupType",0)
Exit Function
End Function
Function GetpLookupType(ByVal field,ByVal table)
doAssignmentByRef GetpLookupType,GetFieldData(table,field,"pLookupType",0)
Exit Function
End Function
Function GetLookupTable(ByVal field,ByVal table)
doAssignmentByRef GetLookupTable,GetFieldData(table,field,"LookupTable","")
Exit Function
End Function
Function GetLWLinkField(ByVal field,ByVal table,ByVal addWrap)
if bValue(addWrap) then
doAssignmentByRef GetLWLinkField,AddFieldWrappers(GetFieldData(table,field,"LinkField",""))
Exit Function
else
doAssignmentByRef GetLWLinkField,GetFieldData(table,field,"LinkField","")
Exit Function
end if
End Function
Function GetLWLinkFieldType(ByVal field,ByVal table)
doAssignmentByRef GetLWLinkFieldType,GetFieldData(table,field,"LinkFieldType",0)
Exit Function
End Function
Function GetLWDisplayField(ByVal field,ByVal table,ByVal addWrap)
if bValue(addWrap) and not bValue(GetFieldData(table,field,"CustomDisplay",false)) then
doAssignmentByRef GetLWDisplayField,AddFieldWrappers(GetFieldData(table,field,"DisplayField",""))
Exit Function
else
doAssignmentByRef GetLWDisplayField,GetFieldData(table,field,"DisplayField","")
Exit Function
end if
End Function
Function NeedEncode(ByVal field,ByVal table)
doAssignmentByRef NeedEncode,GetFieldData(table,field,"NeedEncode",false)
Exit Function
End Function
Function getValidation(ByVal field,ByVal table)
doAssignmentByRef getValidation,GetFieldData(table,field,"validateAs",CreateDictionary())
Exit Function
End Function
Function AppearOnListPage(ByVal field,ByVal table)
doAssignmentByRef AppearOnListPage,GetFieldData(table,field,"bListPage",false)
Exit Function
End Function
Function AppearOnAddPage(ByVal field,ByVal table)
doAssignmentByRef AppearOnAddPage,GetFieldData(table,field,"bAddPage",false)
Exit Function
End Function
Function AppearOnInlineAdd(ByVal field,ByVal table)
doAssignmentByRef AppearOnInlineAdd,GetFieldData(table,field,"bInlineAdd",false)
Exit Function
End Function
Function AppearOnEditPage(ByVal field,ByVal table)
doAssignmentByRef AppearOnEditPage,GetFieldData(table,field,"bEditPage",false)
Exit Function
End Function
Function AppearOnInlineEdit(ByVal field,ByVal table)
doAssignmentByRef AppearOnInlineEdit,GetFieldData(table,field,"bInlineEdit",false)
Exit Function
End Function
Function AppearOnViewPage(ByVal field,ByVal table)
doAssignmentByRef AppearOnViewPage,GetFieldData(table,field,"bViewPage",false)
Exit Function
End Function
Function AppearOnPrinterPage(ByVal field,ByVal table)
doAssignmentByRef AppearOnPrinterPage,GetFieldData(table,field,"bPrinterPage",false)
Exit Function
End Function
Function AppearOnExportPage(ByVal field,ByVal table)
doAssignmentByRef AppearOnExportPage,GetFieldData(table,field,"bExportPage",false)
Exit Function
End Function
Function AppearOnRegisterOrSearchPage(ByVal field,ByVal pageType,ByVal table)
Dim arrFields,match,i
Set arrFields = (CreateDictionary())
if IsEqual(pageType,PAGE_REGISTER) then
doAssignmentByRef arrFields,GetTableData(table,".fieldsForRegister",CreateDictionary())
else
if IsEqual(pageType,PAGE_SEARCH) then
doAssignmentByRef arrFields,GetTableData(table,".allSearchFields",CreateDictionary())
end if
end if
if not bValue(asp_count(arrFields)) then
AppearOnRegisterOrSearchPage = "break"
Exit Function
end if
match = false
i = 0
do while IsLess(i,asp_count(arrFields))
if IsEqual(ArrayElement(arrFields,i),field) then
match = true
exit do
end if
i = CSmartDbl(i)+1
loop
doAssignmentByRef AppearOnRegisterOrSearchPage,match
Exit Function
End Function
Function AppearOnCurrentPage(ByVal fName,ByVal pageType,ByVal pageLikeInline)
if IsEqual(pageType,PAGE_LIST) then
if bValue(AppearOnListPage(fName,"")) then
AppearOnCurrentPage = true
Exit Function
else
doAssignmentByRef AppearOnCurrentPage,AppearOnRegisterOrSearchPage(fName,PAGE_SEARCH,"")
Exit Function
end if
else
if IsEqual(pageType,PAGE_ADD) then
if bValue(pageLikeInline) then
if bValue(AppearOnInlineAdd(fName,"")) and bValue(AppearOnListPage(fName,"")) then
AppearOnCurrentPage = true
Exit Function
end if
else
if bValue(AppearOnAddPage(fName,"")) then
AppearOnCurrentPage = true
Exit Function
end if
end if
else
if IsEqual(pageType,PAGE_EDIT) then
if bValue(pageLikeInline) then
if bValue(AppearOnInlineEdit(fName,"")) and bValue(AppearOnListPage(fName,"")) then
AppearOnCurrentPage = true
Exit Function
end if
else
if bValue(AppearOnEditPage(fName,"")) then
AppearOnCurrentPage = true
Exit Function
end if
end if
else
if (IsEqual(pageType,PAGE_SEARCH) or IsEqual(pageType,PAGE_REPORT)) or IsEqual(pageType,PAGE_CHART) then
doAssignmentByRef AppearOnCurrentPage,AppearOnRegisterOrSearchPage(fName,PAGE_SEARCH,"")
Exit Function
else
if IsEqual(pageType,PAGE_REGISTER) then
doAssignmentByRef AppearOnCurrentPage,AppearOnRegisterOrSearchPage(fName,PAGE_REGISTER,"")
Exit Function
else
AppearOnCurrentPage = "break"
Exit Function
end if
end if
end if
end if
end if
AppearOnCurrentPage = false
Exit Function
End Function
Function GetPasswordField(ByVal table)
doAssignmentByRef GetPasswordField,GetTableData(table,".PasswordField","")
Exit Function
End Function
Function GetUserNameField(ByVal table)
doAssignmentByRef GetUserNameField,GetTableData(table,".UserNameField","")
Exit Function
End Function
Function GetTablesList(ByVal pdfMode)
Dim arr,strPerm
Set arr = (CreateDictionary())
setArrElement arr,asp_count(arr),"customer"
setArrElement arr,asp_count(arr),"courses"
setArrElement arr,asp_count(arr),"siteusers"
doAssignmentByRef GetTablesList,arr
Exit Function
End Function
Function GetFieldsList(ByVal table)
Dim t,arr,f
if not bValue(table) then
doAssignment table,strTableName
end if
if not bValue(asp_array_key_exists(table,tables_data)) then
doAssignmentByRef GetFieldsList,CreateDictionary()
Exit Function
end if
doAssignmentByRef t,asp_array_keys(ArrayElement(tables_data,table),empty)
Set arr = (CreateDictionary())
GetCollectionBounds t,i_commonfunctions_loopIdx8,i_commonfunctions_loopMax8
do while i_commonfunctions_loopIdx8<=i_commonfunctions_loopMax8
i_commonfunctions_arrKey8 = GetCollectionKey(t,i_commonfunctions_loopIdx8)
doAssignment f,ArrayElement(t,i_commonfunctions_arrKey8)
if not IsEqual(asp_substr(f,0,1),".") then
setArrElement arr,asp_count(arr),f
end if
i_commonfunctions_loopIdx8=i_commonfunctions_loopIdx8+1
loop
doAssignmentByRef GetFieldsList,arr
Exit Function
End Function
Function GetBinaryFieldsIndices(ByVal table)
Dim fields,out,f,idx
doAssignmentByRef fields,GetFieldsList(table)
Set out = (CreateDictionary())
GetCollectionBounds fields,i_commonfunctions_loopIdx9,i_commonfunctions_loopMax9
do while i_commonfunctions_loopIdx9<=i_commonfunctions_loopMax9
idx = GetCollectionKey(fields,i_commonfunctions_loopIdx9)
doAssignment f,ArrayElement(fields,idx)
if bValue(IsBinaryType(GetFieldType(f,table))) then
setArrElement out,asp_count(out),CSmartDbl(idx)+1
end if
i_commonfunctions_loopIdx9=i_commonfunctions_loopIdx9+1
loop
doAssignmentByRef GetBinaryFieldsIndices,out
Exit Function
End Function
Function GetNBFieldsList(ByVal table)
Dim t,arr,f
doAssignmentByRef t,GetFieldsList(table)
Set arr = (CreateDictionary())
GetCollectionBounds t,i_commonfunctions_loopIdx10,i_commonfunctions_loopMax10
do while i_commonfunctions_loopIdx10<=i_commonfunctions_loopMax10
i_commonfunctions_arrKey10 = GetCollectionKey(t,i_commonfunctions_loopIdx10)
doAssignment f,ArrayElement(t,i_commonfunctions_arrKey10)
if not bValue(IsBinaryType(GetFieldType(f,table))) then
setArrElement arr,asp_count(arr),f
end if
i_commonfunctions_loopIdx10=i_commonfunctions_loopIdx10+1
loop
doAssignmentByRef GetNBFieldsList,arr
Exit Function
End Function
Function CategoryControl(ByVal field,ByVal table)
doAssignmentByRef CategoryControl,GetFieldData(table,field,"CategoryControl","")
Exit Function
End Function
Function GetCreateThumbnail(ByVal field,ByVal table)
doAssignmentByRef GetCreateThumbnail,GetFieldData(table,field,"CreateThumbnail",false)
Exit Function
End Function
Function GetThumbnailPrefix(ByVal field,ByVal table)
doAssignmentByRef GetThumbnailPrefix,GetFieldData(table,field,"ThumbnailPrefix","")
Exit Function
End Function
Function ResizeOnUpload(ByVal field,ByVal table)
doAssignmentByRef ResizeOnUpload,GetFieldData(table,field,"ResizeImage",false)
Exit Function
End Function
Function GetNewImageSize(ByVal field,ByVal table)
doAssignmentByRef GetNewImageSize,GetFieldData(table,field,"NewSize",0)
Exit Function
End Function
Function GetFieldByGoodFieldName(ByVal field,ByVal table)
Dim value,key
if not bValue(table) then
doAssignment table,strTableName
end if
if not bValue(asp_array_key_exists(table,tables_data)) then
GetFieldByGoodFieldName = ""
Exit Function
end if
GetCollectionBounds ArrayElement(tables_data,table),i_commonfunctions_loopIdx11,i_commonfunctions_loopMax11
do while i_commonfunctions_loopIdx11<=i_commonfunctions_loopMax11
key = GetCollectionKey(ArrayElement(tables_data,table),i_commonfunctions_loopIdx11)
doAssignment value,ArrayElement(ArrayElement(tables_data,table),key)
if IsLess(1,asp_count(value)) then
if IsEqual(ArrayElement(value,"GoodName"),field) then
doAssignmentByRef GetFieldByGoodFieldName,key
Exit Function
end if
end if
i_commonfunctions_loopIdx11=i_commonfunctions_loopIdx11+1
loop
GetFieldByGoodFieldName = ""
Exit Function
End Function
Function GetFullFieldName(ByVal field,ByVal table)
Dim fname
fname = (CSmartStr(AddTableWrappers(GetOriginalTableName(table))) & ".") & CSmartStr(AddFieldWrappers(field))
doAssignmentByRef GetFullFieldName,GetFieldData(table,field,"FullName",fname)
Exit Function
End Function
Function GetNRows(ByVal field,ByVal table)
doAssignmentByRef GetNRows,GetFieldData(table,field,"nRows",field)
Exit Function
End Function
Function GetNCols(ByVal field,ByVal table)
doAssignmentByRef GetNCols,GetFieldData(table,field,"nCols",field)
Exit Function
End Function
Function GetOriginalTableName(ByVal table)
if not bValue(table) then
doAssignment table,strTableName
end if
doAssignmentByRef GetOriginalTableName,GetTableData(table,".OriginalTable",table)
Exit Function
End Function
Function GetTableKeys(ByVal table)
doAssignmentByRef GetTableKeys,GetTableData(table,".Keys",CreateDictionary())
Exit Function
End Function
Function GetNumberOfChars(ByVal table)
doAssignmentByRef GetNumberOfChars,GetTableData(table,".NumberOfChars",0)
Exit Function
End Function
Function GetTableURL(ByVal table)
if not bValue(table) then
doAssignment table,strTableName
end if
if IsEqual("customer",table) then
GetTableURL = "customer"
Exit Function
end if
if IsEqual("courses",table) then
GetTableURL = "courses"
Exit Function
end if
if IsEqual("siteusers",table) then
GetTableURL = "siteusers"
Exit Function
end if
End Function
Function GetTableByShort(ByVal shortTName)
if not bValue(shortTName) then
GetTableByShort = false
Exit Function
end if
if IsEqual("customer",shortTName) then
GetTableByShort = "customer"
Exit Function
end if
if IsEqual("courses",shortTName) then
GetTableByShort = "courses"
Exit Function
end if
if IsEqual("siteusers",shortTName) then
GetTableByShort = "siteusers"
Exit Function
end if
End Function
Function GetTableOwnerID(ByVal table)
doAssignmentByRef GetTableOwnerID,GetTableData(table,".OwnerID",0)
Exit Function
End Function
Function IsRequired(ByVal field,ByVal table)
doAssignmentByRef IsRequired,GetFieldData(table,field,"IsRequired",false)
Exit Function
End Function
Function UseRTE(ByVal field,ByVal table)
doAssignmentByRef UseRTE,GetFieldData(table,field,"UseRTE",false)
Exit Function
End Function
Function UseRTEBasic(ByVal field,ByVal table)
doAssignmentByRef UseRTEBasic,GetFieldData(table,field,"UseRTEBasic",false)
Exit Function
End Function
Function UseRTEFCK(ByVal field,ByVal table)
doAssignmentByRef UseRTEFCK,GetFieldData(table,field,"UseRTEFCK",false)
Exit Function
End Function
Function UseRTEInnova(ByVal field,ByVal table)
doAssignmentByRef UseRTEInnova,GetFieldData(table,field,"UseRTEInnova",false)
Exit Function
End Function
Function UseTimestamp(ByVal field,ByVal table)
doAssignmentByRef UseTimestamp,GetFieldData(table,field,"UseTimestamp",false)
Exit Function
End Function
Function GetUploadFolder(ByVal field,ByVal table)
Dim path
doAssignmentByRef path,GetFieldData(table,field,"UploadFolder","")
if bValue(asp_strlen(path)) and not IsEqual(asp_substr(path,CSmartDbl(asp_strlen(path))-1,empty),"/") then
path = CSmartStr(path) & "/"
end if
doAssignmentByRef GetUploadFolder,path
Exit Function
End Function
Function GetFieldIndex(ByVal field,ByVal table)
doAssignmentByRef GetFieldIndex,GetFieldData(table,field,"Index",0)
Exit Function
End Function
Function GetQueryObject(ByVal table)
Dim ret
ret = null
if not bValue(asp_array_key_exists(table,tables_data)) then
doAssignmentByRef GetQueryObject,ret
Exit Function
end if
doAssignmentByRef GetQueryObject,ArrayElement(ArrayElement(tables_data,table),".sqlquery")
Exit Function
End Function
Function GetListOfFieldsByExprType(ByVal needaggregate,ByVal table)
Dim query,fields,out,aggr,f
if not bValue(asp_strlen(table)) then
doAssignment table,strTableName
end if
if not bValue(asp_array_key_exists(table,tables_data)) then
doAssignmentByRef GetListOfFieldsByExprType,CreateDictionary()
Exit Function
end if
doAssignmentByRef query,ArrayElement(ArrayElement(tables_data,table),".sqlquery")
doAssignmentByRef fields,GetFieldsList(table)
Set out = (CreateDictionary())
GetCollectionBounds fields,i_commonfunctions_loopIdx12,i_commonfunctions_loopMax12
do while i_commonfunctions_loopIdx12<=i_commonfunctions_loopMax12
idx = GetCollectionKey(fields,i_commonfunctions_loopIdx12)
doAssignment f,ArrayElement(fields,idx)
doAssignmentByRef aggr,query.IsAggrFuncField_p1(idx)
if bValue(needaggregate) and bValue(aggr) or not bValue(needaggregate) and not bValue(aggr) then
setArrElement out,asp_count(out),f
end if
i_commonfunctions_loopIdx12=i_commonfunctions_loopIdx12+1
loop
doAssignmentByRef GetListOfFieldsByExprType,out
Exit Function
End Function
Function DateEditType(ByVal field,ByVal table)
doAssignmentByRef DateEditType,GetFieldData(table,field,"DateEditType",0)
Exit Function
End Function
Function GetEditParams(ByVal field,ByVal table)
doAssignmentByRef GetEditParams,GetFieldData(table,field,"EditParams","")
Exit Function
End Function
Function GetChartType(ByVal shorttable)
GetChartType = ""
Exit Function
End Function
Function GetData(ByVal data,ByVal field,ByVal format)
doAssignmentByRef GetData,GetDataInt(ArrayElement(data,field),data,field,format)
Exit Function
End Function
Function GetDataInt(ByVal value,ByVal data,ByVal field,ByVal format)
Dim ret,numbers,thumbnailed,thumbprefix,thumbname,link,title,iquery,arrKeys,keylink,j
if IsEqual(format,FORMAT_CUSTOM) and bValue(data) then
doAssignmentByRef GetDataInt,CustomExpression(value,data,field,"")
Exit Function
end if
ret = ""
if bValue(IsBinaryType(GetFieldType(field,""))) then
ret = "LONG BINARY DATA - CANNOT BE DISPLAYED"
else
doAssignment ret,value
end if
if IsFalse(ret) then
ret = ""
end if
if IsEqual(format,FORMAT_DATE_SHORT) then
doAssignmentByRef ret,format_shortdate(db2time(value))
else
if IsEqual(format,FORMAT_DATE_LONG) then
doAssignmentByRef ret,format_longdate(db2time(value))
else
if IsEqual(format,FORMAT_DATE_TIME) then
doAssignmentByRef ret,str_format_datetime(db2time(value))
else
if IsEqual(format,FORMAT_TIME) then
if bValue(IsDateFieldType(GetFieldType(field,""))) then
doAssignmentByRef ret,str_format_time(db2time(value))
else
doAssignmentByRef numbers,parsenumbers(value)
if not bValue(asp_count(numbers)) then
GetDataInt = ""
Exit Function
end if
do while IsLess(asp_count(numbers),3)
setArrElement numbers,asp_count(numbers),0
loop
doAssignmentByRef ret,str_format_time(CreateDictionary6(Empty,0,Empty,0,Empty,0,Empty,ArrayElement(numbers,0),Empty,ArrayElement(numbers,1),Empty,ArrayElement(numbers,2)))
end if
else
if IsEqual(format,FORMAT_NUMBER) then
doAssignmentByRef ret,str_format_number(value,GetFieldData(strTableName,field,"DecimalDigits",false))
else
if IsEqual(format,FORMAT_CURRENCY) then
doAssignmentByRef ret,str_format_currency(value)
else
if IsEqual(format,FORMAT_CHECKBOX) then
ret = ""
else
if IsEqual(format,FORMAT_PERCENT) then
if not IsEqual(value,"") then
ret = CSmartStr(CSmartDbl(value)*100) & "%"
end if
else
if IsEqual(format,FORMAT_PHONE_NUMBER) then
if IsEqual(asp_strlen(ret),7) then
ret = (CSmartStr(asp_substr(ret,0,3)) & "-") & CSmartStr(asp_substr(ret,3,empty))
else
if IsEqual(asp_strlen(ret),10) then
ret = (((("(" & CSmartStr(asp_substr(ret,0,3))) & ") ") & CSmartStr(asp_substr(ret,3,3))) & "-") & CSmartStr(asp_substr(ret,6,empty))
end if
end if
else
if IsEqual(format,FORMAT_FILE_IMAGE) then
if not bValue(CheckImageExtension(ret)) then
GetDataInt = ""
Exit Function
end if
thumbnailed = false
thumbprefix = ""
if bValue(thumbnailed) then
thumbname = CSmartStr(thumbprefix) & CSmartStr(ret)
if not IsEqual(asp_substr(GetLinkPrefix(field,""),0,7),"http://") and not bValue(myfile_exists(getabspath(CSmartStr(GetLinkPrefix(field,"")) & CSmartStr(thumbname)))) then
doAssignment thumbname,ret
end if
ret = (""
ret = CSmartStr(ret) & "
")
else
if bValue(isEnableSection508()) then
ret = ("
"
else
ret = ("
"
end if
end if
else
if IsEqual(format,FORMAT_HYPERLINK) then
if bValue(data) then
doAssignmentByRef ret,GetHyperlink(ret,field,data,"")
end if
else
if IsEqual(format,FORMAT_EMAILHYPERLINK) then
doAssignment link,ret
doAssignment title,ret
if IsEqual(asp_substr(ret,0,7),"mailto:") then
doAssignmentByRef title,asp_substr(ret,8,empty)
else
link = "mailto:" & CSmartStr(link)
end if
ret = ((("") & CSmartStr(title)) & ""
else
if IsEqual(format,FORMAT_FILE) then
iquery = (("table=" & CSmartStr(GetTableURL(strTableName))) & "&field=") & CSmartStr(asp_rawurlencode(field))
doAssignmentByRef arrKeys,GetTableKeys(strTableName)
keylink = ""
j = 0
do while IsLess(j,asp_count(arrKeys))
keylink = CSmartStr(keylink) & ((("&key" & CSmartStr(CSmartDbl(j)+1)) & "=") & CSmartStr(asp_rawurlencode(ArrayElement(data,ArrayElement(arrKeys,j)))))
j = CSmartDbl(j)+1
loop
iquery = CSmartStr(iquery) & CSmartStr(keylink)
GetDataInt = ((("") & CSmartStr(htmlspecialchars(ret))) & ""
Exit Function
else
if IsEqual(GetEditFormat(field,""),EDIT_FORMAT_CHECKBOX) and IsEqual(format,FORMAT_NONE) then
if bValue(ret) and not IsEqual(ret,0) then
ret = "Yes"
else
ret = "No"
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
doAssignmentByRef GetDataInt,ret
Exit Function
End Function
Function ProcessLargeText(ByVal strValue,ByVal iquery,ByVal table,ByVal mode,ByVal format)
Dim cNumberOfChars,useUTF8,ret
if not bValue(table) then
doAssignment table,strTableName
end if
doAssignmentByRef cNumberOfChars,GetNumberOfChars(table)
if IsEqual(asp_substr(strValue,0,8),"") & CSmartStr("More")) & " ...")
else
if ((not IsEqual(format,EDIT_FORMAT_LOOKUP_WIZARD) and IsLess(0,cNumberOfChars)) and IsLess(cNumberOfChars,asp_strlen(strValue))) and IsEqual(mode,MODE_PRINT) then
if bValue(useUTF8) then
doAssignmentByRef ret,utf8_substr(strValue,0,cNumberOfChars)
else
doAssignmentByRef ret,asp_substr(strValue,0,cNumberOfChars)
end if
doAssignmentByRef ret,htmlspecialchars(ret)
if IsLess(cNumberOfChars,asp_strlen(strValue)) then
ret = CSmartStr(ret) & " ..."
end if
else
doAssignmentByRef ret,htmlspecialchars(strValue)
end if
end if
doAssignmentByRef ProcessLargeText,asp_nl2br(ret)
Exit Function
End Function
Function GetHyperlink(ByVal str,ByVal field,ByVal data,ByVal table)
Dim ret,title,link,i,target,var_type,prefix
if not bValue(asp_strlen(table)) then
doAssignment table,strTableName
end if
if not bValue(asp_strlen(str)) then
GetHyperlink = ""
Exit Function
end if
doAssignment ret,str
doAssignment title,ret
doAssignment link,ret
if IsEqual(asp_substr(ret,CSmartDbl(asp_strlen(ret))-1,empty),"#") then
doAssignmentByRef i,asp_strpos(ret,"#",empty)
doAssignmentByRef title,asp_substr(ret,0,i)
doAssignmentByRef link,asp_substr(ret,CSmartDbl(i)+1,(CSmartDbl(asp_strlen(ret))-CSmartDbl(i))-2)
if not bValue(title) then
doAssignment title,link
end if
end if
target = ""
if IsFalse(asp_strpos(link,"://",empty)) and not IsEqual(asp_substr(link,0,7),"mailto:") then
link = CSmartStr(prefix) & CSmartStr(link)
end if
ret = ((((("") & CSmartStr(title)) & ""
doAssignmentByRef GetHyperlink,ret
Exit Function
End Function
Function AddLinkPrefix(ByVal field,ByVal link,ByVal table)
if IsFalse(asp_strpos(link,"://",empty)) and not IsEqual(asp_substr(link,0,7),"mailto:") then
AddLinkPrefix = CSmartStr(GetLinkPrefix(field,table)) & CSmartStr(link)
Exit Function
end if
doAssignmentByRef AddLinkPrefix,link
Exit Function
End Function
Function GetTotalsForTime(ByVal value)
Dim time
doAssignmentByRef time,parsenumbers(value)
do while IsLess(asp_count(time),3)
setArrElement time,asp_count(time),0
loop
doAssignmentByRef GetTotalsForTime,time
Exit Function
End Function
Function GetTotals(ByVal field,ByVal value,ByVal stype,ByVal iNumberOfRows,ByVal sFormat)
Dim days,s,m,h,d,sValue,data
days = 0
if IsEqual(stype,"AVERAGE") then
if bValue(iNumberOfRows) then
if IsEqual(sFormat,FORMAT_TIME) then
if bValue(value) then
doAssignmentByRef value,round(CSmartDbl(value)/CSmartDbl(iNumberOfRows),0)
s = value mod 60
value = CSmartDbl(value)-CSmartDbl(s)
value = CSmartDbl(value)/60
m = value mod 60
value = CSmartDbl(value)-CSmartDbl(m)
value = CSmartDbl(value)/60
h = value mod 24
value = CSmartDbl(value)-CSmartDbl(h)
value = CSmartDbl(value)/24
doAssignment d,value
value = CSmartStr(IIF(not IsEqual(d,0),CSmartStr(d) & "d ","")) & CSmartStr(mysprintf("%02d:%02d:%02d",CreateDictionary3(Empty,h,Empty,m,Empty,s)))
end if
else
doAssignmentByRef value,round(CSmartDbl(value)/CSmartDbl(iNumberOfRows),2)
end if
else
GetTotals = ""
Exit Function
end if
end if
if IsEqual(stype,"TOTAL") then
if IsEqual(sFormat,FORMAT_TIME) then
if bValue(value) then
s = value mod 60
value = CSmartDbl(value)-CSmartDbl(s)
value = CSmartDbl(value)/60
m = value mod 60
value = CSmartDbl(value)-CSmartDbl(m)
value = CSmartDbl(value)/60
h = value mod 24
value = CSmartDbl(value)-CSmartDbl(h)
value = CSmartDbl(value)/24
doAssignment d,value
value = CSmartStr(IIF(not IsEqual(d,0),CSmartStr(d) & "d ","")) & CSmartStr(mysprintf("%02d:%02d:%02d",CreateDictionary3(Empty,h,Empty,m,Empty,s)))
end if
end if
end if
sValue = ""
Set data = (CreateDictionary1(field,value))
if IsEqual(sFormat,FORMAT_CURRENCY) then
doAssignmentByRef sValue,str_format_currency(value)
else
if IsEqual(sFormat,FORMAT_PERCENT) then
sValue = CSmartStr(str_format_number(CSmartDbl(value)*100,false)) & "%"
else
if IsEqual(sFormat,FORMAT_NUMBER) then
doAssignmentByRef sValue,str_format_number(value,GetFieldData(strTableName,field,"DecimalDigits",false))
else
if IsEqual(sFormat,FORMAT_CUSTOM) and not IsEqual(stype,"COUNT") then
doAssignmentByRef sValue,GetData(data,field,sFormat)
else
doAssignment sValue,value
end if
end if
end if
end if
if IsEqual(stype,"COUNT") then
doAssignmentByRef GetTotals,value
Exit Function
end if
if IsEqual(stype,"TOTAL") then
doAssignmentByRef GetTotals,sValue
Exit Function
end if
if IsEqual(stype,"AVERAGE") then
doAssignmentByRef GetTotals,sValue
Exit Function
end if
GetTotals = ""
Exit Function
End Function
Function DisplayLookupWizard(ByVal field,ByVal value,ByVal data,ByVal keylink,ByVal mode)
Dim LookupSQL,where,lookupvalue,iquery,out,arr,numeric,var_type,val,var_in,rsLookup,found,lookuprow,strdata
if not bValue(asp_strlen(value)) then
DisplayLookupWizard = ""
Exit Function
end if
LookupSQL = "SELECT "
LookupSQL = CSmartStr(LookupSQL) & CSmartStr(GetLWDisplayField(field,"",true))
LookupSQL = CSmartStr(LookupSQL) & ((" FROM " & CSmartStr(AddTableWrappers(GetLookupTable(field,"")))) & " WHERE ")
where = ""
doAssignment lookupvalue,value
iquery = ("field=" & CSmartStr(htmlspecialchars(asp_rawurlencode(field)))) & CSmartStr(keylink)
out = ""
if bValue(Multiselect(field,"")) then
doAssignmentByRef arr,splitvalues(value)
numeric = true
doAssignmentByRef var_type,GetLWLinkFieldType(field,"")
if not bValue(var_type) then
GetCollectionBounds arr,i_commonfunctions_loopIdx16,i_commonfunctions_loopMax16
do while i_commonfunctions_loopIdx16<=i_commonfunctions_loopMax16
i_commonfunctions_arrKey16 = GetCollectionKey(arr,i_commonfunctions_loopIdx16)
doAssignment val,ArrayElement(arr,i_commonfunctions_arrKey16)
if bValue(asp_strlen(val)) and not bValue(asp_is_numeric(val)) then
numeric = false
exit do
end if
i_commonfunctions_loopIdx16=i_commonfunctions_loopIdx16+1
loop
else
numeric = not bValue(NeedQuotes(var_type))
end if
var_in = ""
GetCollectionBounds arr,i_commonfunctions_loopIdx17,i_commonfunctions_loopMax17
i_commonfunctions_exitLoop17=false
do while i_commonfunctions_loopIdx17<=i_commonfunctions_loopMax17
i_commonfunctions_exitLoop17=false
do
i_commonfunctions_arrKey17 = GetCollectionKey(arr,i_commonfunctions_loopIdx17)
doAssignment val,ArrayElement(arr,i_commonfunctions_arrKey17)
if bValue(numeric) and not bValue(asp_strlen(val)) then
exit do
end if
if bValue(asp_strlen(var_in)) then
var_in = CSmartStr(var_in) & ","
end if
if bValue(numeric) then
var_in = CSmartStr(var_in) & CSmartStr(CSmartDbl(val)+0)
else
var_in = CSmartStr(var_in) & (("'" & CSmartStr(db_addslashes(val))) & "'")
end if
loop while false
if i_commonfunctions_exitLoop17 then _
exit do
i_commonfunctions_loopIdx17=i_commonfunctions_loopIdx17+1
loop
if bValue(asp_strlen(var_in)) then
LookupSQL = CSmartStr(LookupSQL) & (((CSmartStr(GetLWLinkField(field,"",true)) & " in (") & CSmartStr(var_in)) & ")")
doAssignmentByRef where,GetLWWhere(field,"")
if bValue(asp_strlen(where)) then
LookupSQL = CSmartStr(LookupSQL) & ((" and (" & CSmartStr(where)) & ")")
end if
LogInfo LookupSQL
doAssignmentByRef rsLookup,db_query(LookupSQL,conn)
found = false
do while bValue(doAssignmentByRef(lookuprow,db_fetch_numarray(rsLookup)))
doAssignment lookupvalue,ArrayElement(lookuprow,0)
if bValue(found) then
out = CSmartStr(out) & ","
end if
found = true
out = CSmartStr(out) & CSmartStr(GetDataInt(lookupvalue,data,field,ViewFormat(field,"")))
loop
if bValue(found) then
if bValue(NeedEncode(field,"")) and not IsEqual(mode,MODE_EXPORT) then
doAssignmentByRef DisplayLookupWizard,ProcessLargeText(out,iquery,"",mode,GetEditFormat(field,""))
Exit Function
else
doAssignmentByRef DisplayLookupWizard,out
Exit Function
end if
end if
end if
else
doAssignmentByRef strdata,make_db_value(field,value,"","","")
LookupSQL = CSmartStr(LookupSQL) & ((CSmartStr(GetLWLinkField(field,"",true)) & " = ") & CSmartStr(strdata))
doAssignmentByRef where,GetLWWhere(field,"")
if bValue(asp_strlen(where)) then
LookupSQL = CSmartStr(LookupSQL) & ((" and (" & CSmartStr(where)) & ")")
end if
LogInfo LookupSQL
doAssignmentByRef rsLookup,db_query(LookupSQL,conn)
if bValue(doAssignmentByRef(lookuprow,db_fetch_numarray(rsLookup))) then
doAssignment lookupvalue,ArrayElement(lookuprow,0)
end if
end if
if not bValue(out) then
doAssignmentByRef out,GetDataInt(lookupvalue,data,field,ViewFormat(field,""))
end if
if bValue(NeedEncode(field,"")) and not IsEqual(mode,MODE_EXPORT) then
doAssignmentByRef value,ProcessLargeText(out,iquery,"",mode,GetEditFormat(field,""))
else
doAssignment value,out
end if
doAssignmentByRef DisplayLookupWizard,value
Exit Function
End Function
Function DisplayNoImage()
Dim path
doAssignmentByRef path,getabspath("images/no_image.gif")
asp_header "Content-Type: image/gif"
printfile path
End Function
Function DisplayFile()
Dim path
doAssignmentByRef path,getabspath("images/file.gif")
asp_header "Content-Type: image/gif"
printfile path
End Function
Function my_strrpos(ByVal haystack,ByVal needle)
Dim index
doAssignmentByRef index,asp_strpos(asp_strrev(haystack),asp_strrev(needle),empty)
if IsFalse(index) then
my_strrpos = false
Exit Function
end if
index = (CSmartDbl(asp_strlen(haystack))-CSmartDbl(asp_strlen(needle)))-CSmartDbl(index)
doAssignmentByRef my_strrpos,index
Exit Function
End Function
Function strlen_utf8(ByVal str)
Dim len,i,olen,c
len = 0
i = 0
doAssignmentByRef olen,asp_strlen(str)
do while IsLess(i,olen)
doAssignmentByRef c,asc(asp_substr(str,i,1))
if IsLess(c,128) then
i = CSmartDbl(i)+1
else
if (IsLess(i,CSmartDbl(olen)-1) and IsLessOrEqual(192,c)) and IsLessOrEqual(c,223) then
i = CSmartDbl(i)+2
else
if (IsLess(i,CSmartDbl(olen)-2) and IsLessOrEqual(224,c)) and IsLessOrEqual(c,239) then
i = CSmartDbl(i)+3
else
if IsLess(i,CSmartDbl(olen)-3) and IsLessOrEqual(240,c) then
i = CSmartDbl(i)+4
else
exit do
end if
end if
end if
end if
len = CSmartDbl(len)+1
loop
doAssignmentByRef strlen_utf8,len
Exit Function
End Function
Function substr_utf8(ByVal str,ByVal index,ByVal strlen)
Dim len,i,olen,oindex,c
if IsLessOrEqual(strlen,0) then
substr_utf8 = ""
Exit Function
end if
len = 0
i = 0
doAssignmentByRef olen,asp_strlen(str)
oindex = -1
do while IsLess(i,olen)
if IsEqual(len,index) then
doAssignment oindex,i
end if
doAssignmentByRef c,asc(asp_substr(str,i,1))
if IsLess(c,128) then
i = CSmartDbl(i)+1
else
if (IsLess(i,CSmartDbl(olen)-1) and IsLessOrEqual(192,c)) and IsLessOrEqual(c,223) then
i = CSmartDbl(i)+2
else
if (IsLess(i,CSmartDbl(olen)-2) and IsLessOrEqual(224,c)) and IsLessOrEqual(c,239) then
i = CSmartDbl(i)+3
else
if IsLess(i,CSmartDbl(olen)-3) and IsLessOrEqual(240,c) then
i = CSmartDbl(i)+4
else
exit do
end if
end if
end if
end if
len = CSmartDbl(len)+1
if IsLessOrEqual(0,oindex) and IsEqual(len,CSmartDbl(index)+CSmartDbl(strlen)) then
doAssignmentByRef substr_utf8,asp_substr(str,oindex,CSmartDbl(i)-CSmartDbl(oindex))
Exit Function
end if
loop
if IsLess(0,oindex) then
doAssignmentByRef substr_utf8,asp_substr(str,oindex,CSmartDbl(olen)-CSmartDbl(oindex))
Exit Function
end if
substr_utf8 = ""
Exit Function
End Function
Function jsreplace(ByVal str)
Dim ret
doAssignmentByRef ret,asp_str_replace(CreateDictionary4(Empty,"\",Empty,"'",Empty,vbcr,Empty,vblf),CreateDictionary4(Empty,"\\",Empty,"\'",Empty,"\r",Empty,"\n"),str)
doAssignmentByRef jsreplace,my_str_ireplace("","",ret)
Exit Function
End Function
Function LogInfo(ByVal SQL)
End Function
Function CheckImageExtension(ByVal filename)
Dim ext
if IsLess(asp_strlen(filename),4) then
CheckImageExtension = false
Exit Function
end if
doAssignmentByRef ext,asp_strtoupper(asp_substr(filename,CSmartDbl(asp_strlen(filename))-4,empty))
if (((IsEqual(ext,".GIF") or IsEqual(ext,".JPG")) or IsEqual(ext,"JPEG")) or IsEqual(ext,".PNG")) or IsEqual(ext,".BMP") then
doAssignmentByRef CheckImageExtension,ext
Exit Function
end if
CheckImageExtension = false
Exit Function
End Function
Function RTESafe(ByVal strText)
Dim tmpString
tmpString = ""
doAssignmentByRef tmpString,trim(strText)
if not bValue(tmpString) then
RTESafe = ""
Exit Function
end if
doAssignmentByRef tmpString,asp_str_replace(chr(145),chr(39),tmpString)
doAssignmentByRef tmpString,asp_str_replace(chr(146),chr(39),tmpString)
doAssignmentByRef tmpString,asp_str_replace("'","'",tmpString)
doAssignmentByRef tmpString,asp_str_replace(chr(147),chr(34),tmpString)
doAssignmentByRef tmpString,asp_str_replace(chr(148),chr(34),tmpString)
doAssignmentByRef tmpString,asp_str_replace(chr(10)," ",tmpString)
doAssignmentByRef tmpString,asp_str_replace(chr(13)," ",tmpString)
doAssignmentByRef RTESafe,tmpString
Exit Function
End Function
Function html_special_decode(ByVal str)
Dim ret
doAssignment ret,str
doAssignmentByRef ret,asp_str_replace(">",">",ret)
doAssignmentByRef ret,asp_str_replace("<","<",ret)
doAssignmentByRef ret,asp_str_replace(""","""",ret)
doAssignmentByRef ret,asp_str_replace("'","'",ret)
doAssignmentByRef ret,asp_str_replace("'","'",ret)
doAssignmentByRef ret,asp_str_replace("&","&",ret)
doAssignmentByRef html_special_decode,ret
Exit Function
End Function
Function CalcSearchParameters()
Dim sWhere,var_SESSION,strSearchFor,sfor,strSearchFor2,var_type,f,strSearchOption,where
sWhere = ""
if IsEqual(Session(CSmartStr(strTableName) & "_search"),2) then
GetCollectionBounds Session(CSmartStr(strTableName) & "_asearchfor"),i_commonfunctions_loopIdx21,i_commonfunctions_loopMax21
do while i_commonfunctions_loopIdx21<=i_commonfunctions_loopMax21
f = GetCollectionKey(Session(CSmartStr(strTableName) & "_asearchfor"),i_commonfunctions_loopIdx21)
doAssignment sfor,ArrayElement(Session(CSmartStr(strTableName) & "_asearchfor"),f)
doAssignmentByRef strSearchFor,trim(sfor)
strSearchFor2 = ""
doAssignment var_type,ArrayElement(Session(CSmartStr(strTableName) & "_asearchfortype"),f)
if bValue(asp_array_key_exists(f,Session(CSmartStr(strTableName) & "_asearchfor2"))) then
doAssignmentByRef strSearchFor2,trim(ArrayElement(Session(CSmartStr(strTableName) & "_asearchfor2"),f))
end if
if not IsEqual(strSearchFor,"") or bValue(true) then
if not bValue(sWhere) then
if IsEqual(Session(CSmartStr(strTableName) & "_asearchtype"),"and") then
sWhere = "1=1"
else
sWhere = "1=0"
end if
end if
doAssignmentByRef strSearchOption,trim(ArrayElement(Session(CSmartStr(strTableName) & "_asearchopt"),f))
if bValue(doAssignmentByRef(where,StrWhereAdv(f,strSearchFor,strSearchOption,strSearchFor2,var_type,false))) then
if bValue(ArrayElement(Session(CSmartStr(strTableName) & "_asearchnot"),f)) then
where = ("not (" & CSmartStr(where)) & ")"
end if
if IsEqual(Session(CSmartStr(strTableName) & "_asearchtype"),"and") then
sWhere = CSmartStr(sWhere) & (" and " & CSmartStr(where))
else
sWhere = CSmartStr(sWhere) & (" or " & CSmartStr(where))
end if
end if
end if
i_commonfunctions_loopIdx21=i_commonfunctions_loopIdx21+1
loop
end if
doAssignmentByRef CalcSearchParameters,sWhere
Exit Function
End Function
Function gSQLWhere(ByVal where,ByVal having)
Dim sqlHead,sqlGroupBy,oHaving,sqlHaving
doAssignmentByRef sqlHead,gQuery.HeadToSql()
doAssignmentByRef sqlGroupBy,gQuery.GroupByToSql()
doAssignmentByRef oHaving,gQuery.Having()
doAssignmentByRef sqlHaving,oHaving.toSql_p1(gQuery)
doAssignmentByRef gSQLWhere,gSQLWhere_having(sqlHead,gsqlFrom,gsqlWhereExpr,sqlGroupBy,sqlHaving,where,having)
Exit Function
End Function
Function gSQLWhere_having(ByVal sqlHead,ByVal sqlFrom,ByVal sqlWhere,ByVal sqlGroupBy,ByVal sqlHaving,ByVal where,ByVal having)
Dim strWhere,strHaving
doAssignmentByRef strWhere,whereAdd(sqlWhere,where)
if bValue(asp_strlen(strWhere)) then
strWhere = (" where " & CSmartStr(strWhere)) & " "
end if
doAssignmentByRef strHaving,whereAdd(sqlHaving,having)
if bValue(asp_strlen(strHaving)) then
strHaving = (" having " & CSmartStr(strHaving)) & " "
end if
gSQLWhere_having = (((((((CSmartStr(sqlHead) & " ") & CSmartStr(sqlFrom)) & " ") & CSmartStr(strWhere)) & " ") & CSmartStr(sqlGroupBy)) & " ") & CSmartStr(strHaving)
Exit Function
End Function
Function whereAdd(ByVal where,ByVal clause)
if not bValue(asp_strlen(clause)) then
doAssignmentByRef whereAdd,where
Exit Function
end if
if not bValue(asp_strlen(where)) then
doAssignmentByRef whereAdd,clause
Exit Function
end if
whereAdd = ((("(" & CSmartStr(where)) & ") and (") & CSmartStr(clause)) & ")"
Exit Function
End Function
Function AddWhere(ByVal sql,ByVal where)
Dim tsql,n,n1,n2
if not bValue(asp_strlen(where)) then
doAssignmentByRef AddWhere,sql
Exit Function
end if
doAssignmentByRef sql,asp_str_replace(CreateDictionary3(Empty,vbcrlf,Empty,vblf,Empty," ")," ",sql)
doAssignmentByRef tsql,asp_strtolower(sql)
doAssignmentByRef n,my_strrpos(tsql," where ")
doAssignmentByRef n1,my_strrpos(tsql," group by ")
doAssignmentByRef n2,my_strrpos(tsql," order by ")
if IsFalse(n1) then
doAssignmentByRef n1,asp_strlen(tsql)
end if
if IsFalse(n2) then
doAssignmentByRef n2,asp_strlen(tsql)
end if
if IsLess(n2,n1) then
doAssignment n1,n2
end if
if IsFalse(n) then
AddWhere = ((CSmartStr(asp_substr(sql,0,n1)) & " where ") & CSmartStr(where)) & CSmartStr(asp_substr(sql,n1,empty))
Exit Function
else
AddWhere = (((((CSmartStr(asp_substr(sql,0,CSmartDbl(n)+CSmartDbl(asp_strlen(" where ")))) & "(") & CSmartStr(asp_substr(sql,CSmartDbl(n)+CSmartDbl(asp_strlen(" where ")),(CSmartDbl(n1)-CSmartDbl(n))-CSmartDbl(asp_strlen(" where "))))) & ") and (") & CSmartStr(where)) & ")") & CSmartStr(asp_substr(sql,n1,empty))
Exit Function
end if
End Function
Function KeyWhere(ByRef keys,ByVal table)
Dim strWhere,keyFields,value,kf,valueisnull
if not bValue(table) then
doAssignment table,strTableName
end if
strWhere = ""
doAssignmentByRef keyFields,GetTableKeys(table)
GetCollectionBounds keyFields,i_commonfunctions_loopIdx22,i_commonfunctions_loopMax22
do while i_commonfunctions_loopIdx22<=i_commonfunctions_loopMax22
i_commonfunctions_arrKey22 = GetCollectionKey(keyFields,i_commonfunctions_loopIdx22)
doAssignment kf,ArrayElement(keyFields,i_commonfunctions_arrKey22)
if bValue(asp_strlen(strWhere)) then
strWhere = CSmartStr(strWhere) & " and "
end if
doAssignmentByRef value,make_db_value(kf,ArrayElement(keys,kf),"","","")
valueisnull = IsIdentical(value,"null")
if bValue(valueisnull) then
strWhere = CSmartStr(strWhere) & (CSmartStr(GetFullFieldName(kf,table)) & " is null")
else
strWhere = CSmartStr(strWhere) & ((CSmartStr(GetFullFieldName(kf,table)) & "=") & CSmartStr(make_db_value(kf,ArrayElement(keys,kf),"","","")))
end if
i_commonfunctions_loopIdx22=i_commonfunctions_loopIdx22+1
loop
doAssignmentByRef KeyWhere,strWhere
Exit Function
End Function
Function StrWhereExpression(ByVal strField,ByVal SearchFor,ByVal strSearchOption,ByVal SearchFor2)
Dim var_type,ismssql,isdb2,isMysql,btexttype,strQuote,sSearchFor,sSearchFor2,time,ret,var_like,sSearchForMysql
doAssignmentByRef var_type,GetFieldType(strField,"")
ismssql = false
isdb2 = false
isMysql = true
doAssignmentByRef btexttype,IsTextType(var_type)
btexttype = false
if IsEqual(strSearchOption,"Empty") then
if bValue(IsCharType(var_type)) and (not bValue(ismssql) or not bValue(btexttype)) then
StrWhereExpression = ((("(" & CSmartStr(GetFullFieldName(strField,""))) & " is null or ") & CSmartStr(GetFullFieldName(strField,""))) & "='')"
Exit Function
else
if bValue(ismssql) and bValue(btexttype) then
StrWhereExpression = ((("(" & CSmartStr(GetFullFieldName(strField,""))) & " is null or ") & CSmartStr(GetFullFieldName(strField,""))) & " LIKE '')"
Exit Function
else
StrWhereExpression = CSmartStr(GetFullFieldName(strField,"")) & " is null"
Exit Function
end if
end if
end if
strQuote = ""
if bValue(NeedQuotes(var_type)) then
strQuote = "'"
end if
doAssignment sSearchFor,SearchFor
doAssignment sSearchFor2,SearchFor2
if bValue(IsBinaryType(var_type)) then
StrWhereExpression = ""
Exit Function
end if
if (bValue(IsDateFieldType(var_type)) and not IsEqual(strSearchOption,"Contains")) and not IsEqual(strSearchOption,"Starts with") then
doAssignmentByRef time,localdatetime2db(SearchFor,"")
if IsEqual(time,"null") then
StrWhereExpression = ""
Exit Function
end if
doAssignmentByRef sSearchFor,db_datequotes(time)
if IsEqual(strSearchOption,"Between") then
doAssignmentByRef time,localdatetime2db(SearchFor2,"")
if IsEqual(time,"null") then
sSearchFor2 = ""
else
doAssignmentByRef sSearchFor2,db_datequotes(time)
end if
end if
end if
if (not bValue(strQuote) and not bValue(asp_is_numeric(sSearchFor))) and not bValue(asp_is_numeric(sSearchFor)) then
StrWhereExpression = ""
Exit Function
else
if (not bValue(strQuote) and not IsEqual(strSearchOption,"Contains")) and not IsEqual(strSearchOption,"Starts with") then
sSearchFor = 0+CSmartDbl(sSearchFor)
sSearchFor2 = 0+CSmartDbl(sSearchFor2)
else
if (not bValue(IsDateFieldType(var_type)) and not IsEqual(strSearchOption,"Contains")) and not IsEqual(strSearchOption,"Starts with") then
if bValue(btexttype) then
sSearchFor = (CSmartStr(strQuote) & CSmartStr(db_addslashes(sSearchFor))) & CSmartStr(strQuote)
if IsEqual(strSearchOption,"Between") and bValue(sSearchFor2) then
sSearchFor2 = (CSmartStr(strQuote) & CSmartStr(db_addslashes(sSearchFor2))) & CSmartStr(strQuote)
end if
else
doAssignmentByRef sSearchFor,isEnableUpper((CSmartStr(strQuote) & CSmartStr(db_addslashes(sSearchFor))) & CSmartStr(strQuote))
if IsEqual(strSearchOption,"Between") and bValue(sSearchFor2) then
doAssignmentByRef sSearchFor2,isEnableUpper((CSmartStr(strQuote) & CSmartStr(db_addslashes(sSearchFor2))) & CSmartStr(strQuote))
end if
end if
else
if (not bValue(IsDateFieldType(var_type)) or IsEqual(strSearchOption,"Contains")) or IsEqual(strSearchOption,"Starts with") then
doAssignmentByRef sSearchFor,db_addslashes(sSearchFor)
end if
end if
end if
end if
if bValue(IsCharType(var_type)) and not bValue(btexttype) then
doAssignmentByRef strField,isEnableUpper(GetFullFieldName(strField,""))
else
if IsEqual(strSearchOption,"Contains") or IsEqual(strSearchOption,"Starts with") then
doAssignmentByRef strField,db_field2char(GetFullFieldName(strField,""),var_type)
else
if IsEqual(ViewFormat(strField,""),FORMAT_TIME) then
doAssignmentByRef strField,db_field2time(GetFullFieldName(strField,""),var_type)
else
doAssignmentByRef strField,GetFullFieldName(strField,"")
end if
end if
end if
ret = ""
var_like = "like"
if bValue(isMysql) then
doAssignmentByRef sSearchForMysql,asp_str_replace("\\","\\\\",sSearchFor)
end if
if IsEqual(strSearchOption,"Contains") then
if bValue(isMysql) then
doAssignment sSearchFor,sSearchForMysql
end if
if bValue(IsCharType(var_type)) and not bValue(btexttype) then
StrWhereExpression = (((CSmartStr(strField) & " ") & CSmartStr(var_like)) & " ") & CSmartStr(isEnableUpper(("'%" & CSmartStr(sSearchFor)) & "%'"))
Exit Function
else
StrWhereExpression = ((((CSmartStr(strField) & " ") & CSmartStr(var_like)) & " '%") & CSmartStr(sSearchFor)) & "%'"
Exit Function
end if
else
if IsEqual(strSearchOption,"Equals") then
StrWhereExpression = (CSmartStr(strField) & "=") & CSmartStr(sSearchFor)
Exit Function
else
if IsEqual(strSearchOption,"Starts with") then
if bValue(isMysql) then
doAssignment sSearchFor,sSearchForMysql
end if
if bValue(IsCharType(var_type)) and not bValue(btexttype) then
StrWhereExpression = (((CSmartStr(strField) & " ") & CSmartStr(var_like)) & " ") & CSmartStr(isEnableUpper(("'" & CSmartStr(sSearchFor)) & "%'"))
Exit Function
else
StrWhereExpression = ((((CSmartStr(strField) & " ") & CSmartStr(var_like)) & " '") & CSmartStr(sSearchFor)) & "%'"
Exit Function
end if
else
if IsEqual(strSearchOption,"More than") then
StrWhereExpression = (CSmartStr(strField) & ">") & CSmartStr(sSearchFor)
Exit Function
else
if IsEqual(strSearchOption,"Less than") then
StrWhereExpression = (CSmartStr(strField) & "<") & CSmartStr(sSearchFor)
Exit Function
else
if IsEqual(strSearchOption,"Between") then
ret = (CSmartStr(strField) & ">=") & CSmartStr(sSearchFor)
if bValue(sSearchFor2) then
ret = CSmartStr(ret) & (((" and " & CSmartStr(strField)) & "<=") & CSmartStr(sSearchFor2))
end if
doAssignmentByRef StrWhereExpression,ret
Exit Function
end if
end if
end if
end if
end if
end if
StrWhereExpression = ""
Exit Function
End Function
Function StrWhereAdv(ByVal strField,ByVal SearchFor,ByVal strSearchOption,ByVal SearchFor2,ByVal etype,ByVal isSuggest)
Dim var_type,isOracle,ismssql,isdb2,btexttype,isMysql,var_like,ret,value,whereStr,value1,value2,cleanvalue2,gstrField,timeArr
doAssignmentByRef var_type,GetFieldType(strField,"")
isOracle = false
ismssql = false
isdb2 = false
doAssignmentByRef btexttype,IsTextType(var_type)
btexttype = false
isMysql = true
if bValue(IsBinaryType(var_type)) then
StrWhereAdv = ""
Exit Function
end if
if IsEqual(strSearchOption,"Empty") then
if (bValue(IsCharType(var_type)) and (not bValue(ismssql) or not bValue(btexttype))) and not bValue(isOracle) then
StrWhereAdv = ((("(" & CSmartStr(GetFullFieldName(strField,""))) & " is null or ") & CSmartStr(GetFullFieldName(strField,""))) & "='')"
Exit Function
else
if bValue(ismssql) and bValue(btexttype) then
StrWhereAdv = ((("(" & CSmartStr(GetFullFieldName(strField,""))) & " is null or ") & CSmartStr(GetFullFieldName(strField,""))) & " LIKE '')"
Exit Function
else
StrWhereAdv = CSmartStr(GetFullFieldName(strField,"")) & " is null"
Exit Function
end if
end if
end if
var_like = "like"
if IsEqual(GetEditFormat(strField,""),EDIT_FORMAT_LOOKUP_WIZARD) then
if bValue(Multiselect(strField,"")) then
doAssignmentByRef SearchFor,splitvalues(SearchFor)
else
Set SearchFor = (CreateDictionary1(Empty,SearchFor))
end if
ret = ""
GetCollectionBounds SearchFor,i_commonfunctions_loopIdx23,i_commonfunctions_loopMax23
do while i_commonfunctions_loopIdx23<=i_commonfunctions_loopMax23
i_commonfunctions_arrKey23 = GetCollectionKey(SearchFor,i_commonfunctions_loopIdx23)
doAssignment value,ArrayElement(SearchFor,i_commonfunctions_arrKey23)
if not ((IsEqual(value,"null") or IsEqual(value,"Null")) or IsEqual(value,"")) then
if bValue(asp_strlen(ret)) then
ret = CSmartStr(ret) & " or "
end if
if IsEqual(strSearchOption,"Equals") then
doAssignmentByRef value,make_db_value(strField,value,"","","")
if not (IsEqual(value,"null") or IsEqual(value,"Null")) then
ret = CSmartStr(ret) & ((CSmartStr(GetFullFieldName(strField,"")) & "=") & CSmartStr(value))
end if
else
if bValue(isSuggest) then
ret = CSmartStr(ret) & ((((((" " & CSmartStr(GetFullFieldName(strField,""))) & " ") & CSmartStr(var_like)) & " '%") & CSmartStr(value)) & "%'")
else
if not IsFalse(asp_strpos(value,",",empty)) or not IsFalse(asp_strpos(value,"""",empty)) then
value = ("""" & CSmartStr(asp_str_replace("""","""""",value))) & """"
end if
doAssignmentByRef value,db_addslashes(value)
if bValue(isMysql) then
doAssignmentByRef value,asp_str_replace("\\","\\\\",value)
end if
ret = CSmartStr(ret) & (((CSmartStr(GetFullFieldName(strField,"")) & " = '") & CSmartStr(value)) & "'")
ret = CSmartStr(ret) & ((((((" or " & CSmartStr(GetFullFieldName(strField,""))) & " ") & CSmartStr(var_like)) & " '%,") & CSmartStr(value)) & ",%'")
ret = CSmartStr(ret) & ((((((" or " & CSmartStr(GetFullFieldName(strField,""))) & " ") & CSmartStr(var_like)) & " '%,") & CSmartStr(value)) & "'")
ret = CSmartStr(ret) & ((((((" or " & CSmartStr(GetFullFieldName(strField,""))) & " ") & CSmartStr(var_like)) & " '") & CSmartStr(value)) & ",%'")
end if
end if
end if
i_commonfunctions_loopIdx23=i_commonfunctions_loopIdx23+1
loop
if bValue(asp_strlen(ret)) then
ret = ("(" & CSmartStr(ret)) & ")"
end if
doAssignmentByRef StrWhereAdv,ret
Exit Function
end if
if IsEqual(GetEditFormat(strField,""),EDIT_FORMAT_CHECKBOX) then
if IsEqual(SearchFor,"none") then
StrWhereAdv = ""
Exit Function
end if
if bValue(NeedQuotes(var_type)) then
isOracle = false
if IsEqual(SearchFor,"on") then
whereStr = ("(" & CSmartStr(GetFullFieldName(strField,""))) & "<>'0' "
if not bValue(isOracle) then
whereStr = CSmartStr(whereStr) & ((" and " & CSmartStr(GetFullFieldName(strField,""))) & "<>'' ")
end if
whereStr = CSmartStr(whereStr) & ((" and " & CSmartStr(GetFullFieldName(strField,""))) & " is not null)")
doAssignmentByRef StrWhereAdv,whereStr
Exit Function
else
if IsEqual(SearchFor,"off") then
whereStr = ("(" & CSmartStr(GetFullFieldName(strField,""))) & "='0' "
if not bValue(isOracle) then
whereStr = CSmartStr(whereStr) & ((" or " & CSmartStr(GetFullFieldName(strField,""))) & "='' ")
end if
whereStr = CSmartStr(whereStr) & ((" or " & CSmartStr(GetFullFieldName(strField,""))) & " is null)")
end if
end if
else
if IsEqual(SearchFor,"on") then
StrWhereAdv = ((("(" & CSmartStr(GetFullFieldName(strField,""))) & "<>0 and ") & CSmartStr(GetFullFieldName(strField,""))) & " is not null)"
Exit Function
else
if IsEqual(SearchFor,"off") then
StrWhereAdv = ((("(" & CSmartStr(GetFullFieldName(strField,""))) & "=0 or ") & CSmartStr(GetFullFieldName(strField,""))) & " is null)"
Exit Function
end if
end if
end if
end if
doAssignmentByRef value1,make_db_value(strField,SearchFor,etype,"","")
value2 = false
cleanvalue2 = false
if IsEqual(strSearchOption,"Between") then
doAssignmentByRef cleanvalue2,prepare_for_db(strField,SearchFor2,etype,"","")
doAssignmentByRef value2,make_db_value(strField,SearchFor2,etype,"","")
end if
if (not IsEqual(strSearchOption,"Contains") and not IsEqual(strSearchOption,"Starts with")) and (IsIdentical(value1,"null") or IsIdentical(value2,"null")) then
StrWhereAdv = ""
Exit Function
end if
if bValue(IsCharType(var_type)) and not bValue(btexttype) then
doAssignmentByRef value1,isEnableUpper(value1)
doAssignmentByRef value2,isEnableUpper(value2)
doAssignmentByRef gstrField,isEnableUpper(GetFullFieldName(strField,""))
else
if IsEqual(strSearchOption,"Contains") or IsEqual(strSearchOption,"Starts with") then
doAssignmentByRef gstrField,db_field2char(GetFullFieldName(strField,""),var_type)
else
if IsEqual(ViewFormat(strField,""),FORMAT_TIME) then
doAssignmentByRef gstrField,db_field2time(GetFullFieldName(strField,""),var_type)
else
doAssignmentByRef gstrField,GetFullFieldName(strField,"")
end if
end if
end if
ret = ""
if IsEqual(strSearchOption,"Contains") then
doAssignmentByRef SearchFor,db_addslashes(SearchFor)
if bValue(isMysql) then
doAssignmentByRef SearchFor,asp_str_replace("\\","\\\\",SearchFor)
end if
if bValue(IsCharType(var_type)) and not bValue(btexttype) then
StrWhereAdv = (((CSmartStr(gstrField) & " ") & CSmartStr(var_like)) & " ") & CSmartStr(isEnableUpper(("'%" & CSmartStr(SearchFor)) & "%'"))
Exit Function
else
StrWhereAdv = ((((CSmartStr(gstrField) & " ") & CSmartStr(var_like)) & " '%") & CSmartStr(SearchFor)) & "%'"
Exit Function
end if
else
if IsEqual(strSearchOption,"Equals") then
StrWhereAdv = (CSmartStr(gstrField) & "=") & CSmartStr(value1)
Exit Function
else
if IsEqual(strSearchOption,"Starts with") then
doAssignmentByRef SearchFor,db_addslashes(SearchFor)
if bValue(isMysql) then
doAssignmentByRef SearchFor,asp_str_replace("\\","\\\\",SearchFor)
end if
if bValue(IsCharType(var_type)) and not bValue(btexttype) then
StrWhereAdv = (((CSmartStr(gstrField) & " ") & CSmartStr(var_like)) & " ") & CSmartStr(isEnableUpper(("'" & CSmartStr(SearchFor)) & "%'"))
Exit Function
else
StrWhereAdv = ((((CSmartStr(gstrField) & " ") & CSmartStr(var_like)) & " '") & CSmartStr(SearchFor)) & "%'"
Exit Function
end if
else
if IsEqual(strSearchOption,"More than") then
StrWhereAdv = (CSmartStr(gstrField) & ">") & CSmartStr(value1)
Exit Function
else
if IsEqual(strSearchOption,"Less than") then
StrWhereAdv = (CSmartStr(gstrField) & "<") & CSmartStr(value1)
Exit Function
else
if IsEqual(strSearchOption,"Equal or more than") then
StrWhereAdv = (CSmartStr(gstrField) & ">=") & CSmartStr(value1)
Exit Function
else
if IsEqual(strSearchOption,"Equal or less than") then
StrWhereAdv = (CSmartStr(gstrField) & "<=") & CSmartStr(value1)
Exit Function
else
if IsEqual(strSearchOption,"Between") then
ret = ((CSmartStr(gstrField) & ">=") & CSmartStr(value1)) & " and "
if bValue(IsDateFieldType(var_type)) then
doAssignmentByRef timeArr,db2time(cleanvalue2)
if (IsEqual(ArrayElement(timeArr,3),0) and IsEqual(ArrayElement(timeArr,4),0)) and IsEqual(ArrayElement(timeArr,5),0) then
doAssignmentByRef timeArr,adddays(timeArr,1)
value2 = (((CSmartStr(ArrayElement(timeArr,0)) & "-") & CSmartStr(ArrayElement(timeArr,1))) & "-") & CSmartStr(ArrayElement(timeArr,2))
doAssignmentByRef value2,add_db_quotes(strField,value2,strTableName)
ret = CSmartStr(ret) & ((CSmartStr(gstrField) & "<") & CSmartStr(value2))
else
ret = CSmartStr(ret) & ((CSmartStr(gstrField) & "<=") & CSmartStr(value2))
end if
else
ret = CSmartStr(ret) & ((CSmartStr(gstrField) & "<=") & CSmartStr(value2))
end if
doAssignmentByRef StrWhereAdv,ret
Exit Function
end if
end if
end if
end if
end if
end if
end if
end if
StrWhereAdv = ""
Exit Function
End Function
Function gSQLRowCount(ByVal where,ByVal having)
Dim sqlHead,sqlGroupBy,oHaving,sqlHaving
doAssignmentByRef sqlHead,gQuery.HeadToSql()
doAssignmentByRef sqlGroupBy,gQuery.GroupByToSql()
doAssignmentByRef oHaving,gQuery.Having()
doAssignmentByRef sqlHaving,oHaving.toSql_p1(gQuery)
doAssignmentByRef gSQLRowCount,gSQLRowCount_int(sqlHead,gsqlFrom,gsqlWhereExpr,sqlGroupBy,sqlHaving,where,having)
Exit Function
End Function
Function gSQLRowCount_int(ByVal sqlHead,ByVal sqlFrom,ByVal sqlWhere,ByVal sqlGroupBy,ByVal sqlHaving,ByVal where,ByVal having)
Dim strWhere,countstr,countrs,countdata
doAssignmentByRef strWhere,whereAdd(sqlWhere,where)
if bValue(asp_strlen(strWhere)) then
strWhere = (" where " & CSmartStr(strWhere)) & " "
end if
if bValue(asp_strlen(sqlGroupBy)) then
if bValue(bSubqueriesSupported) then
countstr = ("select count(*) from (" & CSmartStr(gSQLWhere_having(sqlHead,sqlFrom,sqlWhere,sqlGroupBy,sqlHaving,where,having))) & ") a"
else
doAssignmentByRef countstr,gSQLWhere_having(sqlHead,sqlFrom,sqlWhere,sqlGroupBy,sqlHaving,where,having)
doAssignmentByRef gSQLRowCount_int,GetMySQL4RowCount(countstr)
Exit Function
end if
else
countstr = ("select count(*) " & CSmartStr(sqlFrom)) & CSmartStr(strWhere)
end if
doAssignmentByRef countrs,db_query(countstr,conn)
doAssignmentByRef countdata,db_fetch_numarray(countrs)
doAssignmentByRef gSQLRowCount_int,ArrayElement(countdata,0)
Exit Function
End Function
Function GetRowCount(ByVal strSQL)
Dim tstr,ind1,ind2,ind3,countstr,countrs,countdata
doAssignmentByRef strSQL,asp_str_replace(CreateDictionary3(Empty,vbcrlf,Empty,vblf,Empty," ")," ",strSQL)
doAssignmentByRef tstr,asp_strtoupper(strSQL)
doAssignmentByRef ind1,asp_strpos(tstr,"SELECT ",empty)
doAssignmentByRef ind2,my_strrpos(tstr," FROM ")
doAssignmentByRef ind3,my_strrpos(tstr," GROUP BY ")
if IsFalse(ind3) then
doAssignmentByRef ind3,asp_strpos(tstr," ORDER BY ",empty)
if IsFalse(ind3) then
doAssignmentByRef ind3,asp_strlen(strSQL)
end if
end if
countstr = (CSmartStr(asp_substr(strSQL,0,CSmartDbl(ind1)+6)) & " count(*) ") & CSmartStr(asp_substr(strSQL,CSmartDbl(ind2)+1,CSmartDbl(ind3)-CSmartDbl(ind2)))
doAssignmentByRef countrs,db_query(countstr,conn)
doAssignmentByRef countdata,db_fetch_numarray(countrs)
doAssignmentByRef GetRowCount,ArrayElement(countdata,0)
Exit Function
End Function
Function AddTop(ByVal strSQL,ByVal n)
Dim tstr,ind1
doAssignmentByRef tstr,asp_strtoupper(strSQL)
doAssignmentByRef ind1,asp_strpos(tstr,"SELECT",empty)
AddTop = (((CSmartStr(asp_substr(strSQL,0,CSmartDbl(ind1)+6)) & " top ") & CSmartStr(n)) & " ") & CSmartStr(asp_substr(strSQL,CSmartDbl(ind1)+6,empty))
Exit Function
End Function
Function AddTopDB2(ByVal strSQL,ByVal n)
AddTopDB2 = ((CSmartStr(strSQL) & " fetch first ") & CSmartStr(n)) & " rows only"
Exit Function
End Function
Function AddTopIfx(ByVal strSQL,ByVal n)
AddTopIfx = (((CSmartStr(asp_substr(strSQL,0,7)) & "limit ") & CSmartStr(n)) & " ") & CSmartStr(asp_substr(strSQL,7,empty))
Exit Function
End Function
Function AddRowNumber(ByVal strSQL,ByVal n)
AddRowNumber = (("select * from (" & CSmartStr(strSQL)) & ") where rownum<") & CSmartStr(CSmartDbl(n)+1)
Exit Function
End Function
Function NeedQuotesNumeric(ByVal var_type)
if ((((((((((((IsEqual(var_type,203) or IsEqual(var_type,8)) or IsEqual(var_type,129)) or IsEqual(var_type,130)) or IsEqual(var_type,7)) or IsEqual(var_type,133)) or IsEqual(var_type,134)) or IsEqual(var_type,135)) or IsEqual(var_type,201)) or IsEqual(var_type,205)) or IsEqual(var_type,200)) or IsEqual(var_type,202)) or IsEqual(var_type,72)) or IsEqual(var_type,13) then
NeedQuotesNumeric = true
Exit Function
else
NeedQuotesNumeric = false
Exit Function
end if
End Function
Function IsNumberType(ByVal var_type)
if ((((((((((((((IsEqual(var_type,20) or IsEqual(var_type,6)) or IsEqual(var_type,14)) or IsEqual(var_type,5)) or IsEqual(var_type,10)) or IsEqual(var_type,3)) or IsEqual(var_type,131)) or IsEqual(var_type,4)) or IsEqual(var_type,2)) or IsEqual(var_type,16)) or IsEqual(var_type,21)) or IsEqual(var_type,19)) or IsEqual(var_type,18)) or IsEqual(var_type,17)) or IsEqual(var_type,139)) or IsEqual(var_type,11) then
IsNumberType = true
Exit Function
end if
IsNumberType = false
Exit Function
End Function
Function IsFloatType(ByVal var_type)
if ((IsEqual(var_type,14) or IsEqual(var_type,5)) or IsEqual(var_type,131)) or IsEqual(var_type,6) then
IsFloatType = true
Exit Function
end if
IsFloatType = false
Exit Function
End Function
Function NeedQuotes(ByVal var_type)
NeedQuotes = not bValue(IsNumberType(var_type))
Exit Function
End Function
Function IsBinaryType(ByVal var_type)
if (IsEqual(var_type,128) or IsEqual(var_type,205)) or IsEqual(var_type,204) then
IsBinaryType = true
Exit Function
end if
IsBinaryType = false
Exit Function
End Function
Function IsDateFieldType(ByVal var_type)
if (IsEqual(var_type,7) or IsEqual(var_type,133)) or IsEqual(var_type,135) then
IsDateFieldType = true
Exit Function
end if
IsDateFieldType = false
Exit Function
End Function
Function IsTimeType(ByVal var_type)
if IsEqual(var_type,134) then
IsTimeType = true
Exit Function
end if
IsTimeType = false
Exit Function
End Function
Function IsCharType(ByVal var_type)
if ((((bValue(IsTextType(var_type)) or IsEqual(var_type,8)) or IsEqual(var_type,129)) or IsEqual(var_type,200)) or IsEqual(var_type,202)) or IsEqual(var_type,130) then
IsCharType = true
Exit Function
end if
IsCharType = false
Exit Function
End Function
Function IsTextType(ByVal var_type)
if IsEqual(var_type,201) or IsEqual(var_type,203) then
IsTextType = true
Exit Function
end if
IsTextType = false
Exit Function
End Function
Function IsGuid(ByVal var_type)
if IsEqual(var_type,72) then
IsGuid = true
Exit Function
end if
IsGuid = false
Exit Function
End Function
Function IsAdmin()
IsAdmin = false
Exit Function
End Function
Function GetUserPermissions(ByVal table)
GetUserPermissions = "ADESPIM"
Exit Function
End Function
Function CheckFieldPermissions(ByVal field,ByVal table)
doAssignmentByRef CheckFieldPermissions,GetFieldData(table,field,"FieldPermissions",false)
Exit Function
End Function
Function CheckSecurity(ByVal strValue,ByVal strAction)
Dim var_SESSION,strPerm
CheckSecurity = true
Exit Function
End Function
Function SecuritySQL(ByVal strAction,ByVal table)
Dim ownerid,var_SESSION,ret,strPerm
if not bValue(asp_strlen(table)) then
doAssignment table,strTableName
end if
SecuritySQL = ""
Exit Function
End Function
Function make_db_value(ByVal field,ByVal value,ByVal controltype,ByVal postfilename,ByVal table)
Dim ret
doAssignmentByRef ret,prepare_for_db(field,value,controltype,postfilename,table)
if IsFalse(ret) then
doAssignmentByRef make_db_value,ret
Exit Function
end if
doAssignmentByRef make_db_value,add_db_quotes(field,ret,table)
Exit Function
End Function
Function add_db_quotes(ByVal field,ByVal value,ByVal table)
Dim var_type,strvalue
doAssignmentByRef var_type,GetFieldType(field,table)
if bValue(IsBinaryType(var_type)) then
doAssignmentByRef add_db_quotes,db_addslashesbinary(value)
Exit Function
end if
if (IsIdentical(value,"") or IsFalse(value)) and not bValue(IsCharType(var_type)) then
add_db_quotes = "null"
Exit Function
end if
if bValue(NeedQuotes(var_type)) then
if not bValue(IsDateFieldType(var_type)) then
value = ("'" & CSmartStr(db_addslashes(value))) & "'"
else
doAssignmentByRef value,db_datequotes(value)
end if
else
strvalue = CSmartStr(value)
doAssignmentByRef strvalue,asp_str_replace(",",".",strvalue)
if bValue(asp_is_numeric(strvalue)) then
doAssignment value,strvalue
else
value = 0
end if
end if
doAssignmentByRef add_db_quotes,value
Exit Function
End Function
Function prepare_for_db(ByVal field,ByVal value,ByVal controltype,ByVal postfilename,ByVal table)
Dim filename,var_type,time,dformat,a,y,m,d,ret
filename = ""
doAssignmentByRef var_type,GetFieldType(field,table)
if not bValue(controltype) or IsEqual(controltype,"multiselect") then
if bValue(asp_is_array(value)) then
doAssignmentByRef value,combinevalues(value)
end if
if (IsIdentical(value,"") or IsFalse(value)) and not bValue(IsCharType(var_type)) then
prepare_for_db = ""
Exit Function
end if
if bValue(IsGuid(var_type)) then
if not bValue(IsGuidString(value)) then
prepare_for_db = ""
Exit Function
end if
end if
doAssignmentByRef prepare_for_db,value
Exit Function
else
if IsEqual(controltype,"time") then
if not bValue(asp_strlen(value)) then
prepare_for_db = ""
Exit Function
end if
doAssignmentByRef time,localtime2db(value)
if bValue(IsDateFieldType(GetFieldType(field,table))) then
time = "2000-01-01 " & CSmartStr(time)
end if
doAssignmentByRef prepare_for_db,time
Exit Function
else
if IsEqual(asp_substr(controltype,0,4),"date") then
doAssignmentByRef dformat,asp_substr(controltype,4,empty)
if IsEqual(dformat,EDIT_DATE_SIMPLE) or IsEqual(dformat,EDIT_DATE_SIMPLE_DP) then
doAssignmentByRef time,localdatetime2db(value,"")
if IsEqual(time,"null") then
prepare_for_db = ""
Exit Function
end if
doAssignmentByRef prepare_for_db,time
Exit Function
else
if IsEqual(dformat,EDIT_DATE_DD) or IsEqual(dformat,EDIT_DATE_DD_DP) then
doAssignmentByRef a,explode("-",value)
if IsLess(asp_count(a),3) then
prepare_for_db = ""
Exit Function
else
doAssignment y,ArrayElement(a,0)
doAssignment m,ArrayElement(a,1)
doAssignment d,ArrayElement(a,2)
end if
if IsLess(y,100) then
if IsLess(y,70) then
y = CSmartDbl(y)+2000
else
y = CSmartDbl(y)+1900
end if
end if
doAssignmentByRef prepare_for_db,mysprintf("%04d-%02d-%02d",CreateDictionary3(Empty,y,Empty,m,Empty,d))
Exit Function
else
prepare_for_db = ""
Exit Function
end if
end if
else
if IsEqual(asp_substr(controltype,0,8),"checkbox") then
if IsEqual(value,"on") then
ret = 1
else
if IsEqual(value,"none") then
prepare_for_db = ""
Exit Function
else
ret = 0
end if
end if
doAssignmentByRef prepare_for_db,ret
Exit Function
else
prepare_for_db = false
Exit Function
end if
end if
end if
end if
End Function
Function DeleteUploadedFiles(ByVal where,ByVal table)
Dim sql,rs,data,value,field,isAbs,filename
doAssignmentByRef sql,gSQLWhere(where,"")
doAssignmentByRef rs,db_query(sql,conn)
if not bValue(doAssignmentByRef(data,db_fetch_array(rs))) then
Exit Function
end if
GetCollectionBounds data,i_commonfunctions_loopIdx28,i_commonfunctions_loopMax28
do while i_commonfunctions_loopIdx28<=i_commonfunctions_loopMax28
field = GetCollectionKey(data,i_commonfunctions_loopIdx28)
doAssignment value,ArrayElement(data,field)
if bValue(asp_strlen(value)) and IsEqual(GetEditFormat(field,""),EDIT_FORMAT_FILE) then
doAssignmentByRef isAbs,GetFieldData(table,field,"Absolute",false)
filename = CSmartStr(GetUploadFolder(field,"")) & CSmartStr(value)
if not bValue(isAbs) then
doAssignmentByRef filename,getabspath(filename)
end if
runner_delete_file filename
if bValue(GetCreateThumbnail(field,"")) then
filename = (CSmartStr(GetUploadFolder(field,"")) & CSmartStr(GetThumbnailPrefix(field,""))) & CSmartStr(value)
if not bValue(isAbs) then
doAssignmentByRef filename,getabspath(filename)
end if
runner_delete_file filename
end if
end if
i_commonfunctions_loopIdx28=i_commonfunctions_loopIdx28+1
loop
End Function
Function combinevalues(ByVal arr)
Dim ret,val
ret = ""
GetCollectionBounds arr,i_commonfunctions_loopIdx29,i_commonfunctions_loopMax29
do while i_commonfunctions_loopIdx29<=i_commonfunctions_loopMax29
i_commonfunctions_arrKey29 = GetCollectionKey(arr,i_commonfunctions_loopIdx29)
doAssignment val,ArrayElement(arr,i_commonfunctions_arrKey29)
if bValue(asp_strlen(ret)) then
ret = CSmartStr(ret) & ","
end if
if IsFalse(asp_strpos(val,",",empty)) and IsFalse(asp_strpos(val,"""",empty)) then
ret = CSmartStr(ret) & CSmartStr(val)
else
doAssignmentByRef val,asp_str_replace("""","""""",val)
ret = CSmartStr(ret) & (("""" & CSmartStr(val)) & """")
end if
i_commonfunctions_loopIdx29=i_commonfunctions_loopIdx29+1
loop
doAssignmentByRef combinevalues,ret
Exit Function
End Function
Function splitvalues(ByVal str)
Dim arr,start,i,inquot,val
Set arr = (CreateDictionary())
start = 0
i = 0
inquot = false
do while IsLessOrEqual(i,asp_strlen(str))
if IsLess(i,asp_strlen(str)) and IsEqual(asp_substr(str,i,1),"""") then
inquot = not bValue(inquot)
else
if IsEqual(i,asp_strlen(str)) or not bValue(inquot) and IsEqual(asp_substr(str,i,1),",") then
doAssignmentByRef val,asp_substr(str,start,CSmartDbl(i)-CSmartDbl(start))
start = CSmartDbl(i)+1
if bValue(asp_strlen(val)) and IsEqual(asp_substr(val,0,1),"""") then
doAssignmentByRef val,asp_substr(val,1,CSmartDbl(asp_strlen(val))-2)
doAssignmentByRef val,asp_str_replace("""""","""",val)
end if
setArrElement arr,asp_count(arr),val
end if
end if
i = CSmartDbl(i)+1
loop
doAssignmentByRef splitvalues,arr
Exit Function
End Function
Function GetDateEdit(ByVal field,ByVal value,ByVal var_type,ByVal fieldNum,ByVal search,ByVal record_id,ByRef pageObj)
Dim is508,strLabel,cfieldname,cfield,tvalue,time,dp,ovalue,fmt,sundayfirst,ovalue1,showtime,ret,retday,retmonth,retyear
doAssignmentByRef is508,isEnableSection508()
doAssignmentByRef strLabel,Label(field,"")
doAssignmentByRef cfieldname,GoodFieldName(field)
cfield = (("value_" & CSmartStr(GoodFieldName(field))) & "_") & CSmartStr(record_id)
if bValue(fieldNum) then
cfield = (((("value" & CSmartStr(fieldNum)) & "_") & CSmartStr(GoodFieldName(field))) & "_") & CSmartStr(record_id)
end if
doAssignment tvalue,value
doAssignmentByRef time,db2time(tvalue)
if not bValue(asp_count(time)) then
Set time = (CreateDictionary6(Empty,0,Empty,0,Empty,0,Empty,0,Empty,0,Empty,0))
end if
dp = 0
do
If IsEqual(var_type,EDIT_DATE_SIMPLE_DP) then
doAssignment ovalue,value
if IsEqual(ArrayElement(locale_info,"LOCALE_IDATE"),1) then
fmt = ((("dd" & CSmartStr(ArrayElement(locale_info,"LOCALE_SDATE"))) & "MM") & CSmartStr(ArrayElement(locale_info,"LOCALE_SDATE"))) & "yyyy"
sundayfirst = "false"
else
if IsEqual(ArrayElement(locale_info,"LOCALE_IDATE"),0) then
fmt = ((("MM" & CSmartStr(ArrayElement(locale_info,"LOCALE_SDATE"))) & "dd") & CSmartStr(ArrayElement(locale_info,"LOCALE_SDATE"))) & "yyyy"
sundayfirst = "true"
else
fmt = ((("yyyy" & CSmartStr(ArrayElement(locale_info,"LOCALE_SDATE"))) & "MM") & CSmartStr(ArrayElement(locale_info,"LOCALE_SDATE"))) & "dd"
sundayfirst = "false"
end if
end if
if bValue(ArrayElement(time,5)) then
fmt = CSmartStr(fmt) & " HH:mm:ss"
else
if bValue(ArrayElement(time,3)) or bValue(ArrayElement(time,4)) then
fmt = CSmartStr(fmt) & " HH:mm"
end if
end if
if bValue(ArrayElement(time,0)) then
doAssignmentByRef ovalue,format_datetime_custom(time,fmt)
end if
ovalue1 = (((CSmartStr(ArrayElement(time,2)) & "-") & CSmartStr(ArrayElement(time,1))) & "-") & CSmartStr(ArrayElement(time,0))
showtime = "false"
if bValue(DateEditShowTime(field,"")) then
showtime = "true"
ovalue1 = CSmartStr(ovalue1) & (((((" " & CSmartStr(ArrayElement(time,3))) & ":") & CSmartStr(ArrayElement(time,4))) & ":") & CSmartStr(ArrayElement(time,5)))
end if
ret = (((((""
ret = CSmartStr(ret) & ((((((" ")
ret = CSmartStr(ret) & (((((" ") & "
")
ResponseWrite ret
Exit Function
End If
If IsEqual(var_type,EDIT_DATE_SIMPLE_DP) or IsEqual(var_type,EDIT_DATE_DD_DP) then
dp = 1
End If
If IsEqual(var_type,EDIT_DATE_SIMPLE_DP) or IsEqual(var_type,EDIT_DATE_DD_DP) or IsEqual(var_type,EDIT_DATE_DD) then
retday = (((((""
retmonth = (((((""
retyear = (((((""
sundayfirst = "false"
if IsEqual(ArrayElement(locale_info,"LOCALE_ILONGDATE"),1) then
ret = (((CSmartStr(retday) & " ") & CSmartStr(retmonth)) & " ") & CSmartStr(retyear)
else
if IsEqual(ArrayElement(locale_info,"LOCALE_ILONGDATE"),0) then
ret = (((CSmartStr(retmonth) & " ") & CSmartStr(retday)) & " ") & CSmartStr(retyear)
sundayfirst = "true"
else
ret = (((CSmartStr(retyear) & " ") & CSmartStr(retmonth)) & " ") & CSmartStr(retday)
end if
end if
if (bValue(ArrayElement(time,0)) and bValue(ArrayElement(time,1))) and bValue(ArrayElement(time,2)) then
ret = CSmartStr(ret) & (((((((((("")
else
ret = CSmartStr(ret) & (((("")
end if
if bValue(dp) then
ret = CSmartStr(ret) & ((((((((((((((" ") & "
") & "")
end if
ResponseWrite ret
Exit Function
End If
doAssignment ovalue,value
if bValue(ArrayElement(time,0)) then
if (bValue(ArrayElement(time,3)) or bValue(ArrayElement(time,4))) or bValue(ArrayElement(time,5)) then
doAssignmentByRef ovalue,str_format_datetime(time)
else
doAssignmentByRef ovalue,format_shortdate(time)
end if
end if
ResponseWrite (((((""
Exit Function
Loop While false
End Function
Function BuildSecondDropdownArray(ByVal arrName,ByVal strSQL)
Dim i,rs,row
ResponseWrite CSmartStr(arrName) & "=new Array();" & vbcrlf
i = 0
doAssignmentByRef rs,db_query(strSQL,conn)
do while bValue(doAssignmentByRef(row,db_fetch_numarray(rs)))
ResponseWrite ((((CSmartStr(arrName) & "[") & CSmartStr(CSmartDbl(i)*3)) & "]='") & CSmartStr(jsreplace(ArrayElement(row,0)))) & "';" & vbcrlf
ResponseWrite ((((CSmartStr(arrName) & "[") & CSmartStr(CSmartDbl(i)*3+1)) & "]='") & CSmartStr(jsreplace(ArrayElement(row,1)))) & "';" & vbcrlf
ResponseWrite ((((CSmartStr(arrName) & "[") & CSmartStr(CSmartDbl(i)*3+2)) & "]='") & CSmartStr(jsreplace(ArrayElement(row,2)))) & "';" & vbcrlf
i = CSmartDbl(i)+1
loop
End Function
Function BuildSelectControl(ByVal field,ByVal value,ByVal fieldNum,ByVal mode,ByVal id,ByVal additionalCtrlParams,ByRef pageObj)
Dim table,strLabel,is508,alt,cfield,clookupfield,openlookup,ctype,addnewitem,advancedadd,strCategoryControl,categoryFieldId,bUseCategory,dependentLookups,lookupType,LCType,horizontalLookup,inputStyle,lookupTable,strLookupWhere,lookupSize,add_page,list_page,strPerm,multiple,postfix,avalue,className,arr,res,opt,spacer,i,celementvalue,lookup_value,lookupSQL,rs_lookup,data,rs,found,checked
doAssignment table,strTableName
doAssignmentByRef strLabel,Label(field,"")
doAssignmentByRef is508,isEnableSection508()
alt = ""
if (IsEqual(mode,MODE_INLINE_EDIT) or IsEqual(mode,MODE_INLINE_ADD)) and bValue(is508) then
alt = (" alt=""" & CSmartStr(htmlspecialchars(strLabel))) & """ "
end if
cfield = (("value_" & CSmartStr(GoodFieldName(field))) & "_") & CSmartStr(id)
clookupfield = (("display_value_" & CSmartStr(GoodFieldName(field))) & "_") & CSmartStr(id)
openlookup = (("open_lookup_" & CSmartStr(GoodFieldName(field))) & "_") & CSmartStr(id)
ctype = (("type_" & CSmartStr(GoodFieldName(field))) & "_") & CSmartStr(id)
if bValue(fieldNum) then
cfield = (((("value" & CSmartStr(fieldNum)) & "_") & CSmartStr(GoodFieldName(field))) & "_") & CSmartStr(id)
ctype = (((("type" & CSmartStr(fieldNum)) & "_") & CSmartStr(GoodFieldName(field))) & "_") & CSmartStr(id)
end if
addnewitem = false
advancedadd = false
doAssignmentByRef strCategoryControl,CategoryControl(field,table)
doAssignmentByRef categoryFieldId,GoodFieldName(CategoryControl(field,table))
doAssignmentByRef bUseCategory,UseCategory(field,table)
doAssignmentByRef dependentLookups,GetFieldData(table,field,"DependentLookups",CreateDictionary())
doAssignmentByRef lookupType,GetLookupType(field,table)
doAssignmentByRef LCType,LookupControlType(field,table)
doAssignmentByRef horizontalLookup,GetFieldData(table,field,"HorizontalLookup",false)
doAssignment inputStyle,IIF(ArrayElement(additionalCtrlParams,"style"),("style=""" & CSmartStr(ArrayElement(additionalCtrlParams,"style"))) & """","")
doAssignmentByRef lookupTable,GetLookupTable(field,table)
doAssignmentByRef strLookupWhere,LookupWhere(field,table)
doAssignmentByRef lookupSize,SelectSize(field,table)
if IsEqual(LCType,LCT_CBLIST) then
lookupSize = 2
end if
add_page = CSmartStr(GetTableURL(lookupTable)) & "_add.asp"
list_page = CSmartStr(GetTableURL(lookupTable)) & "_list.asp"
doAssignmentByRef strPerm,GetUserPermissions(lookupTable)
if not IsFalse(asp_strpos(strPerm,"A",empty)) then
doAssignmentByRef addnewitem,GetFieldData(table,field,"AllowToAdd",false)
advancedadd = not bValue(GetFieldData(table,field,"SimpleAdd",false))
if not bValue(advancedadd) then
addnewitem = false
end if
end if
if IsEqual(LCType,LCT_LIST) and IsFalse(asp_strpos(strPerm,"S",empty)) then
LCType = LCT_DROPDOWN
end if
if IsEqual(LCType,LCT_LIST) then
addnewitem = false
end if
if IsEqual(mode,MODE_SEARCH) then
addnewitem = false
end if
multiple = ""
postfix = ""
if IsLess(1,lookupSize) then
doAssignmentByRef avalue,splitvalues(value)
multiple = " multiple"
postfix = "[]"
else
Set avalue = (CreateDictionary1(Empty,CSmartStr(value)))
end if
className = "DropDownLookup"
if IsEqual(LCType,LCT_AJAX) then
className = "EditBoxLookup"
else
if IsEqual(LCType,LCT_LIST) then
className = "ListPageLookup"
else
if IsEqual(LCType,LCT_CBLIST) then
className = "CheckBoxLookup"
end if
end if
end if
if IsEqual(lookupType,LT_LISTOFVALUES) then
doAssignmentByRef arr,GetFieldData(table,field,"LookupValues",CreateDictionary())
if IsLess(1,lookupSize) then
ResponseWrite (((""
end if
if IsEqual(LCType,LCT_DROPDOWN) then
alt = ""
ResponseWrite ((((((((((""
else
if IsEqual(LCType,LCT_CBLIST) then
ResponseWrite "