#INCLUDE WCONNECT.H
DEFINE CLASS HOME AS rbPage
UserGroupHeader = []
UserGroupFooter = []
FUNCTION PAGE()
THIS.UserGroupHeader = THIS.MergeToString([UserGroupHeaderFragment.htm])
THIS.UserGroupFooter = THIS.MergeToString([UserGroupFooterFragment.htm])
THIS.DataSetup()
THIS.Content = THIS.MeetingHTML()
THIS.Merge("Home.htm")
THIS.CloseCursor('qResult')
ENDFUNC
csCodeParser v0.9 stats: 47 lines in 0.00 seconds.
This.Page() handles the web hit.
Notice that this is just a supervisor function, and calls very little native VFP code.
IMPORTANT NOTE:
Keep Data handling separate from HTML generation.
If you mix data and HTML your code will be an awful mess.
Our basic template pages have placeholders for:
This.Content
This.ErrorMessage
FUNCTION SetCookie
LOCAL lcHTML
lcHTML = []
Response.Writeln([HTTP/1.1 200 OK])
Response.Writeln([Content-type: text/html])
Response.Writeln([Expires: 0])
Response.Writeln([Set-Cookie: SessionID=]+Process.SessionID+[; path=/] )
Response.Writeln('')
lcHTML = lcHTML+[<html>] + CRLF
lcHTML = lcHTML+[] + CRLF
lcHTML = lcHTML+[<head>] + CRLF
lcHTML = lcHTML+[<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">] + CRLF
lcHTML = lcHTML+[<meta http-equiv="REFRESH" content="0.1;URL=/home.page.fox?SessionID=_72K1BQUWJ">]
lcHTML = lcHTML+[<title></title>] + CRLF
lcHTML = lcHTML+[</head>] + CRLF
lcHTML = lcHTML+[] + CRLF
lcHTML = lcHTML+[<body>] + CRLF
lcHTML = lcHTML+[<!-- Housekeeping - setting sessionid -->] + CRLF
lcHTML = lcHTML+[</body>] + CRLF
lcHTML = lcHTML+[] + CRLF
lcHTML = lcHTML+[</html>] + CRLF
Response.Writeln(lcHTML)
ENDFUNC
HIDDEN PROCEDURE DataSetup()
LOCAL ldDate
ldDate = DATE()
SELECT TOP 1 mdate, bctopic, bcdescript, ;
mt, mtdescript, ;
bSpeaker AS bcspeaker, ;
mSpeaker AS mtspeaker ;
FROM (Site.DataPath + "Meetings.dbf") ;
LEFT OUTER JOIN (Site.DataPath + "Speaker.dbf") AS BEGIN ON BEGIN.speakerid = bspeakerid ;
LEFT OUTER JOIN (Site.DataPath + "Speaker.dbf") AS MAIN ON MAIN.speakerid = mspeakerid ;
ORDER BY mdate ;
WHERE mdate >= ldDate ;
INTO CURSOR qResult NOFILTER READWRITE
SELECT qResult
REPLACE bcspeaker WITH [] FOR ISNULL(bcspeaker)
REPLACE mtspeaker WITH [] FOR ISNULL(mtspeaker)
GO TOP
ENDPROC
HIDDEN FUNCTION MeetingHTML()
RETURN []
LOCAL lcHTML
STORE [] TO lcHTML
IF RECCOUNT("qResult") > 0
SELECT qResult
lcHTML = lcHTML+[ <table border="0" cellpadding="2" cellspacing="1" style="border-collapse: collapse" bordercolor="#111111" width="610" id="AutoNumber1">] + CRLF
lcHTML = lcHTML+[ <tr>] + CRLF
lcHTML = lcHTML+[ <td width="150" bgcolor="#C0C0C0">]+TRANSFORM(mdate)+[</td>] + CRLF
IF EMPTY(ALLTRIM(bctopic+bcspeaker+bcdescript))
lcHTML = lcHTML+[ </tr>] + CRLF
ELSE
lcHTML = lcHTML+[ <td width="650" bgcolor="#C0C0C0" colspan="2"><b>Jump Start</b></td>] + CRLF
lcHTML = lcHTML+[ </tr>] + CRLF
lcHTML = lcHTML+[ <tr>] + CRLF
lcHTML = lcHTML+[ <td width="150" rowspan="5"> </td>] + CRLF
lcHTML = lcHTML+[ <td width="250" bgcolor="#C0C0C0">]+bctopic+[</td>] + CRLF
lcHTML = lcHTML+[ <td width="400" bgcolor="#C0C0C0">]+bcspeaker+[</td>] + CRLF
lcHTML = lcHTML+[ </tr>] + CRLF
lcHTML = lcHTML+[ <tr>] + CRLF
lcHTML = lcHTML+[ <td width="650" colspan="2">]+bcdescript+[</td>] + CRLF
lcHTML = lcHTML+[ </tr>] + CRLF
ENDIF
lcHTML = lcHTML+[ <tr>] + CRLF
lcHTML = lcHTML+[ <td width="650" bgcolor="#C0C0C0" colspan="2"><b>Main Topic</b></td>] + CRLF
lcHTML = lcHTML+[ </tr>] + CRLF
lcHTML = lcHTML+[ <tr>] + CRLF
lcHTML = lcHTML+[ <td width="250" bgcolor="#C0C0C0">]+mt+[</td>] + CRLF
lcHTML = lcHTML+[ <td width="400" bgcolor="#C0C0C0">]+mtspeaker+[</td>] + CRLF
lcHTML = lcHTML+[ </tr>] + CRLF
lcHTML = lcHTML+[ <tr>] + CRLF
lcHTML = lcHTML+[ <td width="650" colspan="2">]+mtdescript+[</td>] + CRLF
lcHTML = lcHTML+[ </tr>] + CRLF
lcHTML = lcHTML+[ </table>] + CRLF
ELSE
lcHTML = [So long, and thanks for all the fish.]
ENDIF
RETURN lcHTML
ENDFUNC
ENDDEFINE
csCodeParser v0.9 stats: 135 lines in 0.01 seconds.