source: trunk/Modules/Meet/MeetPage.php@ 59

Last change on this file since 59 was 56, checked in by chronos, 5 years ago
  • Modified: Updated Common package.
File size: 10.1 KB
Line 
1<?php
2
3class ModuleMeet extends AppModule
4{
5 function __construct($System)
6 {
7 parent::__construct($System);
8 $this->Name = 'Meet';
9 $this->Version = '1.0';
10 $this->Creator = 'Chronos';
11 $this->License = 'GNU/GPL';
12 $this->Description = 'List of dance meet items';
13 $this->Dependencies = array();
14 $this->RSSChannels = array();
15 }
16
17 function Start()
18 {
19 $this->System->RegisterPage('seznamka', 'PageMeetList');
20 $this->System->RegisterPage(array('seznamka', 'inzerat'), 'PageMeetItem');
21 $this->System->RegisterPage(array('seznamka', 'aktualizace'), 'PageMeetUpdate');
22 $this->System->RegisterPage(array('seznamka', 'rss'), 'PageMeetRss');
23 $this->System->RegisterMenuItem('/seznamka', 'Seznamka');
24 }
25}
26
27class PageMeetList extends Page
28{
29 function __construct($System)
30 {
31 parent::__construct($System);
32 $this->FullTitle = 'Taneční seznamka';
33 $this->ShortTitle = 'Seznamka';
34 }
35
36 function Show()
37 {
38 $Filter = new Filter();
39 $Filter->Items = array(
40 array('Name' => 'pohlavi', 'Type' => 'Enumeration', 'DbName' => 'Gender', 'Title' => 'Pohlaví',
41 'States' => array(0 => 'Obě', 1 => 'Muži', 2 => 'Ženy')),
42 array('Name' => 'name', 'Type' => 'String', 'DbName' => 'Name', 'Title' => 'Jméno'),
43 array('Name' => 'vek', 'Type' => 'Integer', 'DbName' => 'Age', 'Title' => 'Věk', 'Units' => 'let'),
44 array('Name' => 'vyska', 'Type' => 'Integer', 'DbName' => 'Height', 'Title' => 'Výška', 'Units' => 'cm'),
45 array('Name' => 'vaha', 'Type' => 'Integer', 'DbName' => 'Weight', 'Title' => 'Váha', 'Units' => 'Kg'),
46 array('Name' => 'message', 'Type' => 'String', 'DbName' => 'Message', 'Title' => 'Zpráva'),
47 array('Name' => 'location', 'Type' => 'String', 'DbName' => 'Location', 'Title' => 'Umístění'),
48 array('Name' => 'source', 'Type' => 'String', 'DbName' => 'SourceName', 'Title' => 'Import'),
49 );
50
51 $Output = '';
52 $this->Title = 'Seznamka - '.$this->Title;
53 if (array_key_exists('lvm', $_GET) and ($_GET['lvm'] == 'seznam'))
54 $this->RawPage = true;
55 else $Output .= '<div class="title">Inzeráty</div>';
56
57 $Output .= $Filter->GetOutput($this->System->Link('/seznamka/'));
58 $Where = $Filter->GetWhere($this->Database);
59
60 $DbResult = $this->Database->query('SELECT COUNT(*) FROM (SELECT *, '.
61 '(SELECT MeetSource.Name FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceName FROM `MeetItem`) AS T WHERE (T.Hidden=0) AND '.$Where);
62 $DbRow = $DbResult->fetch_row();
63 $PageList = GetPageList($DbRow[0]);
64
65 $Gender = array('', 'Muž', 'Žena');
66 $Output .= '<div id="list_content">';
67 $Output .= $PageList['Output'];
68 $TableColumns = array(
69 array('Name' => 'Time', 'Title' => 'Čas'),
70 array('Name' => 'Name', 'Title' => 'Jméno'),
71 array('Name' => 'Height', 'Title' => 'Výška'),
72 array('Name' => 'Age', 'Title' => 'Věk'),
73 array('Name' => 'Weight', 'Title' => 'Váha'),
74 array('Name' => 'Location', 'Title' => 'Umístění'),
75 array('Name' => 'Gender', 'Title' => 'Pohlaví'),
76 array('Name' => 'Message', 'Title' => 'Zpráva'),
77 array('Name' => 'Source', 'Title' => 'Import'),
78 array('Name' => '', 'Title' => 'Detail'),
79 );
80 $Order = GetOrderTableHeader($TableColumns, 'Time', 1);
81 $Output .= '<table class="WideTable">';
82 $Output .= $Order['Output'];
83 $DbResult = $this->Database->query('SELECT * FROM (SELECT *, (SELECT MeetSource.Name FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceName, '.
84 '(SELECT MeetSource.URL FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceURL FROM MeetItem) AS T WHERE (T.Hidden=0) AND '.
85 $Where.$Order['SQL'].$PageList['SQLLimit']);
86 while ($MeetItem = $DbResult->fetch_assoc())
87 {
88 $Output .= '<tr>'.
89 '<td>'.HumanDate(MysqlDateToTime($MeetItem['Time'])).'</td>'.
90 '<td>'.$MeetItem['Name'].'</td>'.
91 '<td>'.$MeetItem['Height'].'</td>'.
92 '<td>'.$MeetItem['Age'].'</td>'.
93 '<td>'.$MeetItem['Weight'].'</td>'.
94 '<td>'.$MeetItem['Location'].'</td>'.
95 '<td>'.$Gender[$MeetItem['Gender']].'</td>'.
96 '<td>'.$MeetItem['Message'].'</td>'.
97 '<td><a href="'.$MeetItem['SourceURL'].'">'.$MeetItem['SourceName'].'</a></td>'.
98 '<td><a href="'.$this->System->Link('/seznamka/inzerat/'.$MeetItem['Id']).'">Ukázat</a></td>';
99 $Output .= '</tr>';
100 }
101 $Output .= '</table>';
102 $Output .= $PageList['Output'];
103 $Output .= '</div>';
104 if (array_key_exists('lvm', $_GET) and ($_GET['lvm'] == 'seznam'))
105 {
106 }
107 else
108 {
109 $Output .= '<div><a href="'.$this->System->Link('/seznamka/rss/').'"><img src="'.$this->System->Link('/images/rss20.png').'" alt="rss20"/></a></div>';
110 }
111 return $Output;
112 }
113}
114
115class PageMeetUpdate extends Page
116{
117 function __construct($System)
118 {
119 parent::__construct($System);
120 $this->FullTitle = 'Aktualizace taneční seznamky';
121 $this->ShortTitle = 'Aktualizace seznamky';
122 }
123
124 function Show()
125 {
126 $MeetSources = new MeetSources();
127 $MeetSources->Database = $this->Database;
128 if (array_key_exists('i', $_GET)) $Output = $MeetSources->Parse($_GET['i']);
129 else $Output = $MeetSources->Parse();
130 return $Output;
131 }
132}
133
134class PageMeetItem extends Page
135{
136 function __construct($System)
137 {
138 parent::__construct($System);
139 $this->FullTitle = 'Inzerát taneční seznamky';
140 $this->ShortTitle = 'Inzerát seznamky';
141 }
142
143 function Show()
144 {
145 $this->Title = 'Inzerát - Seznamka - '.$this->Title;
146 $Output = '';
147 if (count($this->System->PathItems) > 2)
148 {
149 $id = $this->System->PathItems[2] * 1;
150 } else return 'Položka nenalezena';
151 if ($this->System->IsAdmin())
152 {
153 if (array_key_exists('hide', $_GET)) $this->Database->update('MeetItem', 'Id='.$id, array('Hidden' => 1));
154 if (array_key_exists('unhide', $_GET)) $this->Database->update('MeetItem', 'Id='.$id, array('Hidden' => 0));
155 }
156
157 $Output .= '<div class="title">Inzerát</div>';
158 $Gender = array('', 'Muž', 'Žena');
159 $DbResult = $this->Database->select('MeetItem', '*, (SELECT MeetSource.Name FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceName, '.
160 '(SELECT MeetSource.URL FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceURL', 'Id='.$id);
161 if ($DbResult->num_rows > 0)
162 {
163 $MeetItem = $DbResult->fetch_assoc();
164 if (($MeetItem['Hidden'] == '1') and !$this->System->IsAdmin())
165 return 'Položka nenalezena';
166 if ($MeetItem['Link'] != '') $Link = '<a href="'.$MeetItem['Link'].'">Odkaz</a>';
167 else $Link = '';
168 $Output .= '<table class="ItemTable">'.
169 '<tr><th>Čas</th><td>'.HumanDate(MysqlDateToTime($MeetItem['Time'])).'</td></tr>'.
170 '<tr><th>Pohlaví</th><td>'.$Gender[$MeetItem['Gender']].'</td></tr>'.
171 '<tr><th>Jméno</th><td>'.$MeetItem['Name'].'</td></tr>'.
172 '<tr><th>Výška</th><td>'.$MeetItem['Height'].'</td></tr>'.
173 '<tr><th>Věk</th><td>'.$MeetItem['Age'].'</td></tr>'.
174 '<tr><th>Váha</th><td>'.$MeetItem['Weight'].'</td></tr>'.
175 '<tr><th>Umístění</th><td>'.$MeetItem['Location'].'</td></tr>'.
176 '<tr><th>Email</th><td>'.$MeetItem['Email'].'</td></tr>'.
177 '<tr><th>Telefón</th><td>'.$MeetItem['Phone'].'</td></tr>'.
178 '<tr><th>Zpráva</th><td>'.$MeetItem['Message'].'</td></tr>'.
179 '<tr><th>Původní web</th><td>'.$Link.'</td></tr>'.
180 '<tr><th>Zdroj importu</th><td><a href="'.$MeetItem['SourceURL'].'">'.$MeetItem['SourceName'].'</a></td></tr>';
181 $Output .= '</table>';
182 if ($this->System->IsAdmin()) {
183 if ($MeetItem['Hidden'] == '1')
184 $Output .= '<div>Skrytá položka <a href="?unhide">Zviditelnit</a></div>';
185 else $Output .= '<div>Viditelná položka <a href="?hide">Skrýt</a></div>';
186 }
187 } else $Output .= 'Položka nenalezena';
188 return $Output;
189 }
190}
191
192class PageMeetRss extends Page
193{
194 function __construct($System)
195 {
196 parent::__construct($System);
197 $this->FullTitle = 'RSS kanál taneční seznamky';
198 $this->ShortTitle = 'RSS inzeráty seznamky';
199 }
200
201 function Show()
202 {
203 global $Config;
204
205 $this->RawPage = true;
206 $RSS = new RSS();
207 $RSS->Title = 'Taneční seznamka';
208 $RSS->Description = '';
209 $RSS->Link = $this->System->AbsoluteLink('/seznamka/');
210
211 $DbResult = $this->Database->select('MeetItem', '*, (SELECT MeetSource.Name FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceName, '.
212 '(SELECT MeetSource.URL FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceURL', '`Hidden`=0 ORDER BY `Time` DESC LIMIT 30');
213 while ($MeetItem = $DbResult->fetch_assoc())
214 {
215 $Title = $MeetItem['Name'];
216 if ($MeetItem['Age'] != '') $Title .= ', '.$MeetItem['Age'].' let';
217 if ($MeetItem['Weight'] != '') $Title .= ', '.$MeetItem['Height'].' cm';
218 if ($MeetItem['Location'] != '') $Title .= ', '.$MeetItem['Location'];
219 $Description = $MeetItem['Message']."<br/>\n";
220 if ($MeetItem['Email'] != '') $Description .= '<br/>Email: '.$MeetItem['Email'];
221 if ($MeetItem['Phone'] != '') $Description .= '<br/>Telefon: '.$MeetItem['Phone'];
222 if ($MeetItem['Age'] != '') $Description .= '<br/>Věk: '.$MeetItem['Age'].' let';
223 if ($MeetItem['Height'] != '') $Description .= '<br/>Výška: '.$MeetItem['Height'].' cm';
224 if ($MeetItem['Weight'] != '') $Description .= '<br/>Váha: '.$MeetItem['Weight'].' kg';
225 $Description .= '<br/>Zdroj importu: <a href="'.$MeetItem['SourceURL'].'">'.$MeetItem['SourceName'].'</a>';
226 $Time = MysqlDateTimeToTime($MeetItem['Time']);
227 $TimeImport = MysqlDateTimeToTime($MeetItem['TimeImport']);
228 // Append time part of TimeImport time to item time so new items will appear in correct time order even if item doesn't have time part specified
229 if (TimeToMysqlTime($Time) == '00:00:00')
230 {
231 $Time = MysqlDateTimeToTime(TimeToMysqlDate($Time).' '.TimeToMysqlTime($TimeImport));
232 }
233 $RSS->Items[] = array(
234 'Title' => $Title,
235 'Description' => $Description,
236 'Time' => $Time,
237 'Link' => $this->System->AbsoluteLink('/seznamka/inzerat/'.$MeetItem['Id'].'/'),
238 );
239 }
240
241 return $RSS->Generate();
242 }
243}
Note: See TracBrowser for help on using the repository browser.