Changeset 581
- Timestamp:
- Sep 12, 2013, 9:14:38 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 7 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Log/Log.php
r578 r581 13 13 $this->License = 'GNU/GPL'; 14 14 $this->Description = 'Log various application events'; 15 $this->Dependencies = array('Error' );15 $this->Dependencies = array('Error', 'News'); 16 16 17 17 $this->Excludes = array(); … … 22 22 $this->System->RegisterPage('log.php', 'PageLog'); 23 23 $this->System->ModuleManager->Modules['Error']->OnError[] = array($this, 'DoAddItem'); 24 $this->System->ModuleManager->Modules['News']->RegisterRSS(array('Title' => 'Záznamy', 25 'Channel' => 'log', 'Callback' => array('PageLog', 'ShowRSS'), 'Permission' => LICENCE_ADMIN)); 24 26 } 25 27 … … 111 113 if(array_key_exists('a', $_POST)) $Action = $_POST['a']; 112 114 else if(array_key_exists('a', $_GET)) $Action = $_GET['a']; 113 else $Action = ''; 114 if($Action == 'rss') $Output = $this->ShowRSS(); 115 else $Action = ''; 115 116 if($Action == 'delerrlog') $Output = $this->DeleteErrorLog(); 116 117 else $Output = $this->ShowList(); -
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 } -
trunk/Modules/News/RSS.php
r578 r581 1 1 <?php 2 2 3 $InitSystem = true; 4 include_once('includes/global.php'); 5 6 $Items = array(); 7 if($_GET['channel'] == 'news') 8 { 9 $DbResult = $System->Database->query('SELECT UNIX_TIMESTAMP(`News`.`Time`) AS `UnixTime`, '. 10 '`News`.`Title`, `News`.`Time`, `User`.`Name`, `News`.`Text` '. 11 'FROM `News` JOIN `User` ON `User`.`ID` = `News`.`User` ORDER BY `Time` DESC LIMIT 10'); 12 while($DbRow = $DbResult->fetch_assoc()) 13 { 14 $Items[] = array 15 ( 16 'Title' => $DbRow['Title'], 17 'Link' => 'http://'.$Config['Web']['Host'].$System->Link('/'), 18 'Description' => $DbRow['Text'].' ('.$DbRow['Name'].')', 19 'Time' => $DbRow['UnixTime'], 20 ); 21 } 22 echo(GenerateRSS(array 23 ( 24 'Title' => 'WoW překlad - Změny systému', 25 'Link' => 'http://'.$Config['Web']['Host'].$System->Link('/'), 26 'Description' => 'Překlad textů WoW', 27 'WebmasterEmail' => $Config['Web']['AdminEmail'], 28 'Items' => $Items, 29 ))); 30 } else 31 if($_GET['channel'] == 'translation') 32 { 33 $DbResult = $System->Database->query('SELECT UNIX_TIMESTAMP(`Date`) AS `Date`, `User`.`Name` AS `UserName`, `Text` FROM `Log` JOIN `User` ON `User`.`ID` = `Log`.`User` WHERE `Type` = 1 ORDER BY `Date` DESC LIMIT 100'); 34 while($DbRow = $DbResult->fetch_assoc()) 35 { 36 $Items[] = array 37 ( 38 'Title' => strip_tags($DbRow['Text'].' ('.$DbRow['UserName'].')'), 39 'Link' => 'http://'.$Config['Web']['Host'].$System->Link('/'), 40 'Description' => $DbRow['Text'], 41 'Time' => $DbRow['Date'], 42 ); 43 } 44 echo(GenerateRSS(array 45 ( 46 'Title' => 'WoW překlad - Poslední překlady', 47 'Link' => 'http://'.$Config['Web']['Host'].$System->Link('/'), 48 'Description' => 'Překlad textů WoW', 49 'WebmasterEmail' => $Config['Web']['AdminEmail'], 50 'Items' => $Items, 51 ))); 52 } else 53 if($_GET['channel'] == 'shoutbox') 54 { 55 $TitleLength = 50; 56 mb_internal_encoding('utf-8'); 57 $DbResult = $System->Database->query('SELECT UNIX_TIMESTAMP(`Date`) AS `UnixDate`, `User`, `UserName`, `Text` FROM `ShoutBox` ORDER BY `ID` DESC LIMIT 20'); 58 while($DbRow = $DbResult->fetch_assoc()) 59 { 60 $Title = mb_substr($DbRow['Text'], 0, $TitleLength); 61 if(mb_strlen($Title) == $TitleLength) $Title .= '...'; 62 $Items[] = array 63 ( 64 'Title' => $DbRow['UserName'].': '.$Title, 65 'Link' => 'http://'.$Config['Web']['Host'].$System->Link('/'), 66 'Description' => $DbRow['Text'], 67 'Time' => $DbRow['UnixDate'], 68 ); 69 } 70 echo(GenerateRSS(array 71 ( 72 'Title' => 'WoW překlad - Shoutbox', 73 'Link' => 'http://'.$Config['Web']['Host'].$System->Link('/'), 74 'Description' => 'Překlad textů WoW', 75 'WebmasterEmail' => $Config['Web']['AdminEmail'], 76 'Items' => $Items, 77 ))); 78 } else echo('Nezadán žádný kanál'); 3 function GenerateRSS($Data) 4 { 5 global $Config; 6 7 $Result = '<?xml version="1.0" encoding="'.$Config['Web']['Charset'].'" ?>'."\n". //<? 8 '<rss version="2.0">'."\n". 9 " <channel>\n". 10 " <title>".$Data['Title']."</title>\n". 11 " <link>".$Data['Link']."</link>\n". 12 " <description>".$Data['Description']."</description>\n". 13 " <language>cs</language>\n". 14 " <webMaster>".$Data['WebmasterEmail']."</webMaster>\n". 15 " <pubDate>".date('r')."</pubDate>\n". 16 " <ttl>20</ttl>\n"; 17 foreach($Data['Items'] as $Item) 18 { 19 $Result .= " <item>\n". 20 ' <title>'.htmlspecialchars($Item['Title'])."</title>\n". 21 ' <description>'.htmlspecialchars($Item['Description'])."</description>\n". 22 ' <pubDate>'.date('r',$Item['Time'])."</pubDate>\n". 23 ' <link>'.$Item['Link']."</link>\n". 24 " </item>\n"; 25 } 26 $Result .= " </channel>\n". 27 "</rss>"; 28 return($Result); 29 } 30 31 class PageRSS extends Page 32 { 33 function Show() 34 { 35 $this->RawPage = true; 36 37 if(array_key_exists($_GET['channel'], $this->System->ModuleManager->Modules['News']->RSSChannels)) 38 { 39 $Channel = $this->System->ModuleManager->Modules['News']->RSSChannels[$_GET['channel']]; 40 if($this->System->User->Licence($Channel['Permission'])) 41 { 42 if(is_string($Channel['Callback'][0])) 43 { 44 $Class = new $Channel['Callback'][0]($this->System); 45 $Output = $Class->$Channel['Callback'][1](); 46 } else $Output = call_user_func($Channel['Callback']); 47 } else $Output = 'Nemáte oprávnění'; 48 } else $Output = 'Nezadán žádný kanál'; 49 return($Output); 50 } 51 } -
trunk/Modules/ShoutBox/ShoutBox.php
r561 r581 11 11 $this->License = 'GNU/GPL'; 12 12 $this->Description = 'Simple user chat system.'; 13 $this->Dependencies = array( );13 $this->Dependencies = array('News'); 14 14 } 15 15 … … 17 17 { 18 18 $this->System->RegisterPage('shoutbox', 'PageShoutBox'); 19 $this->System->RegisterRSS(array('Title' => 'Kecátko', 'Channel' => 'shoutbox')); 20 19 $this->System->ModuleManager->Modules['News']->RegisterRSS(array( 20 'Title' => 'Kecátko', 'Channel' => 'shoutbox', 'Callback' => array('PageShoutBox', 'ShowRSS'), 21 'Permission' => LICENCE_ANONYMOUS)); 21 22 } 22 23 … … 120 121 return($Output); 121 122 } 123 124 function ShowRSS() 125 { 126 $TitleLength = 50; 127 mb_internal_encoding('utf-8'); 128 $DbResult = $this->Database->query('SELECT UNIX_TIMESTAMP(`Date`) AS `UnixDate`, `User`, `UserName`, `Text` FROM `ShoutBox` ORDER BY `ID` DESC LIMIT 20'); 129 while($DbRow = $DbResult->fetch_assoc()) 130 { 131 $Title = mb_substr($DbRow['Text'], 0, $TitleLength); 132 if(mb_strlen($Title) == $TitleLength) $Title .= '...'; 133 $Items[] = array 134 ( 135 'Title' => $DbRow['UserName'].': '.$Title, 136 'Link' => 'http://'.$this->System->Config['Web']['Host'].$this->System->Link('/'), 137 'Description' => $DbRow['Text'], 138 'Time' => $DbRow['UnixDate'], 139 ); 140 } 141 $Output = GenerateRSS(array 142 ( 143 'Title' => 'WoW překlad - Shoutbox', 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 } 122 151 } -
trunk/Modules/Translation/Translation.php
r561 r581 16 16 $this->License = 'GNU/GPL'; 17 17 $this->Description = 'Translation of text items and groups from original language to other languages.'; 18 $this->Dependencies = array( );18 $this->Dependencies = array('News'); 19 19 } 20 20 … … 25 25 $this->System->RegisterPage('save.php', 'PageTranslationSave'); 26 26 $this->System->RegisterPage('TranslationList.php', 'PageTranslationList'); 27 $this->System->RegisterRSS(array('Title' => 'Poslední překlady', 'Channel' => 'translation')); 27 $this->System->ModuleManager->Modules['News']->RegisterRSS(array('Title' => 'Poslední překlady', 28 'Channel' => 'translation', 'Callback' => array($this, 'ShowRSS'), 'Permission' => LICENCE_ANONYMOUS)); 29 } 30 31 function ShowRSS() 32 { 33 $DbResult = $this->Database->query('SELECT UNIX_TIMESTAMP(`Date`) AS `Date`, `User`.`Name` AS `UserName`, `Text` FROM `Log` JOIN `User` ON `User`.`ID` = `Log`.`User` WHERE `Type` = 1 ORDER BY `Date` DESC LIMIT 100'); 34 while($DbRow = $DbResult->fetch_assoc()) 35 { 36 $Items[] = array 37 ( 38 'Title' => strip_tags($DbRow['Text'].' ('.$DbRow['UserName'].')'), 39 'Link' => 'http://'.$this->System->Config['Web']['Host'].$this->System->Link('/'), 40 'Description' => $DbRow['Text'], 41 'Time' => $DbRow['Date'], 42 ); 43 } 44 $Output = GenerateRSS(array 45 ( 46 'Title' => 'WoW překlad - Poslední překlady', 47 'Link' => 'http://'.$this->System->Config['Web']['Host'].$this->System->Link('/'), 48 'Description' => 'Překlad textů WoW', 49 'WebmasterEmail' => $this->System->Config['Web']['AdminEmail'], 50 'Items' => $Items, 51 )); 52 return($Output); 28 53 } 29 54 } -
trunk/includes/Version.php
r580 r581 1 1 <?php 2 2 3 $Revision = 58 0; // Subversion revision3 $Revision = 581; // Subversion revision 4 4 $DatabaseRevision = 574; // Database structure revision 5 $ReleaseTime = '2013-09-1 1';5 $ReleaseTime = '2013-09-12'; -
trunk/includes/global.php
r579 r581 5 5 include_once(dirname(__FILE__).'/system.php'); 6 6 include_once(dirname(__FILE__).'/Update.php'); 7 include_once(dirname(__FILE__).'/rss.php');8 7 include_once(dirname(__FILE__).'/Page.php'); 9 8 if(file_exists(dirname(__FILE__).'/config.php')) -
trunk/includes/system.php
r579 r581 11 11 var $PathItems; 12 12 var $Menu; 13 var $RSSChannels;14 13 var $DoNotShowPage; 15 14 … … 188 187 } 189 188 190 function RegisterRSS($Channel, $Pos = NULL)191 {192 if(is_null($Pos)) $this->RSSChannels[] = $Channel;193 else {194 array_splice($this->RSSChannels, $Pos, 0, array($Channel));195 }196 }197 198 189 function SearchPage($PathItems, $Pages) 199 190 { … … 361 352 '<script type="text/javascript" src="'.$this->System->Link('/style/global.js').'"></script>'. 362 353 '<link rel="shortcut icon" href="'.$this->System->Link('/images/favicon.ico').'" />'; 363 foreach($this->System->RSSChannels as $Channel) 364 { 365 $Output .= ' <link rel="alternate" title="'.$Channel['Title'].'" href="'. 366 $this->System->Link('/rss.php?channel='.$Channel['Channel']).'" type="application/rss+xml" />'; 367 } 354 $Output .= $this->System->ModuleManager->Modules['News']->ShowRSSHeader(); 368 355 $Output .= '<title>'.$this->System->Config['Web']['Title'].'</title>'. 369 356 '</head><body>';
Note:
See TracChangeset
for help on using the changeset viewer.