Changeset 659 for trunk/Modules/News/NewsPage.php
- Timestamp:
- May 29, 2014, 11:59:39 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/News/NewsPage.php
r614 r659 14 14 $this->UploadedFilesFolder = $this->System->ModuleManager->Modules['News']->UploadedFilesFolder; 15 15 if(count($this->System->PathItems) > 1) 16 { 16 { 17 17 if($this->System->PathItems[1] == 'subscription') return($this->ShowSubscription()); 18 18 else if($this->System->PathItems[1] == 'rss') return($this->ShowRSS()); … … 20 20 } else return($this->ShowMain()); 21 21 } 22 22 23 23 function ShowView() 24 24 { … … 52 52 foreach($Enclosures as $Enclosure) 53 53 { 54 if(file_exists($this->UploadedFilesFolder.$Enclosure)) 54 if(file_exists($this->UploadedFilesFolder.$Enclosure)) 55 55 $Output .= ' <a href="'.$this->System->Link('/'.$this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>'; 56 56 } … … 61 61 return($Output); 62 62 } 63 63 64 64 function ShowAdd() 65 65 { … … 78 78 if($this->System->User->CheckPermission('News', 'Insert', 'Group', $DbRow['Id'])) 79 79 { 80 if($DbRow['Id'] == $Category['Id']) $Selected = ' selected="1"'; 80 if($DbRow['Id'] == $Category['Id']) $Selected = ' selected="1"'; 81 81 else $Selected = ''; 82 82 $Output .= '<option value="'.$DbRow['Id'].'"'.$Selected.'>'.$DbRow['Caption'].'</option>'; … … 96 96 return($Output); 97 97 } 98 98 99 99 function ShowAdd2() 100 100 { … … 122 122 } 123 123 $Enclosures = substr($Enclosures, 1); 124 124 125 125 $_POST['content'] = str_replace("\n",'<br />',$_POST['content']); 126 126 $this->Database->insert('News', array('Category' => $Category['Id'], 'Title' => $_POST['title'], 127 127 'Content' => $_POST['content'], 'Date' => 'NOW()', 'IP' => $RemoteAddr, 128 'Enclosure' => $Enclosures, 'Author' => $this->System->User->User['Name'], 128 'Enclosure' => $Enclosures, 'Author' => $this->System->User->User['Name'], 129 129 'User' => $this->System->User->User['Id'], 'Link' => $_POST['link'])); 130 130 $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 />'; … … 134 134 return($Output); 135 135 } 136 136 137 137 function ShowEdit() 138 138 { … … 159 159 return($Output); 160 160 } 161 161 162 162 function ShowUpdate() 163 163 { 164 164 $Output = ''; 165 $RemoteAddr = GetRemoteAddress(); 165 $RemoteAddr = GetRemoteAddress(); 166 166 $Category = $this->GetCategory(); 167 167 if($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) … … 175 175 { 176 176 $_POST['content'] = str_replace("\n", '<br />', $_POST['content']); 177 $this->Database->update('News', 'Id='.$_POST['id'], array('Title' => $_POST['title'], 177 $this->Database->update('News', 'Id='.$_POST['id'], array('Title' => $_POST['title'], 178 178 'Content' => $_POST['content'], 'Link' => $_POST['link'])); 179 179 $Output .= 'Aktualita uložena!<br />'; … … 184 184 return($Output); 185 185 } 186 186 187 187 function ShowDelete() 188 188 { … … 197 197 // TODO: Make upload using general File class 198 198 if($Row['Enclosure'] != '') 199 { 199 { 200 200 $Output .= '<br />Přílohy: '; 201 201 $Enclosures = explode(';', $Row['Enclosure']); … … 211 211 return($Output); 212 212 } 213 213 214 214 function ShowList() 215 215 { … … 226 226 $Output .= '<strong>Seznam aktualit kategorie '.$Category['Caption'].':</strong><div style="font-size: small;">'; 227 227 $Output .= PagesList('?category='.$Category['Id'].'&page=', $Page, $PageMax, $PerPage); 228 228 229 229 $DbResult = $this->Database->query('SELECT `News`.*, `User`.`Name` FROM `News` '. 230 230 'LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE `Category`='.$Category['Id'].' ORDER BY `News`.`Id` DESC LIMIT '.($Page * $PerPage).','.$PerPage); … … 249 249 foreach($Enclosures as $Enclosure) 250 250 { 251 if(file_exists($this->UploadedFilesFolder.$Enclosure)) 251 if(file_exists($this->UploadedFilesFolder.$Enclosure)) 252 252 $Output .= ' <a href="'.$this->System->Link('/'.$this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>'; 253 253 } … … 260 260 return($Output); 261 261 } 262 262 263 263 function GetCategory() 264 264 { … … 267 267 if(array_key_exists('category', $_POST)) $Category['Id'] = $_POST['category'] * 1; 268 268 //if(is_null($Category)) throw new Exception('Kategorie neurčena'); 269 else 269 else 270 270 { 271 271 $DbResult = $this->Database->select('NewsCategory', '*', '`Id`='.$Category['Id'].' ORDER BY `Sequence`'); … … 275 275 return($Category); 276 276 } 277 277 278 278 function ShowMain() 279 279 { 280 $Output = ''; 280 $Output = ''; 281 281 if(array_key_exists('action',$_GET)) $Action = $_GET['action']; 282 282 else $Action = ''; … … 290 290 return($Output); 291 291 } 292 292 293 293 function ShowSubscription() 294 { 294 { 295 295 if(array_key_exists('build', $_GET)) 296 296 { … … 302 302 $Select = $this->System->Config['Web']['RootFolder'].'/aktuality/rss/?select='.substr($Select, 1); 303 303 $Output = 'Výsledný RSS kanál: <a href="'.$Select.'">'.$Select.'</a>'; 304 } else 304 } else 305 305 { 306 306 $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 />'. … … 314 314 $Output.= '<input type="submit" value="Sestavit"/>'. 315 315 '</form>'; 316 } 317 return($Output); 318 } 319 316 } 317 return($Output); 318 } 319 320 320 function ShowRSS() 321 321 { … … 332 332 $CategoryName = ''; 333 333 334 // Prepare WHERE condition 335 if(array_key_exists('select', $_GET)) 334 // Prepare WHERE condition 335 if(array_key_exists('select', $_GET)) 336 336 { 337 337 $Where = ''; … … 339 339 foreach($Parts as $Part) 340 340 { 341 $Where .= 'OR (`Category`='.($Part * 1).')'; 341 $Where .= 'OR (`Category`='.($Part * 1).')'; 342 342 } 343 343 $Where = substr($Where, 2); … … 354 354 // Update news from discussion forum 355 355 /* 356 $ForumCategory = 4; 356 $ForumCategory = 4; 357 357 $Database->select_db('forum'); 358 358 $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); … … 361 361 while($Row = $DbResult->fetch_array()) 362 362 { 363 $Row['post_text'] = StrTr($Row['post_text'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE"); 364 $Row['post_text'] = str_replace("\n","<br>", $Row['post_text']); 365 $Row['post_subject'] = StrTr($Row['post_subject'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE"); 366 $Row['topic_title'] = StrTr($Row['topic_title'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE"); 367 $Index = $Index + 1; 368 363 $Row['post_text'] = StrTr($Row['post_text'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE"); 364 $Row['post_text'] = str_replace("\n","<br>", $Row['post_text']); 365 $Row['post_subject'] = StrTr($Row['post_subject'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE"); 366 $Row['topic_title'] = StrTr($Row['topic_title'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE"); 367 $Index = $Index + 1; 368 369 369 $Title = $Row['topic_title'].'-'.$Row['post_subject']; 370 370 $Content = $Row['post_text']; … … 374 374 //echo('category='.$ForumCategory.' AND title="'.addslashes($Title).'" AND content="'.addslashes($Content).'" AND author="'.addslashes($Author).'" AND date="'.$Date.'"'); 375 375 $DbResult2 = $Database->select('news', '*', 'category='.$ForumCategory.' AND title="'.addslashes($Title).'" AND content="'.addslashes($Content).'" AND author="'.addslashes($Author).'" AND date="'.$Date.'"'); 376 if($DbResult2->num_rows == 0) //echo('.'); else echo('x'); 376 if($DbResult2->num_rows == 0) //echo('.'); else echo('x'); 377 377 $Database->insert('news', array('category' => $ForumCategory, 'title' => $Title, 'content' => $Content, 'author' => $Author, 'date' => $Date)); 378 //echo($Date); 378 //echo($Date); 379 379 $Database->select_db('forum'); 380 380 } … … 388 388 $EnclosuresText = ''; 389 389 if($Row['Enclosure'] != '') 390 { 390 { 391 391 $EnclosuresText .= '<br />Přílohy: '; 392 392 $Enclosures = explode(';', $Row['Enclosure']); 393 393 foreach($Enclosures as $Enclosure) 394 394 { 395 if(file_exists($this->UploadedFilesFolder.$Enclosure)) 396 $EnclosuresText .= ' <a href="'.$this->System->Link('/aktuality/'.$ UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>';395 if(file_exists($this->UploadedFilesFolder.$Enclosure)) 396 $EnclosuresText .= ' <a href="'.$this->System->Link('/aktuality/'.$this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>'; 397 397 } 398 398 } … … 409 409 $RSS = new RSS(); 410 410 $RSS->Title = $this->System->Config['Web']['Title'].' - Aktuality'; 411 $RSS->Link = 'http://'.$this->System->Config['Web']['Host'].'/'; 412 $RSS->Description = 'Aktuality '.$this->System->Config['Web']['Description']; 413 $RSS->WebmasterEmail = $this->System->Config['Web']['AdminEmail']; 411 $RSS->Link = 'http://'.$this->System->Config['Web']['Host'].'/'; 412 $RSS->Description = 'Aktuality '.$this->System->Config['Web']['Description']; 413 $RSS->WebmasterEmail = $this->System->Config['Web']['AdminEmail']; 414 414 $RSS->Items = $Items; 415 return($RSS->Generate()); 416 } 415 return($RSS->Generate()); 416 } 417 417 }
Note:
See TracChangeset
for help on using the changeset viewer.