source: trunk/Modules/TV/ModuleTV.pas

Last change on this file was 151, checked in by chronos, 5 months ago
File size: 2.6 KB
Line 
1unit ModuleTV;
2
3interface
4
5uses
6 Classes, SysUtils, ModularSystem, ModuleBase, WebPage;
7
8type
9
10 { TModuleUser }
11
12 TModuleTV = class(TModule)
13 private
14 WebPageTV: TWebPage;
15 public
16 ModuleBase: TModuleBase;
17 constructor Create(Owner: TComponent); override;
18 destructor Destroy; override;
19 procedure Start; override;
20 procedure Stop; override;
21 procedure Install; override;
22 procedure Uninstall; override;
23 procedure Upgrade; override;
24 end;
25
26
27implementation
28
29uses
30 Core, PageTV, SqlDatabase;
31
32{ TModuleTV }
33
34constructor TModuleTV.Create(Owner: TComponent);
35begin
36 inherited;
37 Identification := 'TV';
38 Title := 'Television channels';
39 Version := '1.0';
40 License := 'GNU/LGPL v3';
41 Author := 'Chronosoft';
42 Dependencies.Add('Base');
43end;
44
45destructor TModuleTV.Destroy;
46begin
47 inherited;
48end;
49
50procedure TModuleTV.Start;
51begin
52 BeforeStart;
53 ModuleBase := TModuleBase(Manager.FindModuleByName('Base'));
54 WebPageTV := TWebPageTV.Create(nil);
55 ModuleBase.Pages.RegisterPage(WebPageTV, 'tv');
56 AfterStart;
57end;
58
59procedure TModuleTV.Stop;
60begin
61 BeforeStop;
62 ModuleBase.Pages.UnregisterPage(WebPageTV);
63 FreeAndNil(WebPageTV);
64 ModuleBase := nil;
65 AfterStop;
66end;
67
68procedure TModuleTV.Install;
69var
70 DbRows: TDbRows;
71begin
72 try
73 DbRows := TDbRows.Create;
74
75 Core.Core.CommonDatabase.Query(DbRows,
76 'CREATE TABLE IF NOT EXISTS `TV` (' +
77 ' `Id` int(11) NOT NULL AUTO_INCREMENT,' +
78 ' `Name` varchar(16) COLLATE utf8_czech_ci NOT NULL,' +
79 ' `Frequency` int(11) NOT NULL DEFAULT "0",' +
80 ' `Norm` varchar(8) COLLATE utf8_czech_ci NOT NULL,' +
81 ' `Homepage` varchar(255) COLLATE utf8_czech_ci NOT NULL,' +
82 ' `Language` varchar(32) COLLATE utf8_czech_ci NOT NULL,' +
83 ' `ShortName` varchar(16) COLLATE utf8_czech_ci NOT NULL,' +
84 ' `Stream` varchar(255) COLLATE utf8_czech_ci NOT NULL,' +
85 ' `StreamWeb` varchar(255) COLLATE utf8_czech_ci NOT NULL,' +
86 ' `SourceType` varchar(255) COLLATE utf8_czech_ci NOT NULL,' +
87 ' `Category` varchar(255) COLLATE utf8_czech_ci NOT NULL,' +
88 ' PRIMARY KEY (`Id`)' +
89 ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;');
90
91 finally
92 DbRows.Free;
93 end;
94 inherited Install;
95end;
96
97procedure TModuleTV.Uninstall;
98var
99 DbRows: TDbRows;
100begin
101 inherited Uninstall;
102 try
103 DbRows := TDbRows.Create;
104 Core.Core.CommonDatabase.Query(DbRows, 'DROP TABLE IF EXISTS `TV`');
105 finally
106 DbRows.Free;
107 end;
108end;
109
110procedure TModuleTV.Upgrade;
111begin
112 inherited;
113end;
114
115end.
116
Note: See TracBrowser for help on using the repository browser.