Changeset 105
- Timestamp:
- Oct 9, 2012, 1:58:45 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 7 added
- 41 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application/UWebSession.pas
r103 r105 7 7 uses 8 8 Classes, SysUtils, UHTTPServer, USqlDatabase, UHTTPSessionMySQL, UUser, 9 UHtmlClasses, UWebPage, UUtils, UXmlClasses, DateUtils; 9 UHtmlClasses, UWebPage, UUtils, UXmlClasses, DateUtils, UModularSystem, 10 UPageList, UWebApp, SpecializedList; 10 11 11 12 type … … 14 15 TWebSession = class(THTTPHandlerData) 15 16 private 17 procedure GeneratePageDefault(ASession: TWebSession; Page: TWebPage); 18 procedure RegisterModules; 19 procedure CheckModules; 16 20 public 17 21 MainModule: TObject; 18 22 Database: TSqlDatabase; 19 23 SessionStorage: THTTPSessionStorageMySQL; 20 User: TWebUser;21 UserOnline: TWebOnlineUser;22 24 HtmlDocument: THtmlDocument; 23 25 GlobalTitle: string; 24 26 TimeStart: TDateTime; 25 procedure LoadUserInfo; 27 BaseURL: string; 28 ModuleManager: TModuleManager; 26 29 procedure InitDatabase; 27 30 constructor Create; override; 28 31 destructor Destroy; override; 29 32 procedure GeneratePage(Page: TWebPage); 33 procedure Run; 30 34 end; 31 32 TGeneratePageEvent = procedure (Session: TWebSession; Page: TWebPage) of object;33 35 34 36 implementation 35 37 36 38 uses 37 UCore; 39 UCore, UModuleSystem, UModuleZdechovNET, UModuleUser, UPageAdmin, UModuleTV, 40 UModuleFinance, UModuleNetwork, UModulePortal, UModuleIS, UModuleBase, 41 UModuleNews; 42 43 resourcestring 44 SError = '<div>Error: %s</div>'; 45 38 46 39 47 { TWebSession } … … 42 50 begin 43 51 inherited; 52 ModuleManager := TModuleManager.Create(nil); 44 53 Database := TSqlDatabase.Create(nil); 45 54 SessionStorage := THTTPSessionStorageMySQL.Create(nil); 46 55 SessionStorage.Database := Database; 47 56 HtmlDocument := THtmlDocument.Create; 48 User := TWebUser.Create;49 User.Database := Database;50 UserOnline := TWebOnlineUser.Create;51 UserOnline.Database := Database;52 57 end; 53 58 54 59 destructor TWebSession.Destroy; 55 60 begin 61 ModuleManager.StopAll; 62 FreeAndNil(ModuleManager); 56 63 FreeAndNil(HtmlDocument); 57 FreeAndNil(User);58 FreeAndNil(UserOnline);59 64 FreeAndNil(SessionStorage); 60 65 FreeAndNil(Database); … … 64 69 procedure TWebSession.GeneratePage(Page: TWebPage); 65 70 begin 66 with T Core(MainModule) do71 with TModuleBase(ModuleManager.FindModuleByName('Base')) do 67 72 if Assigned(GeneratePage) then GeneratePage(Self, Page) 68 73 else GeneratePageDefault(Self, Page); 69 74 end; 75 76 procedure TWebSession.Run; 77 var 78 FileName: string; 79 PageName: string; 80 Page: TRegistredPage; 81 BaseUrlParts: TListString; 82 ModuleBase: TModuleBase; 83 begin 84 RegisterModules; 85 CheckModules; 86 ModuleManager.StartInstalled; 87 88 try 89 BaseUrlParts := TListString.Create; 90 BaseUrlParts.Explode(BaseURL, '/', StrToStr); 91 while (BaseUrlParts.Count > 0) and (Request.Path.Count > 0) and 92 (BaseUrlParts[0] = Request.Path[0]) do begin 93 BaseUrlParts.Delete(0); 94 Request.Path.Delete(0); 95 end; 96 finally 97 BaseUrlParts.Free; 98 end; 99 if Request.Path.Count > 0 then PageName := Request.Path[0] 100 else PageName := ''; 101 ModuleBase := TModuleBase(ModuleManager.FindModuleByName('Base')); 102 Page := ModuleBase.Pages.FindByName(PageName); 103 if Assigned(Page) then begin 104 try 105 Page.Page.OnProduce(Self); 106 except 107 on E: Exception do begin 108 THTMLString(Self.HtmlDocument.Body.SubItems.AddNew(THtmlString.Create)). 109 Text := Format(SError, [E.Message]); 110 if Assigned(GeneratePage) then ModuleBase.GeneratePage(Self, Page.Page) 111 else GeneratePageDefault(Self, Page.Page); 112 end; 113 end; 114 end else begin 115 Core.WebApp1.HTTPServer.FileResponse(Self) 116 end; 117 end; 118 119 procedure TWebSession.GeneratePageDefault(ASession: TWebSession; Page: TWebPage); 120 var 121 I: Integer; 122 begin 123 with ASession do begin 124 HtmlDocument.ContentLanguage := 'cs'; 125 GlobalTitle := 'WebSystem'; 126 127 //Page.Page.OnProduce(HandlerData); 128 HtmlDocument.Title := Page.Caption; 129 with HtmlDocument.AsXmlDocument do 130 try 131 Formated := TCore(MainModule).FormatHTML; 132 Response.Content.WriteString(AsString); 133 finally 134 Free; 135 end; 136 end; 137 end; 138 70 139 71 140 procedure TWebSession.InitDatabase; … … 79 148 end; 80 149 81 procedure TWebSession. LoadUserInfo;150 procedure TWebSession.RegisterModules; 82 151 begin 83 if TCore(MainModule).ModuleManager.ModuleRunning('User') then begin 84 User.HandlerData := Self; 85 UserOnline.HandlerData := Self; 86 UserOnline.Update; 87 User.Id := UserOnline.User; 88 User.Load; 152 with ModuleManager do begin 153 RegisterModule(TModuleSystem.Create(nil), True); 154 RegisterModule(TModuleBase.Create(nil), True); 155 RegisterModule(TModuleUser.Create(nil), True); 156 RegisterModule(TModuleZdechovNET.Create(nil), True); 157 RegisterModule(TModuleTV.Create(nil), True); 158 RegisterModule(TModuleFinance.Create(nil), True); 159 RegisterModule(TModuleNetwork.Create(nil), True); 160 RegisterModule(TModulePortal.Create(nil), True); 161 RegisterModule(TModuleIS.Create(nil), True); 162 RegisterModule(TModuleNews.Create(nil), True); 89 163 end; 90 164 end; 91 165 166 procedure TWebSession.CheckModules; 167 var 168 DbRows: TDbRows; 169 Module: TModule; 170 I: Integer; 171 begin 172 try 173 DbRows := TDbRows.Create; 174 Database.Query(DbRows, 'SELECT * FROM INFORMATION_SCHEMA.TABLES ' + 175 'WHERE TABLE_SCHEMA = "' + Database.Database + '" AND TABLE_NAME = "SystemModule"'); 176 Module := ModuleManager.FindModuleByName('System'); 177 if DbRows.Count > 0 then Module.SetInstalledState(True) 178 else Module.SetInstalledState(False); 179 finally 180 DbRows.Free; 181 end; 182 end; 183 184 92 185 end. 93 186 -
trunk/Modules/Finance/UModuleFinance.pas
r101 r105 6 6 7 7 uses 8 Classes, SysUtils, UModularSystem, SpecializedDictionary; 8 Classes, SysUtils, UModularSystem, SpecializedDictionary, UModuleBase, 9 UWebPage; 9 10 10 11 type … … 13 14 14 15 TModuleFinance = class(TModule) 16 private 17 WebPageFinance: TWebPage; 15 18 public 19 ModuleBase: TModuleBase; 16 20 constructor Create(Owner: TComponent); override; 17 21 destructor Destroy; override; … … 39 43 License := 'GNU/LGPL v3'; 40 44 Author := 'Chronosoft'; 45 Dependencies.Add('Base'); 41 46 end; 42 47 … … 48 53 procedure TModuleFinance.Start; 49 54 begin 50 Core.Pages.RegisterPage(TWebPageFinance, WebPageFinance, 'finance'); 55 BeforeStart; 56 ModuleBase := TModuleBase(Manager.FindModuleByName('Base')); 57 WebPageFinance := TWebPageFinance.Create(nil); 58 ModuleBase.Pages.RegisterPage(WebPageFinance, 'finance'); 51 59 //RegisterPage(TUserControlPage, UserControlPage, ''); 52 inherited;60 AfterStart; 53 61 end; 54 62 55 63 procedure TModuleFinance.Stop; 56 64 begin 57 inherited; 58 Core.Pages.UnregisterPage('finance'); 65 BeforeStop; 66 ModuleBase.Pages.UnregisterPage(WebPageFinance); 67 FreeAndNil(WebPageFinance); 68 ModuleBase := nil; 69 AfterStop; 59 70 end; 60 71 -
trunk/Modules/IS/UModuleIS.pas
r102 r105 6 6 7 7 uses 8 Classes, SysUtils, UModularSystem, SpecializedDictionary, USqlDatabase; 8 Classes, SysUtils, UModularSystem, SpecializedDictionary, USqlDatabase, 9 UModuleBase; 9 10 10 11 type … … 15 16 private 16 17 public 18 ModuleBase: TModuleBase; 17 19 constructor Create(Owner: TComponent); override; 18 20 destructor Destroy; override; … … 40 42 License := 'GNU/LGPL v3'; 41 43 Author := 'Chronosoft'; 44 Dependencies.Add('Base'); 42 45 end; 43 46 … … 49 52 procedure TModuleIS.Start; 50 53 begin 51 Core.Pages.RegisterPage(TWebPagePortal, WebPagePortal, 'portal'); 52 inherited; 54 BeforeStart; 55 ModuleBase := TModuleBase(Manager.FindModuleByName('Base')); 56 //ModuleBase.Pages.RegisterPage(TWebPagePortal, WebPagePortal, 'portal'); 57 AfterStart; 53 58 end; 54 59 55 60 procedure TModuleIS.Stop; 56 61 begin 57 inherited; 58 Core.Pages.UnregisterPage('portal'); 62 BeforeStop; 63 //ModuleBase.Pages.UnregisterPage('portal'); 64 ModuleBase := nil; 65 AfterStop; 59 66 end; 60 67 -
trunk/Modules/Network/UModuleNetwork.pas
r102 r105 6 6 7 7 uses 8 Classes, SysUtils, UModularSystem, SpecializedDictionary; 8 Classes, SysUtils, UModularSystem, SpecializedDictionary, UModuleBase, 9 UWebPage; 9 10 10 11 type … … 13 14 14 15 TModuleNetwork = class(TModule) 16 private 17 WebPageNetwork: TWebPage; 15 18 public 19 ModuleBase: TModuleBase; 16 20 constructor Create(Owner: TComponent); override; 17 21 destructor Destroy; override; … … 39 43 License := 'GNU/LGPL v3'; 40 44 Author := 'Chronosoft'; 45 Dependencies.Add('Base'); 41 46 end; 42 47 … … 48 53 procedure TModuleNetwork.Start; 49 54 begin 50 Core.Pages.RegisterPage(TWebPageNetwork, WebPageNetwork, 'sit'); 55 BeforeStart; 56 ModuleBase := TModuleBase(Manager.FindModuleByName('Base')); 57 WebPageNetwork := TWebPageNetwork.Create(nil); 58 ModuleBase.Pages.RegisterPage(WebPageNetwork, 'sit'); 51 59 //RegisterPage(TUserControlPage, UserControlPage, ''); 52 inherited;60 AfterStart; 53 61 end; 54 62 55 63 procedure TModuleNetwork.Stop; 56 64 begin 57 inherited; 58 Core.Pages.UnregisterPage('sit'); 65 BeforeStop; 66 ModuleBase.Pages.UnregisterPage(WebPageNetwork); 67 FreeAndNil(WebPageNetwork); 68 ModuleBase := nil; 69 AfterStop; 59 70 end; 60 71 -
trunk/Modules/Portal/UModulePortal.pas
r104 r105 7 7 uses 8 8 Classes, SysUtils, UModularSystem, SpecializedDictionary, USqlDatabase, 9 UUtils, UWebSession, SpecializedList, UUser, UWebPage, UHtmlClasses; 9 UUtils, UWebSession, SpecializedList, UUser, UWebPage, UHtmlClasses, 10 UModuleBase, UModuleUser; 10 11 11 12 type … … 16 17 private 17 18 Time: TDateTime; 19 WebPagePortal: TWebPage; 18 20 function ShowFooter(Session: TWebSession): string; 19 21 function ShowHeader(Session: TWebSession): string; 20 22 procedure GeneratePage(ASession: TWebSession; Page: TWebPage); 21 23 public 24 ModuleBase: TModuleBase; 25 ModuleUser: TModuleUser; 22 26 constructor Create(Owner: TComponent); override; 23 27 destructor Destroy; override; … … 46 50 Author := 'Chronosoft'; 47 51 Dependencies.Add('User'); 52 Dependencies.Add('Finance'); 53 Dependencies.Add('News'); 48 54 end; 49 55 … … 55 61 procedure TModulePortal.Start; 56 62 begin 57 Core.GeneratePage := GeneratePage; 58 Core.Pages.RegisterPage(TWebPagePortal, WebPagePortal, 'portal'); 59 inherited; 63 BeforeStart; 64 ModuleBase := TModuleBase(Manager.FindModuleByName('Base')); 65 ModuleBase.GeneratePage := GeneratePage; 66 WebPagePortal := TWebPagePortal.Create(nil); 67 ModuleBase.Pages.RegisterPage(WebPagePortal, ''); 68 TWebPagePortal(WebPagePortal).ModuleUser := TModuleUser(Manager.FindModuleByName('User')); 69 AfterStart; 60 70 end; 61 71 62 72 procedure TModulePortal.Stop; 63 73 begin 64 inherited; 65 Core.Pages.UnregisterPage('portal'); 74 BeforeStop; 75 ModuleBase.Pages.UnregisterPage(WebPagePortal); 76 FreeAndNil(WebPagePortal); 77 ModuleBase := nil; 78 AfterStop; 66 79 end; 67 80 … … 208 221 '<div class="Navigation"><span class="MenuItem"><strong>Navigace :: </strong> '; 209 222 Output := Output + Navigation + '</span><div class="MenuItem2">'; 210 if Session.User.Id = UnknownUser then223 if ModuleUser.User.Id = UnknownUser then 211 224 Output := Output + '<a href="' + MakeLink('Přihlášení', 212 225 NavigationLink('/?Action=LoginForm')) + ' ' + 213 226 MakeLink('Registrace', NavigationLink('/?Action=UserRegister')) 214 else Output := Output + Session.User.Name + ' ' + MakeLink('Odhlásit',227 else Output := Output + ModuleUser.User.Name + ' ' + MakeLink('Odhlásit', 215 228 NavigationLink('/?Action=Logout')); 216 229 // <a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=UserOptions">Nastavení</a>'; -
trunk/Modules/Portal/UPagePortal.pas
r104 r105 8 8 Classes, SysUtils, FileUtil, UWebPage, UHTTPServer, USqlDatabase, UUtils, 9 9 SpecializedDictionary, UWebSession, SpecializedList, UHtmlClasses, 10 UModularSystem ;10 UModularSystem, UModuleUser, UModuleNews; 11 11 12 12 type … … 26 26 function WebcamPanel: string; 27 27 public 28 { public declarations } 28 ModuleUser: TModuleUser; 29 ModuleNews: TModuleNews; 29 30 end; 30 31 … … 37 38 38 39 uses 39 UCore, U ModuleUser, UWebObjects, UUser;40 UCore, UWebObjects, UUser; 40 41 41 42 function TWebPagePortal.SystemMessage(Title, Text: string): string; … … 76 77 if ((HyperLink.Values['PermissionModule'] = '') or 77 78 ((HyperLink.Values['PermissionModule'] <> '') and 78 Session.User.CheckPermission(HyperLink.Values['PermissionModule'], HyperLink.Values['PermissionOperation']))) then79 ModuleUser.User.CheckPermission(HyperLink.Values['PermissionModule'], HyperLink.Values['PermissionOperation']))) then 79 80 Result := Result + '<img alt="' + HyperLink.Values['Name'] + '" src="images/favicons/' + HyperLink.Values['IconFile'] + '" width="16" height="16" /> <a href="' + HyperLink.Values['URL'] + '">' + HyperLink.Values['Name'] + '</a><br />'; 80 81 end; … … 118 119 Form := TQueryForm.Create; // UserLogin 119 120 Form.Load(Session.Request.Post); 120 Session.UserOnline.Login(121 Session.User.GetIdByNamePassword(121 ModuleUser.UserOnline.Login( 122 ModuleUser.User.GetIdByNamePassword( 122 123 TQueryFormGroup(Form.Groups[0]).Rows.FindByName('Username').Value.Value, 123 124 TQueryFormGroup(Form.Groups[0]).Rows.FindByName('Password').Value.Value)); 124 125 Output := Output + SystemMessage('Přihlášení', 'Přihlášení provedeno'); 125 if Session.User.Id <> UnknownUser then begin126 if ModuleUser.User.Id <> UnknownUser then begin 126 127 //Form.LoadValuesFromForm; 127 128 TQueryFormGroup(Form.Groups[0]).Rows.FindByName('Password').Value.Value := ''; … … 132 133 end else 133 134 if Query.Values['Action'] = 'Logout' then begin 134 Session.UserOnline.Logout;135 ModuleUser.UserOnline.Logout; 135 136 Output := Output + SystemMessage('Odhlášení', 'Uživatel odhlášen'); 136 137 end else … … 249 250 else if Panel.Values['Module'] = 'UserOptions' then 250 251 begin 251 if Session.User.Id <> UnknownUser then252 if ModuleUser.User.Id <> UnknownUser then 252 253 Output := Output + ShowPanel('Přihlášený uživatel', UserPanel); 253 254 end else … … 255 256 Output := Output + ShowPanel('Kamery', WebcamPanel) 256 257 else if Panel.Values['Module'] = 'NewsGroupList' then 257 // Output := Output + Panel('Aktuality', $this->System->Modules['News']->Show(), array('<a href="?Action=CustomizeNews">Upravit</a>')); 258 //Output := Output + ShowPanel('Aktuality', 259 //ModuleNews.Show, 260 //['<a href="?Action=CustomizeNews">Upravit</a>']); 258 261 end; 259 262 Output := Output + '</td>'; -
trunk/Modules/System/UModuleSystem.pas
r97 r105 77 77 for I := 0 to DbRows.Count - 1 do 78 78 with DbRows[I] do begin 79 Module := Core.ModuleManager.FindModuleByName(Values['Name']);79 Module := Manager.FindModuleByName(Values['Name']); 80 80 if Assigned(Module) then 81 81 if Values['Installed'] = '1' then Module.SetInstalledState(True) … … 85 85 DbRows.Free; 86 86 end; 87 Core.ModuleManager.OnModuleChange := ModuleChange;87 Manager.OnModuleChange := ModuleChange; 88 88 inherited; 89 89 end; … … 91 91 procedure TModuleSystem.Stop; 92 92 begin 93 inherited Stop; 94 Core.ModuleManager.OnModuleChange := nil; 93 BeforeStop; 94 Manager.OnModuleChange := nil; 95 AfterStop; 95 96 end; 96 97 … … 152 153 Core.CommonDatabase.Select(DbRows, 'SystemModule', 'Name'); 153 154 154 for I := 0 to Core.ModuleManager.Modules.Count - 1 do155 with TModule( Core.ModuleManager.Modules[I]) do begin155 for I := 0 to Manager.Modules.Count - 1 do 156 with TModule(Manager.Modules[I]) do begin 156 157 Data.Clear; 157 158 Data.Add('Name', Identification); -
trunk/Modules/TV/UModuleTV.pas
r99 r105 6 6 7 7 uses 8 Classes, SysUtils, UModularSystem, SpecializedDictionary; 8 Classes, SysUtils, UModularSystem, SpecializedDictionary, UModuleBase, 9 UWebPage; 9 10 10 11 type … … 13 14 14 15 TModuleTV = class(TModule) 16 private 17 WebPageTV: TWebPage; 15 18 public 19 ModuleBase: TModuleBase; 16 20 constructor Create(Owner: TComponent); override; 17 21 destructor Destroy; override; … … 39 43 License := 'GNU/LGPL v3'; 40 44 Author := 'Chronosoft'; 45 Dependencies.Add('Base'); 41 46 end; 42 47 … … 48 53 procedure TModuleTV.Start; 49 54 begin 50 Core.Pages.RegisterPage(TWebPageTV, WebPageTV, 'tv'); 51 inherited; 55 BeforeStart; 56 ModuleBase := TModuleBase(Manager.FindModuleByName('Base')); 57 WebPageTV := TWebPageTV.Create(nil); 58 ModuleBase.Pages.RegisterPage(WebPageTV, 'tv'); 59 AfterStart; 52 60 end; 53 61 54 62 procedure TModuleTV.Stop; 55 63 begin 56 inherited; 57 Core.Pages.UnregisterPage('tv'); 64 BeforeStop; 65 ModuleBase.Pages.UnregisterPage(WebPageTV); 66 FreeAndNil(WebPageTV); 67 ModuleBase := nil; 68 AfterStop; 58 69 end; 59 70 -
trunk/Modules/TV/UPageTV.pas
r103 r105 7 7 uses 8 8 Classes, SysUtils, FileUtil, UWebPage, UHTTPServer, USqlDatabase, UHtmlClasses, 9 UUtils ;9 UUtils, UModuleUser; 10 10 11 11 type … … 19 19 procedure HandlePlaylist(HandlerData: THTTPHandlerData); 20 20 public 21 { public declarations }21 ModuleUser: TModuleUser; 22 22 end; 23 23 … … 56 56 begin 57 57 with TWebSession(HandlerData) do begin 58 LoadUserInfo;58 ModuleUser.LoadUserInfo; 59 59 with HtmlDocument.Body, THtmlString(SubItems.AddNew(THtmlString.Create)) do begin 60 60 Text := 'Stažení přehrávače: <a href="http://www.videolan.org/vlc/">VLC Media Player</a><br/>' + -
trunk/Modules/User/UModuleUser.pas
r103 r105 6 6 7 7 uses 8 Classes, SysUtils, UModularSystem, SpecializedDictionary; 8 Classes, SysUtils, UModularSystem, SpecializedDictionary, UUser, 9 UModuleBase, UWebPage; 9 10 10 11 type 11 12 12 { TModuleUser } 13 13 14 14 TModuleUser = class(TModule) 15 private 16 UserControlPage: TWebPage; //TUserControlPage; 15 17 public 18 User: TWebUser; 19 UserOnline: TWebOnlineUser; 20 ModuleBase: TModuleBase; 16 21 constructor Create(Owner: TComponent); override; 17 22 destructor Destroy; override; … … 21 26 procedure Uninstall; override; 22 27 procedure Upgrade; override; 28 procedure LoadUserInfo; 23 29 end; 24 30 … … 27 33 28 34 uses 29 UCore, U UserControlPage, USqlDatabase;35 UCore, USqlDatabase, UUserControlPage; 30 36 31 37 { TModuleUser } … … 39 45 License := 'GNU/LGPL v3'; 40 46 Author := 'Chronosoft'; 47 Dependencies.Add('Base'); 41 48 end; 42 49 … … 48 55 procedure TModuleUser.Start; 49 56 begin 50 Core.Pages.RegisterPage(TUserControlPage, UserControlPage, 'uzivatel'); 57 BeforeStart; 58 ModuleBase := TModuleBase(Manager.FindModuleByName('Base')); 59 UserControlPage := TUserControlPage.Create(nil); 60 ModuleBase.Pages.RegisterPage(UserControlPage, 'uzivatel'); 51 61 //RegisterPage(TUserControlPage, UserControlPage, ''); 52 inherited; 62 User := TWebUser.Create; 63 //User.Database := Database; 64 UserOnline := TWebOnlineUser.Create; 65 //UserOnline.Database := Database; 66 AfterStart; 53 67 end; 54 68 55 69 procedure TModuleUser.Stop; 56 70 begin 57 inherited; 58 Core.Pages.UnregisterPage('uzivatel'); 71 BeforeStop; 72 FreeAndNil(User); 73 FreeAndNil(UserOnline); 74 ModuleBase.Pages.UnregisterPage(UserControlPage); 75 FreeAndNil(UserControlPage); 76 ModuleBase := nil; 77 AfterStop; 59 78 end; 60 79 … … 183 202 end; 184 203 204 procedure TModuleUser.LoadUserInfo; 205 begin 206 User.HandlerData := ModuleBase.HandlerData; 207 UserOnline.HandlerData := ModuleBase.HandlerData; 208 UserOnline.Update; 209 User.Id := UserOnline.User; 210 User.Load; 211 end; 212 213 214 185 215 end. 186 216 -
trunk/Modules/User/UUserControlPage.pas
r103 r105 7 7 uses 8 8 Classes, SysUtils, FileUtil, UWebPage, UHTTPServer, UHtmlClasses, UXmlClasses, 9 UWebObjects ;9 UWebObjects, UModuleUser, UModuleBase; 10 10 11 11 type … … 21 21 procedure HandleProfile(HandlerData: THTTPHandlerData); 22 22 public 23 { public declarations } 24 end; 23 ModuleUser: TModuleUser; 24 ModuleBase: TModuleBase; 25 end; 25 26 26 27 var … … 47 48 else PageName := ''; 48 49 with HtmlDocument.Body do begin 49 LoadUserInfo;50 ModuleUser.LoadUserInfo; 50 51 if PageName = '' then PageName := 'prihlaseni'; 51 52 if PageName = 'prihlaseni' then HandleLogin(HandlerData) … … 91 92 with THtmlString(SubItems.AddNew(THtmlString.Create)) do 92 93 Text := 'Přihlášení uživatele: ' + TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value; 93 UserId := User.GetIdByNamePassword(TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value,94 UserId := ModuleUser.User.GetIdByNamePassword(TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value, 94 95 TQueryFormGroup(Form.Groups[0]).Rows.FindByName('Password').Value.Value); 95 96 if UserId = -1 then begin 96 97 with THtmlString(SubItems.AddNew(THtmlString.Create)) do 97 98 Text := '<br/>Chybné jméno nebo heslo'; 98 end else UserOnline.Login(UserId);99 end else ModuleUser.UserOnline.Login(UserId); 99 100 Form.Free; 100 101 end else … … 149 150 with THtmlString(SubItems.AddNew(THtmlString.Create)) do 150 151 Text := 'Registrace uživatele: ' + TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value; 151 User.Add(TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value,152 ModuleUser.User.Add(TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value, 152 153 TQueryFormGroup(Form.Groups[0]).Rows.FindByName('Password').Value.Value, 153 154 TQueryFormGroup(Form.Groups[0]).Rows.FindByName('Email').Value.Value); 154 UserId := User.GetIdByNamePassword(TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value,155 UserId := ModuleUser.User.GetIdByNamePassword(TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value, 155 156 TQueryFormGroup(Form.Groups[0]).Rows.FindByName('Password').Value.Value); 156 if UserId <> -1 then UserOnline.Login(UserId);157 if UserId <> -1 then ModuleUser.UserOnline.Login(UserId); 157 158 Form.Free; 158 159 end else SubItems.AddNew(Form); … … 163 164 begin 164 165 with TWebSession(HandlerData), Core, HtmlDocument.Body do begin 165 UserOnline.Logout;166 ModuleUser.UserOnline.Logout; 166 167 with THtmlString(SubItems.AddNew(THtmlString.Create)) do 167 168 Text := 'Uživatel odhlášen'; … … 185 186 Hint := 'Zadejte vaše přihlašovací jméno'; 186 187 Required := True; 187 Value.Value := User.Name;188 Value.Value := ModuleUser.User.Name; 188 189 end; 189 190 with AddNewItem do begin … … 200 201 Required := True; 201 202 ItemType := fitText; 202 Value.Value := User.Email;203 Value.Value := ModuleUser.User.Email; 203 204 end; 204 205 with AddNewItem do begin … … 208 209 Required := False; 209 210 ItemType := fitText; 210 Value.Value := User.FullName;211 Value.Value := ModuleUser.User.FullName; 211 212 end; 212 213 end; … … 218 219 with THtmlString(SubItems.AddNew(THtmlString.Create)) do 219 220 Text := 'Profil uživatele: ' + TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value + ' uložen'; 220 User.Name := TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value;221 User.FullName := TQueryFormGroup(Form.Groups[0]).Rows.FindByName('FullName').Value.Value;222 User.Email := TQueryFormGroup(Form.Groups[0]).Rows.FindByName('Email').Value.Value;223 User.Save;221 ModuleUser.User.Name := TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value; 222 ModuleUser.User.FullName := TQueryFormGroup(Form.Groups[0]).Rows.FindByName('FullName').Value.Value; 223 ModuleUser.User.Email := TQueryFormGroup(Form.Groups[0]).Rows.FindByName('Email').Value.Value; 224 ModuleUser.User.Save; 224 225 Form.Free; 225 226 end else SubItems.AddNew(Form); -
trunk/Modules/ZdechovNET/UAboutPage.pas
r103 r105 6 6 7 7 uses 8 Classes, SysUtils, FileUtil, UWebPage, UHTTPServer, UHtmlClasses ;8 Classes, SysUtils, FileUtil, UWebPage, UHTTPServer, UHtmlClasses, UModuleUser; 9 9 10 10 type … … 17 17 { private declarations } 18 18 public 19 { public declarations }19 ModuleUser: TModuleUser; 20 20 end; 21 21 … … 37 37 begin 38 38 with TWebSession(HandlerData) do begin 39 LoadUserInfo;39 ModuleUser.LoadUserInfo; 40 40 with HtmlDocument.Body, THtmlString(SubItems.AddNew(THtmlString.Create)) do begin 41 41 Text := '<img align="left" src="' + NavigationLink('/images/umisteni.gif') + '" alt="Umístění obce"/>' + -
trunk/Modules/ZdechovNET/UContactPage.pas
r103 r105 6 6 7 7 uses 8 Classes, SysUtils, FileUtil, UWebPage, UHTTPServer, UHtmlClasses ;8 Classes, SysUtils, FileUtil, UWebPage, UHTTPServer, UHtmlClasses, UModuleUser; 9 9 10 10 type … … 17 17 { private declarations } 18 18 public 19 { public declarations }19 ModuleUser: TModuleUser; 20 20 end; 21 21 … … 33 33 begin 34 34 with TWebSession(HandlerData), HtmlDocument.Body, THtmlString(SubItems.AddNew(THtmlString.Create)) do begin 35 LoadUserInfo;35 ModuleUser.LoadUserInfo; 36 36 Text := '<strong>Kontaktní informace</strong><br/>' + 37 37 'Provozovatel: <strong>Ing. Jiří Hajda</strong><br/>' + -
trunk/Modules/ZdechovNET/UDocumentsPage.pas
r103 r105 6 6 7 7 uses 8 Classes, SysUtils, FileUtil, UWebPage, UHTTPServer, UHtmlClasses ;8 Classes, SysUtils, FileUtil, UWebPage, UHTTPServer, UHtmlClasses, UModuleUser; 9 9 10 10 type … … 17 17 { private declarations } 18 18 public 19 { public declarations }19 ModuleUser: TModuleUser; 20 20 end; 21 21 … … 35 35 begin 36 36 with TWebSession(HandlerData) do begin 37 LoadUserInfo;37 ModuleUser.LoadUserInfo; 38 38 with HtmlDocument.Body, THtmlString(SubItems.AddNew(THtmlString.Create)) do begin 39 39 Text := '<strong>O obci:</strong><br/>' + -
trunk/Modules/ZdechovNET/UHistoryPage.pas
r103 r105 6 6 7 7 uses 8 Classes, SysUtils, FileUtil, UWebPage, UHTTPServer, UHtmlClasses, USqlDatabase; 8 Classes, SysUtils, FileUtil, UWebPage, UHTTPServer, UHtmlClasses, USqlDatabase, 9 UModuleUser; 9 10 10 11 type … … 17 18 { private declarations } 18 19 public 19 { public declarations }20 ModuleUser: TModuleUser; 20 21 end; 21 22 … … 38 39 begin 39 40 with TWebSession(HandlerData) do begin 40 LoadUserInfo;41 ModuleUser.LoadUserInfo; 41 42 with HtmlDocument.Body, THtmlString(SubItems.AddNew(THtmlString.Create)) do begin 42 43 Text := '<table>'; -
trunk/Modules/ZdechovNET/UHostingPage.pas
r103 r105 6 6 7 7 uses 8 Classes, SysUtils, FileUtil, UWebPage, UHTTPServer, USqlDatabase, UHtmlClasses; 8 Classes, SysUtils, FileUtil, UWebPage, UHTTPServer, USqlDatabase, UHtmlClasses, 9 UModuleUser; 9 10 10 11 type … … 17 18 { private declarations } 18 19 public 19 { public declarations }20 ModuleUser: TModuleUser; 20 21 end; 21 22 … … 39 40 begin 40 41 with TWebSession(HandlerData) do begin 41 LoadUserInfo;42 ModuleUser.LoadUserInfo; 42 43 with HtmlDocument.Body, THtmlString(SubItems.AddNew(THtmlString.Create)) do begin 43 44 Text := 'V nabídce je provoz virtualizovaných Linuxových serverů dle dohodnutých parameterů.<br/><br/>' + -
trunk/Modules/ZdechovNET/UInternetPage.pas
r102 r105 6 6 7 7 uses 8 Classes, SysUtils, FileUtil, UWebPage, UHTTPServer ;8 Classes, SysUtils, FileUtil, UWebPage, UHTTPServer, UModuleUser; 9 9 10 10 type … … 17 17 { private declarations } 18 18 public 19 { public declarations }19 ModuleUser: TModuleUser; 20 20 end; 21 21 … … 35 35 begin 36 36 with TWebSession(HandlerData) do begin 37 LoadUserInfo;37 ModuleUser.LoadUserInfo; 38 38 with HtmlDocument.Body, THtmlString(SubItems.AddNew(THtmlString.Create)) do begin 39 39 Text := Text + 'Hlavní náplní činnosti sítě je poskytovat výhodné připojení k internetu pro občany.<br/><br/>' + -
trunk/Modules/ZdechovNET/ULinksPage.pas
r103 r105 6 6 7 7 uses 8 Classes, SysUtils, FileUtil, UWebPage, UHTTPServer, UHtmlClasses ;8 Classes, SysUtils, FileUtil, UWebPage, UHTTPServer, UHtmlClasses, UModuleUser; 9 9 10 10 type … … 17 17 { private declarations } 18 18 public 19 { public declarations }19 ModuleUser: TModuleUser; 20 20 end; 21 21 … … 35 35 begin 36 36 with TWebSession(HandlerData), HtmlDocument.Body, THtmlString(SubItems.AddNew(THtmlString.Create)) do begin 37 LoadUserInfo;37 ModuleUser.LoadUserInfo; 38 38 Text := '<strong>Odkazy související s obcí:</strong><br/>' + 39 39 -
trunk/Modules/ZdechovNET/UModuleZdechovNET.pas
r104 r105 7 7 uses 8 8 Classes, SysUtils, UModularSystem, SpecializedDictionary, UWebPage, 9 UWebSession, DateUtils; 9 UWebSession, DateUtils, UModuleBase, UModuleUser, 10 UInternetPage, UHostingPage, UHistoryPage, UDocumentsPage, UVoIPPage, 11 ULinksPage, UPlansPage, UServerInfoPage, UWebCamPage, UUser, 12 UNetworkPage, UAboutPage, UContactPage, UProjectsPage; 10 13 11 14 type … … 15 18 TModuleZdechovNET = class(TModule) 16 19 private 20 InternetPage: TInternetPage; 21 HostingPage: THostingPage; 22 HistoryPage: THistoryPage; 23 DocumentsPage: TDocumentsPage; 24 VoIPPage: TVoIPPage; 25 LinksPage: TLinksPage; 26 ContactPage: TContactPage; 27 ServerInfoPage: TServerInfoPage; 28 WebCamPage: TWebCamPage; 29 PlansPage: TPlansPage; 30 NetworkPage: TNetworkPage; 31 ProjectsPage: TProjectsPage; 32 AboutPage: TAboutPage; 17 33 procedure Footer(Session: TWebSession); 18 34 procedure GeneratePage(ASession: TWebSession; Page: TWebPage); 19 35 procedure TopMenu(Session: TWebSession); 20 36 public 37 ModuleBase: TModuleBase; 38 ModuleUser: TModuleUser; 21 39 constructor Create(Owner: TComponent); override; 22 40 destructor Destroy; override; … … 32 50 33 51 uses 34 UCore, USqlDatabase, UXmlClasses, UHtmlClasses, UUtils, 35 UInternetPage, UHostingPage, UHistoryPage, UDocumentsPage, UVoIPPage, 36 ULinksPage, UPlansPage, UServerInfoPage, UWebCamPage, UUser, 37 UNetworkPage, UAboutPage, UContactPage, UProjectsPage; 52 UCore, USqlDatabase, UXmlClasses, UHtmlClasses, UUtils; 38 53 39 54 { TModuleZdechovNET } … … 48 63 Author := 'Chronosoft'; 49 64 Dependencies.Add('User'); 65 Dependencies.Add('Base'); 50 66 end; 51 67 … … 57 73 procedure TModuleZdechovNET.Start; 58 74 begin 59 with Core.Pages do begin 60 Core.GeneratePage := GeneratePage; 61 RegisterPage(TInternetPage, InternetPage, 'internet'); 62 RegisterPage(THostingPage, HostingPage, 'hosting'); 63 RegisterPage(THistoryPage, HistoryPage, 'historie'); 64 RegisterPage(TDocumentsPage, DocumentsPage, 'dokumenty'); 65 RegisterPage(TVoIPPage, VoIPPage, 'voip'); 66 RegisterPage(TLinksPage, LinksPage, 'odkazy'); 67 RegisterPage(TContactPage, ContactPage, 'kontakt'); 68 RegisterPage(TServerInfoPage, ServerInfoPage, 'serverinfo'); 69 RegisterPage(TWebCamPage, WebCamPage, 'kamery'); 70 RegisterPage(TPlansPage, PlansPage, 'plany'); 71 RegisterPage(TNetworkPage, NetworkPage, 'sit'); 72 RegisterPage(TProjectsPage, ProjectsPage, 'projekty'); 73 RegisterPage(TAboutPage, AboutPage, ''); 75 ModuleBase := TModuleBase(Manager.FindModuleByName('Base')); 76 ModuleUser := TModuleUser(Manager.FindModuleByName('User')); 77 with ModuleBase, Pages do begin 78 //GeneratePage := GeneratePage; 79 InternetPage := TInternetPage.Create(nil); 80 RegisterPage(InternetPage, 'internet'); 81 HostingPage := THostingPage.Create(nil); 82 RegisterPage(HostingPage, 'hosting'); 83 HistoryPage := THistoryPage.Create(nil); 84 RegisterPage(HistoryPage, 'historie'); 85 DocumentsPage := TDocumentsPage.Create(nil); 86 RegisterPage(DocumentsPage, 'dokumenty'); 87 VoIPPage := TVoIPPage.Create(nil); 88 RegisterPage(VoIPPage, 'voip'); 89 LinksPage := TLinksPage.Create(nil); 90 RegisterPage(LinksPage, 'odkazy'); 91 ContactPage := TContactPage.Create(nil); 92 RegisterPage(ContactPage, 'kontakt'); 93 ServerInfoPage := TServerInfoPage.Create(nil); 94 RegisterPage(ServerInfoPage, 'serverinfo'); 95 WebCamPage := TWebCamPage.Create(nil); 96 RegisterPage(WebCamPage, 'kamery'); 97 PlansPage := TPlansPage.Create(nil); 98 RegisterPage(PlansPage, 'plany'); 99 NetworkPage := TNetworkPage.Create(nil); 100 RegisterPage(NetworkPage, 'sit'); 101 ProjectsPage := TProjectsPage.Create(nil); 102 RegisterPage(ProjectsPage, 'projekty'); 103 AboutPage := TAboutPage.Create(nil); 104 RegisterPage(AboutPage, ''); 74 105 end; 75 106 inherited; … … 79 110 begin 80 111 inherited Stop; 81 with Core.Pages do begin 82 UnregisterPage('internet'); 83 UnregisterPage('hosting'); 84 UnregisterPage('historie'); 85 UnregisterPage('dokumenty'); 86 UnregisterPage('voip'); 87 UnregisterPage('odkazy'); 88 UnregisterPage('kontakt'); 89 UnregisterPage('serverinfo'); 90 UnregisterPage('kamery'); 91 UnregisterPage('plany'); 92 UnregisterPage('sit'); 93 UnregisterPage('projekty'); 94 UnregisterPage(''); 95 end; 112 with ModuleBase, Pages do begin 113 UnregisterPage(AboutPage); 114 FreeAndNil(AboutPage); 115 UnregisterPage(InternetPage); 116 FreeAndNil(InternetPage); 117 UnregisterPage(HostingPage); 118 FreeAndNil(HostingPage); 119 UnregisterPage(HistoryPage); 120 FreeAndNil(HistoryPage); 121 UnregisterPage(DocumentsPage); 122 FreeAndNil(DocumentsPage); 123 UnregisterPage(VoIPPage); 124 FreeAndNil(VoIPPage); 125 UnregisterPage(LinksPage); 126 FreeAndNil(LinksPage); 127 UnregisterPage(ContactPage); 128 FreeAndNil(ContactPage); 129 UnregisterPage(ServerInfoPage); 130 FreeAndNil(ServerInfoPage); 131 UnregisterPage(WebCamPage); 132 FreeAndNil(WebCamPage); 133 UnregisterPage(PlansPage); 134 FreeAndNil(PlansPage); 135 UnregisterPage(NetworkPage); 136 FreeAndNil(NetworkPage); 137 UnregisterPage(ProjectsPage); 138 FreeAndNil(ProjectsPage); 139 end; 140 ModuleBase := nil; 141 ModuleUser := nil; 96 142 end; 97 143 … … 179 225 begin 180 226 inherited Uninstall; 181 Core.GeneratePage := nil;227 ModuleBase.GeneratePage := nil; 182 228 try 183 229 DbRows := TDbRows.Create; … … 257 303 '<li><a href="http://wiki.zdechov.net/">Wiki</a></li>' + 258 304 '</ul><ul class="MenuItem2">'; //<li> </li>'; 259 if Assigned( TCore(MainModule).Pages.FindByName('uzivatel')) then begin260 if UserOnline.User = UnknownUser then begin305 if Assigned(ModuleBase.Pages.FindByName('uzivatel')) then begin 306 if ModuleUser.UserOnline.User = UnknownUser then begin 261 307 Text := Text + '</ul>' + 262 308 '<ul class="MenuItem2">' + … … 268 314 Text := Text + '</ul>' + 269 315 '<ul class="MenuItem2">' + 270 '<li>' + User.FullName + '</li>' +316 '<li>' + ModuleUser.User.FullName + '</li>' + 271 317 '<li>' + MakeLink('Odhlášení', NavigationLink('/uzivatel/odhlaseni/')) + '</li>' + 272 318 '<li>' + MakeLink('Profil', NavigationLink('/uzivatel/profil/')) + '</li>'; -
trunk/Modules/ZdechovNET/UNetworkPage.pas
r103 r105 6 6 7 7 uses 8 Classes, SysUtils, FileUtil, UWebPage, UHTTPServer, UHtmlClasses ;8 Classes, SysUtils, FileUtil, UWebPage, UHTTPServer, UHtmlClasses, UModuleUser; 9 9 10 10 type … … 17 17 { private declarations } 18 18 public 19 { public declarations }19 ModuleUser: TModuleUser; 20 20 end; 21 21 … … 37 37 begin 38 38 with TWebSession(HandlerData) do begin 39 LoadUserInfo;39 ModuleUser.LoadUserInfo; 40 40 with HtmlDocument.Body, THtmlString(SubItems.AddNew(THtmlString.Create)) do begin 41 41 Text := MakeLink('Historie', NavigationLink('/historie/')) + '<br/>' + -
trunk/Modules/ZdechovNET/UPlansPage.pas
r103 r105 6 6 7 7 uses 8 Classes, SysUtils, FileUtil, UWebPage, UHtmlClasses, UHTTPServer, USqlDatabase; 8 Classes, SysUtils, FileUtil, UWebPage, UHtmlClasses, UHTTPServer, USqlDatabase, 9 UModuleUser; 9 10 10 11 type … … 17 18 { private declarations } 18 19 public 19 { public declarations }20 ModuleUser: TModuleUser; 20 21 end; 21 22 … … 38 39 begin 39 40 with TWebSession(HandlerData) do begin 40 LoadUserInfo;41 ModuleUser.LoadUserInfo; 41 42 with HtmlDocument.Body, THtmlString(SubItems.AddNew(THtmlString.Create)) do begin 42 43 Text := '<table>'; -
trunk/Modules/ZdechovNET/UProjectsPage.pas
r103 r105 6 6 7 7 uses 8 Classes, SysUtils, FileUtil, UWebPage, UHtmlClasses, UHTTPServer, USqlDatabase; 8 Classes, SysUtils, FileUtil, UWebPage, UHtmlClasses, UHTTPServer, USqlDatabase, 9 UModuleUser; 9 10 10 11 type … … 17 18 { private declarations } 18 19 public 19 { public declarations }20 ModuleUser: TModuleUser; 20 21 end; 21 22 … … 38 39 begin 39 40 with TWebSession(HandlerData) do begin 40 LoadUserInfo;41 ModuleUser.LoadUserInfo; 41 42 with HtmlDocument.Body, THtmlString(SubItems.AddNew(THtmlString.Create)) do begin 42 43 try -
trunk/Modules/ZdechovNET/UVoIPPage.pas
r103 r105 6 6 7 7 uses 8 Classes, SysUtils, FileUtil, UWebPage, UHtmlClasses, UHTTPServer ;8 Classes, SysUtils, FileUtil, UWebPage, UHtmlClasses, UHTTPServer, UModuleUser; 9 9 10 10 type … … 17 17 { private declarations } 18 18 public 19 { public declarations }19 ModuleUser: TModuleUser; 20 20 end; 21 21 … … 35 35 begin 36 36 with TWebSession(HandlerData) do begin 37 LoadUserInfo;37 ModuleUser.LoadUserInfo; 38 38 with HtmlDocument.Body, THtmlString(SubItems.AddNew(THtmlString.Create)) do begin 39 39 Text := 'Volejte levněji do pevných a mobilních sítí s sekundovou tarifikací a bez měsíčního paušálu.' + -
trunk/Modules/ZdechovNET/UWebCamPage.pas
r103 r105 6 6 7 7 uses 8 Classes, SysUtils, FileUtil, UWebPage, UHTTPServer, UHtmlClasses, USqlDatabase; 8 Classes, SysUtils, FileUtil, UWebPage, UHTTPServer, UHtmlClasses, USqlDatabase, 9 UModuleUser; 9 10 10 11 type … … 17 18 { private declarations } 18 19 public 19 { public declarations }20 ModuleUser: TModuleUser; 20 21 end; 21 22 … … 46 47 begin 47 48 with TWebSession(HandlerData) do begin 48 LoadUserInfo;49 ModuleUser.LoadUserInfo; 49 50 with HtmlDocument.Body, THtmlString(SubItems.AddNew(THtmlString.Create)) do begin 50 51 Text := ''; -
trunk/Packages/CoolWeb/WebServer/UWebApp.pas
r96 r105 24 24 TPageList = class(TListObject) 25 25 RootDir: string; 26 function FindByPage(Page: TWebPage): TRegistredPage; 26 27 function FindByName(Name: string): TRegistredPage; 27 procedure RegisterPage(Page Class: TWebPageClass; out Reference; Path: string);28 procedure UnregisterPage(Pa th: string);28 procedure RegisterPage(Page: TWebPage; Path: string); 29 procedure UnregisterPage(Page: TWebPage); 29 30 function ProducePage(HandlerData: THTTPHandlerData): Boolean; 30 31 end; … … 78 79 { TPageList } 79 80 81 function TPageList.FindByPage(Page: TWebPage): TRegistredPage; 82 var 83 I: Integer; 84 begin 85 I := 0; 86 while (I < Count) and (TRegistredPage(Items[I]).Page <> Page) do Inc(I); 87 if I < Count then Result := TRegistredPage(Items[I]) 88 else Result := nil; 89 end; 90 80 91 function TPageList.FindByName(Name: string): TRegistredPage; 81 92 var … … 117 128 end; 118 129 119 procedure TPageList.RegisterPage(PageClass: TWebPageClass; out Reference; 120 Path: string); 130 procedure TPageList.RegisterPage(Page: TWebPage; Path: string); 121 131 var 122 132 NewPage: TRegistredPage; … … 125 135 NewPage := TRegistredPage(AddNew(TRegistredPage.Create)); 126 136 // NewPage.Page := PageClass.Create(Self); 127 NewPage.Page := Page Class.Create(nil);137 NewPage.Page := Page; 128 138 NewPage.Name := Path; 129 TWebPage(Reference) := NewPage.Page; 130 end; 131 132 procedure TPageList.UnregisterPage(Path: string); 133 var 134 Page: TRegistredPage; 135 begin 136 Page := FindByName(Path); 137 Remove(Page); 139 end; 140 141 procedure TPageList.UnregisterPage(Page: TWebPage); 142 var 143 RegPage: TRegistredPage; 144 begin 145 RegPage := FindByPage(Page); 146 Remove(RegPage); 138 147 end; 139 148 -
trunk/Packages/ModularSystem/Demo
-
Property svn:ignore
set to
lib
Demo.exe
-
Property svn:ignore
set to
-
trunk/Packages/ModularSystem/Demo/Demo.lpi
r89 r105 35 35 <Item1> 36 36 <PackageName Value="ModularSystem"/> 37 <DefaultFilename Value="..\ModularSystem.lpk" Prefer="True"/> 37 38 </Item1> 38 39 <Item2> -
trunk/Packages/ModularSystem/Demo/Demo.lps
r89 r105 2 2 <CONFIG> 3 3 <ProjectSession> 4 <PathDelim Value="\"/> 4 5 <Version Value="9"/> 5 6 <BuildModes Active="Default"/> 6 <Units Count=" 5">7 <Units Count="6"> 7 8 <Unit0> 8 9 <Filename Value="Demo.lpr"/> 9 10 <IsPartOfProject Value="True"/> 10 11 <UnitName Value="Demo"/> 11 <UsageCount Value="2 0"/>12 <UsageCount Value="22"/> 12 13 </Unit0> 13 14 <Unit1> … … 18 19 <ResourceBaseClass Value="Form"/> 19 20 <UnitName Value="UMainForm"/> 20 < IsVisibleTab Value="True"/>21 < EditorIndex Value="1"/>22 < WindowIndex Value="0"/>23 < TopLine Value="87"/>24 < CursorPos X="46" Y="105"/>25 < UsageCount Value="20"/>26 <Loaded Value="True"/>21 <EditorIndex Value="4"/> 22 <WindowIndex Value="0"/> 23 <TopLine Value="61"/> 24 <CursorPos X="37" Y="76"/> 25 <UsageCount Value="22"/> 26 <Loaded Value="True"/> 27 <LoadedDesigner Value="True"/> 27 28 </Unit1> 28 29 <Unit2> … … 30 31 <IsPartOfProject Value="True"/> 31 32 <UnitName Value="UModuleUser"/> 32 <UsageCount Value="20"/> 33 <EditorIndex Value="2"/> 34 <WindowIndex Value="0"/> 35 <TopLine Value="13"/> 36 <CursorPos X="17" Y="26"/> 37 <UsageCount Value="22"/> 38 <Loaded Value="True"/> 33 39 </Unit2> 34 40 <Unit3> … … 36 42 <IsPartOfProject Value="True"/> 37 43 <UnitName Value="UModuleBase"/> 38 <UsageCount Value="20"/> 44 <IsVisibleTab Value="True"/> 45 <EditorIndex Value="1"/> 46 <WindowIndex Value="0"/> 47 <TopLine Value="10"/> 48 <CursorPos X="40" Y="17"/> 49 <UsageCount Value="22"/> 50 <Loaded Value="True"/> 39 51 </Unit3> 40 52 <Unit4> … … 45 57 <WindowIndex Value="0"/> 46 58 <TopLine Value="1"/> 47 <CursorPos X=" 36" Y="4"/>48 <UsageCount Value="2 0"/>59 <CursorPos X="17" Y="14"/> 60 <UsageCount Value="22"/> 49 61 <Loaded Value="True"/> 50 62 </Unit4> 63 <Unit5> 64 <Filename Value="..\UModularSystem.pas"/> 65 <UnitName Value="UModularSystem"/> 66 <EditorIndex Value="3"/> 67 <WindowIndex Value="0"/> 68 <TopLine Value="117"/> 69 <CursorPos X="1" Y="133"/> 70 <UsageCount Value="11"/> 71 <Loaded Value="True"/> 72 </Unit5> 51 73 </Units> 52 74 <General> 53 75 <ActiveWindowIndexAtStart Value="0"/> 54 76 </General> 55 <JumpHistory Count=" 1" HistoryIndex="0">77 <JumpHistory Count="29" HistoryIndex="28"> 56 78 <Position1> 57 <Filename Value="UM ainForm.pas"/>58 <Caret Line="1 " Column="1" TopLine="1"/>79 <Filename Value="UModuleUser.pas"/> 80 <Caret Line="13" Column="51" TopLine="10"/> 59 81 </Position1> 82 <Position2> 83 <Filename Value="UModuleUser.pas"/> 84 <Caret Line="15" Column="23" TopLine="2"/> 85 </Position2> 86 <Position3> 87 <Filename Value="UModuleBase.pas"/> 88 <Caret Line="13" Column="31" TopLine="10"/> 89 </Position3> 90 <Position4> 91 <Filename Value="UModuleBase.pas"/> 92 <Caret Line="12" Column="43" TopLine="1"/> 93 </Position4> 94 <Position5> 95 <Filename Value="UModuleACL.pas"/> 96 <Caret Line="13" Column="29" TopLine="1"/> 97 </Position5> 98 <Position6> 99 <Filename Value="UModuleACL.pas"/> 100 <Caret Line="14" Column="43" TopLine="1"/> 101 </Position6> 102 <Position7> 103 <Filename Value="UMainForm.pas"/> 104 <Caret Line="14" Column="39" TopLine="1"/> 105 </Position7> 106 <Position8> 107 <Filename Value="UMainForm.pas"/> 108 <Caret Line="92" Column="54" TopLine="77"/> 109 </Position8> 110 <Position9> 111 <Filename Value="UMainForm.pas"/> 112 <Caret Line="71" Column="23" TopLine="54"/> 113 </Position9> 114 <Position10> 115 <Filename Value="UMainForm.pas"/> 116 <Caret Line="46" Column="7" TopLine="33"/> 117 </Position10> 118 <Position11> 119 <Filename Value="UMainForm.pas"/> 120 <Caret Line="71" Column="35" TopLine="57"/> 121 </Position11> 122 <Position12> 123 <Filename Value="UMainForm.pas"/> 124 <Caret Line="72" Column="35" TopLine="58"/> 125 </Position12> 126 <Position13> 127 <Filename Value="UMainForm.pas"/> 128 <Caret Line="74" Column="35" TopLine="60"/> 129 </Position13> 130 <Position14> 131 <Filename Value="UMainForm.pas"/> 132 <Caret Line="137" Column="3" TopLine="135"/> 133 </Position14> 134 <Position15> 135 <Filename Value="UMainForm.pas"/> 136 <Caret Line="138" Column="3" TopLine="136"/> 137 </Position15> 138 <Position16> 139 <Filename Value="UMainForm.pas"/> 140 <Caret Line="139" Column="3" TopLine="137"/> 141 </Position16> 142 <Position17> 143 <Filename Value="UMainForm.pas"/> 144 <Caret Line="140" Column="3" TopLine="138"/> 145 </Position17> 146 <Position18> 147 <Filename Value="UMainForm.pas"/> 148 <Caret Line="35" Column="15" TopLine="22"/> 149 </Position18> 150 <Position19> 151 <Filename Value="UMainForm.pas"/> 152 <Caret Line="40" Column="15" TopLine="25"/> 153 </Position19> 154 <Position20> 155 <Filename Value="UMainForm.pas"/> 156 <Caret Line="95" Column="77" TopLine="86"/> 157 </Position20> 158 <Position21> 159 <Filename Value="UMainForm.pas"/> 160 <Caret Line="98" Column="65" TopLine="76"/> 161 </Position21> 162 <Position22> 163 <Filename Value="..\UModularSystem.pas"/> 164 <Caret Line="183" Column="1" TopLine="164"/> 165 </Position22> 166 <Position23> 167 <Filename Value="..\UModularSystem.pas"/> 168 <Caret Line="237" Column="33" TopLine="220"/> 169 </Position23> 170 <Position24> 171 <Filename Value="..\UModularSystem.pas"/> 172 <Caret Line="183" Column="1" TopLine="170"/> 173 </Position24> 174 <Position25> 175 <Filename Value="..\UModularSystem.pas"/> 176 <Caret Line="233" Column="1" TopLine="220"/> 177 </Position25> 178 <Position26> 179 <Filename Value="..\UModularSystem.pas"/> 180 <Caret Line="130" Column="1" TopLine="117"/> 181 </Position26> 182 <Position27> 183 <Filename Value="..\UModularSystem.pas"/> 184 <Caret Line="131" Column="1" TopLine="117"/> 185 </Position27> 186 <Position28> 187 <Filename Value="..\UModularSystem.pas"/> 188 <Caret Line="132" Column="1" TopLine="117"/> 189 </Position28> 190 <Position29> 191 <Filename Value="..\UModularSystem.pas"/> 192 <Caret Line="133" Column="1" TopLine="117"/> 193 </Position29> 60 194 </JumpHistory> 61 195 </ProjectSession> 62 <EditorMacros Count="0"/> 196 <Debugging> 197 <BreakPoints Count="1"> 198 <Item1> 199 <Kind Value="bpkSource"/> 200 <WatchScope Value="wpsLocal"/> 201 <WatchKind Value="wpkWrite"/> 202 <Source Value="..\UModularSystem.pas"/> 203 <Line Value="233"/> 204 </Item1> 205 </BreakPoints> 206 </Debugging> 63 207 </CONFIG> -
trunk/Packages/ModularSystem/Demo/UMainForm.lfm
r89 r105 10 10 OnDestroy = FormDestroy 11 11 OnShow = FormShow 12 LCLVersion = '1. 1'12 LCLVersion = '1.0.1.3' 13 13 object ListViewModules: TListView 14 14 Left = 8 … … 30 30 end 31 31 item 32 Caption = 'State' 32 Caption = 'Installed' 33 Width = 80 34 end 35 item 36 Caption = 'Running' 33 37 Width = 80 34 38 end … … 80 84 TabOrder = 3 81 85 end 86 object ButtonUpdate1: TButton 87 Left = 248 88 Height = 25 89 Top = 281 90 Width = 75 91 Action = AModuleStart 92 Anchors = [akLeft, akBottom] 93 TabOrder = 4 94 end 95 object ButtonUpdate2: TButton 96 Left = 328 97 Height = 25 98 Top = 281 99 Width = 75 100 Action = AModuleStop 101 Anchors = [akLeft, akBottom] 102 TabOrder = 5 103 end 82 104 object PopupMenu1: TPopupMenu 83 105 left = 183 … … 92 114 Action = AModuleUpdate 93 115 end 116 object MenuItem4: TMenuItem 117 Action = AModuleStart 118 end 119 object MenuItem5: TMenuItem 120 Action = AModuleStop 121 end 94 122 end 95 123 object ActionList1: TActionList 96 left = 1 3797 top = 1 65124 left = 184 125 top = 136 98 126 object AModuleInstall: TAction 99 127 Caption = 'Install' … … 108 136 OnExecute = ButtonUpdateClick 109 137 end 138 object AModuleStart: TAction 139 Caption = 'Start' 140 OnExecute = AModuleStartExecute 141 end 142 object AModuleStop: TAction 143 Caption = 'Stop' 144 OnExecute = AModuleStopExecute 145 end 110 146 end 111 147 end -
trunk/Packages/ModularSystem/Demo/UMainForm.pas
r89 r105 15 15 TMainForm = class(TForm) 16 16 published 17 AModuleStart: TAction; 18 AModuleStop: TAction; 17 19 AModuleInstall: TAction; 18 20 AModuleUninstall: TAction; … … 22 24 ButtonUninstall: TButton; 23 25 ButtonInstall: TButton; 26 ButtonUpdate1: TButton; 27 ButtonUpdate2: TButton; 24 28 ListViewModules: TListView; 25 29 MenuItem1: TMenuItem; 26 30 MenuItem2: TMenuItem; 27 31 MenuItem3: TMenuItem; 32 MenuItem4: TMenuItem; 33 MenuItem5: TMenuItem; 28 34 PopupMenu1: TPopupMenu; 35 procedure AModuleStartExecute(Sender: TObject); 36 procedure AModuleStopExecute(Sender: TObject); 29 37 procedure ButtonInstallClick(Sender: TObject); 30 38 procedure ButtonUninstallClick(Sender: TObject); … … 44 52 45 53 const 46 InstalledText: array[Boolean] of string = ('Not installed', 'Installed');54 BoolText: array[Boolean] of string = ('No', 'Yes'); 47 55 48 56 var … … 66 74 Item.Caption := Title; 67 75 Item.Data := ModuleManager.Modules[Item.Index]; 68 Item.SubItems.Add( Name);76 Item.SubItems.Add(Identification); 69 77 Item.SubItems.Add(Version); 70 Item.SubItems.Add(InstalledText[Installed]); 78 Item.SubItems.Add(BoolText[Installed]); 79 Item.SubItems.Add(BoolText[Running]); 71 80 Item.SubItems.Add(License); 72 81 Item.SubItems.Add(StringReplace(Dependencies.Text, LineEnding, ', ', [rfReplaceAll])); … … 79 88 var 80 89 Installed: Boolean; 90 Running: Boolean; 81 91 begin 82 92 if Assigned(ListViewModules.Selected) then Installed := TModule(ListViewModules.Selected.Data).Installed; 93 if Assigned(ListViewModules.Selected) then Running := TModule(ListViewModules.Selected.Data).Running; 83 94 AModuleInstall.Enabled := Assigned(ListViewModules.Selected) and not Installed; 84 95 AModuleUninstall.Enabled := Assigned(ListViewModules.Selected) and Installed; 85 96 AModuleUpdate.Enabled := Assigned(ListViewModules.Selected) and Installed; 97 AModuleStart.Enabled := Assigned(ListViewModules.Selected) and not Running; 98 AModuleStop.Enabled := Assigned(ListViewModules.Selected) and Running; 86 99 end; 87 100 88 101 procedure TMainForm.RegisterModules; 89 102 begin 90 ModuleManager.RegisterModule(TModuleUser.Create );91 ModuleManager.RegisterModule(TModuleBase.Create );92 ModuleManager.RegisterModule(TModuleACL.Create );103 ModuleManager.RegisterModule(TModuleUser.Create(nil)); 104 ModuleManager.RegisterModule(TModuleBase.Create(nil)); 105 ModuleManager.RegisterModule(TModuleACL.Create(nil)); 93 106 end; 94 107 … … 129 142 end; 130 143 144 procedure TMainForm.AModuleStartExecute(Sender: TObject); 145 var 146 ModuleList: TStringList; 147 begin 148 if Assigned(ListViewModules.Selected) then begin 149 try 150 ModuleList := TStringList.Create; 151 TModule(ListViewModules.Selected.Data).EnumModulesStart(ModuleList); 152 if ModuleList.Count > 0 then begin 153 if MessageDlg('These modules will be started in addition to ' + 154 TModule(ListViewModules.Selected.Data).Name + ': ' + 155 StringReplace(ModuleList.Text, LineEnding, ', ', [rfReplaceAll]), 156 mtConfirmation, [mbYes, mbNo], 0) = mrYes then 157 TModule(ListViewModules.Selected.Data).Start; 158 end else TModule(ListViewModules.Selected.Data).Start; 159 finally 160 ModuleList.Free; 161 end; 162 RefreshList; 163 end; 164 end; 165 166 procedure TMainForm.AModuleStopExecute(Sender: TObject); 167 var 168 ModuleList: TStringList; 169 begin 170 if Assigned(ListViewModules.Selected) then begin 171 try 172 ModuleList := TStringList.Create; 173 TModule(ListViewModules.Selected.Data).EnumModulesStop(ModuleList); 174 if ModuleList.Count > 0 then begin 175 if MessageDlg('These modules will be stopped in addition to ' + 176 TModule(ListViewModules.Selected.Data).Name + ': ' + 177 StringReplace(ModuleList.Text, LineEnding, ', ', [rfReplaceAll]), 178 mtConfirmation, [mbYes, mbNo], 0) = mrYes then 179 TModule(ListViewModules.Selected.Data).Stop; 180 end else TModule(ListViewModules.Selected.Data).Stop; 181 finally 182 ModuleList.Free; 183 end; 184 185 RefreshList; 186 end; 187 end; 188 131 189 procedure TMainForm.ButtonUninstallClick(Sender: TObject); 132 190 var … … 155 213 begin 156 214 if Assigned(ListViewModules.Selected) then begin 157 TModule(ListViewModules.Selected.Data).Up date;215 TModule(ListViewModules.Selected.Data).Upgrade; 158 216 RefreshList; 159 217 end; … … 162 220 procedure TMainForm.FormDestroy(Sender: TObject); 163 221 begin 164 ModuleManager.Free;222 FreeAndNil(ModuleManager); 165 223 end; 166 224 -
trunk/Packages/ModularSystem/Demo/UModuleACL.pas
r89 r105 12 12 13 13 TModuleACL = class(TModule) 14 constructor Create ; override;14 constructor Create(AOwner: TComponent); override; 15 15 destructor Destroy; override; 16 16 end; … … 21 21 { TModuleACL } 22 22 23 constructor TModuleACL.Create ;23 constructor TModuleACL.Create(AOwner: TComponent); 24 24 begin 25 25 inherited; 26 Name:= 'UserACL';26 Identification := 'UserACL'; 27 27 Title := 'User ACL'; 28 28 Version := '1.0'; -
trunk/Packages/ModularSystem/Demo/UModuleBase.pas
r89 r105 10 10 type 11 11 TModuleBase = class(TModule) 12 constructor Create ; override;12 constructor Create(AOwner: TComponent); override; 13 13 destructor Destroy; override; 14 14 end; … … 19 19 { TModuleUser } 20 20 21 constructor TModuleBase.Create ;21 constructor TModuleBase.Create(AOwner: TComponent); 22 22 begin 23 23 inherited; 24 Name:= 'Base';24 Identification := 'Base'; 25 25 Title := 'Base'; 26 26 Version := '1.0'; -
trunk/Packages/ModularSystem/Demo/UModuleUser.pas
r89 r105 13 13 14 14 TModuleUser = class(TModule) 15 constructor Create ; override;15 constructor Create(AOwner: TComponent); override; 16 16 destructor Destroy; override; 17 17 end; … … 21 21 { TModuleUser } 22 22 23 constructor TModuleUser.Create ;23 constructor TModuleUser.Create(AOwner: TComponent); 24 24 begin 25 25 inherited; 26 Name:= 'User';26 Identification := 'User'; 27 27 Title := 'User'; 28 28 Version := '1.0'; -
trunk/Packages/ModularSystem/ModularSystem.lpk
r92 r105 20 20 <Description Value="Modular system"/> 21 21 <License Value="GNU/LGPLv3"/> 22 <Version Minor=" 2"/>22 <Version Minor="1"/> 23 23 <Files Count="1"> 24 24 <Item1> … … 28 28 </Item1> 29 29 </Files> 30 <i18n> 31 <EnableI18N Value="True"/> 32 <OutDir Value="Language"/> 33 <EnableI18NForLFM Value="True"/> 34 </i18n> 30 35 <Type Value="RunAndDesignTime"/> 31 <RequiredPkgs Count=" 1">36 <RequiredPkgs Count="2"> 32 37 <Item1> 38 <PackageName Value="Common"/> 39 </Item1> 40 <Item2> 33 41 <PackageName Value="FCL"/> 34 </Item 1>42 </Item2> 35 43 </RequiredPkgs> 36 44 <UsageOptions> -
trunk/Packages/ModularSystem/UModularSystem.pas
r94 r105 6 6 7 7 uses 8 Classes, SysUtils, Contnrs ;8 Classes, SysUtils, Contnrs, URegistry; 9 9 10 10 type … … 19 19 TModule = class(TComponent) 20 20 private 21 FEnabled: Boolean; 21 22 FRunning: Boolean; 22 23 FInstalled: Boolean; 23 Manager: TModuleManager;24 FManager: TModuleManager; 24 25 FVersion: string; 25 26 FIdentification: string; … … 29 30 FDependencies: TStringList; 30 31 FDescription: TStringList; 32 procedure SetEnabled(AValue: Boolean); 31 33 procedure SetInstalled(AValue: Boolean); 32 34 procedure SetRunning(AValue: Boolean); 35 protected 36 procedure BeforeStart; virtual; 37 procedure AfterStart; virtual; 38 procedure BeforeStop; virtual; 39 procedure AfterStop; virtual; 33 40 public 34 41 API: TAPI; 35 MarkForInstall: Boolean;36 42 procedure Start; virtual; 37 43 procedure Stop; virtual; … … 48 54 property Running: Boolean read FRunning write SetRunning; 49 55 property Installed: Boolean read FInstalled write SetInstalled; 56 property Enabled: Boolean read FEnabled write SetEnabled; 50 57 published 58 property Manager: TModuleManager read FManager; 51 59 property Version: string read FVersion write FVersion; 52 60 property Identification: string read FIdentification write FIdentification; … … 79 87 procedure EnumModulesInstall(Dependencies, ModuleList: TStringList); 80 88 procedure EnumModulesUninstall(ModuleName: string; ModuleList: TStringList); 81 procedure RegisterModule(Module: TModule; MarkForInstall: Boolean = False);89 procedure RegisterModule(Module: TModule; Enabled: Boolean = True); 82 90 procedure UnregisterModule(Module: TModule); 83 91 procedure StartInstalled; 84 procedure Install Marked;92 procedure InstallEnabled; 85 93 procedure StopAll; 86 94 procedure UninstallAll; 95 procedure LoadFromRegistry(Context: TRegistryContext); 96 procedure SaveToRegistry(Context: TRegistryContext); 87 97 constructor Create(AOwner: TComponent); override; 88 98 destructor Destroy; override; … … 143 153 for I := 0 to Dependencies.Count - 1 do begin 144 154 Module := FindModuleByName(Dependencies[I]); 145 if Assigned(Module) then begin155 if Assigned(Module) and Module.Enabled then begin 146 156 if not Module.Running then Module.Start; 147 157 end else raise Exception.CreateFmt(SModuleNotFound, [ModuleName, Dependencies[I]]); … … 199 209 for I := 0 to Dependencies.Count - 1 do begin 200 210 Module := FindModuleByName(Dependencies[I]); 201 if Assigned(Module) then begin211 if Assigned(Module) and Module.Enabled then begin 202 212 if not Module.Installed then Module.Install; 203 213 end else raise Exception.CreateFmt(SModuleNotFound, [ModuleName, Dependencies[I]]); … … 248 258 249 259 procedure TModuleManager.RegisterModule(Module: TModule; 250 MarkForInstall: Boolean = False);260 Enabled: Boolean = True); 251 261 begin 252 262 Modules.Add(Module); 253 Module. Manager := Self;263 Module.FManager := Self; 254 264 Module.API := API; 255 Module. MarkForInstall := MarkForInstall;265 Module.Enabled := Enabled; 256 266 end; 257 267 … … 270 280 end; 271 281 272 procedure TModuleManager.Install Marked;282 procedure TModuleManager.InstallEnabled; 273 283 var 274 284 I: Integer; … … 276 286 for I := 0 to Modules.Count - 1 do 277 287 with TModule(Modules[I]) do 278 if not Installed and MarkForInstallthen Install;288 if not Installed and Enabled then Install; 279 289 end; 280 290 … … 301 311 inherited; 302 312 Modules := TObjectList.Create; 313 //Modules.OwnsObjects := False; 303 314 end; 304 315 … … 307 318 StopAll; 308 319 FreeAndNil(Modules); 309 inherited Destroy; 320 inherited; 321 end; 322 323 procedure TModuleManager.LoadFromRegistry(Context: TRegistryContext); 324 var 325 I: Integer; 326 begin 327 with TRegistryEx.Create do 328 try 329 RootKey := Context.RootKey; 330 for I := 0 to Modules.Count - 1 do 331 with TModule(Modules[I]) do begin 332 OpenKey(Context.Key + '\' + Identification, True); 333 Running := ReadBoolWithDefault('Run', Enabled); 334 end; 335 finally 336 Free; 337 end; 338 end; 339 340 procedure TModuleManager.SaveToRegistry(Context: TRegistryContext); 341 var 342 I: Integer; 343 begin 344 with TRegistryEx.Create do 345 try 346 RootKey := Context.RootKey; 347 for I := 0 to Modules.Count - 1 do 348 with TModule(Modules[I]) do begin 349 OpenKey(Context.Key + '\' + Identification, True); 350 WriteBool('Run', Running); 351 end; 352 finally 353 Free; 354 end; 310 355 end; 311 356 … … 318 363 end; 319 364 365 procedure TModule.BeforeStart; 366 begin 367 if Running then Exit; 368 if not Installed then Install; 369 Manager.StartDependencies(Identification, Dependencies); 370 end; 371 372 procedure TModule.AfterStart; 373 begin 374 FRunning := True; 375 end; 376 377 procedure TModule.BeforeStop; 378 begin 379 if not Running then Exit; 380 FRunning := False; 381 Manager.StopDependencies(Identification); 382 end; 383 384 procedure TModule.AfterStop; 385 begin 386 end; 387 320 388 procedure TModule.SetInstalled(AValue: Boolean); 321 389 begin … … 324 392 end; 325 393 394 procedure TModule.SetEnabled(AValue: Boolean); 395 begin 396 if FEnabled = AValue then Exit; 397 FEnabled := AValue; 398 if not FEnabled and FInstalled then Uninstall; 399 end; 400 326 401 procedure TModule.Start; 327 402 begin 328 if Running then Exit;329 Manager.StartDependencies(Identification, Dependencies);330 FRunning := True;403 BeforeStart; 404 // Do something 405 AfterStart; 331 406 end; 332 407 333 408 procedure TModule.Stop; 334 409 begin 335 if not Running then Exit;336 Manager.StopDependencies(Identification);337 FRunning := False;410 BeforeStop; 411 // Do something 412 AfterStop; 338 413 end; 339 414 … … 403 478 begin 404 479 Running := False; 405 Description.Free;406 Dependencies.Free;407 inherited Destroy;480 FreeAndNil(FDescription); 481 FreeAndNil(FDependencies); 482 inherited; 408 483 end; 409 484 -
trunk/Pages/UPageAdmin.pas
r103 r105 64 64 with TWebSession(HandlerData) do begin 65 65 with HtmlDocument.Body, THtmlString(SubItems.AddNew(THtmlString.Create)) do begin 66 TModuleSystem( Core.ModuleManager.FindModuleByName('System')).UpdateModuleList;66 TModuleSystem(ModuleManager.FindModuleByName('System')).UpdateModuleList; 67 67 Text := 'Seznam modulů synchronizován'; 68 68 Text := Text + '<br/><br/>'; … … 82 82 '<table class="WideTable"><tr><th>Name</th><th>Installed</th><th>Title</th><th>Version</th>' + 83 83 '<th>License</th><th>Author</th><th>Decsription</th><th>Dependencies</th><th>Actions</th></tr>'; 84 for I := 0 to Core.ModuleManager.Modules.Count - 1 do85 with TModule( Core.ModuleManager.Modules[I]) do begin84 for I := 0 to ModuleManager.Modules.Count - 1 do 85 with TModule(ModuleManager.Modules[I]) do begin 86 86 Text := Text + '<tr><td>' + Identification + '</td><td>' + BooleanText[Installed] + '</td><td>' + Title + 87 87 '</td><td>' + Version + '</td><td>' + License + '</td><td>' + Author + … … 106 106 if Request.Query.SearchKey('name') <> -1 then begin 107 107 ModuleName := Request.Query.Values['name']; 108 Module := Core.ModuleManager.FindModuleByName(ModuleName);108 Module := ModuleManager.FindModuleByName(ModuleName); 109 109 if Assigned(Module) then begin 110 110 Text := 'Installing module ' + ModuleName; … … 128 128 if Request.Query.SearchKey('name') <> -1 then begin 129 129 ModuleName := Request.Query.Values['name']; 130 Module := Core.ModuleManager.FindModuleByName(ModuleName);130 Module := ModuleManager.FindModuleByName(ModuleName); 131 131 if Assigned(Module) then begin 132 132 Text := 'Uninstalling module ' + ModuleName; -
trunk/Pages/UServerInfoPage.pas
r103 r105 6 6 7 7 uses 8 Classes, SysUtils, FileUtil, UWebPage, UWebApp, UHTTPServer ;8 Classes, SysUtils, FileUtil, UWebPage, UWebApp, UHTTPServer, UModuleUser; 9 9 10 10 type … … 17 17 { private declarations } 18 18 public 19 { public declarations }19 ModuleUser: TModuleUser; 20 20 end; 21 21 … … 35 35 begin 36 36 with TWebSession(HandlerData) do begin 37 LoadUserInfo;37 ModuleUser.LoadUserInfo; 38 38 Session.Values['Test'] := 'Tst'; 39 39 TCore(MainModule).WebApp1.HTTPServer.ServerInfo(HandlerData); -
trunk/UCore.pas
r103 r105 17 17 18 18 type 19 TCore = class;20 21 22 19 { TCore } 23 20 … … 27 24 procedure WebApp1PageProduce(HandlerData: THTTPHandlerData); 28 25 private 29 FGeneratePage: TGeneratePageEvent;30 26 procedure Show(Content: string); 31 procedure RegisterModules;32 procedure CheckModules;33 27 public 34 28 CommonDatabase: TSqlDatabase; 35 ModuleManager: TModuleManager;36 29 Load: string; 37 30 Unload: string; … … 47 40 NetworkPort: Integer; 48 41 MaxConnections: Integer; 49 Pages: TPageList;50 42 DatabaseHostname: string; 51 43 DatabaseUserName: string; 52 44 DatabasePassword: string; 53 45 DatabaseSchema: string; 54 procedure GeneratePageDefault(ASession: TWebSession; Page: TWebPage);55 46 procedure LoadFromRegistry; 56 47 procedure SaveToRegistry; … … 58 49 constructor Create(AOwner: TComponent); override; 59 50 destructor Destroy; override; 60 property GeneratePage: TGeneratePageEvent read FGeneratePage write FGeneratePage;61 51 end; 62 52 … … 67 57 implementation 68 58 69 uses70 UModuleSystem, UModuleZdechovNET, UModuleUser, UPageAdmin, UModuleTV,71 UModuleFinance, UModuleNetwork, UModulePortal, UModuleIS;72 73 resourcestring74 SError = '<div>Error: %s</div>';75 76 59 77 60 { TCore } 78 79 procedure TCore.GeneratePageDefault(ASession: TWebSession; Page: TWebPage);80 var81 I: Integer;82 begin83 with ASession do begin84 HtmlDocument.ContentLanguage := 'cs';85 GlobalTitle := 'WebSystem';86 87 //Page.Page.OnProduce(HandlerData);88 HtmlDocument.Title := Page.Caption;89 with HtmlDocument.AsXmlDocument do90 try91 Formated := TCore(MainModule).FormatHTML;92 Response.Content.WriteString(AsString);93 finally94 Free;95 end;96 end;97 end;98 61 99 62 constructor TCore.Create(AOwner: TComponent); 100 63 begin 101 64 inherited; 102 ModuleManager := TModuleManager.Create(nil);103 Pages := TPageList.Create;104 65 CommonDatabase := TSqlDatabase.Create(nil); 105 66 106 67 LoadFromRegistry; 107 with Pages do begin108 RegisterPage(TPageAdmin, PageAdmin, 'administration');109 end;110 68 with WebApp1 do begin 111 69 if ServerType = stTCP then begin … … 121 79 //SaveToRegistry; 122 80 FreeAndNil(CommonDatabase); 123 ModuleManager.StopAll;124 FreeAndNil(ModuleManager);125 FreeAndNil(Pages);126 81 inherited; 127 82 end; … … 154 109 end; 155 110 156 procedure TCore.RegisterModules;157 begin158 with ModuleManager do begin159 RegisterModule(TModuleSystem.Create(nil), True);160 RegisterModule(TModuleUser.Create(nil), True);161 RegisterModule(TModuleZdechovNET.Create(nil), True);162 RegisterModule(TModuleTV.Create(nil), True);163 RegisterModule(TModuleFinance.Create(nil), True);164 RegisterModule(TModuleNetwork.Create(nil), True);165 RegisterModule(TModulePortal.Create(nil), True);166 RegisterModule(TModuleIS.Create(nil), True);167 end;168 end;169 170 procedure TCore.CheckModules;171 var172 DbRows: TDbRows;173 Module: TModule;174 I: Integer;175 begin176 try177 DbRows := TDbRows.Create;178 CommonDatabase.Query(DbRows, 'SELECT * FROM INFORMATION_SCHEMA.TABLES ' +179 'WHERE TABLE_SCHEMA = "' + CommonDatabase.Database + '" AND TABLE_NAME = "SystemModule"');180 Module := ModuleManager.FindModuleByName('System');181 if DbRows.Count > 0 then Module.SetInstalledState(True)182 else Module.SetInstalledState(False);183 finally184 DbRows.Free;185 end;186 end;187 188 111 procedure TCore.WebApp1PageProduce(HandlerData: THTTPHandlerData); 189 112 var 190 FileName: string;191 PageName: string;192 Page: TRegistredPage;193 113 NewSession: TWebSession; 194 BaseUrlParts: TListString;195 114 begin 196 with HandlerData do begin 197 try 198 BaseUrlParts := TListString.Create; 199 BaseUrlParts.Explode(BaseURL, '/', StrToStr); 200 while (BaseUrlParts.Count > 0) and (Request.Path.Count > 0) and 201 (BaseUrlParts[0] = Request.Path[0]) do begin 202 BaseUrlParts.Delete(0); 203 Request.Path.Delete(0); 204 end; 205 finally 206 BaseUrlParts.Free; 207 end; 208 if Request.Path.Count > 0 then PageName := Request.Path[0] 209 else PageName := ''; 210 Page := Pages.FindByName(PageName); 211 if Assigned(Page) then begin 212 NewSession := TWebSession.Create; 213 NewSession.MainModule := Self; 214 NewSession.Assign(HandlerData); 215 NewSession.TimeStart := Now; 216 NewSession.Database.HostName := DatabaseHostName; 217 NewSession.Database.Password := DatabasePassword; 218 NewSession.Database.Database := DatabaseSchema; 219 NewSession.Database.UserName := DatabaseUserName; 220 NewSession.InitDatabase; 221 try 222 Page.Page.OnProduce(NewSession); 223 except 224 on E: Exception do begin 225 THTMLString(TWebSession(NewSession).HtmlDocument.Body.SubItems.AddNew(THtmlString.Create)). 226 Text := Format(SError, [E.Message]); 227 if Assigned(GeneratePage) then GeneratePage(NewSession, Page.Page) 228 else GeneratePageDefault(NewSession, Page.Page); 229 end; 230 end; 231 HandlerData.Assign(NewSession); 232 end else begin 233 WebApp1.HTTPServer.FileResponse(HandlerData) 234 end; 235 end; 115 NewSession := TWebSession.Create; 116 NewSession.MainModule := Self; 117 NewSession.Assign(HandlerData); 118 NewSession.TimeStart := Now; 119 NewSession.Database.HostName := DatabaseHostName; 120 NewSession.Database.Password := DatabasePassword; 121 NewSession.Database.Database := DatabaseSchema; 122 NewSession.Database.UserName := DatabaseUserName; 123 NewSession.InitDatabase; 124 NewSession.BaseURL := BaseURL; 125 NewSession.Run; 126 HandlerData.Assign(NewSession); 236 127 end; 237 128 … … 296 187 CommonDatabase.Connect; 297 188 298 RegisterModules;299 CheckModules;300 ModuleManager.StartInstalled;301 302 189 WebApp1.HTTPServer.DocumentRoot := ExtractFileDir(ParamStrUTF8(0)); 303 190 WebApp1.Run; -
trunk/ZdechovNET.lpi
r103 r105 36 36 </Target> 37 37 <SearchPaths> 38 <OtherUnitFiles Value="/usr/lib/mysql;/usr/lib64/mysql;Application;WebServer;Network;Pages;Modules/User;Common;Modules/System;Modules/ZdechovNET;Modules/TV;Modules/Finance;Modules/Network;Modules/Portal;Modules/IS "/>38 <OtherUnitFiles Value="/usr/lib/mysql;/usr/lib64/mysql;Application;WebServer;Network;Pages;Modules/User;Common;Modules/System;Modules/ZdechovNET;Modules/TV;Modules/Finance;Modules/Network;Modules/Portal;Modules/IS;Modules/News;Modules/Base"/> 39 39 <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> 40 40 </SearchPaths> … … 117 117 </Item7> 118 118 </RequiredPackages> 119 <Units Count="3 5">119 <Units Count="37"> 120 120 <Unit0> 121 121 <Filename Value="ZdechovNET.lpr"/> … … 216 216 <Filename Value="Modules/ZdechovNET/UInternetPage.pas"/> 217 217 <IsPartOfProject Value="True"/> 218 <HasResources Value="True"/> 218 <ComponentName Value="InternetPage"/> 219 <HasResources Value="True"/> 220 <ResourceBaseClass Value="DataModule"/> 219 221 <UnitName Value="UInternetPage"/> 220 222 </Unit16> … … 326 328 <UnitName Value="UUser"/> 327 329 </Unit34> 330 <Unit35> 331 <Filename Value="Modules/News/UModuleNews.pas"/> 332 <IsPartOfProject Value="True"/> 333 <UnitName Value="UModuleNews"/> 334 </Unit35> 335 <Unit36> 336 <Filename Value="Modules/Base/UModuleBase.pas"/> 337 <IsPartOfProject Value="True"/> 338 <UnitName Value="UModuleBase"/> 339 </Unit36> 328 340 </Units> 329 341 </ProjectOptions> -
trunk/languages/index.cs.po
r103 r105 59 59 60 60 #: ucore.serror 61 msgctxt "ucore.serror" 61 62 msgid "<div>Error: %s</div>" 62 63 msgstr "" … … 117 118 msgstr "" 118 119 120 #: uwebsession.serror 121 msgctxt "uwebsession.serror" 122 msgid "<div>Error: %s</div>" 123 msgstr "" 124 -
trunk/languages/index.po
r103 r105 51 51 52 52 #: ucore.serror 53 msgctxt "ucore.serror" 53 54 msgid "<div>Error: %s</div>" 54 55 msgstr "" … … 107 108 msgstr "" 108 109 110 #: uwebsession.serror 111 msgctxt "uwebsession.serror" 112 msgid "<div>Error: %s</div>" 113 msgstr "" 114
Note:
See TracChangeset
for help on using the changeset viewer.