Changeset 25 for branches/lazarus/Application
- Timestamp:
- Sep 8, 2010, 8:34:15 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/lazarus/Application/UCustomCGIApplication.pas
r24 r25 12 12 TCustomCGIApplication = class; 13 13 14 TPageProducer = procedure(Body: T customCGIApplication);14 TPageProducer = procedure(Body: TCustomCGIApplication); 15 15 16 16 TRegistredPage = class … … 34 34 ShowRuntimeInfo: Boolean; 35 35 Charset: string; 36 FormatHTML: Boolean;37 36 Admin: string; 38 37 AdminEmail: string; … … 42 41 Pages: TObjectList; 43 42 Database: TSqlDatabase; 43 PageName: string; 44 ModuleName: string; 44 45 procedure Execute; override; 45 46 constructor Create; … … 52 53 53 54 resourcestring 54 SPageNotFound = ' Stránka nenalezena';55 SPageNotFound = 'Page not found'; 55 56 56 57 { TCustomCGIApplication } … … 86 87 var 87 88 I: Integer; 88 PageName: string;89 TitleTag: THtmlString; 89 90 begin 90 91 //SysInfo; … … 92 93 93 94 HtmlDocument.ContentLanguage := 'cs'; 94 HtmlDocument.Title := 'Test document';95 GlobalTitle := 'ZděchovNET'; 95 96 HtmlDocument.Styles.Add('Style/' + Style + '/Style.css'); 96 97 HtmlDocument.Scripts.Add('Style/' + Style + '/Global.js'); … … 98 99 99 100 PageName := Query.Values['p']; 100 if PageName = '' then PageName := 'index'; 101 if PageName = '' then PageName := 'History'; 102 ModuleName := Query.Values['m']; 103 if ModuleName = '' then ModuleName := 'Main'; 101 104 I := 0; 102 while (I < Pages.Count) and (TRegistredPage(Pages[I]).Name <> PageName) do Inc(I);105 while (I < Pages.Count) and (TRegistredPage(Pages[I]).Name <> ModuleName) do Inc(I); 103 106 if I < Pages.Count then begin 104 with THtmlString(HtmlDocument.Body.SubItems[HtmlDocument.Body.SubItems.Add(THtmlString.Create)]) do begin 105 Text := '<div class="TitlePanel">' + HtmlDocument.Title + '</div>'; 106 end; 107 TitleTag := THtmlString.Create; 108 HtmlDocument.Body.SubItems.Add(TitleTag); 107 109 TopMenu; 108 110 TRegistredPage(Pages[I]).Producer(Self); 111 TitleTag.Text := '<div class="TitlePanel"><span class="GlobalTitle">' + GlobalTitle + 112 '</span> - ' + HtmlDocument.Title + '</div>'; 109 113 with HtmlDocument.AsXmlDocument do begin 114 Formated := ConfigFormatHTML; 110 115 Output.Add(AsString); 111 116 Free; … … 140 145 TextNode: TXmlString; 141 146 begin 142 Tag := TXMLTag.Create; 143 Tag.Name := 'ul'; 144 Tag.Attributes.Values['class'] := 'Footer'; 145 AdminTag := TXMLTag.Create; 146 AdminTag.Name := 'li'; 147 TextNode := TXmlString.Create; 148 TextNode.Text := Admin; 149 AdminTag.SubElements.Add(TextNode); 150 EmailTag := TXMLTag.Create; 151 EmailTag.Name := 'li'; 152 TextNode := TXmlString.Create; 153 TextNode.Text := AdminEmail; 154 EmailTag.SubElements.Add(TextNode); 155 Tag.SubElements.Add(AdminTag); 156 Tag.SubElements.Add(EmailTag); 157 if ShowRuntimeInfo then begin 158 ExecutionTimeTag := TXMLTag.Create; 159 ExecutionTimeTag.Name := 'li'; 160 TextNode := TXmlString.Create; 161 TextNode.Text := 'Doba generování: ' + 162 FloatToStr(Round(((Now - TimeStart) / OneMillisecond) * 100) / 100) + ' s / '; // + ini_get('max_execution_time') + ' s'; 163 ExecutionTimeTag.SubElements.Add(TextNode); 164 Tag.SubElements.Add(ExecutionTimeTag); 165 UsedMemoryTag := TXMLTag.Create; 166 UsedMemoryTag.Name := 'li'; 167 TextNode := TXmlString.Create; 168 // TextNode.Text := 'Použitá paměť: ' + System.PrefixMultiplier.AddPrefixMultipliers(memory_get_peak_usage(FALSE), 'B').' / '.ini_get('memory_limit').'B'; 169 UsedMemoryTag.SubElements.Add(TextNode); 170 Tag.SubElements.Add(UsedMemoryTag); 147 with TXmlTag(HtmlDocument.Body.SubItems[HtmlDocument.Body.SubItems.Add(TXmlTag.Create)]) do begin 148 Name := 'ul'; 149 Attributes.Values['class'] := 'Footer'; 150 with TXmlTag(SubElements[SubElements.Add(TXmlTag.Create)]) do begin 151 Name := 'li'; 152 with TXmlString(SubElements[SubElements.Add(TXmlString.Create)]) do begin 153 Text := Admin; 154 end; 155 end; 156 with TXmlTag(SubElements[SubElements.Add(TXmlTag.Create)]) do begin 157 Name := 'li'; 158 with TXmlString(SubElements[SubElements.Add(TXmlString.Create)]) do begin 159 Text := AdminEmail; 160 end; 161 end; 162 if ShowRuntimeInfo then begin 163 with TXmlTag(SubElements[SubElements.Add(TXmlTag.Create)]) do begin 164 Name := 'li'; 165 with TXmlString(SubElements[SubElements.Add(TXmlString.Create)]) do begin 166 Text := 'Doba generování: ' + 167 FloatToStr(Round(((Now - TimeStart) / OneMillisecond) * 100) / 100) + ' s / '; // + ini_get('max_execution_time') + ' s'; 168 end; 169 end; 170 with TXmlTag(SubElements[SubElements.Add(TXmlTag.Create)]) do begin 171 Name := 'li'; 172 with TXmlString(SubElements[SubElements.Add(TXmlString.Create)]) do begin 173 //Text := 'Použitá paměť: ' + System.PrefixMultiplier.AddPrefixMultipliers(memory_get_peak_usage(FALSE), 'B').' / '.ini_get('memory_limit').'B'; 174 end; 175 end; 176 end; 171 177 end; 172 178 end; 173 179 174 180 procedure TCustomCGIApplication.Show(Content: string); 175 var176 BodyParam: string;177 StyleTag: TXMLTag;178 181 begin 179 182 //HtmlDocument.Title := ; … … 217 220 '<li>' + MakeLink('Odkazy', NavigationMakeLink('Main', 'Links')) + '</li>' + 218 221 '<li>' + MakeLink('Kontakt', NavigationMakeLink('Main', 'Contact')) + '</li>'; 219 (* if ($this->System->UserOnline->User == $this->System->UserOnline->AnonymousUserId) then begin 220 221 $Output .= '</ul>';222 $Output .= '<ul class="MenuItem2">';223 $Output .= '<li>'.$this->System->HTML->MakeLink($this->System->Localization->Translate('UserLogin'), $this->System->Navigation->MakeLink('User', 'Login')).'</li>';222 Text := Text + '</ul><ul class="MenuItem2"><li> </li>'; 223 (* if System.UserOnline.User = System.UserOnline.AnonymousUserId then begin 224 Text := Text + '</ul>' + 225 '<ul class="MenuItem2">' + 226 '<li>' + MakeLink('Přihlášení', NavigationMakeLink('User', 'Login')) + '</li>'; 224 227 //$Output .= '<li>'.$this->System->HTML->MakeLink($this->System->Translate('UserRegistration'), $this->System->MakeLink('UserList', 'Register')).'</li>'; 225 228 end else begin 226 $Output .= '</ul>';227 $Output .= '<ul class="MenuItem2">';228 $Output .= '<li>'.$this->System->User->Data['FullName'].'</li>';229 $Output .= '<li>'.$this->System->HTML->MakeLink($this->System->Localization->Translate('UserLogout'), $this->System->Navigation->MakeLink('User', 'Logout')).'</li>';230 $Output .= '<li>'.$this->System->HTML->MakeLink($this->System->Localization->Translate('UserView'), $this->System->Navigation->MakeLink('User', 'View',229 Text := Text + '</ul>' + 230 '<ul class="MenuItem2">' + 231 '<li>' + System.User.FullName + '</li>' + 232 '<li>' + MakeLink('Odhlášení', NavigationMakeLink('User', 'Logout')) + '</li>' + 233 '<li>' + MakeLink('Profil', NavigationMakeLink('User', 'View', 231 234 array('Id' => $this->System->User->Id))).'</li>'; 232 235 end;
Note:
See TracChangeset
for help on using the changeset viewer.