Changeset 103 for trunk/UCore.pas
- Timestamp:
- Oct 8, 2012, 8:48:16 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UCore.pas
r102 r103 10 10 UXmlClasses, UHtmlClasses, UUtils, UApplicationInfo, UHTTPServerTCP, 11 11 UHTTPSessionFile, UUser, SpecializedList, Registry, 12 UModularSystem ;12 UModularSystem, UWebSession; 13 13 14 14 const … … 27 27 procedure WebApp1PageProduce(HandlerData: THTTPHandlerData); 28 28 private 29 FGeneratePage: TGeneratePageEvent; 29 30 procedure Show(Content: string); 30 31 procedure RegisterModules; … … 51 52 DatabasePassword: string; 52 53 DatabaseSchema: string; 54 procedure GeneratePageDefault(ASession: TWebSession; Page: TWebPage); 53 55 procedure LoadFromRegistry; 54 56 procedure SaveToRegistry; … … 56 58 constructor Create(AOwner: TComponent); override; 57 59 destructor Destroy; override; 60 property GeneratePage: TGeneratePageEvent read FGeneratePage write FGeneratePage; 58 61 end; 59 62 … … 73 76 74 77 { TCore } 78 79 procedure TCore.GeneratePageDefault(ASession: TWebSession; Page: TWebPage); 80 var 81 I: Integer; 82 begin 83 with ASession do begin 84 HtmlDocument.ContentLanguage := 'cs'; 85 GlobalTitle := 'WebSystem'; 86 87 //Page.Page.OnProduce(HandlerData); 88 HtmlDocument.Title := Page.Caption; 89 with HtmlDocument.AsXmlDocument do 90 try 91 Formated := TCore(MainModule).FormatHTML; 92 Response.Content.WriteString(AsString); 93 finally 94 Free; 95 end; 96 end; 97 end; 75 98 76 99 constructor TCore.Create(AOwner: TComponent); … … 102 125 FreeAndNil(Pages); 103 126 inherited; 104 end;105 106 procedure TWebSession.Footer;107 var108 Tag: TXMLTag;109 AdminTag: TXMLTag;110 EmailTag: TXMLTag;111 ExecutionTimeTag: TXMLTag;112 UsedMemoryTag: TXMLTag;113 TextNode: TXmlString;114 begin115 with TXmlTag(HtmlDocument.Body.SubItems.AddNew(TXmlTag.Create)) do begin116 Name := 'ul';117 Attributes.Values['class'] := 'Footer';118 with TXmlTag(SubElements.AddNew(TXmlTag.Create)) do begin119 Name := 'li';120 with TXmlString(SubElements.AddNew(TXmlString.Create)) do begin121 Text := MainModule.Admin;122 end;123 end;124 with TXmlTag(SubElements.AddNew(TXmlTag.Create)) do begin125 Name := 'li';126 with TXmlString(SubElements.AddNew(TXmlString.Create)) do begin127 Text := MainModule.AdminEmail;128 end;129 end;130 if MainModule.ShowRuntimeInfo then begin131 with TXmlTag(SubElements.AddNew(TXmlTag.Create)) do begin132 Name := 'li';133 with TXmlString(SubElements.AddNew(TXmlString.Create)) do begin134 Text := 'Doba generování: ' +135 FloatToStr(Round(((Now - TimeStart) / OneMillisecond) * 100) / 100) + ' s / '; // + ini_get('max_execution_time') + ' s';136 end;137 end;138 with TXmlTag(SubElements.AddNew(TXmlTag.Create)) do begin139 Name := 'li';140 with TXmlString(SubElements.AddNew(TXmlString.Create)) do begin141 //Text := 'Použitá paměť: ' + System.PrefixMultiplier.AddPrefixMultipliers(memory_get_peak_usage(FALSE), 'B').' / '.ini_get('memory_limit').'B';142 end;143 end;144 end;145 end;146 127 end; 147 128 … … 202 183 finally 203 184 DbRows.Free; 204 end;205 end;206 207 procedure TWebSession.TopMenu;208 begin209 with THtmlString(HtmlDocument.Body.SubItems.InsertNew(1, THtmlString.Create)) do begin210 Text := '<div class="Navigation">';211 // Visitor212 Text := Text + '<ul class="MenuItem">' +213 '<li>' + MakeLink('Úvod', NavigationLink('/')) + '</li>' +214 '<li>' + MakeLink('Internet', NavigationLink('/internet/')) + '</li>' +215 '<li>' + MakeLink('Hosting', NavigationLink('/hosting/')) + '</li>' +216 '<li>' + MakeLink('VoIP', NavigationLink('/voip/')) + '</li>' +217 '<li>' + MakeLink('Síť', NavigationLink('/sit/')) + '</li>' +218 '<li>' + MakeLink('Odkazy', NavigationLink('/odkazy/')) + '</li>' +219 '<li>' + MakeLink('Kontakt', NavigationLink('/kontakt/')) + '</li>' +220 '<li>' + MakeLink('Kamery', NavigationLink('/kamery/')) + '</li>' +221 '<li><a href="https://mail.zdechov.net/">Pošta</a></li>' +222 '<li><a href="http://wiki.zdechov.net/">Wiki</a></li>' +223 '</ul><ul class="MenuItem2">'; //<li> </li>';224 if Assigned(MainModule.Pages.FindByName('uzivatel')) then begin225 if UserOnline.User = AnonymousUserId then begin226 Text := Text + '</ul>' +227 '<ul class="MenuItem2">' +228 '<li>' + MakeLink('Přihlášení', NavigationLink('/uzivatel/prihlaseni/')) + '</li>' +229 '<li>' + MakeLink('Registrace', NavigationLink('/uzivatel/registrace/')) + '</li>' +230 '<li></li>';231 // $Output .= '<li>'.$this->System->HTML->MakeLink($this->System->Translate('UserRegistration'), $this->System->MakeLink('UserList', 'Register')).'</li>';232 end else begin233 Text := Text + '</ul>' +234 '<ul class="MenuItem2">' +235 '<li>' + User.FullName + '</li>' +236 '<li>' + MakeLink('Odhlášení', NavigationLink('/uzivatel/odhlaseni/')) + '</li>' +237 '<li>' + MakeLink('Profil', NavigationLink('/uzivatel/profil/')) + '</li>';238 end;239 end else Text := Text + '</ul><ul class="MenuItem2"> ';240 Text := Text + '</ul></div>';241 185 end; 242 186 end; … … 281 225 THTMLString(TWebSession(NewSession).HtmlDocument.Body.SubItems.AddNew(THtmlString.Create)). 282 226 Text := Format(SError, [E.Message]); 283 NewSession.GeneratePage(Page.Page); 227 if Assigned(GeneratePage) then GeneratePage(NewSession, Page.Page) 228 else GeneratePageDefault(NewSession, Page.Page); 284 229 end; 285 230 end;
Note:
See TracChangeset
for help on using the changeset viewer.