| 1 | <?php
|
|---|
| 2 |
|
|---|
| 3 | class ModuleMeet extends Module
|
|---|
| 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(): void
|
|---|
| 18 | {
|
|---|
| 19 | $this->System->RegisterPage(['seznamka'], 'PageMeetList');
|
|---|
| 20 | $this->System->RegisterPage(['seznamka', 'inzerat'], 'PageMeetItem');
|
|---|
| 21 | $this->System->RegisterPage(['seznamka', 'aktualizace'], 'PageMeetUpdate');
|
|---|
| 22 | $this->System->RegisterPage(['seznamka', 'rss'], 'PageMeetRss');
|
|---|
| 23 | Core::Cast($this->System)->RegisterMenuItem('/seznamka', 'Seznamka');
|
|---|
| 24 | }
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | class PageMeetList extends Page
|
|---|
| 28 | {
|
|---|
| 29 | function __construct($System)
|
|---|
| 30 | {
|
|---|
| 31 | parent::__construct($System);
|
|---|
| 32 | $this->Title = 'Seznamka';
|
|---|
| 33 | $this->Description = 'Taneční seznamka';
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | function Show(): string
|
|---|
| 37 | {
|
|---|
| 38 | global $Config;
|
|---|
| 39 |
|
|---|
| 40 | $Filter = new Filter();
|
|---|
| 41 | $Filter->Items = array(
|
|---|
| 42 | array('Name' => 'pohlavi', 'Type' => 'Enumeration', 'DbName' => 'Gender', 'Title' => 'Pohlaví',
|
|---|
| 43 | 'States' => array(0 => 'Obě', 1 => 'Muži', 2 => 'Ženy')),
|
|---|
| 44 | array('Name' => 'name', 'Type' => 'String', 'DbName' => 'Name', 'Title' => 'Jméno'),
|
|---|
| 45 | array('Name' => 'vek', 'Type' => 'Integer', 'DbName' => 'Age', 'Title' => 'Věk', 'Units' => 'let'),
|
|---|
| 46 | array('Name' => 'vyska', 'Type' => 'Integer', 'DbName' => 'Height', 'Title' => 'Výška', 'Units' => 'cm'),
|
|---|
| 47 | array('Name' => 'vaha', 'Type' => 'Integer', 'DbName' => 'Weight', 'Title' => 'Váha', 'Units' => 'Kg'),
|
|---|
| 48 | array('Name' => 'message', 'Type' => 'String', 'DbName' => 'Message', 'Title' => 'Zpráva'),
|
|---|
| 49 | array('Name' => 'location', 'Type' => 'String', 'DbName' => 'Location', 'Title' => 'Umístění'),
|
|---|
| 50 | array('Name' => 'source', 'Type' => 'String', 'DbName' => 'SourceName', 'Title' => 'Zdroj'),
|
|---|
| 51 | );
|
|---|
| 52 |
|
|---|
| 53 | $Output = '';
|
|---|
| 54 | if (array_key_exists('lvm', $_GET) and ($_GET['lvm'] == 'seznam'))
|
|---|
| 55 | {
|
|---|
| 56 | $this->RawPage = true;
|
|---|
| 57 | } else {
|
|---|
| 58 | $Output .= '<div class="title">Inzeráty</div>';
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 61 | $Output .= $Filter->GetOutput($this->System->Link('/seznamka/'));
|
|---|
| 62 | $Where = $Filter->GetWhere($this->Database);
|
|---|
| 63 |
|
|---|
| 64 | $DbResult = $this->Database->query('SELECT COUNT(*) FROM (SELECT *, '.
|
|---|
| 65 | '(SELECT MeetSource.Name FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceName FROM `MeetItem`) AS T '.
|
|---|
| 66 | 'WHERE '.GetDefaultMeetFilter('T').' AND '.$Where);
|
|---|
| 67 | $DbRow = $DbResult->fetch_row();
|
|---|
| 68 | $PageList = GetPageList($DbRow[0]);
|
|---|
| 69 |
|
|---|
| 70 | $Gender = array('', 'Muž', 'Žena');
|
|---|
| 71 | $Output .= '<div id="list_content">';
|
|---|
| 72 | $Output .= $PageList['Output'];
|
|---|
| 73 | $TableColumns = array(
|
|---|
| 74 | array('Name' => 'Time', 'Title' => 'Čas'),
|
|---|
| 75 | array('Name' => 'Name', 'Title' => 'Jméno'),
|
|---|
| 76 | array('Name' => 'Height', 'Title' => 'Výška'),
|
|---|
| 77 | array('Name' => 'Age', 'Title' => 'Věk'),
|
|---|
| 78 | array('Name' => 'Weight', 'Title' => 'Váha'),
|
|---|
| 79 | array('Name' => 'Location', 'Title' => 'Umístění'),
|
|---|
| 80 | array('Name' => 'Gender', 'Title' => 'Pohlaví'),
|
|---|
| 81 | array('Name' => 'Message', 'Title' => 'Zpráva'),
|
|---|
| 82 | array('Name' => 'Source', 'Title' => 'Zdroj'),
|
|---|
| 83 | array('Name' => '', 'Title' => 'Detail'),
|
|---|
| 84 | );
|
|---|
| 85 | $Order = GetOrderTableHeader($TableColumns, 'Time', 1);
|
|---|
| 86 | $Output .= '<table class="WideTable">';
|
|---|
| 87 | $Output .= $Order['Output'];
|
|---|
| 88 | $DbResult = $this->Database->query('SELECT * FROM (SELECT *, (SELECT MeetSource.Name FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceName, '.
|
|---|
| 89 | '(SELECT MeetSource.URL FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceURL FROM MeetItem) AS T WHERE '.GetDefaultMeetFilter('T').' AND '.
|
|---|
| 90 | $Where.$Order['SQL'].$PageList['SQLLimit']);
|
|---|
| 91 | while ($MeetItem = $DbResult->fetch_assoc())
|
|---|
| 92 | {
|
|---|
| 93 | $Output .= '<tr>'.
|
|---|
| 94 | '<td>'.HumanDate(MysqlDateToTime($MeetItem['Time'])).'</td>'.
|
|---|
| 95 | '<td>'.$MeetItem['Name'].'</td>'.
|
|---|
| 96 | '<td>'.$MeetItem['Height'].'</td>'.
|
|---|
| 97 | '<td>'.$MeetItem['Age'].'</td>'.
|
|---|
| 98 | '<td>'.$MeetItem['Weight'].'</td>'.
|
|---|
| 99 | '<td>'.$MeetItem['Location'].'</td>'.
|
|---|
| 100 | '<td>'.$Gender[$MeetItem['Gender']].'</td>'.
|
|---|
| 101 | '<td>'.$MeetItem['Message'].'</td>'.
|
|---|
| 102 | '<td><a href="'.$MeetItem['SourceURL'].'">'.$MeetItem['SourceName'].'</a></td>'.
|
|---|
| 103 | '<td><a href="'.$this->System->Link('/seznamka/inzerat/'.$MeetItem['Id']).'">Ukázat</a></td>';
|
|---|
| 104 | $Output .= '</tr>';
|
|---|
| 105 | }
|
|---|
| 106 | $Output .= '</table>';
|
|---|
| 107 | $Output .= $PageList['Output'];
|
|---|
| 108 | $Output .= '</div>';
|
|---|
| 109 | if (array_key_exists('lvm', $_GET) and ($_GET['lvm'] == 'seznam'))
|
|---|
| 110 | {
|
|---|
| 111 | }
|
|---|
| 112 | else
|
|---|
| 113 | {
|
|---|
| 114 | $Output .= '<div><a href="'.$this->System->Link('/seznamka/rss/').'"><img src="'.$this->System->Link('/images/rss20.png').'" alt="rss20"/></a></div>';
|
|---|
| 115 |
|
|---|
| 116 | $Output .= '<div style="text-align: center;">Vložit nový inzerát: ';
|
|---|
| 117 | $Output .= '<form style="display:inline;"><select name="insert" id="insert" onchange="">';
|
|---|
| 118 | $DbResult = $this->Database->select('MeetSource', 'InsertURL, Name, Id', 'InsertURL != ""');
|
|---|
| 119 | while ($DbRow = $DbResult->fetch_assoc())
|
|---|
| 120 | {
|
|---|
| 121 | $Output .= '<option value="'.$DbRow['Id'].'" onclick="window.open(\''.
|
|---|
| 122 | $DbRow['InsertURL'].'\',\'_blank\',\'\')" onselect="window.open(\''.
|
|---|
| 123 | $DbRow['InsertURL'].'\',\'_blank\',\'\')">'.$DbRow['Name'].'</option>';
|
|---|
| 124 | }
|
|---|
| 125 | $Output .= '</select></form></div>';
|
|---|
| 126 | }
|
|---|
| 127 | return $Output;
|
|---|
| 128 | }
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 131 | class PageMeetUpdate extends Page
|
|---|
| 132 | {
|
|---|
| 133 | function __construct($System)
|
|---|
| 134 | {
|
|---|
| 135 | parent::__construct($System);
|
|---|
| 136 | $this->Title = 'Aktualizace seznamky';
|
|---|
| 137 | $this->Description = 'Aktualizace taneční seznamky';
|
|---|
| 138 | }
|
|---|
| 139 |
|
|---|
| 140 | function Show(): string
|
|---|
| 141 | {
|
|---|
| 142 | $MeetSources = new MeetSources();
|
|---|
| 143 | $MeetSources->Database = $this->Database;
|
|---|
| 144 | if (array_key_exists('i', $_GET)) $Output = $MeetSources->Parse($_GET['i']);
|
|---|
| 145 | else $Output = $MeetSources->Parse();
|
|---|
| 146 | return $Output;
|
|---|
| 147 | }
|
|---|
| 148 | }
|
|---|
| 149 |
|
|---|
| 150 | class PageMeetItem extends Page
|
|---|
| 151 | {
|
|---|
| 152 | function __construct($System)
|
|---|
| 153 | {
|
|---|
| 154 | parent::__construct($System);
|
|---|
| 155 | $this->Title = 'Inzerát';
|
|---|
| 156 | $this->Description = 'Inzerát taneční seznamky';
|
|---|
| 157 | }
|
|---|
| 158 |
|
|---|
| 159 | function Show(): string
|
|---|
| 160 | {
|
|---|
| 161 | $Output = '';
|
|---|
| 162 | if (count($this->System->PathItems) > 2)
|
|---|
| 163 | {
|
|---|
| 164 | $id = $this->System->PathItems[2] * 1;
|
|---|
| 165 | } else return 'Položka nenalezena';
|
|---|
| 166 | if (Core::Cast($this->System)->IsAdmin())
|
|---|
| 167 | {
|
|---|
| 168 | if (array_key_exists('hide', $_GET)) $this->Database->update('MeetItem', 'Id='.$id, array('Hidden' => 1));
|
|---|
| 169 | if (array_key_exists('unhide', $_GET)) $this->Database->update('MeetItem', 'Id='.$id, array('Hidden' => 0));
|
|---|
| 170 | }
|
|---|
| 171 |
|
|---|
| 172 | $Output .= '<div class="title">Inzerát</div>';
|
|---|
| 173 | $Gender = array('', 'Muž', 'Žena');
|
|---|
| 174 | $DbResult = $this->Database->select('MeetItem', '*, (SELECT MeetSource.Name FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceName, '.
|
|---|
| 175 | '(SELECT MeetSource.URL FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceURL, '.GetDefaultMeetFilter().' AS Filter', 'Id='.$id);
|
|---|
| 176 | if ($DbResult->num_rows > 0)
|
|---|
| 177 | {
|
|---|
| 178 | $MeetItem = $DbResult->fetch_assoc();
|
|---|
| 179 | if (($MeetItem['Filter'] == '0') and !Core::Cast($this->System)->IsAdmin())
|
|---|
| 180 | return 'Položka nenalezena';
|
|---|
| 181 | if ($MeetItem['Link'] != '') $Link = '<a href="'.$MeetItem['Link'].'">Odkaz</a>';
|
|---|
| 182 | else $Link = '';
|
|---|
| 183 | $Output .= '<table class="ItemTable">'.
|
|---|
| 184 | '<tr><th>Čas</th><td>'.HumanDate(MysqlDateToTime($MeetItem['Time'])).'</td></tr>'.
|
|---|
| 185 | '<tr><th>Pohlaví</th><td>'.$Gender[$MeetItem['Gender']].'</td></tr>'.
|
|---|
| 186 | '<tr><th>Jméno</th><td>'.$MeetItem['Name'].'</td></tr>'.
|
|---|
| 187 | '<tr><th>Výška</th><td>'.$MeetItem['Height'].'</td></tr>'.
|
|---|
| 188 | '<tr><th>Věk</th><td>'.$MeetItem['Age'].'</td></tr>'.
|
|---|
| 189 | '<tr><th>Váha</th><td>'.$MeetItem['Weight'].'</td></tr>'.
|
|---|
| 190 | '<tr><th>Umístění</th><td>'.$MeetItem['Location'].'</td></tr>'.
|
|---|
| 191 | '<tr><th>Email</th><td>'.$MeetItem['Email'].'</td></tr>'.
|
|---|
| 192 | '<tr><th>Telefón</th><td>'.$MeetItem['Phone'].'</td></tr>'.
|
|---|
| 193 | '<tr><th>Zpráva</th><td>'.$MeetItem['Message'].'</td></tr>'.
|
|---|
| 194 | '<tr><th>Původní stránka</th><td>'.$Link.'</td></tr>'.
|
|---|
| 195 | '<tr><th>Zdroj</th><td><a href="'.$MeetItem['SourceURL'].'">'.$MeetItem['SourceName'].'</a></td></tr>';
|
|---|
| 196 | $Output .= '</table>';
|
|---|
| 197 |
|
|---|
| 198 | $Output .= '<div style="margin-top: 10pt; text-align: center;">Vložit nový inzerát: ';
|
|---|
| 199 | $Output .= '<form style="display:inline;"><select name="insert" id="insert" onchange="">';
|
|---|
| 200 | $DbResult = $this->Database->select('MeetSource', 'InsertURL, Name, Id', 'InsertURL != ""');
|
|---|
| 201 | while ($DbRow = $DbResult->fetch_assoc())
|
|---|
| 202 | {
|
|---|
| 203 | $Output .= '<option value="'.$DbRow['Id'].'" onclick="window.open(\''.
|
|---|
| 204 | $DbRow['InsertURL'].'\',\'_blank\',\'\')">'.$DbRow['Name'].'</option>';
|
|---|
| 205 | }
|
|---|
| 206 | $Output .= '</select></form></div>';
|
|---|
| 207 |
|
|---|
| 208 | if (Core::Cast($this->System)->IsAdmin())
|
|---|
| 209 | {
|
|---|
| 210 | if ($MeetItem['Hidden'] == '1')
|
|---|
| 211 | $Output .= '<div>Skrytá položka <a href="?unhide">Zviditelnit</a></div>';
|
|---|
| 212 | else $Output .= '<div>Viditelná položka <a href="?hide">Skrýt</a></div>';
|
|---|
| 213 | }
|
|---|
| 214 | } else $Output .= 'Položka nenalezena';
|
|---|
| 215 | return $Output;
|
|---|
| 216 | }
|
|---|
| 217 | }
|
|---|
| 218 |
|
|---|
| 219 | class PageMeetRss extends Page
|
|---|
| 220 | {
|
|---|
| 221 | function __construct($System)
|
|---|
| 222 | {
|
|---|
| 223 | parent::__construct($System);
|
|---|
| 224 | $this->Title = 'RSS inzeráty seznamky';
|
|---|
| 225 | $this->Description = 'RSS kanál taneční seznamky';
|
|---|
| 226 | }
|
|---|
| 227 |
|
|---|
| 228 | function Show(): string
|
|---|
| 229 | {
|
|---|
| 230 | global $Config;
|
|---|
| 231 |
|
|---|
| 232 | $this->RawPage = true;
|
|---|
| 233 | $RSS = new RSS();
|
|---|
| 234 | $RSS->Title = 'Taneční seznamka';
|
|---|
| 235 | $RSS->Description = '';
|
|---|
| 236 | $RSS->Link = $this->System->AbsoluteLink('/seznamka/');
|
|---|
| 237 |
|
|---|
| 238 | $DbResult = $this->Database->query('SELECT *, (SELECT MeetSource.Name FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceName, '.
|
|---|
| 239 | '(SELECT MeetSource.URL FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceURL FROM MeetItem WHERE '.
|
|---|
| 240 | GetDefaultMeetFilter().' ORDER BY `Time` DESC LIMIT 30');
|
|---|
| 241 | while ($MeetItem = $DbResult->fetch_assoc())
|
|---|
| 242 | {
|
|---|
| 243 | $Title = $MeetItem['Name'];
|
|---|
| 244 | if ($MeetItem['Age'] != '') $Title .= ', '.$MeetItem['Age'].' let';
|
|---|
| 245 | if ($MeetItem['Weight'] != '') $Title .= ', '.$MeetItem['Height'].' cm';
|
|---|
| 246 | if ($MeetItem['Location'] != '') $Title .= ', '.$MeetItem['Location'];
|
|---|
| 247 | $Description = $MeetItem['Message']."<br/>\n";
|
|---|
| 248 | if ($MeetItem['Email'] != '') $Description .= '<br/>Email: '.$MeetItem['Email'];
|
|---|
| 249 | if ($MeetItem['Phone'] != '') $Description .= '<br/>Telefon: '.$MeetItem['Phone'];
|
|---|
| 250 | if ($MeetItem['Age'] != '') $Description .= '<br/>Věk: '.$MeetItem['Age'].' let';
|
|---|
| 251 | if ($MeetItem['Height'] != '') $Description .= '<br/>Výška: '.$MeetItem['Height'].' cm';
|
|---|
| 252 | if ($MeetItem['Weight'] != '') $Description .= '<br/>Váha: '.$MeetItem['Weight'].' kg';
|
|---|
| 253 | $Description .= '<br/>Zdroj: <a href="'.$MeetItem['SourceURL'].'">'.$MeetItem['SourceName'].'</a>';
|
|---|
| 254 | $Time = MysqlDateTimeToTime($MeetItem['Time']);
|
|---|
| 255 | $TimeImport = MysqlDateTimeToTime($MeetItem['TimeImport']);
|
|---|
| 256 | // 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
|
|---|
| 257 | if (TimeToMysqlTime($Time) == '00:00:00')
|
|---|
| 258 | {
|
|---|
| 259 | $Time = MysqlDateTimeToTime(TimeToMysqlDate($Time).' '.TimeToMysqlTime($TimeImport));
|
|---|
| 260 | }
|
|---|
| 261 | $RSS->Items[] = array(
|
|---|
| 262 | 'Title' => $Title,
|
|---|
| 263 | 'Description' => $Description,
|
|---|
| 264 | 'Time' => $Time,
|
|---|
| 265 | 'Link' => $this->System->AbsoluteLink('/seznamka/inzerat/'.$MeetItem['Id'].'/'),
|
|---|
| 266 | );
|
|---|
| 267 | }
|
|---|
| 268 |
|
|---|
| 269 | return $RSS->Generate();
|
|---|
| 270 | }
|
|---|
| 271 | }
|
|---|