Changeset 816 for trunk/Modules/FrontPage
- Timestamp:
- Feb 22, 2015, 11:20:50 PM (11 years ago)
- File:
-
- 1 edited
-
trunk/Modules/FrontPage/FrontPage.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/FrontPage/FrontPage.php
r809 r816 28 28 function HandleLoginForm() 29 29 { 30 global $Message, $MessageType;30 global $Message, $MessageType; 31 31 32 if(array_key_exists('action', $_GET))33 {34 if($_GET['action'] == 'login')35 {36 if(array_key_exists('LoginUser', $_POST) and array_key_exists('LoginPass', $_POST))37 {38 if(array_key_exists('StayLogged', $_POST)) $StayLogged = true;39 else $StayLogged = false;40 $this->System->User->Login($_POST['LoginUser'], $_POST['LoginPass'], $StayLogged);41 if($this->System->User->Role == LICENCE_ANONYMOUS)42 {43 $Message = T('Incorrect name or password');44 $MessageType = MESSAGE_CRITICAL;45 } else46 {47 $Message = sprintf(T('Login successful. Welcome <strong>%s</strong>!'), $this->System->User->Name);48 $MessageType = MESSAGE_INFORMATION;49 }50 } else51 {52 $Message = T('User name or password was not entered');53 $MessageType = MESSAGE_CRITICAL;54 }55 } else56 if($_GET['action'] == 'logout')57 {58 if($this->System->User->Role != LICENCE_ANONYMOUS)59 {60 $this->System->ModuleManager->Modules['Log']->WriteLog('Odhlášení', LOG_TYPE_USER);61 $this->System->User->Logout();62 $Message = T('You were logged out');63 $MessageType = MESSAGE_INFORMATION;64 }65 }66 }32 if(array_key_exists('action', $_GET)) 33 { 34 if($_GET['action'] == 'login') 35 { 36 if(array_key_exists('LoginUser', $_POST) and array_key_exists('LoginPass', $_POST)) 37 { 38 if(array_key_exists('StayLogged', $_POST)) $StayLogged = true; 39 else $StayLogged = false; 40 $this->System->User->Login($_POST['LoginUser'], $_POST['LoginPass'], $StayLogged); 41 if($this->System->User->Role == LICENCE_ANONYMOUS) 42 { 43 $Message = T('Incorrect name or password'); 44 $MessageType = MESSAGE_CRITICAL; 45 } else 46 { 47 $Message = sprintf(T('Login successful. Welcome <strong>%s</strong>!'), $this->System->User->Name); 48 $MessageType = MESSAGE_INFORMATION; 49 } 50 } else 51 { 52 $Message = T('User name or password was not entered'); 53 $MessageType = MESSAGE_CRITICAL; 54 } 55 } else 56 if($_GET['action'] == 'logout') 57 { 58 if($this->System->User->Role != LICENCE_ANONYMOUS) 59 { 60 $this->System->ModuleManager->Modules['Log']->WriteLog('Odhlášení', LOG_TYPE_USER); 61 $this->System->User->Logout(); 62 $Message = T('You were logged out'); 63 $MessageType = MESSAGE_INFORMATION; 64 } 65 } 66 } 67 67 } 68 68 } … … 72 72 function Show() 73 73 { 74 global $Message, $MessageType;74 global $Message, $MessageType; 75 75 76 $this->Title = T('Home');77 $this->System->ModuleManager->Modules['FrontPage']->HandleLoginForm();78 $Output = '';79 if(isset($Message)) $Output .= ShowMessage($Message, $MessageType);76 $this->Title = T('Home'); 77 $this->System->ModuleManager->Modules['FrontPage']->HandleLoginForm(); 78 $Output = ''; 79 if(isset($Message)) $Output .= ShowMessage($Message, $MessageType); 80 80 81 $Output .= '<br />'.82 '<table class="Home"><tr><td colspan="3">'.$this->ShowWelcome().83 '</td></tr>';81 $Output .= '<br />'. 82 '<table class="Home"><tr><td colspan="3">'.$this->ShowWelcome(). 83 '</td></tr>'; 84 84 $Output .= '<tr><td colspan="3"><h3><a href="'.$this->System->Link('/download/').'">'.T('Download Czech File').'</a></h3></td></tr>'; 85 85 86 $Output .= '<tr><td class="SideBox">'.$this->ShowLastTranslated().'</td>'.87 '<td class="news-box">'.$this->System->ModuleManager->Modules['News']->ShowBox().'</td>'.88 '<td class="SideBox">'.$this->System->ModuleManager->Modules['ShoutBox']->ShowBox().'</td>'.89 '</tr></table>';90 return($Output);86 $Output .= '<tr><td class="SideBox">'.$this->ShowLastTranslated().'</td>'. 87 '<td class="news-box">'.$this->System->ModuleManager->Modules['News']->ShowBox().'</td>'. 88 '<td class="SideBox">'.$this->System->ModuleManager->Modules['ShoutBox']->ShowBox().'</td>'. 89 '</tr></table>'; 90 return($Output); 91 91 } 92 92 93 93 function ShowLastTranslated() 94 94 { 95 $Count = 40;96 $Output = '<strong>'.T('Last translated').':</strong>';95 $Count = 40; 96 $Output = '<strong>'.T('Last translated').':</strong>'; 97 97 98 $GroupListQuery = 'SELECT `Group`.* FROM `Group`';99 $Query = '';100 $UnionItems = array();101 $DbResult = $this->Database->query($GroupListQuery);102 if($DbResult->num_rows > 0)103 {104 while($DbRow = $DbResult->fetch_assoc())105 {106 $UnionItems[] = 'SELECT `T`.`ID`, `T`.`Take`, `T`.`User`, `T`.`ModifyTime`, `T`.`Group`, `T`.`GroupName` '.107 'FROM (SELECT `T`.`User`, `T`.`ID`, `T`.`ModifyTime`, '.108 $DbRow['Id'].' AS `Group`, "'.addslashes($DbRow['Name']).'" AS `GroupName`, `T`.`Take` FROM `'.109 $DbRow['TablePrefix'].'` AS `T`'.110 ' WHERE (`T`.`Complete` = 1) AND (`T`.`Language` != '.$this->System->Config['OriginalLanguage'].') ORDER BY `T`.`ModifyTime` DESC LIMIT '.111 $Count.') AS `T`';112 }113 $Query = 'SELECT `TT`.*, `User`.`Name` AS `UserName`, `User`.`Id` AS `UserId` '.114 ' FROM ('.implode(' UNION ', $UnionItems).') AS `TT`'.115 ' JOIN `User` ON `User`.`Id` = `TT`.`User`'.116 ' ORDER BY `ModifyTime` DESC LIMIT '.$Count;117 $DbResult = $this->Database->query($Query);118 $Output .= '<table class="MiniTable"><tr><th>'.T('Date').'</th><th>'.T('Who').'</th><th>'.T('New').'</th><th>'.T('Source').'</th><th>'.T('Group').'</th></tr>';119 while($DbRow = $DbResult->fetch_assoc())120 {121 $Output .= '<tr><td>'.HumanDate($DbRow['ModifyTime']).'</td>'.122 '<td><a href="user.php?user='.$DbRow['UserId'].'">'.$DbRow['UserName'].'</a></td>'.123 '<td><a href="form.php?group='.$DbRow['Group'].'&ID='.$DbRow['ID'].'">'.$DbRow['ID'].'</a></td>'.124 '<td><a href="form.php?group='.$DbRow['Group'].'&ID='.$DbRow['Take'].'">'.$DbRow['Take'].'</a></td>'.125 '<td><a href="TranslationList.php?group='.$DbRow['Group'].'&action=filter">'.$DbRow['GroupName'].'</a></td></tr>';126 }127 $Output .= '</table>';128 }129 return($Output);98 $GroupListQuery = 'SELECT `Group`.* FROM `Group`'; 99 $Query = ''; 100 $UnionItems = array(); 101 $DbResult = $this->Database->query($GroupListQuery); 102 if($DbResult->num_rows > 0) 103 { 104 while($DbRow = $DbResult->fetch_assoc()) 105 { 106 $UnionItems[] = 'SELECT `T`.`ID`, `T`.`Take`, `T`.`User`, `T`.`ModifyTime`, `T`.`Group`, `T`.`GroupName` '. 107 'FROM (SELECT `T`.`User`, `T`.`ID`, `T`.`ModifyTime`, '. 108 $DbRow['Id'].' AS `Group`, "'.addslashes($DbRow['Name']).'" AS `GroupName`, `T`.`Take` FROM `'. 109 $DbRow['TablePrefix'].'` AS `T`'. 110 ' WHERE (`T`.`Complete` = 1) AND (`T`.`Language` != '.$this->System->Config['OriginalLanguage'].') ORDER BY `T`.`ModifyTime` DESC LIMIT '. 111 $Count.') AS `T`'; 112 } 113 $Query = 'SELECT `TT`.*, `User`.`Name` AS `UserName`, `User`.`Id` AS `UserId` '. 114 ' FROM ('.implode(' UNION ', $UnionItems).') AS `TT`'. 115 ' JOIN `User` ON `User`.`Id` = `TT`.`User`'. 116 ' ORDER BY `ModifyTime` DESC LIMIT '.$Count; 117 $DbResult = $this->Database->query($Query); 118 $Output .= '<table class="MiniTable"><tr><th>'.T('Date').'</th><th>'.T('Who').'</th><th>'.T('New').'</th><th>'.T('Source').'</th><th>'.T('Group').'</th></tr>'; 119 while($DbRow = $DbResult->fetch_assoc()) 120 { 121 $Output .= '<tr><td>'.HumanDate($DbRow['ModifyTime']).'</td>'. 122 '<td><a href="user.php?user='.$DbRow['UserId'].'">'.$DbRow['UserName'].'</a></td>'. 123 '<td><a href="form.php?group='.$DbRow['Group'].'&ID='.$DbRow['ID'].'">'.$DbRow['ID'].'</a></td>'. 124 '<td><a href="form.php?group='.$DbRow['Group'].'&ID='.$DbRow['Take'].'">'.$DbRow['Take'].'</a></td>'. 125 '<td><a href="TranslationList.php?group='.$DbRow['Group'].'&action=filter">'.$DbRow['GroupName'].'</a></td></tr>'; 126 } 127 $Output .= '</table>'; 128 } 129 return($Output); 130 130 } 131 131 132 132 function ShowWelcome() 133 133 { 134 // Cookies have to be used before any text is sent to output135 if(!array_key_exists('HideWelcome', $_COOKIE)) $_COOKIE['HideWelcome'] = 0;136 if(isset($_GET['Action']))137 {138 if($_GET['Action'] == 'HideWelcome')134 // Cookies have to be used before any text is sent to output 135 if(!array_key_exists('HideWelcome', $_COOKIE)) $_COOKIE['HideWelcome'] = 0; 136 if(isset($_GET['Action'])) 137 { 138 if($_GET['Action'] == 'HideWelcome') 139 139 { 140 140 $_COOKIE['HideWelcome'] = 1; 141 141 setcookie('HideWelcome', $_COOKIE['HideWelcome'], time() + 3600 * 24 * 365); 142 142 } 143 if($_GET['Action'] == 'UnHideWelcome')143 if($_GET['Action'] == 'UnHideWelcome') 144 144 { 145 $_COOKIE['HideWelcome'] = 0;145 $_COOKIE['HideWelcome'] = 0; 146 146 setcookie('HideWelcome', $_COOKIE['HideWelcome'], time() + 3600 * 24 * 365); 147 }148 }147 } 148 } 149 149 150 if(isset($_COOKIE['HideWelcome']) and ($_COOKIE['HideWelcome'] == 1))151 {152 $Action = '<a href="?Action=UnHideWelcome">'.T('Show welcome').'</a>';153 $HideWelcome = 'display: none';154 } else155 {156 $Action = '<a href="?Action=HideWelcome">'.T('Hide welcome').'</a>';157 $HideWelcome = '';158 }150 if(isset($_COOKIE['HideWelcome']) and ($_COOKIE['HideWelcome'] == 1)) 151 { 152 $Action = '<a href="?Action=UnHideWelcome">'.T('Show welcome').'</a>'; 153 $HideWelcome = 'display: none'; 154 } else 155 { 156 $Action = '<a href="?Action=HideWelcome">'.T('Hide welcome').'</a>'; 157 $HideWelcome = ''; 158 } 159 159 160 // Echo text even if it is hidden because of caching by external searching engines161 return('<div style="'.$HideWelcome.'">'.162 '<div id="bannertitle">'.$this->System->Config['Web']['Title'].'</div>'.163 'Otevřený webový systém pro překládání textů ze hry World of Warcraft (WoW).<br />'.164 '<ul>'.165 '<li>Projekt je provozován jako otevřený vyznává principy volnosti a otevřenosti. Proto jsou texty volně ke stažení.</li>'.166 '<li>Projekt slouží k týmovému překladu. Kdokoliv může přispět přeložením textů a uveřejněním odkazu popř. banneru na svých stránkách.</li>'.167 '<li>Projekt není zaměřen pouze na jeden server a umožňuje společné překládání lidem z různých serverů. Překladatelé mohou překládat v týmech podle jména svého serveru a exportovat texty pouze od vybraných překladatelů.</li>'.168 '<li>Přeložené texty lze volně stahovat v různých tvarech jako XML, SQL, Addon a Lua. Přeložené texty lze tedy snadno importovat do svého free serveru nebo použít v jiných projektech.</li>'.169 '<li>Cílem projektu je přeložit všechny texty ze hry. Nikoliv pouze texty výprav (questů).</li>'.160 // Echo text even if it is hidden because of caching by external searching engines 161 return('<div style="'.$HideWelcome.'">'. 162 '<div id="bannertitle">'.$this->System->Config['Web']['Title'].'</div>'. 163 'Otevřený webový systém pro překládání textů ze hry World of Warcraft (WoW).<br />'. 164 '<ul>'. 165 '<li>Projekt je provozován jako otevřený vyznává principy volnosti a otevřenosti. Proto jsou texty volně ke stažení.</li>'. 166 '<li>Projekt slouží k týmovému překladu. Kdokoliv může přispět přeložením textů a uveřejněním odkazu popř. banneru na svých stránkách.</li>'. 167 '<li>Projekt není zaměřen pouze na jeden server a umožňuje společné překládání lidem z různých serverů. Překladatelé mohou překládat v týmech podle jména svého serveru a exportovat texty pouze od vybraných překladatelů.</li>'. 168 '<li>Přeložené texty lze volně stahovat v různých tvarech jako XML, SQL, Addon a Lua. Přeložené texty lze tedy snadno importovat do svého free serveru nebo použít v jiných projektech.</li>'. 169 '<li>Cílem projektu je přeložit všechny texty ze hry. Nikoliv pouze texty výprav (questů).</li>'. 170 170 '<li>Díky propracovanému systému volitelných exportů si můžete stáhnout libovolnou část překladu, klidně pouze výpravy. A vynechat tak překlady předmětů, jména postav a jiných.</li>'. 171 '<li>Texty lze překládat do dvou jazyků, češtiny a slovenštiny.</li>'.172 '</ul></div>'.$Action);171 '<li>Texty lze překládat do dvou jazyků, češtiny a slovenštiny.</li>'. 172 '</ul></div>'.$Action); 173 173 } 174 174 }
Note:
See TracChangeset
for help on using the changeset viewer.
