source: trunk/Modules/Dance/Dance.php

Last change on this file was 70, checked in by chronos, 7 weeks ago
  • Fixed: Dance item doesn't have link property.
File size: 7.3 KB
Line 
1<?php
2
3class ModuleDance extends Module
4{
5 function __construct($System)
6 {
7 parent::__construct($System);
8 $this->Name = 'Dance';
9 $this->Version = '1.0';
10 $this->Creator = 'Chronos';
11 $this->License = 'GNU/GPL';
12 $this->Description = 'List of dances';
13 $this->Dependencies = array();
14 $this->RSSChannels = array();
15 }
16
17 function Start(): void
18 {
19 $this->System->RegisterPage(['tance'], 'PageDanceList');
20 $this->System->RegisterPage(['tanec'], 'PageDance');
21 $this->System->RegisterPage(['figura'], 'PageDanceFigure');
22 $this->System->RegisterPage(['figury'], 'PageDanceFigureList');
23 Core::Cast($this->System)->RegisterMenuItem('/tance', 'Tance');
24 Core::Cast($this->System)->RegisterMenuItem('/figury', 'Figury');
25 }
26}
27
28class PageDance extends Page
29{
30 function __construct($System)
31 {
32 parent::__construct($System);
33 $this->Title = 'Tanec';
34 }
35
36 function Show(): string
37 {
38 $Output = '';
39 if (count($this->System->PathItems) > 1)
40 {
41 $id = $this->System->PathItems[1] * 1;
42 } else return 'Položka nenalezena';
43 $Output .= '<div class="title">Tanec</div>';
44 $DbResult = $this->Database->select('Dance', '*, (SELECT DanceGroup.Name FROM DanceGroup WHERE DanceGroup.Id=Dance.Group) AS DanceGroupName', 'Id='.$id);
45 if ($DbResult->num_rows > 0)
46 {
47 $DanceItem = $DbResult->fetch_assoc();
48 $Output .= '<table class="ItemTable">'.
49 '<tr><th>Jméno</th><td>'.$DanceItem['Name'].'</td></tr>'.
50 '<tr><th>Skupina</th><td>'.$DanceItem['DanceGroupName'].'</td></tr>';
51 $Output .= '</table>';
52 } else $Output .= 'Položka nenalezena';
53
54 $Output .= '<br/><div class="title">Taneční figury</div>';
55 $Output .= '<table class="WideTable">';
56 $Output .= '<tr><th>Český název</th><th>Anglický název</th><th>Detail</th></tr>';
57 $DbResult = $this->Database->select('DanceFigure', '*', '(`Dance`='.$id.')');
58 while ($DanceFigure = $DbResult->fetch_assoc())
59 {
60 $Output .= '<tr>'.
61 '<td>'.$DanceFigure['NameCz'].'</td>'.
62 '<td>'.$DanceFigure['NameEn'].'</td>'.
63 '<td><a href="'.$this->System->Link('/figura/'.$DanceFigure['Id'].'/').'">Ukázat</a></td>';
64 '</tr>';
65 }
66 $Output .= '</table>';
67
68 $Output .= '<br/><div class="title">Výuková videa</div>';
69 $Output .= '<table class="WideTable">';
70 $Output .= '<tr><th>Název</th><th>Skupina</th><th>Odkaz</th></tr>';
71 $DbResult = $this->Database->select('Resource', '*, (SELECT Name FROM ResourceGroup WHERE ResourceGroup.Id=Resource.Group) AS GroupName', '(`Dance`='.$id.')');
72 while ($DbRow = $DbResult->fetch_assoc())
73 {
74 $Output .= '<tr>'.
75 '<td>'.$DbRow['Name'].'</td>'.
76 '<td>'.$DbRow['GroupName'].'</td>'.
77 '<td><a href="'.$DbRow['URL'].'">'.$DbRow['URL'].'</a></td>'.
78 '</tr>';
79 }
80 $Output .= '</table>';
81
82 /*
83 $DbResult2 = $this->Database->select('ResourceGroup', '*');
84 while ($ResourceGroup = $DbResult2->fetch_assoc())
85 {
86 $Output .= '<th>'.$ResourceGroup['Name'].'</th>';
87 }
88
89 $DbResult2 = $this->Database->select('ResourceGroup', '*');
90 while ($ResourceGroup = $DbResult2->fetch_assoc())
91 {
92 $Output .= '<td>';
93 while ($Resource = $DbResult3->fetch_assoc())
94 {
95 $Output .= '<a href="'.$Resource['URL'].'">'.$Resource['Name'].'</a> ';
96 }
97 $Output .= '</td>';
98 }*/
99
100 return $Output;
101 }
102}
103
104class PageDanceList extends Page
105{
106 function __construct($System)
107 {
108 parent::__construct($System);
109 $this->Title = 'Tance';
110 }
111
112 function Show(): string
113 {
114 $Output = '<div class="title">Tance</div>';
115 $Output .= '<table class="WideTable">';
116 $Output .= '<tr><th>Název</th><th>Skupina</th><th>Detail</th></tr>';
117 $DbResult = $this->Database->select('Dance', '*, (SELECT Name FROM DanceGroup WHERE DanceGroup.Id=Dance.Group) AS GroupName', '1 ORDER BY `Name`');
118 while ($Dance = $DbResult->fetch_assoc())
119 {
120 $Output .= '<tr>'.
121 '<td>'.$Dance['Name'].'</td>'.
122 '<td>'.$Dance['GroupName'].'</td>'.
123 '<td><a href="'.$this->System->Link('/tanec/'.$Dance['Id'].'/').'">Ukázat</a></td>';
124 $Output .= '</tr>';
125 }
126 $Output .= '</table>';
127
128 return $Output;
129 }
130}
131
132class PageDanceFigure extends Page
133{
134 function __construct($System)
135 {
136 parent::__construct($System);
137 $this->Title = 'Figura';
138 $this->Description = 'Taneční figura';
139 }
140
141 function Show(): string
142 {
143 $Output = '';
144 if (count($this->System->PathItems) > 1)
145 {
146 $id = $this->System->PathItems[1] * 1;
147 } else return 'Položka nenalezena';
148 $Output .= '<div class="title">Taneční figura</div>';
149 $DbResult = $this->Database->select('DanceFigure', '*, (SELECT Dance.Name FROM Dance WHERE Dance.Id=DanceFigure.Dance) AS DanceName', 'Id='.$id);
150 if ($DbResult->num_rows > 0)
151 {
152 $DbRow = $DbResult->fetch_assoc();
153 $Output .= '<table class="ItemTable">'.
154 '<tr><th>České jméno</th><td>'.$DbRow['NameCz'].'</td></tr>'.
155 '<tr><th>Anglické jméno</th><td>'.$DbRow['NameEn'].'</td></tr>'.
156 '<tr><th>Tanec</th><td>'.$DbRow['DanceName'].'</td></tr>';
157 $Output .= '</table>';
158 } else $Output .= 'Položka nenalezena';
159
160 /*$Output .= '<br/><div class="title">Videa</div>';
161 $Output .= '<table class="WideTable">';
162 $Output .= '<tr><th>Skupina videí</th><th></th><th>Detail</th></tr>';
163 $DbResult = $this->Database->select('DanceFigure', '*', '(`Dance`='.$id.')');
164 while ($DanceFigure = $DbResult->fetch_assoc())
165 {
166 $Output .= '<tr>'.
167 '<td>'.$DanceFigure['NameCz'].'</td>'.
168 '<td>'.$DanceFigure['NameEn'].'</td>'.
169 '<td><a href="'.$this->System->Link('/tance/figura/'.$DanceFigure['Id'].'/').'">Ukázat</a></td>';
170 '</tr>';
171 }
172 $Output .= '</table>';
173 */
174 /*
175 $DbResult2 = $this->Database->select('ResourceGroup', '*');
176 while ($ResourceGroup = $DbResult2->fetch_assoc())
177 {
178 $Output .= '<th>'.$ResourceGroup['Name'].'</th>';
179 }
180
181 $DbResult2 = $this->Database->select('ResourceGroup', '*');
182 while ($ResourceGroup = $DbResult2->fetch_assoc())
183 {
184 $Output .= '<td>';
185 while ($Resource = $DbResult3->fetch_assoc())
186 {
187 $Output .= '<a href="'.$Resource['URL'].'">'.$Resource['Name'].'</a> ';
188 }
189 $Output .= '</td>';
190 }*/
191
192 return $Output;
193 }
194}
195
196class PageDanceFigureList extends Page
197{
198 function __construct($System)
199 {
200 parent::__construct($System);
201 $this->Title = 'Figury';
202 $this->Description = 'Taneční figury';
203 }
204
205 function Show(): string
206 {
207 $Output = '<div class="title">Taneční figury</div>';
208 $Output .= '<table class="WideTable">';
209 $Output .= '<tr><th>Název</th><th>Skupina</th><th>Tanec</th><th>Detail</th></tr>';
210 $DbResult = $this->Database->select('DanceFigure', '*, (SELECT Dance.Name FROM Dance WHERE Dance.Id=DanceFigure.Dance) AS DanceName', '1 ORDER BY `NameCz`');
211 while ($DbRow = $DbResult->fetch_assoc())
212 {
213 $Output .= '<tr>'.
214 '<td>'.$DbRow['NameCz'].'</td>'.
215 '<td>'.$DbRow['NameEn'].'</td>'.
216 '<td>'.$DbRow['DanceName'].'</td>'.
217 '<td><a href="'.$this->System->Link('/figura/'.$DbRow['Id'].'/').'">Ukázat</a></td>';
218 $Output .= '</tr>';
219 }
220 $Output .= '</table>';
221
222 return $Output;
223 }
224}
Note: See TracBrowser for help on using the repository browser.