Changeset 102 for trunk/UCore.pas
- Timestamp:
- Oct 4, 2012, 2:06:55 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UCore.pas
r101 r102 19 19 TCore = class; 20 20 21 { TWebSession }22 23 TWebSession = class(THTTPHandlerData)24 private25 procedure TopMenu;26 procedure Footer;27 public28 MainModule: TCore;29 Database: TSqlDatabase;30 SessionStorage: THTTPSessionStorageMySQL;31 User: TWebUser;32 UserOnline: TWebOnlineUser;33 HtmlDocument: THtmlDocument;34 GlobalTitle: string;35 TimeStart: TDateTime;36 procedure LoadUserInfo;37 procedure InitDatabase;38 procedure GeneratePage(Page: TWebPage);39 constructor Create; override;40 destructor Destroy; override;41 end;42 21 43 22 { TCore } … … 87 66 uses 88 67 UModuleSystem, UModuleZdechovNET, UModuleUser, UPageAdmin, UModuleTV, 89 UModuleFinance, UModuleNetwork ;68 UModuleFinance, UModuleNetwork, UModulePortal, UModuleIS; 90 69 91 70 resourcestring 92 71 SError = '<div>Error: %s</div>'; 93 94 { TWebSession }95 96 constructor TWebSession.Create;97 begin98 inherited;99 Database := TSqlDatabase.Create(nil);100 SessionStorage := THTTPSessionStorageMySQL.Create(nil);101 SessionStorage.Database := Database;102 HtmlDocument := THtmlDocument.Create;103 User := TWebUser.Create;104 User.Database := Database;105 UserOnline := TWebOnlineUser.Create;106 UserOnline.Database := Database;107 end;108 109 destructor TWebSession.Destroy;110 begin111 FreeAndNil(HtmlDocument);112 FreeAndNil(User);113 FreeAndNil(UserOnline);114 FreeAndNil(SessionStorage);115 FreeAndNil(Database);116 inherited;117 end;118 119 procedure TWebSession.InitDatabase;120 var121 DbRows: TDbRows;122 begin123 with Database do begin124 Connect;125 end;126 try127 DbRows := TDbRows.Create;128 Database.Query(DbRows, 'SET NAMES utf8');129 finally130 DbRows.Free;131 end;132 end;133 134 procedure TWebSession.LoadUserInfo;135 begin136 if Core.ModuleManager.ModuleRunning('User') then begin137 User.HandlerData := Self;138 UserOnline.HandlerData := Self;139 UserOnline.Update;140 User.Id := UserOnline.User;141 User.Load;142 end;143 end;144 145 procedure TWebSession.GeneratePage(Page: TWebPage);146 var147 I: Integer;148 TitleTag: THtmlString;149 begin150 HtmlDocument.ContentLanguage := 'cs';151 GlobalTitle := 'ZděchovNET';152 HtmlDocument.Styles.Add(NavigationLink('/Style/' + MainModule.Style + '/Style.css'));153 HtmlDocument.Scripts.Add(NavigationLink('/Style/' + MainModule.Style + '/Global.js'));154 HtmlDocument.Scripts.Add(NavigationLink('/Style/' + MainModule.Style + '/jquery.js'));155 156 TitleTag := THtmlString.Create;157 HtmlDocument.Body.SubItems.Insert(0, TitleTag);158 TopMenu;159 //Page.Page.OnProduce(HandlerData);160 HtmlDocument.Title := Page.Caption;161 TitleTag.Text := '<div class="TitlePanel"><span class="GlobalTitle">' + GlobalTitle +162 '</span> - ' + HtmlDocument.Title + '</div>';163 HtmlDocument.Title := GlobalTitle + ' - ' + HtmlDocument.Title;164 with HtmlDocument.AsXmlDocument do165 try166 Formated := MainModule.FormatHTML;167 Response.Content.WriteString(AsString);168 finally169 Free;170 end;171 end;172 72 173 73 … … 282 182 RegisterModule(TModuleFinance.Create(nil), True); 283 183 RegisterModule(TModuleNetwork.Create(nil), True); 184 RegisterModule(TModulePortal.Create(nil), True); 185 RegisterModule(TModuleIS.Create(nil), True); 284 186 end; 285 187 end;
Note:
See TracChangeset
for help on using the changeset viewer.