Changeset 581 for trunk/Modules/News/News.php
- Timestamp:
- Sep 12, 2013, 9:14:38 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/News/News.php
r578 r581 1 1 <?php 2 3 include_once(dirname(__FILE__).'/RSS.php'); 2 4 3 5 class ModuleNews extends AppModule 4 6 { 7 var $RSSChannels; 8 5 9 function __construct($System) 6 10 { … … 17 21 { 18 22 $this->System->RegisterPage('news', 'PageNews'); 19 $this->System->RegisterRSS(array('Title' => 'Změny systému', 'Channel' => 'news')); 23 $this->System->RegisterPage('rss', 'PageRSS'); 24 $this->RegisterRSS(array('Title' => 'Změny systému', 'Channel' => 'news', 25 'Callback' => array('PageNews', 'ShowRSS'), 'Permission' => LICENCE_ANONYMOUS)); 20 26 } 21 27 … … 24 30 $Output = '<strong>Změny systému:</strong><div class="NewsBox">'; 25 31 $DbResult = $this->Database->query('SELECT `News`.`Time`, `User`.`Name`, `News`.`Text`,`News`.`Title`'. 26 32 ' FROM `News` JOIN `User` ON `User`.`ID` = `News`.`User` ORDER BY `Time` DESC LIMIT 10'); 27 33 while($DbRow = $DbResult->fetch_assoc()) 28 34 $Output .= '<div><strong>'.$DbRow['Title'].' ('.HumanDate($DbRow['Time']).')</strong> <br />'.$DbRow['Text'].' ('.$DbRow['Name'].')</div>'; 29 35 $Output .= '<a href="'.$this->System->Link('/news/').'">Všechny zprávy</a>'; 30 $Output .= '</div>'; 36 $Output .= '</div>'; 31 37 return($Output); 38 } 39 40 function RegisterRSS($Channel, $Pos = NULL, $Callback = NULL) 41 { 42 $this->RSSChannels[$Channel['Channel']] = $Channel; 43 44 if(is_null($Pos)) $this->RSSChannelsPos[] = $Channel['Channel']; 45 else { 46 array_splice($this->RSSChannelsPos, $Pos, 0, $Channel['Channel']); 47 } 48 } 49 50 function ShowRSSHeader() 51 { 52 $Output = ''; 53 foreach($this->RSSChannels as $Channel) 54 { 55 if($this->System->User->Licence($Channel['Permission'])) 56 $Output .= ' <link rel="alternate" title="'.$Channel['Title'].'" href="'. 57 $this->System->Link('/rss/?channel='.$Channel['Channel']).'" type="application/rss+xml" />'; 58 } 59 return($Output); 32 60 } 33 61 } … … 95 123 return($Output); 96 124 } 125 126 function ShowRSS() 127 { 128 $DbResult = $this->Database->query('SELECT UNIX_TIMESTAMP(`News`.`Time`) AS `UnixTime`, '. 129 '`News`.`Title`, `News`.`Time`, `User`.`Name`, `News`.`Text` '. 130 'FROM `News` JOIN `User` ON `User`.`ID` = `News`.`User` ORDER BY `Time` DESC LIMIT 10'); 131 while($DbRow = $DbResult->fetch_assoc()) 132 { 133 $Items[] = array 134 ( 135 'Title' => $DbRow['Title'], 136 'Link' => 'http://'.$this->System->Config['Web']['Host'].$this->System->Link('/'), 137 'Description' => $DbRow['Text'].' ('.$DbRow['Name'].')', 138 'Time' => $DbRow['UnixTime'], 139 ); 140 } 141 $Output = GenerateRSS(array 142 ( 143 'Title' => 'WoW překlad - Změny systému', 144 'Link' => 'http://'.$this->System->Config['Web']['Host'].$this->System->Link('/'), 145 'Description' => 'Překlad textů WoW', 146 'WebmasterEmail' => $this->System->Config['Web']['AdminEmail'], 147 'Items' => $Items, 148 )); 149 return($Output); 150 } 97 151 }
Note:
See TracChangeset
for help on using the changeset viewer.