1 | <?php
|
---|
2 |
|
---|
3 | class PageNews extends Page
|
---|
4 | {
|
---|
5 | var $FullTitle = 'Aktualní informace';
|
---|
6 | var $ShortTitle = 'Aktuality';
|
---|
7 | var $ParentClass = 'PagePortal';
|
---|
8 | var $UploadedFilesFolder;
|
---|
9 |
|
---|
10 | function Show()
|
---|
11 | {
|
---|
12 | $this->UploadedFilesFolder = $this->System->ModuleManager->Modules['News']->UploadedFilesFolder;
|
---|
13 | if (count($this->System->PathItems) > 1)
|
---|
14 | {
|
---|
15 | if ($this->System->PathItems[1] == 'subscription') return $this->ShowSubscription();
|
---|
16 | else if ($this->System->PathItems[1] == 'rss') return $this->ShowRSS();
|
---|
17 | else return PAGE_NOT_FOUND;
|
---|
18 | } else return $this->ShowMain();
|
---|
19 | }
|
---|
20 |
|
---|
21 | function ShowView()
|
---|
22 | {
|
---|
23 | $Output = '';
|
---|
24 | if (!$this->System->User->CheckPermission('News', 'Display', 'Item')) $Output .= 'Nemáte oprávnění';
|
---|
25 | else
|
---|
26 | {
|
---|
27 | $Category = $this->GetCategory();
|
---|
28 | if (array_key_exists('id', $_GET)) $Id = $_GET['id'] * 1;
|
---|
29 | $DbResult = $this->Database->query('SELECT `News`.*, `User`.`Name` FROM `News` '.
|
---|
30 | 'LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE `News`.`Id`='.$Id);
|
---|
31 | if ($DbResult->num_rows > 0)
|
---|
32 | {
|
---|
33 | $Row = $DbResult->fetch_array();
|
---|
34 | if ($Row['Name'] == '') $Author = $Row['Author'];
|
---|
35 | else $Author = $Row['Name'];
|
---|
36 | $Output .= '<div class="Panel"><div class="Title">'.$Row['Title'].' ('.HumanDate($Row['Date']).', '.$Author.')';
|
---|
37 | if (($this->System->User->User['Id'] == $Row['User']) and ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])))
|
---|
38 | {
|
---|
39 | $Output .= '<div class="Action">';
|
---|
40 | $Output .= ' <a href="?action=del&category='.$Category['Id'].'&id='.$Row['Id'].'">Smazat</a>';
|
---|
41 | $Output .= ' <a href="?action=edit&category='.$Category['Id'].'&id='.$Row['Id'].'">Upravit</a>';
|
---|
42 | $Output .= '</div>';
|
---|
43 | }
|
---|
44 | $Output .= '</div><div class="Content">'.$this->System->ModuleManager->Modules['News']->ModifyContent($Row['Content']).'<br />';
|
---|
45 | if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';
|
---|
46 | if ($Row['Enclosure'] != '')
|
---|
47 | {
|
---|
48 | $Output .= '<br />Přílohy: ';
|
---|
49 | $Enclosures = explode(';', $Row['Enclosure']);
|
---|
50 | foreach ($Enclosures as $Enclosure)
|
---|
51 | {
|
---|
52 | if (file_exists($this->UploadedFilesFolder.$Enclosure))
|
---|
53 | $Output .= ' <a href="'.$this->System->Link('/'.$this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>';
|
---|
54 | }
|
---|
55 | }
|
---|
56 | $Output .= '</div></div>';
|
---|
57 | } else $Output .= 'Položka nenalezena.';
|
---|
58 | }
|
---|
59 | return $Output;
|
---|
60 | }
|
---|
61 |
|
---|
62 | function ShowAdd()
|
---|
63 | {
|
---|
64 | $Output = '';
|
---|
65 | $Category = $this->GetCategory();
|
---|
66 | if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
|
---|
67 | {
|
---|
68 | $this->System->PageHeaders[] = array($this, 'GetPageHeader');
|
---|
69 | $Output = '<strong>Vložení nové aktuality:</strong><br />';
|
---|
70 | // TODO: Static reference to dynamic category item
|
---|
71 | if ($Category['Id'] == 2) $Output .= 'U inzerátů uvádějte co nejvíce informací ať případný zájemce ví co kupuje. Uvádějte kontaktní údaje jako Jméno, email, tel. číslo, ICQ. Dále navrženou cenu, detajlní popis předmětu nejlépe s odkazem na stránky výrobce. Pokud váš inzerát již není platný, připište do něj např. "Prodáno" pomocí editace.';
|
---|
72 | $Output .= '<form enctype="multipart/form-data" action="?action=add2" method="post">'.
|
---|
73 | 'Kategorie: <select name="category">';
|
---|
74 | $DbResult = $this->Database->select('NewsCategory', '*');
|
---|
75 | while ($DbRow = $DbResult->fetch_array())
|
---|
76 | {
|
---|
77 | if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $DbRow['Id']))
|
---|
78 | {
|
---|
79 | if ($DbRow['Id'] == $Category['Id']) $Selected = ' selected="1"';
|
---|
80 | else $Selected = '';
|
---|
81 | $Output .= '<option value="'.$DbRow['Id'].'"'.$Selected.'>'.$DbRow['Caption'].'</option>';
|
---|
82 | }
|
---|
83 | }
|
---|
84 | $Output .= '</select><br />'.
|
---|
85 | 'Nadpis:<br /><input type="text" size="54" name="title"><br />'.
|
---|
86 | 'Obsah:<br /><textarea name="content" rows="20" cols="40"></textarea><br />'.
|
---|
87 | 'Odkaz:<br /><input type="text" size="54" name="link"><br />'.
|
---|
88 | 'Přílohy (Max. velikost souboru 1 MB):<br /><input type="hidden" name="MAX_FILE_SIZE" value="1000000">'.
|
---|
89 | '<input name="enclosure1" size="38" type="file"><br />'.
|
---|
90 | '<input name="enclosure2" size="38" type="file"><br />'.
|
---|
91 | '<input name="enclosure3" size="38" type="file"><br />'.
|
---|
92 | '<input type="submit" value="Vložit">'.
|
---|
93 | '</form>';
|
---|
94 | } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!';
|
---|
95 | return $Output;
|
---|
96 | }
|
---|
97 |
|
---|
98 | function ShowAdd2()
|
---|
99 | {
|
---|
100 | $Output = '';
|
---|
101 | $RemoteAddr = GetRemoteAddress();
|
---|
102 | $Category = $this->GetCategory();
|
---|
103 | if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
|
---|
104 | {
|
---|
105 | // Process uploaded file
|
---|
106 | // TODO: Make upload using general File class
|
---|
107 | $EnclosureFileNames = array('enclosure1', 'enclosure2', 'enclosure3');
|
---|
108 | $Enclosures = '';
|
---|
109 | foreach ($EnclosureFileNames as $EnclosureName)
|
---|
110 | if (array_key_exists($EnclosureName, $_FILES) and ($_FILES[$EnclosureName]['name'] != ''))
|
---|
111 | {
|
---|
112 | $UploadedFilePath = $this->UploadedFilesFolder.basename($_FILES[$EnclosureName]['name']);
|
---|
113 | if (move_uploaded_file($_FILES[$EnclosureName]['tmp_name'], $UploadedFilePath))
|
---|
114 | {
|
---|
115 | $Output .= 'Soubor '.basename($_FILES[$EnclosureName]['name']).' byl uložen na serveru.<br />';
|
---|
116 | $Enclosures = $Enclosures.';'.basename($_FILES[$EnclosureName]['name']);
|
---|
117 | } else
|
---|
118 | {
|
---|
119 | $Output .= 'Soubor '.basename($_FILES[$EnclosureName]['name']).' se nepodařilo nahrát na server.<br />';
|
---|
120 | }
|
---|
121 | }
|
---|
122 | $Enclosures = substr($Enclosures, 1);
|
---|
123 |
|
---|
124 | $this->Database->insert('News', array('Category' => $Category['Id'], 'Title' => $_POST['title'],
|
---|
125 | 'Content' => $_POST['content'], 'Date' => 'NOW()', 'IP' => $RemoteAddr,
|
---|
126 | 'Enclosure' => $Enclosures, 'Author' => $this->System->User->User['Name'],
|
---|
127 | 'User' => $this->System->User->User['Id'], 'Link' => $_POST['link']));
|
---|
128 | $Output .= 'Aktualita přidána!<br />Pokud budete chtít vaši aktualitu smazat, klikněte na odkaz Smazat v seznamu všech aktualit v kategorii.<br /><br />';
|
---|
129 | $Output .= '<a href="?category='.$_POST['category'].'">Zpět na seznam aktualit</a>';
|
---|
130 | $this->System->ModuleManager->Modules['Log']->NewRecord('News', 'Aktualita přidána', $this->Database->insert_id);
|
---|
131 | } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!';
|
---|
132 | return $Output;
|
---|
133 | }
|
---|
134 |
|
---|
135 | function GetPageHeader()
|
---|
136 | {
|
---|
137 | return '<script src="'.$this->System->Link('/Packages/TinyMCE/tinymce.min.js').'"></script>'.
|
---|
138 | "<script>tinymce.init({
|
---|
139 | selector: 'textarea',
|
---|
140 | force_p_newlines : false,
|
---|
141 | force_br_newlines : true,
|
---|
142 | convert_newlines_to_brs : false,
|
---|
143 | remove_linebreaks : true,
|
---|
144 | plugins: [
|
---|
145 | 'advlist autolink lists link image charmap print preview anchor',
|
---|
146 | 'searchreplace visualblocks code fullscreen',
|
---|
147 | 'insertdatetime media table contextmenu paste code'
|
---|
148 | ],
|
---|
149 | toolbar: 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
|
---|
150 | language: 'cs_CZ',
|
---|
151 | });</script>";
|
---|
152 | }
|
---|
153 |
|
---|
154 | function ShowEdit()
|
---|
155 | {
|
---|
156 | $Output = '';
|
---|
157 | $Category = $this->GetCategory();
|
---|
158 | if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
|
---|
159 | {
|
---|
160 | $DbResult = $this->Database->query('SELECT * FROM `News` WHERE `Id`='.$_GET['id']);
|
---|
161 | $Row = $DbResult->fetch_array();
|
---|
162 | if (($this->System->User->User['Id'] == $Row['User']))
|
---|
163 | {
|
---|
164 | $this->System->PageHeaders[] = array($this, 'GetPageHeader');
|
---|
165 | $Output .= '<strong>Editace aktuality v kategorii '.$Category['Caption'].':</strong><br />';
|
---|
166 | $Output .= '<form action="?action=update" method="post">'.
|
---|
167 | '<input type="hidden" value="'.$_GET['id'].'" name="id">'.
|
---|
168 | 'Nadpis:<br /><input type="text" size="54" name="title" value="'.$Row['Title'].'"><br />'.
|
---|
169 | 'Obsah:<br /><textarea name="content" rows="20" cols="40" style="width: 50%">'.$Row['Content'].'</textarea><br />'.
|
---|
170 | 'Odkaz:<br /><input type="text" size="54" name="link" value="'.$Row['Link'].'"><br />'.
|
---|
171 | '<input type="hidden" name="category" value="'.$Category['Id'].'"><br />'.
|
---|
172 | '<input type="submit" value="Uložit">'.
|
---|
173 | '</form>';
|
---|
174 | } else $Output .= 'Nepovolená operace!';
|
---|
175 | } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!';
|
---|
176 | return $Output;
|
---|
177 | }
|
---|
178 |
|
---|
179 | function ShowUpdate()
|
---|
180 | {
|
---|
181 | $Output = '';
|
---|
182 | $RemoteAddr = GetRemoteAddress();
|
---|
183 | $Category = $this->GetCategory();
|
---|
184 | if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
|
---|
185 | {
|
---|
186 | $_POST['id'] = $_POST['id'] * 1;
|
---|
187 | $DbResult = $this->Database->select('News', '*', '`Id`='.$_POST['id']);
|
---|
188 | if ($DbResult->num_rows > 0)
|
---|
189 | {
|
---|
190 | $Row = $DbResult->fetch_array();
|
---|
191 | if ($this->System->User->User['Id'] == $Row['User'])
|
---|
192 | {
|
---|
193 | $this->Database->update('News', 'Id='.$_POST['id'], array('Title' => $_POST['title'],
|
---|
194 | 'Content' => $_POST['content'], 'Link' => $_POST['link']));
|
---|
195 | $Output .= 'Aktualita uložena!<br />';
|
---|
196 | $Output .= '<a href="?category='.$Category['Id'].'">Zpět na seznam aktualit</a>';
|
---|
197 | } else $Output .= 'Nelze měnit cizí aktualitu!<br />';
|
---|
198 | } else $Output .= 'ID nenalezeno!';
|
---|
199 | } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!';
|
---|
200 | return $Output;
|
---|
201 | }
|
---|
202 |
|
---|
203 | function ShowDelete()
|
---|
204 | {
|
---|
205 | $Output = '';
|
---|
206 | $Category = $this->GetCategory();
|
---|
207 | if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
|
---|
208 | {
|
---|
209 | $DbResult = $this->Database->query('SELECT * FROM `News` WHERE `Id`='.$_GET['id']);
|
---|
210 | $Row = $DbResult->fetch_array();
|
---|
211 | if ($this->System->User->User['Id'] == $Row['User'])
|
---|
212 | {
|
---|
213 | // TODO: Make upload using general File class
|
---|
214 | if ($Row['Enclosure'] != '')
|
---|
215 | {
|
---|
216 | $Output .= '<br />Přílohy: ';
|
---|
217 | $Enclosures = explode(';', $Row['Enclosure']);
|
---|
218 | foreach ($Enclosures as $Enclosure)
|
---|
219 | {
|
---|
220 | if (file_exists($this->UploadedFilesFolder.$Enclosure)) unlink($this->UploadedFilesFolder.$Enclosure);
|
---|
221 | }
|
---|
222 | }
|
---|
223 | $this->Database->query('DELETE FROM `News` WHERE `Id`='.$_GET['id']);
|
---|
224 | $Output .= 'Aktualita smazána!<br /><a href="?category='.$Category['Id'].'">Zpět na seznam aktualit</a>';
|
---|
225 | } else $Output .= 'Nemáte oprávnění.';
|
---|
226 | } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!';
|
---|
227 | return $Output;
|
---|
228 | }
|
---|
229 |
|
---|
230 | function ShowList()
|
---|
231 | {
|
---|
232 | $Output = '';
|
---|
233 | $Category = $this->GetCategory();
|
---|
234 | if ($this->System->User->CheckPermission('News', 'Display', 'Group', $Category['Id']))
|
---|
235 | {
|
---|
236 | $PerPage = 20;
|
---|
237 | $DbResult = $this->Database->select('News', 'COUNT(*)', ' `Category`='.$Category['Id']);
|
---|
238 | $RowTotal = $DbResult->fetch_array();
|
---|
239 | $PageMax = $RowTotal[0];
|
---|
240 | if (array_key_exists('page', $_GET)) $Page = $_GET['page'];
|
---|
241 | else $Page = 0; //round($PageMax/$PerPage);
|
---|
242 | $Output .= '<strong>Seznam aktualit kategorie '.$Category['Caption'].':</strong><div style="font-size: small;">';
|
---|
243 | $Output .= PagesList('?category='.$Category['Id'].'&page=', $Page, $PageMax, $PerPage);
|
---|
244 |
|
---|
245 | $DbResult = $this->Database->query('SELECT `News`.*, `User`.`Name` FROM `News` '.
|
---|
246 | 'LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE `Category`='.$Category['Id'].' ORDER BY `News`.`Id` DESC LIMIT '.($Page * $PerPage).','.$PerPage);
|
---|
247 | while ($Row = $DbResult->fetch_array())
|
---|
248 | {
|
---|
249 | if ($Row['Name'] == '') $Author = $Row['Author'];
|
---|
250 | else $Author = $Row['Name'];
|
---|
251 | $Output .= '<div class="Panel"><div class="Title"><a href="?action=view&id='.$Row['Id'].'">'.$Row['Title'].'</a> ('.HumanDate($Row['Date']).', '.$Author.')';
|
---|
252 | if (($this->System->User->User['Id'] == $Row['User']) and ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])))
|
---|
253 | {
|
---|
254 | $Output .= '<div class="Action">';
|
---|
255 | $Output .= ' <a href="?action=del&category='.$Category['Id'].'&id='.$Row['Id'].'">Smazat</a>';
|
---|
256 | $Output .= ' <a href="?action=edit&category='.$Category['Id'].'&id='.$Row['Id'].'">Upravit</a>';
|
---|
257 | $Output .= '</div>';
|
---|
258 | }
|
---|
259 | $Output .= '</div><div class="Content">'.$this->System->ModuleManager->Modules['News']->ModifyContent($Row['Content']).'<br />';
|
---|
260 | if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';
|
---|
261 | if ($Row['Enclosure'] != '')
|
---|
262 | {
|
---|
263 | $Output .= '<br />Přílohy: ';
|
---|
264 | $Enclosures = explode(';', $Row['Enclosure']);
|
---|
265 | foreach ($Enclosures as $Enclosure)
|
---|
266 | {
|
---|
267 | if (file_exists($this->UploadedFilesFolder.$Enclosure))
|
---|
268 | $Output .= ' <a href="'.$this->System->Link('/'.$this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>';
|
---|
269 | }
|
---|
270 | }
|
---|
271 | $Output .= '</div></div>';
|
---|
272 | }
|
---|
273 | $Output .= PagesList('?category='.$Category['Id'].'&page=', $Page, $PageMax, $PerPage);
|
---|
274 | $Output .= '</div>';
|
---|
275 | } else $Output .= 'Nemáte oprávnění.';
|
---|
276 | return $Output;
|
---|
277 | }
|
---|
278 |
|
---|
279 | function GetCategory()
|
---|
280 | {
|
---|
281 | $Category = array('Id' => 1); // Default category
|
---|
282 | if (array_key_exists('category', $_GET)) $Category['Id'] = $_GET['category'] * 1;
|
---|
283 | if (array_key_exists('category', $_POST)) $Category['Id'] = $_POST['category'] * 1;
|
---|
284 | //if (is_null($Category)) throw new Exception('Kategorie neurčena');
|
---|
285 | else
|
---|
286 | {
|
---|
287 | $DbResult = $this->Database->select('NewsCategory', '*', '`Id`='.$Category['Id'].' ORDER BY `Sequence`');
|
---|
288 | if ($DbResult->num_rows > 0) $Category = $DbResult->fetch_array();
|
---|
289 | else $Category = array('Id' => 0); //throw new Exception('Kategorie nenalezena');
|
---|
290 | }
|
---|
291 | return $Category;
|
---|
292 | }
|
---|
293 |
|
---|
294 | function ShowMain()
|
---|
295 | {
|
---|
296 | $Output = '';
|
---|
297 | if (array_key_exists('action',$_GET)) $Action = $_GET['action'];
|
---|
298 | else $Action = '';
|
---|
299 | if ($Action == 'view') $Output .= $this->ShowView();
|
---|
300 | else if ($Action == 'add') $Output .= $this->ShowAdd();
|
---|
301 | else if ($Action == 'add2') $Output .= $this->ShowAdd2();
|
---|
302 | else if ($Action == 'edit') $Output .= $this->ShowEdit();
|
---|
303 | else if ($Action == 'update') $Output .= $this->ShowUpdate();
|
---|
304 | else if ($Action == 'del') $Output .= $this->ShowDelete();
|
---|
305 | else $Output .= $this->ShowList();
|
---|
306 | return $Output;
|
---|
307 | }
|
---|
308 |
|
---|
309 | function ShowSubscription()
|
---|
310 | {
|
---|
311 | if (array_key_exists('build', $_GET))
|
---|
312 | {
|
---|
313 | $Select = '';
|
---|
314 | foreach ($_POST as $Index => $Item)
|
---|
315 | {
|
---|
316 | if (substr($Index, 0, 8) == 'category') $Select .= '-'.substr($Index, 8);
|
---|
317 | }
|
---|
318 | $Select = $this->System->Config['Web']['RootFolder'].'/aktuality/rss/?select='.substr($Select, 1);
|
---|
319 | $Output = 'Výsledný RSS kanál: <a href="'.$Select.'">'.$Select.'</a>';
|
---|
320 | } else
|
---|
321 | {
|
---|
322 | $Output = 'Vytvořte si vlastní RSS kanál, díky kterému budete moci automaticky sledovat novinky pomocí vaší RSS čtečky. Informace o technologii RSS a programech pro čtení kanálů najdete např. <a href="http://www.lupa.cz/clanky/prehled-rss-ctecek/">zde</a><br />'.
|
---|
323 | '<br />Kategorie:<br />';
|
---|
324 | $Output .= '<form action="?build=1" method="post">';
|
---|
325 | $DbResult = $this->Database->select('NewsCategory', '*', '1 ORDER BY `Caption`');
|
---|
326 | while ($Category = $DbResult->fetch_array())
|
---|
327 | {
|
---|
328 | $Output .= '<input type="checkbox" name="category'.$Category['Id'].'" />'.$Category['Caption'].'<br />';
|
---|
329 | }
|
---|
330 | $Output.= '<input type="submit" value="Sestavit"/>'.
|
---|
331 | '</form>';
|
---|
332 | }
|
---|
333 | return $Output;
|
---|
334 | }
|
---|
335 |
|
---|
336 | function ShowRSS()
|
---|
337 | {
|
---|
338 | $this->ClearPage = true;
|
---|
339 | $this->FormatHTML = false;
|
---|
340 | Header('Content-Type: text/xml');
|
---|
341 |
|
---|
342 | $NewsCount = 15;
|
---|
343 |
|
---|
344 | $Items = array();
|
---|
345 | $Category = '';
|
---|
346 | $CategoryOption = '';
|
---|
347 | $CategoryOptionURL = '';
|
---|
348 | $CategoryName = '';
|
---|
349 |
|
---|
350 | // Prepare WHERE condition
|
---|
351 | if (array_key_exists('select', $_GET))
|
---|
352 | {
|
---|
353 | $Where = '';
|
---|
354 | $Parts = explode('-', $_GET['select']);
|
---|
355 | foreach ($Parts as $Part)
|
---|
356 | {
|
---|
357 | $Where .= 'OR (`Category`='.($Part * 1).')';
|
---|
358 | }
|
---|
359 | $Where = substr($Where, 2);
|
---|
360 | } else $Where = 1;
|
---|
361 |
|
---|
362 | // Get category names
|
---|
363 | $Categories = array();
|
---|
364 | $DbResult = $this->Database->select('NewsCategory', '*');
|
---|
365 | while ($Category = $DbResult->fetch_array())
|
---|
366 | {
|
---|
367 | $Categories[$Category['Id']] = $Category['Caption'];
|
---|
368 | }
|
---|
369 |
|
---|
370 | // Update news from discussion forum
|
---|
371 | /*
|
---|
372 | $ForumCategory = 4;
|
---|
373 | $Database->select_db('forum');
|
---|
374 | $DbResult = $Database->query('SELECT posts.post_time, posts_text.post_subject, posts_text.post_text, users.username, topics.topic_title FROM posts JOIN posts_text ON posts.post_id = posts_text.post_id JOIN users ON users.user_id = posts.poster_id JOIN topics ON topics.topic_id= posts.topic_id ORDER BY post_time DESC LIMIT '.$NewsCount);
|
---|
375 | $Index = 0;
|
---|
376 | //echo(DB_NumRows().',');
|
---|
377 | while ($Row = $DbResult->fetch_array())
|
---|
378 | {
|
---|
379 | $Row['post_text'] = StrTr($Row['post_text'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE");
|
---|
380 | $Row['post_text'] = str_replace("\n","<br>", $Row['post_text']);
|
---|
381 | $Row['post_subject'] = StrTr($Row['post_subject'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE");
|
---|
382 | $Row['topic_title'] = StrTr($Row['topic_title'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE");
|
---|
383 | $Index = $Index + 1;
|
---|
384 |
|
---|
385 | $Title = $Row['topic_title'].'-'.$Row['post_subject'];
|
---|
386 | $Content = $Row['post_text'];
|
---|
387 | $Date = date('Y-m-d H:i:s', $Row['post_time']);
|
---|
388 | $Author = $Row['username'];
|
---|
389 | $Database->select_db('is');
|
---|
390 | //echo('category='.$ForumCategory.' AND title="'.addslashes($Title).'" AND content="'.addslashes($Content).'" AND author="'.addslashes($Author).'" AND date="'.$Date.'"');
|
---|
391 | $DbResult2 = $Database->select('news', '*', 'category='.$ForumCategory.' AND title="'.addslashes($Title).'" AND content="'.addslashes($Content).'" AND author="'.addslashes($Author).'" AND date="'.$Date.'"');
|
---|
392 | if ($DbResult2->num_rows == 0) //echo('.'); else echo('x');
|
---|
393 | $Database->insert('news', array('category' => $ForumCategory, 'title' => $Title, 'content' => $Content, 'author' => $Author, 'date' => $Date));
|
---|
394 | //echo($Date);
|
---|
395 | $Database->select_db('forum');
|
---|
396 | }
|
---|
397 | $Database->select_db('is');
|
---|
398 | */
|
---|
399 |
|
---|
400 | // Get news from database by selected categories
|
---|
401 | $DbResult = $this->Database->query('SELECT *, UNIX_TIMESTAMP(`Date`) AS `UnixTime` FROM `News` LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE '.$Where.' ORDER BY News.Date DESC LIMIT 0,'.$NewsCount);
|
---|
402 | while ($Row = $DbResult->fetch_assoc())
|
---|
403 | {
|
---|
404 | $EnclosuresText = '';
|
---|
405 | if ($Row['Enclosure'] != '')
|
---|
406 | {
|
---|
407 | $EnclosuresText .= '<br />Přílohy: ';
|
---|
408 | $Enclosures = explode(';', $Row['Enclosure']);
|
---|
409 | foreach ($Enclosures as $Enclosure)
|
---|
410 | {
|
---|
411 | if (file_exists($this->UploadedFilesFolder.$Enclosure))
|
---|
412 | $EnclosuresText .= ' <a href="'.$this->System->Link('/aktuality/'.$this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>';
|
---|
413 | }
|
---|
414 | }
|
---|
415 | if ($Row['Name'] == '') $Author = $Row['Author'];
|
---|
416 | else $Author = $Row['Name'];
|
---|
417 | $Items[] = array(
|
---|
418 | 'Title' => $Categories[$Row['Category']].' - '.$Row['Title'],
|
---|
419 | 'Link' => 'http://'.$this->System->Config['Web']['Host'].'/aktuality/?category='.$Row['Category'],
|
---|
420 | 'Description' => $Row['Content'].' ('.$Author.')'.$EnclosuresText,
|
---|
421 | 'Time' => $Row['UnixTime'],
|
---|
422 | );
|
---|
423 | }
|
---|
424 |
|
---|
425 | $RSS = new RSS();
|
---|
426 | $RSS->Title = $this->System->Config['Web']['Title'].' - Aktuality';
|
---|
427 | $RSS->Link = 'http://'.$this->System->Config['Web']['Host'].'/';
|
---|
428 | $RSS->Description = 'Aktuality '.$this->System->Config['Web']['Description'];
|
---|
429 | $RSS->WebmasterEmail = $this->System->Config['Web']['AdminEmail'];
|
---|
430 | $RSS->Items = $Items;
|
---|
431 | return $RSS->Generate();
|
---|
432 | }
|
---|
433 | }
|
---|