lweb/inc/lweb_helper.pbi

68 lines
1.8 KiB
Plaintext

;********************************
;*
;* lweb_helper.pbi
;*
Procedure.s mimetype(file.s)
; TODO:Mimetype dynamic configurable via XML
Select LCase(file)
Case "pdf"
ProcedureReturn "application/pdf"
Case "zip"
ProcedureReturn "application/zip"
Case "gz"
ProcedureReturn "application/gzip"
Case "doc"
ProcedureReturn "application/msword"
Case "xls"
ProcedureReturn "application/vnd.ms-excel"
Case "ppt"
ProcedureReturn "application/vnd.ms-powerpoint"
Case "ico"
ProcedureReturn "image/vnd.microsoft.icon"
Case "png"
ProcedureReturn "image/png"
Case "gif"
ProcedureReturn "image/gif"
Case "jpg"
ProcedureReturn "image/jpeg"
Case "jpeg"
ProcedureReturn "image/jpeg"
Case "txt"
ProcedureReturn "text/plain"
Case "html"
ProcedureReturn "text/html"
Case "htm"
ProcedureReturn "text/html"
Case "mss"
ProcedureReturn "text/html"
Case "php"
ProcedureReturn "text/html"
Case "css"
ProcedureReturn "text/css"
Case "js"
ProcedureReturn "text/javascript"
Default
ProcedureReturn "application/octet-stream"
EndSelect
EndProcedure
Procedure.s MapToJSONString(Map ConvertMap.s())
Protected MyJSON
Protected.s Response
MyJSON = CreateJSON(#PB_Any)
If MyJSON
InsertJSONMap(JSONValue(MyJSON), ConvertMap())
Response = ComposeJSON(MyJSON)
FreeJSON(MyJSON)
ProcedureReturn Response
EndIf
ProcedureReturn #error_string
EndProcedure
Procedure.s xml_error_debug(XMLHandle)
Define Debug_String.s
Debug_String = "XML Error:["+XMLError(XMLHandle)+"] At Line:["+Str(XMLErrorLine(XMLHandle))+"] Position:["+Str(XMLErrorPosition(XMLHandle))+"]"
ProcedureReturn Debug_String
EndProcedure