1 | unit ModuleTV;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, ModularSystem, ModuleBase, WebPage;
|
---|
7 |
|
---|
8 | type
|
---|
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 |
|
---|
27 | implementation
|
---|
28 |
|
---|
29 | uses
|
---|
30 | Core, PageTV, SqlDatabase;
|
---|
31 |
|
---|
32 | { TModuleTV }
|
---|
33 |
|
---|
34 | constructor TModuleTV.Create(Owner: TComponent);
|
---|
35 | begin
|
---|
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');
|
---|
43 | end;
|
---|
44 |
|
---|
45 | destructor TModuleTV.Destroy;
|
---|
46 | begin
|
---|
47 | inherited;
|
---|
48 | end;
|
---|
49 |
|
---|
50 | procedure TModuleTV.Start;
|
---|
51 | begin
|
---|
52 | BeforeStart;
|
---|
53 | ModuleBase := TModuleBase(Manager.FindModuleByName('Base'));
|
---|
54 | WebPageTV := TWebPageTV.Create(nil);
|
---|
55 | ModuleBase.Pages.RegisterPage(WebPageTV, 'tv');
|
---|
56 | AfterStart;
|
---|
57 | end;
|
---|
58 |
|
---|
59 | procedure TModuleTV.Stop;
|
---|
60 | begin
|
---|
61 | BeforeStop;
|
---|
62 | ModuleBase.Pages.UnregisterPage(WebPageTV);
|
---|
63 | FreeAndNil(WebPageTV);
|
---|
64 | ModuleBase := nil;
|
---|
65 | AfterStop;
|
---|
66 | end;
|
---|
67 |
|
---|
68 | procedure TModuleTV.Install;
|
---|
69 | var
|
---|
70 | DbRows: TDbRows;
|
---|
71 | begin
|
---|
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;
|
---|
95 | end;
|
---|
96 |
|
---|
97 | procedure TModuleTV.Uninstall;
|
---|
98 | var
|
---|
99 | DbRows: TDbRows;
|
---|
100 | begin
|
---|
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;
|
---|
108 | end;
|
---|
109 |
|
---|
110 | procedure TModuleTV.Upgrade;
|
---|
111 | begin
|
---|
112 | inherited;
|
---|
113 | end;
|
---|
114 |
|
---|
115 | end.
|
---|
116 |
|
---|