Changeset 54 for trunk/Modules
- Timestamp:
- Jul 20, 2011, 11:52:31 PM (13 years ago)
- Location:
- trunk/Modules
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/UMainModule.lfm
r53 r54 5 5 VerticalOffset = 205 6 6 Width = 431 7 object HTTPServer: THTTPServerCGI8 ShowExceptions = False9 DocumentRoot = './'10 SessionStorage = HTTPSessionStorageMySQL111 OnRequest = HTTPServerRequest12 left = 8113 top = 3214 end15 7 object HTTPSessionStorageMySQL1: THTTPSessionStorageMySQL 16 8 Database = Database -
trunk/Modules/UMainModule.lrs
r53 r54 3 3 LazarusResources.Add('TMainModule','FORMDATA',[ 4 4 'TPF0'#11'TMainModule'#10'MainModule'#14'OldCreateOrder'#8#6'Height'#3#22#1#16 5 +'HorizontalOffset'#3#162#1#14'VerticalOffset'#3#205#0#5'Width'#3#175#1#0#14 6 +'THTTPServerCGI'#10'HTTPServer'#14'ShowExceptions'#8#12'DocumentRoot'#6#2'./' 7 +#14'SessionStorage'#7#24'HTTPSessionStorageMySQL1'#9'OnRequest'#7#17'HTTPSer' 8 +'verRequest'#4'left'#2'Q'#3'top'#2' '#0#0#24'THTTPSessionStorageMySQL'#24'HT' 9 +'TPSessionStorageMySQL1'#8'Database'#7#8'Database'#7'Timeout'#3'0*'#19'Sessi' 10 +'onIdCookieName'#6#9'SessionId'#4'left'#3'8'#1#3'top'#2#31#0#0#12'TSqlDataba' 11 +'se'#8'Database'#9'Connected'#8#8'Encoding'#6#4'utf8'#4'left'#2'Q'#3'top'#2 12 +'V'#0#0#0 5 +'HorizontalOffset'#3#162#1#14'VerticalOffset'#3#205#0#5'Width'#3#175#1#0#24 6 +'THTTPSessionStorageMySQL'#24'HTTPSessionStorageMySQL1'#8'Database'#7#8'Data' 7 +'base'#7'Timeout'#3'0*'#19'SessionIdCookieName'#6#9'SessionId'#4'left'#3'8'#1 8 +#3'top'#2#31#0#0#12'TSqlDatabase'#8'Database'#9'Connected'#8#8'Encoding'#6#4 9 +'utf8'#4'left'#2'Q'#3'top'#2'V'#0#0#0 13 10 ]); -
trunk/Modules/UMainModule.pas
r53 r54 7 7 uses 8 8 Classes, SysUtils, FileUtil, LResources, UHTTPServerCGI, UHTTPSessionMySQL, 9 UHTTPServer, USqlDatabase, UConfig, DateUtils, UWebPage, 9 UHTTPServer, USqlDatabase, UConfig, DateUtils, UWebPage, UWebApp, 10 10 UXmlClasses, UHtmlClasses, UCore, UHTTPServerTCP, 11 11 UHTTPSessionFile, UUser, SpecializedList; 12 12 13 13 type 14 TMainModule = class;15 16 TRegistredPage = class17 Name: string;18 Page: TWebPage;19 end;20 21 { TRegistredPageList }22 23 TRegistredPageList = class(TListObject)24 function FindByName(Name: string): TRegistredPage;25 end;26 27 14 { TMainModule } 28 15 29 16 TMainModule = class(TDataModule) 30 HTTPServer: THTTPServerCGI;31 17 HTTPSessionStorageMySQL1: THTTPSessionStorageMySQL; 32 18 Database: TSqlDatabase; 33 procedure HTTPServerRequest(HandlerData: THTTPHandlerData);34 19 private 35 20 procedure Footer; … … 49 34 Keywords: string; 50 35 HtmlDocument: THtmlDocument; 51 Pages: TRegistredPageList;52 36 PageName: string; 53 37 ModuleName: string; … … 55 39 User: TWebUser; 56 40 UserOnline: TWebOnlineUser; 41 procedure GeneratePage(HandlerData: THTTPHandlerData; Page: TWebPage); 57 42 procedure Run; 58 43 constructor Create(AOwner: TComponent); override; 59 44 destructor Destroy; override; 60 procedure RegisterPage(Name: string; Page: TWebPage);61 45 end; 62 46 … … 64 48 MainModule: TMainModule; 65 49 66 resourcestring67 SPageNotFound = 'Page not found';68 69 50 70 51 implementation 71 52 72 { TRegistredPageList }73 74 function TRegistredPageList.FindByName(Name: string): TRegistredPage;75 var76 I: Integer;77 begin78 I := 0;79 while (I < Count) and (TRegistredPage(Items[I]).Name <> Name) do Inc(I);80 if I < Count then Result := TRegistredPage(Items[I])81 else Result := nil;82 end;83 84 53 { TMainModule } 85 54 86 procedure TMainModule. HTTPServerRequest(HandlerData: THTTPHandlerData);55 procedure TMainModule.GeneratePage(HandlerData: THTTPHandlerData; Page: TWebPage); 87 56 var 88 57 I: Integer; 89 58 TitleTag: THtmlString; 90 Page: TRegistredPage;91 59 begin 92 60 User.HandlerData := HandlerData; … … 103 71 HtmlDocument.Scripts.Add(NavigationLink('/Style/' + Style + '/jquery.js')); 104 72 105 Request.QueryParts.Count := 2;106 Request.QueryParts[0] := 'uzivatel';107 Request.QueryParts[1] := 'prihlaseni';108 109 if Request.QueryParts.Count > 0 then PageName := Request.QueryParts[0]110 else PageName := '';111 Page := Pages.FindByName(PageName);112 if Assigned(Page) then begin113 73 TitleTag := THtmlString.Create; 114 HtmlDocument.Body.SubItems. Add(TitleTag);74 HtmlDocument.Body.SubItems.Insert(0, TitleTag); 115 75 TopMenu; 116 Page.Page.OnProduce(HandlerData);117 HtmlDocument.Title := Page. Page.Caption;76 //Page.Page.OnProduce(HandlerData); 77 HtmlDocument.Title := Page.Caption; 118 78 TitleTag.Text := '<div class="TitlePanel"><span class="GlobalTitle">' + GlobalTitle + 119 79 '</span> - ' + HtmlDocument.Title + '</div>'; … … 126 86 Free; 127 87 end; 128 end else Response.Stream.WriteString(SPageNotFound); 129 end; 130 end; 131 132 procedure TMainModule.RegisterPage(Name: string; Page: TWebPage); 133 var 134 NewRegistredPage: TRegistredPage; 135 begin 136 NewRegistredPage := TRegistredPage.Create; 137 NewRegistredPage.Name := Name; 138 NewRegistredPage.Page := Page; 139 Pages.Add(NewRegistredPage); 140 end; 141 88 end; 89 end; 142 90 143 91 procedure TMainModule.InitDatabase; … … 163 111 begin 164 112 inherited; 165 Pages := TRegistredPageList.Create;166 113 HtmlDocument := THtmlDocument.Create; 167 114 User := TWebUser.Create; … … 174 121 begin 175 122 HtmlDocument.Free; 176 Pages.Free;177 123 User.Free; 178 124 UserOnline.Free; … … 251 197 procedure TMainModule.TopMenu; 252 198 begin 253 with THtmlString(HtmlDocument.Body.SubItems. AddNew(THtmlString.Create)) do begin199 with THtmlString(HtmlDocument.Body.SubItems.InsertNew(1, THtmlString.Create)) do begin 254 200 Text := '<div class="Navigation">'; 255 201 // Visitor … … 286 232 begin 287 233 InitDatabase; 288 MainModule.HTTPServer.ShowExceptions := Config.ShowException;234 Application.HTTPServer.ShowExceptions := Config.ShowException; 289 235 //Database.Query('SELECT * FROM ssss'); 290 MainModule.HTTPServer.Run;291 236 end; 292 237
Note:
See TracChangeset
for help on using the changeset viewer.