Changeset 816 for trunk/Modules
- Timestamp:
- Feb 22, 2015, 11:20:50 PM (10 years ago)
- Location:
- trunk/Modules
- Files:
-
- 40 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/AoWoW/AoWoW.php
r815 r816 16 16 function Start() 17 17 { 18 19 20 21 22 23 18 $this->System->RegisterMenuItem(array( 19 'Title' => 'AoWoW', 20 'Hint' => 'Vyhledávací databáze podobná WoWHead s překlady', 21 'Link' => $this->System->Link('/aowow/'), 22 'Permission' => LICENCE_ANONYMOUS, 23 'Icon' => '', 24 24 )); 25 25 if(array_key_exists('Search', $this->System->ModuleManager->Modules)) -
trunk/Modules/ClientVersion/ClientVersion.php
r800 r816 16 16 function Start() 17 17 { 18 19 20 21 22 23 24 18 $this->System->RegisterPage('client-version', 'PageClientVersion'); 19 $this->System->RegisterMenuItem(array( 20 'Title' => T('Game version'), 21 'Hint' => T('List of the game client versions'), 22 'Link' => $this->System->Link('/client-version/'), 23 'Permission' => LICENCE_ANONYMOUS, 24 'Icon' => '', 25 25 ), 10); 26 26 } … … 29 29 class PageClientVersion extends Page 30 30 { 31 32 33 34 35 36 37 38 39 31 function Show() 32 { 33 if(array_key_exists('action', $_GET)) 34 { 35 if($_GET['action'] == 'item') $Output = $this->ShowItem(); 36 else $Output = $this->ShowList(); 37 } else $Output = $this->ShowList(); 38 return($Output); 39 } 40 40 41 42 41 function ShowItem() 42 { 43 43 if(array_key_exists('id', $_GET)) 44 44 { … … 64 64 } else $Output = ShowMessage(T('Item not found'), MESSAGE_CRITICAL); 65 65 } else $Output = ShowMessage(T('Item not found'), MESSAGE_CRITICAL); 66 67 66 return($Output); 67 } 68 68 69 70 71 69 function ShowList() 70 { 71 $this->Title = T('Game version'); 72 72 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `ClientVersion`'); 73 73 $DbRow = $DbResult->fetch_row(); -
trunk/Modules/Dictionary/Dictionary.php
r809 r816 13 13 $this->Dependencies = array(); 14 14 } 15 15 16 16 function Start() 17 17 { 18 19 20 21 22 23 24 25 18 $this->System->RegisterPage('dictionary', 'PageDictionary'); 19 $this->System->RegisterMenuItem(array( 20 'Name' => 'Dictionary', 21 'Title' => T('Dictionary'), 22 'Hint' => T('Dictionary words from WoW'), 23 'Link' => $this->System->Link('/dictionary/'), 24 'Permission' => LICENCE_ANONYMOUS, 25 'Icon' => '', 26 26 ), 1); 27 27 if(array_key_exists('Search', $this->System->ModuleManager->Modules)) 28 28 $this->System->ModuleManager->Modules['Search']->RegisterSearch('dictionary', 29 T('Dictionary'), array('Text', 'Description'), 29 T('Dictionary'), array('Text', 'Description'), 30 30 '(SELECT * FROM `Dictionary` WHERE `Language` = '.$this->System->Config['OriginalLanguage'].') AS `T`', $this->System->Link('/dictionary/?search=')); 31 31 } … … 35 35 { 36 36 37 function WriteTranslatNames($Text, $mode) 37 function WriteTranslatNames($Text, $mode) 38 38 { 39 39 $Output = ''; … … 62 62 63 63 $buff = GetTranslatNames($Text,$mode,GetTranslatNamesArray()); 64 64 65 65 // $buff[] = array($Line['ID'],GetIDbyName($Table),$Line[$Column],$Line['Tran']); 66 66 foreach($buff as $Line) { 67 if ($mode == 0) 68 { 69 if (strpos(strtolower($Text), strtolower($Line[2])) > 0) 67 if ($mode == 0) 68 { 69 if (strpos(strtolower($Text), strtolower($Line[2])) > 0) 70 70 { 71 71 $Output .= '<tr><td>'.$Line[2].'</td>'; … … 73 73 else $Output .= '<td><a target="_NEW2" href="'.$this->System->Link('/form.php?group='.$Line[1].'&ID='.$Line[0]).'">Překládat</a></td></tr>'; 74 74 } 75 } else 75 } else 76 76 { 77 77 $Output .= '<tr><td>'.$Line[2].'</td>'; … … 101 101 '</form>'; 102 102 } else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 103 return($Output); 103 return($Output); 104 104 } 105 105 … … 125 125 '`User`, `Language` ) VALUES ("'.$_POST['Original'].'", "'.$Entry.'", "", NULL, '.$this->System->Config['OriginalLanguage'].');'); 126 126 } 127 127 128 128 $DbResult = $this->Database->query('SELECT `Id` FROM `Dictionary` WHERE '. 129 129 '`Entry` = '.$Entry.' AND `Language`='.$_POST['Language'].' AND `User`='.$this->System->User->Id); … … 136 136 $this->Database->query('INSERT INTO `Dictionary` ( `Text` , `Entry` , `Description` , '. 137 137 '`User`, `Language` ) VALUES ("'.$_POST['Translated'].'", "'.$Entry.'", "'. 138 138 $_POST['Description'].'", '.$this->System->User->Id.', '.$_POST['Language'].')'); 139 139 $Output = ShowMessage('Záznam byl uložen!'); 140 140 } else $Output = ShowMessage(T('You have to fill all column of form.'), MESSAGE_CRITICAL); 141 141 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 142 return($Output); 142 return($Output); 143 143 } 144 144 … … 176 176 '</fieldset>'. 177 177 '</form>'; 178 } else $Output = ShowMessage(T('Item not found'), MESSAGE_CRITICAL); 178 } else $Output = ShowMessage(T('Item not found'), MESSAGE_CRITICAL); 179 179 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 180 180 return($Output); … … 184 184 { 185 185 global $TranslationTree; 186 186 187 187 $Output = ''; 188 188 $GroupId = LoadGroupIdParameter(); … … 190 190 else $mode = 0; //0 = exact names, 1=all names, 2=nontranslated 191 191 $Table = $TranslationTree[$GroupId]['TablePrefix']; 192 192 193 193 if(array_key_exists('ID', $_GET)) 194 194 { … … 208 208 $Output .= $this->WriteTranslatNames($Text, $mode); 209 209 } 210 } 210 } 211 211 return($Output); 212 212 } … … 215 215 { 216 216 global $LanguageList; 217 217 218 218 $Output = '<form action="?" method="get" style="margin: 0px; padding: 0px;">'. 219 219 '<table style="width: 100%; height: 100%;">'; … … 221 221 if(array_key_exists('search', $_GET)) $Search = $_GET['search']; 222 222 else $Search = ''; 223 223 224 224 $Output .= '<tr><td> 225 225 <input type="text" value="'.$Search.'" name="search" size="30" /> 226 226 <input type="submit" value="'.T('Search').'" />'; 227 if($this->System->User->Licence(LICENCE_USER)) 228 229 230 $Output .= '</td></tr>'. 227 if($this->System->User->Licence(LICENCE_USER)) 228 $Output .= ' <a href="?action=insert">'.T('Add word').'</a>'; 229 230 $Output .= '</td></tr>'. 231 231 '<tr><td>'.T('Language').': '; 232 232 $Lang = '<a href="?language=">'.T('All').'</a>'; … … 236 236 if($Language['Enabled'] == 1) 237 237 { 238 238 $Lang = ' <a href="?language='.$Language['Id'].'">'.$Language['Name'].'</a>'; 239 239 if($Language['Id'] == $_SESSION['language']) $Output .= '<strong>'.$Lang.'</strong> '; 240 240 else $Output .= $Lang; … … 247 247 else $LanguageFilter = ' AND (`T1`.`Language` = '.$_SESSION['language'].')'; 248 248 249 if($Search <> '') 249 if($Search <> '') 250 250 { 251 251 $Condition = ' AND (LOWER(`T1`.`Text`) LIKE LOWER("%'.$Search.'%")) OR '. 252 252 ' (LOWER(`T2`.`Text`) LIKE LOWER("%'.$Search.'%")) OR '. 253 253 '(LOWER(`T1`.`Description`) LIKE LOWER("%'.$Search.'%"))'; 254 } else $Condition = ''; 254 } else $Condition = ''; 255 255 $sql = 'SELECT `User`.`Name` AS `UserName`, `User`.`Id` AS `UserId`, '. 256 256 '`Language`.`Name` AS `LangName`, `T1`.`Id` AS `Id`, '. 257 '`T1`.`Entry`, `T2`.`Text` AS `Original`, `T1`.`Text` AS `Translated`, `T1`.`Description` '. 257 '`T1`.`Entry`, `T2`.`Text` AS `Original`, `T1`.`Text` AS `Translated`, `T1`.`Description` '. 258 258 'FROM `Dictionary` AS `T1` JOIN `Dictionary` AS `T2` '. 259 259 'ON (`T2`.`Entry` = `T1`.`Entry`) AND (`T2`.`Language` = '.$this->System->Config['OriginalLanguage'].') '. … … 262 262 'WHERE 1'. 263 263 $LanguageFilter.$Condition; 264 264 265 265 $DbResult = $this->Database->query('SELECT COUNT(*) FROM ('.$sql.') AS `T1`'); 266 266 $DbRow = $DbResult->fetch_row(); 267 $PageList = GetPageList($DbRow[0]); 267 $PageList = GetPageList($DbRow[0]); 268 268 269 269 $Output .= $PageList['Output']; 270 270 271 271 if(is_numeric($_SESSION['language'])) $LanguageName = $LanguageList[$_SESSION['language']]['Name']; 272 272 else $LanguageName = 'Překlad'; 273 $TableColumns = array( 274 array('Name' => 'Original', 'Title' => T('English')), 273 $TableColumns = array( 274 array('Name' => 'Original', 'Title' => T('English')), 275 275 array('Name' => 'Translated', 'Title' => $LanguageName), 276 ); 276 ); 277 277 if(!is_numeric($_SESSION['language'])) $TableColumns[] = array('Name' => 'LangName', 'Title' => T('Language')); 278 278 $TableColumns[] = array('Name' => 'Description', 'Title' => T('Description')); 279 $TableColumns[] = array('Name' => 'UserName', 'Title' => T('Translator')); 279 $TableColumns[] = array('Name' => 'UserName', 'Title' => T('Translator')); 280 280 if($this->System->User->Licence(LICENCE_USER)) $TableColumns[] = array('Name' => '', 'Title' => T('Action')); 281 281 $Order = GetOrderTableHeader($TableColumns, 'Original'); … … 284 284 $sql_page = $sql.$Order['SQL'].$PageList['SQLLimit']; 285 285 $DbResult = $this->Database->query($sql_page); 286 while($Line = $DbResult->fetch_assoc()) 286 while($Line = $DbResult->fetch_assoc()) 287 287 { 288 288 $Output .= '<tr>'. … … 294 294 if($this->System->User->Licence(LICENCE_USER)) 295 295 { 296 if($Line['UserId'] == $this->System->User->Id) 296 if($Line['UserId'] == $this->System->User->Id) 297 297 $Output .= '<td><a href="?action=remove&id='.$Line['Id'].'" onclick="return confirmAction(\''.T('Do you really want to delete item?').'\');">'.T('Delete').'</a>'. 298 298 ' <a href="?action=modify&id='.$Line['Id'].'">'.T('Modify').'</a></td>'; … … 301 301 $Output .= '</tr>'; 302 302 } 303 $Output .= '</table>'. 303 $Output .= '</table>'. 304 304 $PageList['Output']. 305 '</td></tr>'. 305 '</td></tr>'. 306 306 '</table></form>'; 307 307 return($Output); … … 310 310 function Show() 311 311 { 312 313 314 315 312 global $LanguageList; 313 314 $this->Title = T('Dictionary'); 315 316 316 $LanguageList = GetLanguageList(); 317 317 318 318 if(!isset($_SESSION['language'])) 319 319 { 320 321 322 320 if($this->System->User->Licence(LICENCE_USER)) 321 { 322 $_SESSION['language'] = $this->System->User->Language; 323 323 } else $_SESSION['language'] = ''; 324 324 } 325 325 if(array_key_exists('language', $_GET)) { 326 326 if($_GET['language'] == '') $_SESSION['language'] = ''; 327 327 else $_SESSION['language'] = $_GET['language'] * 1; 328 328 } 329 329 … … 331 331 332 332 $ShowList = true; 333 if(array_key_exists('action', $_GET)) 333 if(array_key_exists('action', $_GET)) 334 334 { 335 335 if($_GET['action'] == 'group') { … … 337 337 $ShowList = false; 338 338 } 339 else if($_GET['action'] == 'insert') $Output .= $this->DictionaryInsert(); 340 else if($_GET['action'] == 'save') $Output .= $this->DictionarySave(); 339 else if($_GET['action'] == 'insert') $Output .= $this->DictionaryInsert(); 340 else if($_GET['action'] == 'save') $Output .= $this->DictionarySave(); 341 341 else if($_GET['action'] == 'remove') $Output .= $this->DictionaryRemove(); 342 342 else if($_GET['action'] == 'modify') $Output .= $this->DictionaryModify(); 343 else $Output .= ShowMessage(T('Unknown action'), MESSAGE_CRITICAL); 344 } 343 else $Output .= ShowMessage(T('Unknown action'), MESSAGE_CRITICAL); 344 } 345 345 if($ShowList == true) $Output .= $this->DictionaryShow(); 346 346 return($Output); -
trunk/Modules/Download/Download.php
r800 r816 3 3 class ModuleDownload extends AppModule 4 4 { 5 6 7 8 9 10 11 12 13 14 5 function __construct($System) 6 { 7 parent::__construct($System); 8 $this->Name = 'Download'; 9 $this->Version = '1.0'; 10 $this->Creator = 'Maron'; 11 $this->License = 'GNU/GPL'; 12 $this->Description = 'Show list of selected export and link to static files'; 13 $this->Dependencies = array(); 14 } 15 15 16 17 18 19 16 function Start() 17 { 18 $this->System->RegisterPage('download', 'PageDownload'); 19 $this->System->RegisterMenuItem(array( 20 20 'Title' => T('Download'), 21 21 'Hint' => T('List of czech to download'), … … 24 24 'Icon' => '', 25 25 ), 1); 26 26 } 27 27 } 28 28 29 29 class PageDownload extends Page 30 30 { 31 32 31 function ShowFiles() 32 { 33 33 $fileslink = $this->System->Link('/files'); 34 34 $Output = '<h3>'.T('Accessories for client').'</h3>'. … … 75 75 '<a href="'.$fileslink.'/ClientDBExtractor.exe">ClientDBExtractor.exe</a> - '.T('tool for exporting dbc files from game client').'<br />'; 76 76 return($Output); 77 77 } 78 78 79 80 79 function ShowDownload() 80 { 81 81 $Output = '<h3>'.T('Download czech').'</h3><br />'; 82 82 … … 101 101 $Output .= '<table class="BaseTable">'. 102 102 $Order['Output']; 103 103 $DbRows = $this->Database->query('SELECT `ClientVersion`.`Version` AS `Version`, '. 104 104 '`Export`.`Id`, `Export`.`ClientVersion`, `Export`.`OutputType`, `Export`.`Title`, '. 105 105 '`Export`.`Description` FROM `Export` '. … … 110 110 $ExportId = $DbExport['Id']; 111 111 112 113 114 115 112 if ($DbExport['OutputType'] == 10) 113 $filename = $this->System->Config['Web']['TempFolder'].'Export/'.$ExportId.'/'.'Instalace_CzechWoW_'.$DbExport['Version'].'.exe'; 114 if ($DbExport['OutputType'] == 7) 115 $filename = $this->System->Config['Web']['TempFolder'].'Export/'.$ExportId.'/'.'CzWoW_Addon-'.$DbExport['Version'].'.zip'; 116 116 117 117 if ($DbExport['OutputType'] == 10) 118 118 $Output .= '<tr><td><a href="'.$this->System->Link('/'.$filename). 119 119 '">CzechWoW_'.$DbExport['Version'].'.exe</a><br /> <a href="'. 120 120 $this->System->Link('/export/?Action=View&ExportId='.$ExportId).'">Export '.$ExportId.'</a></td>'; 121 121 else 122 122 if ($DbExport['OutputType'] == 7) 123 123 $Output .= '<tr><td><a href="'.$this->System->Link('/'.$filename). 124 124 '">CzWoW_Addon-'.$DbExport['Version'].'.zip</a><br /> <a href="'. … … 131 131 $Output .= '<td>'.$DbExport['Title'].'</td>'; //.'<td>'.$DbExport['ClientVersion'].'</td>'; 132 132 133 133 if ((($DbExport['OutputType'] == 10) or ($DbExport['OutputType'] == 7)) and (file_exists($filename))) 134 134 $Output .= '<td>'.date('d.m.y H:i',filemtime($filename)).'</td>'; 135 135 else 136 136 $Output .= '<td> </td>'; 137 137 138 139 138 $Output .= 139 '<td>'.str_replace("\n", '<br />',$DbExport['Description']).'</td>'. 140 140 '</tr>'; 141 141 } … … 146 146 } 147 147 148 149 150 151 148 function Show() 149 { 150 $this->Title = T('Download'); 151 $Output = ''; 152 152 if (isset($_GET['Files'])) $Output .= $this->ShowFiles(); 153 153 else $Output .= $this->ShowDownload(); -
trunk/Modules/Error/Error.php
r790 r816 7 7 var $UserErrors; 8 8 var $OnError; 9 9 10 10 function __construct($System) 11 11 { … … 23 23 $this->OnError = array(); 24 24 } 25 25 26 26 function Install() 27 27 { … … 32 32 { 33 33 parent::UnInstall(); 34 } 35 34 } 35 36 36 function Start() 37 37 { … … 40 40 set_exception_handler(array($this, 'ExceptionHandler')); 41 41 } 42 42 43 43 function Stop() 44 44 { 45 46 47 45 restore_error_handler(); 46 restore_exception_handler(); 47 parent::Stop(); 48 48 } 49 49 50 50 function ErrorHandler($Number, $Message, $FileName, $LineNumber, $Variables) 51 51 { … … 64 64 1024 => 'User Notice' 65 65 ); 66 66 67 67 if(($this->UserErrors & $Number)) 68 68 { … … 73 73 $Backtrace[0]['line'] = $LineNumber; 74 74 $this->Report($Backtrace); 75 //if((E_ERROR | E_PARSE) & $Number) 76 die(); 75 //if((E_ERROR | E_PARSE) & $Number) 76 die(); 77 77 } 78 78 } 79 80 function ExceptionHandler(Exception $Exception) 79 80 function ExceptionHandler(Exception $Exception) 81 81 { 82 $Backtrace = $Exception->getTrace(); 82 $Backtrace = $Exception->getTrace(); 83 83 array_unshift($Backtrace, array( 84 84 'function' => $Exception->getMessage(), … … 89 89 die(); 90 90 } 91 91 92 92 function Report($Backtrace) 93 93 { 94 $Date = date('Y-m-d H:i:s'); 94 $Date = date('Y-m-d H:i:s'); 95 95 $Error = '# '.$Date."\n"; 96 96 foreach($Backtrace as $Item) … … 98 98 if(!array_key_exists('line', $Item)) $Item['line'] = ''; 99 99 if(!array_key_exists('file', $Item)) $Item['file'] = ''; 100 100 101 101 $Error .= ' '.$Item['file'].'('.$Item['line'].")\t".$Item['function']; 102 102 $Arguments = ''; … … 112 112 } 113 113 $Error .= "\n"; 114 114 115 115 // Show error message 116 116 $Output = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>'."\n". 117 117 '<meta http-equiv="Content-Language" content="cs">'."\n". 118 118 '<meta http-equiv="Content-Type" content="text/html; charset='.$this->Encoding.'"></head><body>'."\n". 119 T('An internal error occurred! <br /> Administrator has been made aware of it and the error soon will be removed.').'<br/><br/>'; 119 T('An internal error occurred! <br /> Administrator has been made aware of it and the error soon will be removed.').'<br/><br/>'; 120 120 if($this->ShowError == true) 121 121 $Output .= '<pre>'.$Error.'</pre><br/>'; … … 125 125 $OnError[0]->$OnError[1]($Error); 126 126 } 127 } 127 } -
trunk/Modules/Export/CreateAddon.php
r788 r816 5 5 class ExportAddon extends Export 6 6 { 7 7 8 8 // Replace special codes by lua functions 9 9 function ReplaceVarInText($string, $strlower = 'strlower') 10 10 { 11 11 12 12 $string = str_replace('$N', '"..'.$strlower.'(UnitName("player")).."', $string); 13 13 $string = str_replace('$n', '"..'.$strlower.'(UnitName("player")).."', $string); … … 17 17 $string = str_replace('$r', '"..'.$strlower.'(UnitRace("player")).."', $string); 18 18 $Gender = '$G'; 19 while(strpos($string, $Gender) !== false) 19 while(strpos($string, $Gender) !== false) 20 20 { 21 21 $Before = substr($string, 0, strpos($string, $Gender)); … … 28 28 $Woman = str_replace(' ', '', $Woman); 29 29 $string = $Before.'"..gsub(gsub(UnitSex("player"), "^2$", "'.$Man.'"), "^3$", "'.$Woman.'").."'.$After; 30 } 30 } 31 31 $Gender = '$g'; 32 while(strpos($string, $Gender) !== false) 32 while(strpos($string, $Gender) !== false) 33 33 { 34 34 $Before = substr($string, 0, strpos($string, $Gender)); … … 41 41 $Woman = str_replace(' ', '', $Woman); 42 42 $string = $Before.'"..gsub(gsub(UnitSex("player"), "^2$", "'.$Man.'"),"^3$", "'.$Woman.'").."'.$After; 43 } 43 } 44 44 45 45 $string = str_replace('$', '', $string); 46 46 $string = str_replace("\r", '', $string); 47 47 $string = str_replace("\n", '\r\n', $string); 48 return($string); 48 return($string); 49 49 } 50 50 … … 53 53 // $string = mysql_escape_string($string); 54 54 $string = strtolower($string); 55 55 56 56 $string = str_replace('"', '\"', $string); 57 $string = str_replace('$b$b', ' ', $string); 58 $string = str_replace('$b $b', ' ', $string); 59 $string = str_replace('$b', ' ', $string); 60 $string = $this->ReplaceVarInText($string); 57 $string = str_replace('$b$b', ' ', $string); 58 $string = str_replace('$b $b', ' ', $string); 59 $string = str_replace('$b', ' ', $string); 60 $string = $this->ReplaceVarInText($string); 61 61 $string = str_replace("\r", ' ', $string); 62 62 $string = str_replace("\n", ' ', $string); … … 64 64 $string = str_replace('\\n', ' ', $string); 65 65 $string = str_replace(' ', '', $string); 66 // while(strpos($string, ' ')) 66 // while(strpos($string, ' ')) 67 67 // $string = str_replace(' ', ' ', $string); 68 68 return($string); … … 73 73 $string = $this->Database->real_escape_string($string); 74 74 $string = str_replace('$B', '\r\n', $string); 75 $string = str_replace('$b', '\r\n', $string); 75 $string = str_replace('$b', '\r\n', $string); 76 76 $string = $this->ReplaceVarInText($string,''); 77 77 return($string); … … 104 104 { 105 105 global $TranslationTree, $CreatedFileList; 106 106 107 107 $Output = ''; 108 108 $this->LoadFilters(); 109 109 110 110 $CreatedFileList = array(); 111 111 $CreatedFileListCount = array(); 112 112 113 113 if(!file_exists($this->TempDir.'CzWoW/')) mkdir($this->TempDir.'CzWoW/', 0777, true); 114 114 115 115 $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id.' AND `Group`.`TablePrefix` != ""'); 116 116 while($Group = $DbResult->fetch_assoc()) 117 117 { 118 118 //získání čísla verze pro export 119 $ID = $this->Database->query('SELECT LastVersion FROM `Group` WHERE Id = '.$Group['Id']); 119 $ID = $this->Database->query('SELECT LastVersion FROM `Group` WHERE Id = '.$Group['Id']); 120 120 $LastVersion = $ID->fetch_assoc(); 121 121 122 122 if ($LastVersion['LastVersion'] < $this->ClientVersion['BuildNumber']) 123 123 $ExportVersion = $LastVersion['LastVersion']; … … 125 125 126 126 foreach($TranslationTree[$Group['Id']]['Items'] as $Column) 127 if($Column['AddonFileName'] != '') 127 if($Column['AddonFileName'] != '') 128 128 { 129 129 $this->AddProgress(1); 130 if(!isset($CreatedFileListCount[$Column['AddonFileName']])) 130 if(!isset($CreatedFileListCount[$Column['AddonFileName']])) 131 131 $CreatedFileListCount[$Column['AddonFileName']] = 0; 132 132 $CreatedFileListCount[$Column['AddonFileName']]++; 133 133 $FileIndex = $CreatedFileListCount[$Column['AddonFileName']]; 134 134 135 135 $CreatedFileList[] = $Column['AddonFileName'].'_'.$FileIndex; 136 $FileName = $this->TempDir.'CzWoW/'.$Column['AddonFileName'].'_'.$FileIndex.'.lua'; 136 $FileName = $this->TempDir.'CzWoW/'.$Column['AddonFileName'].'_'.$FileIndex.'.lua'; 137 137 $Output .= $Column['AddonFileName'].': '; 138 138 $i = 0; … … 140 140 $Buffer = 'CZWOW_'.$Column['AddonFileName'].'_count='.$FileIndex.';CZWOW_'.$Column['AddonFileName'].'_'.$FileIndex.'={'; 141 141 $TableTexts = array(); 142 142 143 143 //old version 144 144 //get version before … … 146 146 if ($ExportVersion == '') $BuildNumber = $this->ClientVersion['BuildNumber']; 147 147 $ID = $this->Database->query('SELECT `BuildNumber` FROM `ClientVersion` WHERE '. 148 ' `Imported` = 1 AND `BuildNumber` < '.$BuildNumber.' ORDER BY `BuildNumber` DESC LIMIT 1'); 149 if($ID->num_rows > 0) { 148 ' `Imported` = 1 AND `BuildNumber` < '.$BuildNumber.' ORDER BY `BuildNumber` DESC LIMIT 1'); 149 if($ID->num_rows > 0) { 150 150 $ExportVersionOld = $ID->fetch_assoc(); 151 151 $ExportVersionOld = $ExportVersionOld['BuildNumber']; 152 153 $DbResult2 = $this->Database->query($this->BuildQuery($Group,$ExportVersionOld)); 154 while($Line = $DbResult2->fetch_assoc()) 152 153 $DbResult2 = $this->Database->query($this->BuildQuery($Group,$ExportVersionOld)); 154 while($Line = $DbResult2->fetch_assoc()) 155 155 { 156 $en = trim($this->ReplaceEnText($Line['En'.$Column['Column']])); 156 $en = trim($this->ReplaceEnText($Line['En'.$Column['Column']])); 157 157 $cz = $this->ReplaceCzText($Line[$Column['Column']]); 158 if(($en <> '') and ($cz <> '') and ($this->NotCancel($en))) 158 if(($en <> '') and ($cz <> '') and ($this->NotCancel($en))) 159 159 { 160 $TableTexts[$en] = $cz; 160 $TableTexts[$en] = $cz; 161 161 } 162 162 } 163 163 } 164 164 //last version 165 166 $DbResult2 = $this->Database->query($this->BuildQuery($Group,$ExportVersion)); 167 while($Line = $DbResult2->fetch_assoc()) 165 166 $DbResult2 = $this->Database->query($this->BuildQuery($Group,$ExportVersion)); 167 while($Line = $DbResult2->fetch_assoc()) 168 168 { 169 $en = trim($this->ReplaceEnText($Line['En'.$Column['Column']])); 169 $en = trim($this->ReplaceEnText($Line['En'.$Column['Column']])); 170 170 $cz = $this->ReplaceCzText($Line[$Column['Column']]); 171 if(($en <> '') and ($cz <> '') and ($this->NotCancel($en))) 171 if(($en <> '') and ($cz <> '') and ($this->NotCancel($en))) 172 172 { 173 $TableTexts[$en] = $cz; 173 $TableTexts[$en] = $cz; 174 174 } 175 175 } 176 176 177 177 foreach($TableTexts as $key => $value) { 178 178 $Buffer .= "\n".'["'.$key.'"]="'.$value.'",'; 179 179 $i++; 180 180 } 181 182 181 182 183 183 $Buffer = $Buffer."\n};if not CZWOW_".$Column['AddonFileName']." then CZWOW_".$Column['AddonFileName']."=0; end; CZWOW_".$Column['AddonFileName']."=CZWOW_".$Column['AddonFileName']."+".$i.";\n"; 184 184 … … 193 193 $Buffer = ''; 194 194 foreach($CreatedFileList as $CreatedFile) 195 $Buffer .= 'CZWOW_'.str_replace('_','_count=',$CreatedFile).';'."\n"; 195 $Buffer .= 'CZWOW_'.str_replace('_','_count=',$CreatedFile).';'."\n"; 196 196 foreach($TranslationTree as $Group) 197 197 foreach($TranslationTree[$Group['Id']]['Items'] as $Column) 198 if (($Column['AddonFileName'] != '') and (!in_array($Column['AddonFileName'].'_1', $CreatedFileList))) 198 if (($Column['AddonFileName'] != '') and (!in_array($Column['AddonFileName'].'_1', $CreatedFileList))) 199 199 { 200 $Buffer .= 'CZWOW_'.$Column['AddonFileName'].'_count=0;'."\n"; 201 } 202 200 $Buffer .= 'CZWOW_'.$Column['AddonFileName'].'_count=0;'."\n"; 201 } 202 203 203 file_put_contents($this->TempDir.'CzWoW/'.$CountFiles, $Buffer); 204 205 204 205 206 206 // Generate file Translates.xml 207 207 $Buffer = '<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/.\FrameXML\UI.xsd">'."\n"; … … 218 218 { 219 219 global $TranslationTree; 220 220 221 221 $this->LoadFilters(); 222 222 223 223 $Buffer = "local f=function(name, en, cz) CzWoW_interface[name]=cz;CzWoW_interface_entoname[en]=name; end; CzWoW_interface={};CzWoW_interface_entoname={ };\n"; 224 224 $Group = $TranslationTree[14]; // client table 225 225 $Column['Column'] = 'Text'; 226 226 227 227 $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id.' AND `Group`.`TablePrefix` != "" AND `Group`.`Id` = 14'); 228 228 //$Group = $DbResult->fetch_assoc(); … … 231 231 else 232 232 $CanGenerated = ''; 233 233 234 234 $DbResult = $this->Database->query($this->BuildQuery($Group,$CanGenerated)); 235 while($Line = $DbResult->fetch_array()) 235 while($Line = $DbResult->fetch_array()) 236 236 { 237 237 $Original = $this->my_trim($Line['En'.$Column['Column']]); 238 238 $Translated = $this->my_trim($Line[$Column['Column']]); 239 if($this->ClientVersion['Version'] == '2.4.3') 239 if($this->ClientVersion['Version'] == '2.4.3') 240 240 { 241 241 $Original = str_replace("|Hchannel:%d|h[%s]|h", '[%s]', $Original); … … 265 265 $Buffer = ' 266 266 Čeština pro klienty: 267 Vytvořeno v projektu http://wowpreklad.zdechov.net/ 267 Vytvořeno v projektu http://wowpreklad.zdechov.net/ 268 268 Obsahuje Fonty pro správné zobrazování českých znaků, WoW addon překládající 269 269 texty 270 270 271 271 Instalace: 272 272 Soubory rozbalte/zkopírujte do kořenové složky s hrou. Obvikle bývá 273 273 "C:/Program Files/World of Warcraft/". 274 274 275 275 Verze: 276 Verze Addonu: '.$Line['Version'].' 276 Verze Addonu: '.$Line['Version'].' 277 277 Tato verze je pro verzi hry '.$this->ClientVersion['Version'].' 278 278 279 279 Změny ve verzích: 280 280 281 281 '; 282 282 $DbResult = $System->Database->query('SELECT * FROM `CzWoWPackageVersion` ORDER BY `Date` DESC'); 283 while($Line = $DbResult->fetch_assoc()) 283 while($Line = $DbResult->fetch_assoc()) 284 284 { 285 285 $Buffer .=' 286 Verze: '.$Line['Version'].' 286 Verze: '.$Line['Version'].' 287 287 ============= 288 288 '.$Line['text'].' 289 289 290 290 '; 291 291 } -
trunk/Modules/Export/Export.php
r799 r816 13 13 var $TempDir; 14 14 var $SourceDir; 15 15 16 16 function Init() 17 17 { … … 23 23 if(!file_exists($this->SourceDir)) mkdir($this->SourceDir, 0777, true); 24 24 } 25 25 26 26 function SaveAllUsers() { 27 28 29 30 31 32 33 34 35 36 37 //$this->System->Database->query('UPDATE `ExportUser` SET `Sequence`='.$Value.$Condition);38 39 27 $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$this->Id); 28 $Export = $DbResult->fetch_assoc(); 29 if ($Export['AllUsers']) { 30 $DbResult2 = $this->System->Database->query('SELECT ID FROM `User` WHERE `ID` NOT IN(SELECT `User` FROM `ExportUser` WHERE `Export`='.$this->Id.')'); 31 while($UserLine = $DbResult2->fetch_assoc()) 32 { 33 $Condition = ' WHERE `Export`='.$this->Id.' AND `User`='.$UserLine['ID']; 34 $DbResult = $this->System->Database->query('SELECT * FROM `ExportUser` '.$Condition); //,MAX(`Sequence`) as MaxSequence 35 if($DbResult->num_rows > 0) 36 { 37 // $this->System->Database->query('UPDATE `ExportUser` SET `Sequence`='.$Value.$Condition); 38 } else 39 { 40 40 $this->System->Database->query('INSERT INTO `ExportUser` (`Export`, `User`, `Sequence`) VALUES ('.$this->Id.', '.$UserLine['ID'].', 0)'); 41 42 43 41 } 42 } 43 44 44 $this->System->Database->query('SET @I = 0'); 45 46 47 } 48 45 $this->System->Database->query('UPDATE `ExportUser` SET `Sequence` = (@I := @I + 1) WHERE `Export`='.$this->Id.' ORDER BY `Sequence`;'); 46 } 47 } 48 49 49 function LoadFilters() 50 { 50 { 51 51 $DbResult = $this->Database->query('SELECT * FROM `Export` WHERE `Id`='.$this->Id); 52 52 if($DbResult->num_rows == 0) throw new Exception('Export '.$this->Id.' neexistuje'); 53 $this->Export = $DbResult->fetch_assoc(); 53 $this->Export = $DbResult->fetch_assoc(); 54 54 55 55 // Filter selected users 56 56 $this->UserNames = ''; 57 57 $DbResult = $this->Database->query('SELECT `ExportUser`.*, `User`.`Name`, `User`.`ID` FROM `ExportUser` '. 58 59 58 'LEFT JOIN `User` ON `User`.`ID`=`ExportUser`.`User` '. 59 'WHERE `ExportUser`.`Export`='.$this->Id.' ORDER BY `ExportUser`.`Sequence`'); 60 60 while($UserLine = $DbResult->fetch_assoc()) 61 61 { 62 62 $this->UserNames .= ', '.$UserLine['Name']; 63 63 } 64 $this->UserNames = substr($this->UserNames, 2); 65 64 $this->UserNames = substr($this->UserNames, 2); 65 66 66 if($this->Export['ClientVersion'] != '') 67 67 { 68 68 $DbResult = $this->Database->query('SELECT * FROM `ClientVersion` WHERE `Id`='.$this->Export['ClientVersion']); 69 69 $this->ClientVersion = $DbResult->fetch_assoc(); 70 } else $this->ClientVersion = ''; 71 } 72 70 } else $this->ClientVersion = ''; 71 } 72 73 73 function BuildQuery($Group, $Version = '') 74 74 { 75 75 global $TranslationTree; 76 76 $this->SaveAllUsers(); 77 78 if ($Version <> '') 77 78 if ($Version <> '') 79 79 $ExportVersion = $Version; 80 80 else 81 81 $ExportVersion = $this->ClientVersion['BuildNumber']; 82 82 83 84 85 86 83 $DbResultItem = $this->System->Database->query('SELECT * FROM `ExportGroupItem` WHERE `Export`='.$this->Id); 84 while($GroupItem = $DbResultItem->fetch_assoc()) 85 { 86 $GroupItems[$GroupItem['GroupItem']] = 1; 87 87 } 88 88 // Build selected columns … … 93 93 // $Columns = substr($Columns, 0, -2); 94 94 95 95 96 96 $Query = 'SELECT * FROM (SELECT '.$Columns.' T.`ID`,T.`Language`,T.`User`,T.`Entry`,T.`VersionEnd`,T.`VersionStart`, `User`.`Name` AS `UserName` FROM `'.$Group['TablePrefix'].'` AS `T`'. 97 97 ' JOIN `ExportUser` ON (`ExportUser`.`User`=`T`.`User`) AND (`ExportUser`.`Export`='.$this->Id.') '. … … 105 105 foreach($TranslationTree[$Group['Id']]['Items'] as $Column) { 106 106 $OriginalColumns .= ' `T3`.`'.$Column['Column'].'` AS `En'.$Column['Column'].'`, '; 107 if (isset($GroupItems[$Column['Id']])) 107 if (isset($GroupItems[$Column['Id']])) 108 108 $OriginalColumns .= ' `T3`.`'.$Column['Column'].'` AS `'.$Column['Column'].'`, '; 109 109 } 110 110 $OriginalColumns = substr($OriginalColumns, 0, -2); 111 111 112 112 // Expand query for loading english texts 113 113 $Query = 'SELECT `T4`.*, '.$OriginalColumns.' FROM ('.$Query.') AS `T4` '. 114 114 ' LEFT JOIN `'.$Group['TablePrefix'].'` AS `T3` ON (`T3`.`Entry` = `T4`.`Entry`) '. 115 115 'AND (`T3`.`Language` = '.$this->System->Config['OriginalLanguage'].') AND '. 116 '(`T3`.`VersionStart` = `T4`.`VersionStart`) AND (`T3`.`VersionEnd` = `T4`.`VersionEnd`)'; 116 '(`T3`.`VersionStart` = `T4`.`VersionStart`) AND (`T3`.`VersionEnd` = `T4`.`VersionEnd`)'; 117 117 118 118 return($Query); 119 119 } 120 120 121 121 function NeedGeneration() 122 122 { … … 130 130 else return(true); 131 131 // echo $file; 132 132 133 133 $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` '. 134 135 $result = false; 134 'JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id); 135 $result = false; 136 136 while($Group = $DbResult->fetch_assoc()) 137 137 { … … 146 146 if ($DbResult2->num_rows > 0) { 147 147 $result = true; 148 } 149 } 148 } 149 } 150 150 return($result); 151 151 } 152 152 153 153 function ExportToMangosSQL() 154 154 { 155 155 global $TranslationTree; 156 156 157 157 $this->LoadFilters(); 158 159 $Buffer = 160 "-- Generováno projektem wowpreklad.zdechov.net\n". 158 159 $Buffer = 160 "-- Generováno projektem wowpreklad.zdechov.net\n". 161 161 "-- ===========================================\n". 162 162 "--\n". … … 168 168 "-- Vzato od uživatelů: ".$this->UserNames."\n". 169 169 "-- Generované tabulky: "; 170 170 171 171 $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` '. 172 172 'JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id); 173 173 while($Group = $DbResult->fetch_assoc()) 174 174 { 175 175 $Buffer .= $Group['TablePrefix'].', '; 176 176 } 177 $Buffer .= "\n\n"; 177 $Buffer .= "\n\n"; 178 178 179 179 $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` '. 180 180 'JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id); 181 181 while($Group = $DbResult->fetch_assoc()) 182 182 { … … 186 186 $DbResult2 = $this->Database->query($this->BuildQuery($Group)); 187 187 if($DbResult2->num_rows > 0) 188 while($Line = $DbResult2->fetch_array()) 188 while($Line = $DbResult2->fetch_array()) 189 189 { 190 190 $Values = ''; … … 199 199 // Get multicolumn index 200 200 $ColumnItems = explode(',', $Group['MangosTableIndex']); 201 if(count($ColumnItems) > 1) 201 if(count($ColumnItems) > 1) 202 202 { 203 203 $Where = 'CONCAT('; … … 206 206 $Where = substr($Where, 0, -7).')'; 207 207 } else $Where = '`'.$Group['MangosTableIndex'].'`'; 208 $Where .= ' = "'.$Line[$Group['PrimaryKeyItem']].'";'; 209 208 $Where .= ' = "'.$Line[$Group['PrimaryKeyItem']].'";'; 209 210 210 $Line = 'UPDATE `'.$Group['MangosTable'].'` SET '.$Values.' WHERE '.$Where; 211 211 $Line = str_replace("\n", '\n', $Line); 212 212 $Line = str_replace("\r", '', $Line); 213 213 $Buffer .= $Line."\n"; 214 } 214 } 215 215 } 216 216 } … … 218 218 return($Buffer); 219 219 } 220 221 function ExportToAoWoWSQL() 220 221 function ExportToAoWoWSQL() 222 222 { 223 223 global $TranslationTree, $AoWoWconf; 224 224 225 225 //require_once('../aowow/configs/config.php'); 226 226 227 227 $Buffer = $this->ExportToMangosSQL(); 228 228 229 229 /* 230 230 // Data to aowow 231 231 $Database2 = new mysqli($this->Config['Database']['Host'], $this->Config['Database']['User'], $this->Config['Database']['Password'], $this->Config['Database']['Database']); 232 232 $Database2->query('SET NAMES '.$this->Config['Database']['Charset']); 233 $Database2->select_db($AoWoWconf['mangos']['db']); 233 $Database2->select_db($AoWoWconf['mangos']['db']); 234 234 $AoWoWTables = array( 235 'aowow_resistances' => 'Id', 236 'aowow_spelldispeltype' => 'Id', 235 'aowow_resistances' => 'Id', 236 'aowow_spelldispeltype' => 'Id', 237 237 'aowow_skill' => 'skillID', 238 238 ); 239 foreach($AoWoWTables as $AoWoWTable => $IndexColum) 239 foreach($AoWoWTables as $AoWoWTable => $IndexColum) 240 240 { 241 241 $Buffer .= '--'.$AoWoWTable.', '; 242 $Buffer .= "\n\n"; 242 $Buffer .= "\n\n"; 243 243 $Query = 'SELECT `name`,`'.$IndexColum.'` FROM `'.$AoWoWTable.'`'; 244 244 $DbResult = $Database2->query($Query); 245 while($Line = $DbResult->fetch_assoc()) 245 while($Line = $DbResult->fetch_assoc()) 246 246 { 247 247 $Ori_text = $Line['name']; … … 253 253 $Tran = $DbResult2->fetch_assoc(); 254 254 //echo ($Line['name'].'='.$Tran['tran']); 255 if($Tran['Tran'] == '') 255 if($Tran['Tran'] == '') 256 256 { 257 257 $DbResult2 = $Database2->query('SELECT `OptionText` AS `En`, … … 263 263 $Tran = $DbResult2->fetch_assoc(); 264 264 } 265 265 266 266 if($Tran['Tran'] <> '') 267 267 $Buffer .= 'UPDATE `'.$AoWoWTable.'` SET `name` = "'.addslashes($Tran['Tran']).'" WHERE '.$IndexColum.' = '.$Line[$IndexColum].' ;'."\n"; 268 268 } 269 $Buffer .= "\n\n"; 269 $Buffer .= "\n\n"; 270 270 } 271 271 */ 272 272 if($this->Export['WithDiacritic'] != 1) $Buffer = utf2ascii($Buffer); 273 273 return($Buffer); 274 } 275 276 function HaveVarible($String1, $String2, $StartChar = '$') 274 } 275 276 function HaveVarible($String1, $String2, $StartChar = '$') 277 277 { 278 278 //Export only if translate have same varible % 279 279 280 280 if (strpos($String1,$StartChar) !== false) { 281 281 282 282 while ( strpos($String1,$StartChar) !== false) { 283 283 $pos = strpos($String1,$StartChar); … … 291 291 // echo $pos.'-'.$varible.'-'.$String1.'-' .$String2.' 292 292 // '; 293 293 294 294 if (false === strpos($String2,$varible)) { 295 // echo $varible; 295 // echo $varible; 296 296 return(false); 297 297 } … … 299 299 } 300 300 return (true); 301 } 301 } 302 302 303 303 function AddProgress($add = 1) { … … 312 312 { 313 313 global $TranslationTree; 314 314 315 315 $this->LoadFilters(); 316 316 317 317 $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` '. 318 319 318 'JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` '. 319 'WHERE `ExportGroup`.`Export`='.$this->Id.' AND `Group`.`DBCFileName` != ""'); 320 320 $Output = 'Počet generovaných skupin: '.$DbResult->num_rows."\n"; 321 321 while($Group = $DbResult->fetch_assoc()) … … 323 323 $this->AddProgress(2); 324 324 $Output .= $Group['Name'].', '; 325 if(file_exists($this->SourceDir.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc')) 325 if(file_exists($this->SourceDir.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc')) 326 326 { 327 327 // Load string column index list 328 328 $DbResult2 = $this->Database->query('SELECT * FROM `GroupItem` '. 329 'JOIN `GroupItemDBC` ON `GroupItem`.`Id` = `GroupItemDBC`.`GroupItem` AND `GroupItemDBC`.`ClientVersion` = '.$this->ClientVersion['Id'].' WHERE `GroupItem`.`Group` = '.$Group['Id']);329 'JOIN `GroupItemDBC` ON `GroupItem`.`Id` = `GroupItemDBC`.`GroupItem` AND `GroupItemDBC`.`ClientVersion` = '.$this->ClientVersion['Id'].' WHERE `GroupItem`.`Group` = '.$Group['Id']); 330 330 $ColumnIndexes = array(); 331 331 $ColumnFormat = array(); … … 347 347 $CanExport = false; 348 348 $Output .= ', NE='.$DbRow['ID']; 349 } 349 } 350 350 if (!$this->HaveVarible($DbRow[$Column['Column']],$DbRow['En'.$Column['Column']])) { 351 351 $CanExport = false; 352 352 $Output .= ', NE='.$DbRow['ID']; 353 } 353 } 354 354 } 355 355 356 356 if ($CanExport) 357 357 $LookupTable[$DbRow[$Group['PrimaryKeyItem']]] = $DbRow; 358 358 359 359 } 360 360 361 361 // Open original DBC file 362 362 $SourceDBCFile = new DBCFile(); 363 363 $SourceDBCFile->OpenFile($this->SourceDir.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc', $ColumnFormat); 364 364 365 365 // Create new DBC file 366 366 if(!file_exists($this->TempDir.'dbc/')) mkdir ($this->TempDir.'dbc/', 0777, true); … … 375 375 $Output .= "\n\r"; 376 376 $RowCount = $SourceDBCFile->GetRecordCount(); 377 $FieldCount = $SourceDBCFile->GetFieldCount(); 377 $FieldCount = $SourceDBCFile->GetFieldCount(); 378 378 for($Row = 0; $Row < $RowCount; $Row++) 379 379 { 380 380 $Line = $SourceDBCFile->GetLine($Row); 381 381 382 382 // Get multicolumn index value 383 383 $PrimaryKeyItem = ''; 384 384 $ColumnItems = explode(',', $Group['DBCIndex']); 385 if(count($ColumnItems) > 1) 385 if(count($ColumnItems) > 1) 386 386 { 387 387 foreach($ColumnItems as $ColumnItem) … … 391 391 392 392 if(array_key_exists($PrimaryKeyItem, $LookupTable)) 393 { 393 { 394 394 // Replace text columns 395 $LookupTableItem = $LookupTable[$PrimaryKeyItem]; 395 $LookupTableItem = $LookupTable[$PrimaryKeyItem]; 396 396 foreach($TranslationTree[$Group['Id']]['Items'] as $GroupItem) 397 { 397 { 398 398 if(array_key_exists($GroupItem['Id'], $ColumnIndexes)) 399 399 $Line[$ColumnIndexes[$GroupItem['Id']]] = $LookupTableItem[$GroupItem['Column']]; … … 401 401 } 402 402 $NewDBCFile->SetLine($Row, $Line); 403 403 404 404 // Show completion progress 405 405 $Progress = round($Row / $RowCount * 100); … … 412 412 $OldProgress = $Progress; 413 413 } 414 } 415 $NewDBCFile->Commit(); 414 } 415 $NewDBCFile->Commit(); 416 416 } else $Output .= ShowMessage('Zdrojový soubor '.$this->SourceDirRelative.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc'.' nenalezen.'."\n", MESSAGE_CRITICAL); 417 417 } … … 423 423 { 424 424 global $TranslationTree; 425 425 426 426 $this->LoadFilters(); 427 427 … … 440 440 $File2 = new FileStream(); 441 441 $File2->CreateFile($this->TempDir.'lua/'.$Group['LuaFileName'].'.lua'); 442 442 443 443 $LookupTable = array(); 444 444 $DbResult2 = $this->Database->query($this->BuildQuery($Group)); … … 454 454 if ($CanExport) $Output .= ', NE='.$DbRow['ID']; 455 455 $CanExport = false; 456 } 456 } 457 457 if (!$this->HaveVarible($DbRow[$Column['Column']],$DbRow['En'.$Column['Column']])) { 458 458 if ($CanExport) $Output .= ', NE='.$DbRow['ID']; 459 459 $CanExport = false; 460 } 460 } 461 461 if (!$this->HaveVarible($DbRow['En'.$Column['Column']],$DbRow[$Column['Column']],'%')) { 462 462 if ($CanExport) $Output .= ', NE='.$DbRow['ID']; 463 463 $CanExport = false; 464 } 464 } 465 465 if (!$this->HaveVarible($DbRow[$Column['Column']],$DbRow['En'.$Column['Column']],'%')) { 466 466 if ($CanExport) $Output .= ', NE='.$DbRow['ID']; 467 467 $CanExport = false; 468 } 468 } 469 469 if (!$this->HaveVarible($DbRow[$Column['Column']],$DbRow['En'.$Column['Column']],'\\')) { 470 470 if ($CanExport) $Output .= ', NE='.$DbRow['ID']; 471 471 $CanExport = false; 472 } 472 } 473 473 if (!$this->HaveVarible($DbRow['En'.$Column['Column']],$DbRow[$Column['Column']],'\\')) { 474 474 if ($CanExport) $Output .= ', NE='.$DbRow['ID']; … … 478 478 if ($CanExport) $Output .= ', NE='.$DbRow['ID']; 479 479 $CanExport = false; 480 } 480 } 481 481 if (!$this->HaveVarible($DbRow['En'.$Column['Column']],$DbRow[$Column['Column']],'|')) { 482 482 if ($CanExport) $Output .= ', NE='.$DbRow['ID']; … … 486 486 if ($CanExport) $Output .= ', NE='.$DbRow['ID']; 487 487 $CanExport = false; 488 } 488 } 489 489 if (!$this->HaveVarible($DbRow['En'.$Column['Column']],$DbRow[$Column['Column']],chr(10))) { 490 490 if ($CanExport) $Output .= ', NE='.$DbRow['ID']; … … 492 492 } 493 493 } 494 494 495 495 if ($CanExport) 496 496 $LookupTable[$DbRow['ShortCut']] = $DbRow; 497 497 } 498 498 499 499 while(!$File->EOF()) 500 500 { … … 505 505 $Value['ShortCut'] = trim($LineParts[0]); 506 506 $Line = trim($LineParts[1]); 507 507 508 508 if($Line[0] == '"') 509 509 { … … 519 519 // $Value['Text'] = addslashes(stripslashes($Value['Text'])); 520 520 $Line = trim(substr($Line, strpos($TempLine, '"') + 1)); // Skip closing quote and semicolon { 521 } else 521 } else 522 522 { 523 523 // Nonstring value … … 552 552 return($Output); 553 553 } 554 554 555 555 function GetReadme() { 556 556 $_GET['ExportId'] = $this->Id; 557 557 $PageExport = new PageExport($this->System); 558 $this->LoadFilters(); 558 $this->LoadFilters(); 559 559 $Output = ''; 560 560 //generation readme … … 572 572 '<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />'. 573 573 '<title>Čeština pro WoW</title>'. 574 '</head><body>'. 574 '</head><body>'. 575 575 '<h1>České WoW - čestina pro klienta hry World of Warcraft</h1>'. 576 576 577 577 '<table cellspacing="10"><tr><td valign="top">'. 578 578 579 579 '<p>Texty přebírány z projektu <a href="http://wowpreklad.zdechov.net/">wowpreklad.zdechov.net</a><br>'. 580 580 '<a href="http://wowpreklad.zdechov.net/export/?Action=View&ExportId='.$this->Id.'&Tab=0">Export '.$this->Id.'</a></p><br>'. 581 582 581 582 583 583 '<p><strong>Vlastnosti</strong>'. 584 584 '<ul>'. … … 591 591 '</p>'. 592 592 '<br>'. 593 593 594 594 '<h2>Nejčastější otázky</h2>'. 595 '<p><strong>Jak mám vyhledávat věci v aukci nebo výpravy na internetu s nainstalovanou češtinou?</strong><br> 596 Pokud používáte addon, který mění názvy předmětů jenom zdánlivě pro vás, potřebujete pro vyhledávání v aukci zjistit původní anglický název. Tento název zjistíte jednoduše držením klávesy shift a kliknutím na předmět při otevřené aukci, nebo chatu. Vytvořený odkaz v chatu, nebo text v aukci je v původním znění. Stejně zjistíte i název výpravy kliknutím se shift na výpravu v "quest logu". 595 '<p><strong>Jak mám vyhledávat věci v aukci nebo výpravy na internetu s nainstalovanou češtinou?</strong><br> 596 Pokud používáte addon, který mění názvy předmětů jenom zdánlivě pro vás, potřebujete pro vyhledávání v aukci zjistit původní anglický název. Tento název zjistíte jednoduše držením klávesy shift a kliknutím na předmět při otevřené aukci, nebo chatu. Vytvořený odkaz v chatu, nebo text v aukci je v původním znění. Stejně zjistíte i název výpravy kliknutím se shift na výpravu v "quest logu". 597 597 Pokud jste na serveru s českou lokalizaci (tedy nepoužíváte addon), musíte využít český název pro vyhledávání. Server by měl mít spuštěnou vlastní obdobu databáze wowhead.</p>'. 598 598 599 '<p><strong>Po nainstalování češtiny a spouštění přes soubor WoWlua.exe mi klesl výrazně výkon</strong><br> 600 Problém může být spojen s použitím integrované grafiky místo herní.</p>'. 601 602 '<p><strong>Při spouštění hry přes soubor WoWLua.exe se mi neukládá žádné nastavení addonů a podobně</strong><br> 603 Problém může být způsoben špatně nastavenými právy u souboru WoWLua.exe. Můžete přenastavit práva, nebo spouštět jako správce.</p>'. 604 605 '<p><strong>Po spuštění souboru WoWLua.exe mi píše chybu:</strong><br> 606 Cannot stream required archive data. Please check the network connection. 607 Chyba může být způsobena tím, že jste nenainstalovali češtinu do adresáře se hrou. 608 Nebo jste nainstalovali do jiné verze hry, než je požadovaná. Může se vztahovat i na požadovanou lokalizaci (enUS, enGB)</p>'. 609 610 '<p><strong>Po nainstalování češtiny nemám žádné výpravy (questy) česky</strong><br> 611 Zkontrolujte si v přihlášení, jestli máte povolený addon CzWoW v seznamu addonů.</p>'. 612 613 '<p><strong>Addon mi hlásí spoustu chyb.</strong><br> 614 Chyba může být způsobena kolizí s jinými addony. Vyzkoušejte spuštění hry pouze s addonem CzWoW.</p>'. 615 616 '<p><strong>Ve hře se mi špatně zobrazuje diakritika (háčky, čárky)</strong><br> 617 Chyba je způsobena chybějícími fonty do hry. Potřebné fonty si stáhněte mezi soubory ke stažení.</p>'. 618 619 '<p><strong>Mám nainstalovánu češtinu a nejde mi spustit Wow.exe.</strong><br> 620 Pokud chcete opět spouštět hru přes původní Wow.exe v angličtině, musíte češtinu nejprve odinstalovat ze systému. Především se jedná o soubor Data/enGB/patch-enGB-5.MPQ či Data/enUS/patch-enUS-5.MPQ, který je nutno smazat. U novějších verzí se soubor může jmenovat wow-update-base-50000.MPQ.</p>'. 621 622 '<p><strong>Jak mám hru spustit?</strong><br> 623 Hru musíte spustit přes soubor WowLua.exe v kořenovém adresáři hry.</p>'. 624 625 '<p><strong>Mohu použít tuto češtinu na oficiálních serverech?</strong><br> 599 '<p><strong>Po nainstalování češtiny a spouštění přes soubor WoWlua.exe mi klesl výrazně výkon</strong><br> 600 Problém může být spojen s použitím integrované grafiky místo herní.</p>'. 601 602 '<p><strong>Při spouštění hry přes soubor WoWLua.exe se mi neukládá žádné nastavení addonů a podobně</strong><br> 603 Problém může být způsoben špatně nastavenými právy u souboru WoWLua.exe. Můžete přenastavit práva, nebo spouštět jako správce.</p>'. 604 605 '<p><strong>Po spuštění souboru WoWLua.exe mi píše chybu:</strong><br> 606 Cannot stream required archive data. Please check the network connection. 607 Chyba může být způsobena tím, že jste nenainstalovali češtinu do adresáře se hrou. 608 Nebo jste nainstalovali do jiné verze hry, než je požadovaná. Může se vztahovat i na požadovanou lokalizaci (enUS, enGB)</p>'. 609 610 '<p><strong>Po nainstalování češtiny nemám žádné výpravy (questy) česky</strong><br> 611 Zkontrolujte si v přihlášení, jestli máte povolený addon CzWoW v seznamu addonů.</p>'. 612 613 '<p><strong>Addon mi hlásí spoustu chyb.</strong><br> 614 Chyba může být způsobena kolizí s jinými addony. Vyzkoušejte spuštění hry pouze s addonem CzWoW.</p>'. 615 616 '<p><strong>Ve hře se mi špatně zobrazuje diakritika (háčky, čárky)</strong><br> 617 Chyba je způsobena chybějícími fonty do hry. Potřebné fonty si stáhněte mezi soubory ke stažení.</p>'. 618 619 '<p><strong>Mám nainstalovánu češtinu a nejde mi spustit Wow.exe.</strong><br> 620 Pokud chcete opět spouštět hru přes původní Wow.exe v angličtině, musíte češtinu nejprve odinstalovat ze systému. Především se jedná o soubor Data/enGB/patch-enGB-5.MPQ či Data/enUS/patch-enUS-5.MPQ, který je nutno smazat. U novějších verzí se soubor může jmenovat wow-update-base-50000.MPQ.</p>'. 621 622 '<p><strong>Jak mám hru spustit?</strong><br> 623 Hru musíte spustit přes soubor WowLua.exe v kořenovém adresáři hry.</p>'. 624 625 '<p><strong>Mohu použít tuto češtinu na oficiálních serverech?</strong><br> 626 626 Ne úplně, protože se vystavujete riziku zablokování vašeho účtu z důvodu použití upravené hry. Na oficiálním serveru lze využít pouze Addon s češtinou CzWoW. Instalační soubor určený pro oficiální servery je už takto přizpůsoben.</p>'. 627 627 628 628 '</td><td>'; 629 629 … … 631 631 632 632 $Output .= '</td></tr></table>'. 633 634 633 634 635 635 '</body></html>'; 636 636 return $Output; 637 } 638 637 } 638 639 639 function ExportToXML() 640 640 { 641 641 global $TranslationTree; 642 642 643 643 $this->LoadFilters(); 644 644 … … 653 653 foreach(explode(',', $this->UserNames) as $UserName) 654 654 $Buffer .= " <user>".$UserName."</user>\n"; 655 $Buffer .= 655 $Buffer .= 656 656 " </contributors>\n". 657 657 " </meta>\n". … … 659 659 660 660 $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` '. 661 661 'JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id); 662 662 while($Group = $DbResult->fetch_assoc()) 663 663 { … … 669 669 $Buffer .= ' <group id="'.$Group['Id'].'" name="'.$Group['TablePrefix'].'">'."\n"; 670 670 $DbResult2 = $this->Database->query($this->BuildQuery($Group)); 671 while($Line = $DbResult2->fetch_assoc()) 671 while($Line = $DbResult2->fetch_assoc()) 672 672 { 673 673 $Buffer .= ' <item id="'.$Line['Entry'].'" user="'.$Line['UserName'].'">'."\n"; … … 681 681 } 682 682 $Buffer .= " </item>\n"; 683 } 683 } 684 684 $Buffer .= " </group>\n"; 685 685 } … … 688 688 "</document>"; 689 689 return($Buffer); 690 } 690 } 691 691 } 692 692 … … 706 706 $this->Dependencies = array(); 707 707 } 708 708 709 709 function Start() 710 710 { 711 712 713 714 715 716 717 711 $this->System->RegisterPage('export', 'PageExport'); 712 $this->System->RegisterMenuItem(array( 713 'Title' => 'Exporty', 714 'Hint' => 'Zde si můžete stáhnout přeložené texty', 715 'Link' => $this->System->Link('/export/'), 716 'Permission' => LICENCE_ANONYMOUS, 717 'Icon' => '', 718 718 ), 2); 719 719 } -
trunk/Modules/Export/ExportOutput.php
r743 r816 17 17 //echo($Path.$FileName.'<br />'); 18 18 if(is_dir($Path.$FileName)) CreateZipFromDir($Zip, $Path.$FileName.'/', $ZipPath.$FileName.'/'); 19 else $Zip->addFile(file_get_contents($Path.$FileName), $ZipPath.$FileName); 20 } 19 else $Zip->addFile(file_get_contents($Path.$FileName), $ZipPath.$FileName); 20 } 21 21 } 22 22 } … … 25 25 { 26 26 global $System, $Config; 27 28 $Output = ''; 29 $Export = new Export($System); 30 $Export->Id = $ExportId; 31 $Export->Init(); 32 if(function_exists('gzcompress')) 27 28 $Output = ''; 29 $Export = new Export($System); 30 $Export->Id = $ExportId; 31 $Export->Init(); 32 if(function_exists('gzcompress')) 33 33 { 34 34 $SaveFilename = $Export->TempDir.'CzAoWoW_SQL.zip'; 35 $SQLFilename = 'CzAoWoW_SQL.sql'; 35 $SQLFilename = 'CzAoWoW_SQL.sql'; 36 36 $BufferZip = $Export->ExportToAoWoWSQL(); 37 37 $ZipFile = new zipfile(); … … 43 43 // 'setTimeout("parent.location.href=\''.$SaveFilename.'\'", 3000)'. 44 44 // '</script>'; 45 46 $Output .= 'Pokud nezačalo stahování, soubor by mělo jít stáhnout pomocí tohoto odkazu: '. 45 46 $Output .= 'Pokud nezačalo stahování, soubor by mělo jít stáhnout pomocí tohoto odkazu: '. 47 47 '<a href="'.$System->Link('/'.$Export->TempDirRelative.'CzAoWoW_SQL.zip').'">'.$SQLFilename.'</a><br />'. 48 48 'Pokud se vám zdá, že filtr na export nefunguje, vymažte si vyrovnávací paměť prohlížeče a zkuste stáhnout soubor znovu.'; … … 53 53 { 54 54 global $System, $Config; 55 56 $Export = new Export($System); 57 $Export->Id = $ExportId; 58 55 56 $Export = new Export($System); 57 $Export->Id = $ExportId; 58 59 59 $Output = 'Vygenerovaný SQL kód: <br /><pre class="SQLCode">'. 60 60 htmlspecialchars($Export->ExportToAoWoWSQL()). … … 66 66 { 67 67 global $System, $Config; 68 69 $Output = ''; 70 $Export = new Export($System); 71 $Export->Id = $ExportId; 72 $Export->Init(); 73 if(function_exists('gzcompress')) 68 69 $Output = ''; 70 $Export = new Export($System); 71 $Export->Id = $ExportId; 72 $Export->Init(); 73 if(function_exists('gzcompress')) 74 74 { 75 75 $SaveFilename = $Export->TempDir.'CzWoW_SQL.zip'; 76 $SQLFilename = 'CzWoW_SQL.sql'; 76 $SQLFilename = 'CzWoW_SQL.sql'; 77 77 $BufferZip = $Export->ExportToMangosSQL(); 78 78 $ZipFile = new zipfile(); … … 84 84 // 'setTimeout("parent.location.href=\''.$SaveFilename.'\'", 3000)'. 85 85 // '</script>'; 86 87 $Output .= 'Pokud nezačalo stahování, soubor by mělo jít stáhnout pomocí tohoto odkazu: '. 86 87 $Output .= 'Pokud nezačalo stahování, soubor by mělo jít stáhnout pomocí tohoto odkazu: '. 88 88 '<a href="'.$System->Link('/'.$Export->TempDirRelative.'CzWoW_SQL.zip').'">'.$SQLFilename.'</a><br />'. 89 89 'Pokud se vám zdá, že filtr na export nefunguje, vymažte si vyrovnávací paměť prohlížeče a zkuste stáhnout soubor znovu.'; 90 return($Output); 90 return($Output); 91 91 } 92 92 … … 94 94 { 95 95 global $System; 96 96 97 97 $Export = new Export($System); 98 98 $Export->Id = $ExportId; … … 107 107 { 108 108 global $System; 109 110 if(function_exists('gzcompress')) 109 110 if(function_exists('gzcompress')) 111 111 { 112 112 $Addon = new ExportAddon($System); … … 114 114 $Addon->Init(); 115 115 $Output = $Addon->MakeAddon(); 116 116 117 117 $Output .= 'Generování addonu...<br />'; 118 $SaveFilename = $Addon->TempDir.'CzWoW_Addon-'.$Addon->ClientVersion['Version'].'.zip'; 118 $SaveFilename = $Addon->TempDir.'CzWoW_Addon-'.$Addon->ClientVersion['Version'].'.zip'; 119 119 $Zip = new zipfile(); 120 120 CreateZipFromDir($Zip, $Addon->TempDir.'CzWoW/', 'CzWoW/'); 121 $Zip->addFile(file_get_contents(dirname(__FILE__).'/files/'.$Addon->ClientVersion['Version'].'/CzWoW/OptionsFrame.xml'), 'CzWoW/OptionsFrame.xml'); 122 $Zip->addFile(file_get_contents(dirname(__FILE__).'/files/'.$Addon->ClientVersion['Version'].'/CzWoW/CzWoW.xml'), 'CzWoW/CzWoW.xml'); 123 $Zip->addFile(file_get_contents(dirname(__FILE__).'/files/'.$Addon->ClientVersion['Version'].'/CzWoW/CzWoW.toc'), 'CzWoW/CzWoW.toc'); 124 $Zip->addFile(file_get_contents(dirname(__FILE__).'/files/'.$Addon->ClientVersion['Version'].'/CzWoW/CzWoW.lua'), 'CzWoW/CzWoW.lua'); 125 $Zip->addFile(file_get_contents(dirname(__FILE__).'/files/'.$Addon->ClientVersion['Version'].'/CzWoW/GameMenuFrame.xml'), 'CzWoW/GameMenuFrame.xml'); 126 $Zip->addFile(file_get_contents(dirname(__FILE__).'/files/'.$Addon->ClientVersion['Version'].'/CzWoW/Localization.lua'), 'CzWoW/Localization.lua'); 121 $Zip->addFile(file_get_contents(dirname(__FILE__).'/files/'.$Addon->ClientVersion['Version'].'/CzWoW/OptionsFrame.xml'), 'CzWoW/OptionsFrame.xml'); 122 $Zip->addFile(file_get_contents(dirname(__FILE__).'/files/'.$Addon->ClientVersion['Version'].'/CzWoW/CzWoW.xml'), 'CzWoW/CzWoW.xml'); 123 $Zip->addFile(file_get_contents(dirname(__FILE__).'/files/'.$Addon->ClientVersion['Version'].'/CzWoW/CzWoW.toc'), 'CzWoW/CzWoW.toc'); 124 $Zip->addFile(file_get_contents(dirname(__FILE__).'/files/'.$Addon->ClientVersion['Version'].'/CzWoW/CzWoW.lua'), 'CzWoW/CzWoW.lua'); 125 $Zip->addFile(file_get_contents(dirname(__FILE__).'/files/'.$Addon->ClientVersion['Version'].'/CzWoW/GameMenuFrame.xml'), 'CzWoW/GameMenuFrame.xml'); 126 $Zip->addFile(file_get_contents(dirname(__FILE__).'/files/'.$Addon->ClientVersion['Version'].'/CzWoW/Localization.lua'), 'CzWoW/Localization.lua'); 127 127 $Buffer = $Zip->file(); 128 128 file_put_contents($SaveFilename, $Buffer); … … 132 132 // 'setTimeout("parent.location.href=\''.$SaveFilename.'\'", 3000)'. 133 133 // '</script>'; 134 135 $Output .= 'Soubor ke stažení: '. 134 135 $Output .= 'Soubor ke stažení: '. 136 136 '<a href="'.$System->Link('/'.$Addon->TempDirRelative.'CzWoW_Addon-'.$Addon->ClientVersion['Version'].'.zip').'">CzWoW_Addon-'.$Addon->ClientVersion['Version'].'.zip</a><br />'. 137 137 'Pokud se vám zdá, že filtr na export nefunguje, vymažte si vyrovnávací paměť prohlížeče a zkuste stáhnout soubor znovu.'; … … 143 143 { 144 144 global $Config, $System; 145 146 $Output = ''; 147 $Export = new Export($System); 148 $Export->Id = $ExportId; 149 $Export->Init(); 150 if(function_exists('gzcompress')) 145 146 $Output = ''; 147 $Export = new Export($System); 148 $Export->Id = $ExportId; 149 $Export->Init(); 150 if(function_exists('gzcompress')) 151 151 { 152 152 $SaveFilename = $Export->TempDir.'CzWoW_XML.zip'; 153 $SQLFilename = 'CzWoW_XML.sql'; 153 $SQLFilename = 'CzWoW_XML.sql'; 154 154 $BufferZip = $Export->ExportToXML(); 155 155 $ZipFile = new zipfile(); … … 161 161 // 'setTimeout("parent.location.href=\''.$SaveFilename.'\'", 3000)'. 162 162 // '</script>'; 163 164 $Output .= 'Pokud nezačalo stahování, soubor by mělo jít stáhnout pomocí tohoto odkazu: '. 163 164 $Output .= 'Pokud nezačalo stahování, soubor by mělo jít stáhnout pomocí tohoto odkazu: '. 165 165 '<a href="'.$System->Link('/'.$Export->TempDirRelative.'CzWoW_XML.zip').'">CzWoW_SQL.zip</a><br />'. 166 166 'Pokud se vám zdá, že filtr na export nefunguje, vymažte si vyrovnávací paměť prohlížeče a zkuste stáhnout soubor znovu.'; … … 171 171 { 172 172 global $System; 173 173 174 174 $Export = new Export($System); 175 175 $Export->Id = $ExportId; … … 188 188 $Export->Id = $ExportId; 189 189 $Export->Init(); 190 190 191 191 $Output = ''; 192 192 if(array_key_exists('Regenerate', $_POST)) … … 199 199 $Output .= '<form action="?Action=View&Tab=7&ExportId='.$ExportId.'" method="post"><input type="submit" name="Regenerate" value="Přegenerovat"/></form><br />'; 200 200 $Output .= 'U DBC souborů export textů funguje jinak, protože generování je náročné, jsou požadavky zařazovány do fronty a postupně zpracovávány.<br />DBC soubory je nutné zabalit do souboru patch-enGB-5.MPQ uvnitř složky "DBFilesClient" a hru spouštět přes upravený spouštěcí soubor. Zabalit je můžete pomocí programu <a href="../download/mpqediten32.zip">Ladik\'s MPQ Editor</a>. Stav vygenerování můžete sledovat na této stránce.<br /><br />'; 201 201 202 202 $DbResult = $System->Database->query('SELECT * FROM ExportTask WHERE Export = '.$ExportId); 203 203 if($DbResult->num_rows == 0) … … 206 206 $System->ModuleManager->Modules['Log']->WriteLog('Zadání úlohy pro vygenerování dbc souboru', LOG_TYPE_DOWNLOAD); 207 207 $System->Database->query('UPDATE `ExportTask` SET `Progress`=0 WHERE `Export`='.$Export->Id); 208 } 209 208 } 209 210 210 $DbResult = $System->Database->query('SELECT * FROM `ExportTask` WHERE `Export` = '.$ExportId); 211 211 $ExportTask = $DbResult->fetch_assoc(); … … 216 216 while($Group = $DbResult->fetch_assoc()) 217 217 { 218 if(file_exists($Export->TempDir.'dbc/'.$Group['DBCFileName'].'.dbc')) 219 218 if(file_exists($Export->TempDir.'dbc/'.$Group['DBCFileName'].'.dbc')) 219 $Output .= '<a href="'.$System->Link('/'.$Export->TempDirRelative.'dbc/'.$Group['DBCFileName'].'.dbc').'">'.$Group['DBCFileName'].'.dbc</a><br/>'; 220 220 } 221 221 } else { 222 222 $Output .= ShowProgress($Export); 223 223 224 } 224 } 225 225 return($Output); 226 226 } … … 232 232 233 233 234 234 $Output .= '<script src="http://code.jquery.com/jquery-latest.js"></script>'. 235 235 '<script>'. 236 236 '$(document).ready(function() {'. … … 241 241 '</script>'; 242 242 243 243 244 244 $Output .= ' <strong><div id="progress"></div></strong><br />'; 245 245 … … 248 248 if($DbResult->num_rows > 0) { 249 249 $System->ModuleManager->Modules['Log']->WriteLog('ProcesTask nepracuje přes 2 hodiny, pravděpodobně nepracuje!', LOG_TYPE_ERROR); 250 250 251 251 } 252 252 return ($Output); … … 256 256 { 257 257 global $System; 258 258 259 259 $Export = new Export($System); 260 260 $Export->Id = $ExportId; … … 272 272 $Output .= '<form action="?Action=View&Tab=7&ExportId='.$ExportId.'" method="post"><input type="submit" name="Regenerate" value="Přegenerovat"/></form><br />'; 273 273 $Output .= 'U souhrné instalace češtiny funguje export textů jinak, protože generování je náročné, jsou požadavky zařazovány do fronty a postupně zpracovávány.<br /><br />'; 274 274 275 275 $DbResult = $System->Database->query('SELECT * FROM ExportTask WHERE Export = '.$ExportId); 276 276 if($DbResult->num_rows == 0) … … 278 278 $System->Database->query('INSERT INTO ExportTask (`Export` ,`TimeStart` ) VALUES ('.$ExportId.', NOW())'); 279 279 $System->ModuleManager->Modules['Log']->WriteLog('Zadání úlohy pro vygenerování dbc souboru', LOG_TYPE_DOWNLOAD); 280 } 281 280 } 281 282 282 $DbResult = $System->Database->query('SELECT * FROM `ExportTask` WHERE `Export` = '.$ExportId); 283 283 $ExportTask = $DbResult->fetch_assoc(); … … 287 287 288 288 } else { 289 289 290 290 $Output .= ShowProgress($Export); 291 291 } … … 296 296 { 297 297 global $System, $Config; 298 299 $Export = new Export($System); 300 $Export->Id = $ExportId; 301 $Export->Init(); 302 303 if(function_exists('gzcompress')) 298 299 $Export = new Export($System); 300 $Export->Id = $ExportId; 301 $Export->Init(); 302 303 if(function_exists('gzcompress')) 304 304 { 305 305 $Output = 'Generování lua souborů...<br />'; 306 306 $Export->ExportToLua(); 307 $SaveFilename = $Export->TempDir.'CzWoW_Lua.zip'; 307 $SaveFilename = $Export->TempDir.'CzWoW_Lua.zip'; 308 308 $ZipFile = new zipfile(); 309 309 CreateZipFromDir($ZipFile, $Export->TempDir.'lua/', ''); … … 315 315 // 'setTimeout("parent.location.href=\''.$SaveFilename.'\'", 3000)'. 316 316 // '</script>'; 317 318 $Output .= '<strong>Soubory:</strong><br/>'. 317 318 $Output .= '<strong>Soubory:</strong><br/>'. 319 319 'Souhrný archív <a href="'.$System->Link('/'.$Export->TempDirRelative.'CzWoW_Lua.zip').'">CzWoW_Lua.zip</a><br />'; 320 320 $DbResult = $System->Database->query('SELECT `Group`.* FROM `ExportGroup` JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$Export->Id.' AND `Group`.`LuaFileName` != ""'); -
trunk/Modules/Export/Page.php
r809 r816 14 14 class PageExport extends Page 15 15 { 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 16 function ExportList() 17 { 18 $Output = '<a href="?Action=ViewList">'.T('All').'</a>'; 19 if($this->System->User->Licence(LICENCE_USER)) 20 { 21 $Output .= ' <a href="?Action=ViewList&Filter=Others">Ostatních</a>'. 22 ' <a href="?Action=ViewList&Filter=My">'.T('Mine').'</a>'; 23 } 24 25 if($this->System->User->Licence(LICENCE_USER)) 26 $Output .= '<br/><div style="text-align: center;"><a href="?Action=Create">'.T('Create new export').'</a></div><br/>'; 27 28 $Filter = ''; 29 if(array_key_exists('Filter', $_GET)) 30 { 31 if($_GET['Filter'] == 'My') $Filter = ' WHERE `Export`.`User` = '.$this->System->User->Id; 32 if($_GET['Filter'] == 'Others') $Filter = ' WHERE `Export`.`User` != '.$this->System->User->Id; 33 } 34 35 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` '.$Filter); 36 $DbRow = $DbResult->fetch_row(); 37 $PageList = GetPageList($DbRow[0]); 38 39 $Output .= '<h3>'.T('List of export').'</h3>'. 40 $PageList['Output']; 41 42 $TableColumns = array( 43 array('Name' => 'TimeCreate', 'Title' => T('Time made')), 44 array('Name' => 'UserName', 'Title' => T('Translator')), 45 array('Name' => 'Title', 'Title' => T('Name od export')), 46 // array('Name' => 'UserCount', 'Title' => 'Vybraných překladatelů'), 47 // array('Name' => 'GroupCount', 'Title' => 'Překladových skupin'), 48 array('Name' => 'OutputType', 'Title' => T('Type of output')), 49 array('Name' => 'ClientVersion', 'Title' => T('Client version')), 50 array('Name' => 'UsedCount', 'Title' => T('Viewed count')), 51 array('Name' => '', 'Title' => T('Action')), 52 ); 53 $Order = GetOrderTableHeader($TableColumns, 'TimeCreate', 1); 54 $Output .= '<table class="BaseTable">'. 55 $Order['Output']; 56 57 $DbResult = $this->System->Database->query('SELECT `User`.`Name` AS `UserName`, `Export`.`Id`, `Export`.`TimeCreate`, `Export`.`Title`, `Export`.`User`, `Export`.`UsedCount`, '. 58 58 '(SELECT Version FROM `ClientVersion` WHERE `ClientVersion`.`Id`=`Export`.`ClientVersion`) AS `ClientVersion`, '. 59 59 '(SELECT Id FROM `ClientVersion` WHERE `ClientVersion`.`Id`=`Export`.`ClientVersion`) AS `ClientVersionId`, '. … … 62 62 '(SELECT COUNT(*) FROM `ExportUser` WHERE `ExportUser`.`Export`=`Export`.`Id`) AS `UserCount` FROM `Export` '. 63 63 'LEFT JOIN `User` ON `User`.`ID`=`Export`.`User` '.$Filter.$Order['SQL'].$PageList['SQLLimit']); 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 64 while($Export = $DbResult->fetch_assoc()) 65 { 66 $Action = '<a href="?Action=View&ExportId='.$Export['Id'].'&Tab=0">'.T('View').'</a> '. 67 '<a href="?Action=View&ExportId='.$Export['Id'].'&Tab=7">'.T('Make export').'</a>'; 68 if($Export['User'] == $this->System->User->Id) $Action .= ' <a href="?Action=Delete&ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy delete item?').'\');">'.T('Delete').'</a>'; 69 if($this->System->User->Id != null) $Action .= ' <a href="?Action=Clone&ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy clone item?').'\');">'.T('Clone').'</a>'; 70 $Output .= '<tr><td>'.HumanDate($Export['TimeCreate']).'</td>'. 71 '<td><a href="'.$this->System->Link('/user.php?user='.$Export['User']).'">'.$Export['UserName'].'</a></td>'. 72 '<td>'.$Export['Title'].'</td>'. 73 '<td>'.$Export['OutputType'].'</td>'. 74 '<td><a href="'.$this->System->Link('/client-version/?action=item&id='.$Export['ClientVersionId']).'">'.$Export['ClientVersion'].'</a></td>'. 75 '<td>'.$Export['UsedCount'].'</td>'. 76 '<td>'.$Action.'</td></tr>'; 77 } 78 $Output .= '</table>'. 79 $PageList['Output']; 80 81 return($Output); 82 } 83 84 function ExportCreate() 85 { 86 if($this->System->User->Licence(LICENCE_USER)) 87 { 88 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$this->System->User->Id); 89 $DbRow = $DbResult->fetch_row(); 90 if($DbRow[0] < $this->System->Config['MaxExportPerUser']) 91 { 92 $Output = '<form action="?Action=CreateFinish" method="post">'. 93 '<fieldset><legend>'.T('Creation of new export').'</legend>'. 94 '<table><tr><td>'.T('Identification').':</td><td><input type="text" name="Title" /></td></tr>'. 95 '<tr><td>'.T('Description').':</td><td><textarea name="Description" cols="54" rows="10"></textarea></td></tr>'. 96 '<tr><td colspan="2"><input type="submit" value="'.T('Create').'" /></td></tr>'. 97 '</table></fieldset></form>'; 98 } else $Output = ShowMessage(T('You can\'t create another export. Max for one user is').$this->System->Config['MaxExportPerUser'].'.', MESSAGE_CRITICAL); 99 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 100 return($Output); 101 } 102 103 function ExportCreateFinish() 104 { 105 if($this->System->User->Licence(LICENCE_USER)) 106 { 107 if(array_key_exists('Title', $_POST) and array_key_exists('Description', $_POST)) 108 { 109 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$this->System->User->Id); 110 $DbRow = $DbResult->fetch_row(); 111 if($DbRow[0] < $this->System->Config['MaxExportPerUser']) 112 { 113 $this->System->Database->query('INSERT INTO `Export` (`Title`, `User`, `TimeCreate`, `WithDiacritic`, `Description`) VALUES ("'.$_POST['Title'].'", '.$this->System->User->Id.', NOW(), 1, "'.$_POST['Description'].'")'); 114 $ExportId = $this->System->Database->insert_id; 115 $Output = ShowMessage(T('New export created.<br />Direct link to export').': <a href="?Action=View&ExportId='.$ExportId.'">'.T('here').'</a>'); 116 $this->System->ModuleManager->Modules['Log']->WriteLog(T('New export created').' <a href="'.$this->System->Link('/export/?Action=View&ExportId='.$ExportId).'">'.$ExportId.'</a>.', LOG_TYPE_EXPORT); 117 $_GET['Filter'] = 'my'; 118 $this->ExportList(); 119 } else $Output = ShowMessage(T('You can\'t create another export. Max for one user is').' '.$this->System->Config['MaxExportPerUser'].'.', MESSAGE_CRITICAL); 120 } else $Output = ShowMessage(T('Missing data in form.'), MESSAGE_CRITICAL); 121 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 122 return($Output); 123 } 124 125 function ExportDelete() 126 { 127 if($this->System->User->Licence(LICENCE_USER)) 128 { 129 $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE (`Id`='.($_GET['ExportId'] * 1).') AND (`User`='.$this->System->User->Id.')'); 130 if($DbResult->num_rows > 0) 131 { 132 $this->System->Database->query('DELETE FROM `ExportGroup` WHERE `Export`='.$_GET['ExportId']); 133 $this->System->Database->query('DELETE FROM `ExportGroupItem` WHERE `Export`='.$_GET['ExportId']); 134 $this->System->Database->query('DELETE FROM `ExportLanguage` WHERE `Export`='.$_GET['ExportId']); 135 $this->System->Database->query('DELETE FROM `ExportTask` WHERE `Export`='.$_GET['ExportId']); 136 $this->System->Database->query('DELETE FROM `ExportUser` WHERE `Export`='.$_GET['ExportId']); 137 $this->System->Database->query('DELETE FROM `Export` WHERE `Id`='.$_GET['ExportId']); 138 DeleteDirectory('../tmp/Export/'.$_GET['ExportId'].'/'); 139 $Output = ShowMessage(T('Export deleted.')); 140 $_GET['Filter'] = 'my'; 141 $this->System->ModuleManager->Modules['Log']->WriteLog('Smazán export '.$_GET['ExportId'], LOG_TYPE_EXPORT); 142 $Output .= $this->ExportList(); 143 } else $Output = ShowMessage(T('Export not found.'), MESSAGE_CRITICAL); 144 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 145 return($Output); 146 } 147 148 function SaveAllUsers() 149 { 150 global $System; 151 $Export = new Export($System); 152 152 $Export->Id = $_GET['ExportId']; 153 153 $Export->SaveAllUsers(); 154 155 } 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 if (array_key_exists('AllUsers', $_POST)) { 154 155 } 156 157 function ExportViewTranslators() 158 { 159 global $TranslationTree; 160 161 $Output = ''; 162 $DisabledInput = array(false => ' disabled="disabled"', true => ''); 163 $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']); 164 $Export = $DbResult->fetch_assoc(); 165 if($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true; 166 else $Editable = false; 167 168 if(array_key_exists('Operation', $_POST)) 169 { 170 if($_POST['Operation'] == 'Save') 171 { 172 //print_r($_POST); 173 // Update user selection page 174 foreach($_POST as $Index => $Value) 175 { 176 if(substr($Index, 0, 3) == 'seq') 177 { 178 $UserId = substr($Index, 3) * 1; 179 if(array_key_exists('sel'.$UserId, $_POST)) $Selected = true; 180 else $Selected = false; 181 $Condition = ' WHERE `Export`='.$_GET['ExportId'].' AND `User`='.$UserId; 182 $DbResult = $this->System->Database->query('SELECT * FROM `ExportUser` '.$Condition); 183 if($DbResult->num_rows > 0) 184 { 185 if(!$Selected) $this->System->Database->query('DELETE FROM `ExportUser` '.$Condition); 186 else $this->System->Database->query('UPDATE `ExportUser` SET `Sequence`='.$Value.$Condition); 187 } else 188 { 189 if($Selected) $this->System->Database->query('INSERT INTO `ExportUser` (`Export`, `User`, `Sequence`) VALUES ('.$_GET['ExportId'].', '.$UserId.', '.$Value.')'); 190 } 191 } 192 } 193 194 if (array_key_exists('AllUsers', $_POST)) { 195 195 //add allusers to export 196 197 198 196 $this->System->Database->query('UPDATE `Export` SET `AllUsers`=1 WHERE `Id`='.$_GET['ExportId']); 197 198 //update export stat 199 199 $Export['AllUsers'] = 1; 200 200 $this->SaveAllUsers(); 201 201 } else { 202 202 //update export stat 203 203 $Export['AllUsers'] = 0; 204 204 $this->System->Database->query('UPDATE `Export` SET `AllUsers`=0 WHERE `Id`='.$_GET['ExportId']); 205 205 } 206 206 207 208 209 210 211 212 213 214 215 216 217 218 array('Name' => 'XP', 'Title' => T('Experience')), 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 207 // Recalculate sequence number 208 $this->System->Database->query('SET @I = 0'); 209 $this->System->Database->query('UPDATE `ExportUser` SET `Sequence` = (@I := @I + 1) WHERE `Export`='.$_GET['ExportId'].' ORDER BY `Sequence`;'); 210 $Output .= ShowMessage(T('Select saved.')); 211 } 212 } 213 214 $TableColumns = array( 215 array('Name' => 'Name', 'Title' => T('Name')), 216 array('Name' => 'TranslatedCount', 'Title' => T('Translated count')), 217 array('Name' => 'XP', 'Title' => T('Level')), 218 array('Name' => 'XP', 'Title' => T('Experience')), 219 array('Name' => '', 'Title' => T('Select')), 220 array('Name' => 'Sequence2', 'Title' => T('Order')), 221 ); 222 $Order = GetOrderTableHeader($TableColumns, 'TranslatedCount', 1); 223 if($Order['Column'] != 'Sequence2') $InitialOrder = ', '.substr($Order['SQL'], 10); 224 else $InitialOrder = ''; 225 226 $Query = 'SELECT (@I := @I + 1) AS `Sequence2`, `TT`.* FROM (SELECT `ExportUser`.`Sequence`, `T`.`ID`, `T`.`TranslatedCount`, `T`.`Name`, `T`.`XP` FROM (SELECT `User`.`ID`, `User`.`Name`, `User`.`XP`, `TranslatedCount` FROM `User`) AS T'; 227 $Query .=' LEFT JOIN `ExportUser` ON `ExportUser`.`Export` = '.$_GET['ExportId'].' AND `ExportUser`.`User`=`T`.`ID`'; 228 $Query .=' WHERE `T`.`TranslatedCount` > 0 ORDER BY COALESCE(`ExportUser`.`Sequence`, 100000000)'.$InitialOrder.') AS `TT`'; 229 230 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS `X`'); 231 $DbRow = $DbResult->fetch_row(); 232 $PageList = GetPageList($DbRow[0]); 233 234 $Output .= '<form name="Translators" action="?Action=View&ExportId='.$_GET['ExportId'].'" method="post">'. 235 '<h3>'.T('Translators').'</h3>'; 236 if($Editable) 237 { 238 $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'. 239 '<input type="hidden" name="Operation" value="Save"/><br />'. 240 ' <span onclick="CheckAllCheckbox();">'.CheckBox('CheckAll', False, 'CheckAll').' '.T('Select all on page').'</span> <br />'. 241 ' <span>'.CheckBox('AllUsers', $Export['AllUsers']).' '.T('Export allways from all users').'</span> '. 242 '<br />'. 243 T('Select users from list which you want to export from. And edit their order.').'<br />'. 244 T('Order is done by numeric value which is can be edit to desirable order. Lines with same number will be renumbered in ascending order.'); 245 } 246 247 $Output .= $PageList['Output']. 248 '<table class="BaseTable">'. 249 $Order['Output']; 250 251 $Query = 'SELECT * FROM ('.$Query.') AS `TX` '.$Order['SQL'].$PageList['SQLLimit']; 252 $this->System->Database->query('SET @I = 0'); 253 $DbResult = $this->System->Database->query($Query); 254 while($UserLine = $DbResult->fetch_assoc()) 255 { 256 $XP = GetLevelMinMax($UserLine['XP']); 257 $Checked = $UserLine['Sequence'] != ''; 258 $Selection = CheckBox('sel'.$UserLine['ID'], $Checked, '', 'CheckBox', ((!$Editable) or ($Export['AllUsers']))); 259 $Sequence = '<input type="text" name="seq'.$UserLine['ID'].'" style="text-align: center; width: 40px;" value="'.$UserLine['Sequence2'].'"'.$DisabledInput[$Editable].'/>'; 260 $Output .= '<tr>'. 261 '<td><a href="'.$this->System->Link('/TranslationList.php?user='.$UserLine['ID'].'&state=2&group=0').'" title="Zobrazit všechny jeho přeložené texty">'.$UserLine['Name'].'</a></td>'. 262 '<td>'.$UserLine['TranslatedCount'].'</td>'. 263 '<td>'.$XP['Level'].'</td>'. 264 '<td>'.ProgressBar(150, round($XP['XP'] / $XP['MaxXP'] * 100, 2), $XP['XP'].' / '.$XP['MaxXP']).'</td>'. 265 '<td>'.$Selection.'</td><td>'.$Sequence.'</td></tr>'; 266 } 267 $Output .= '</table>'. 268 '</form>'. 269 $PageList['Output']; 270 return($Output); 271 } 272 273 function ExportViewGeneral() 274 { 275 $DisabledInput = array(false => ' disabled="disabled"', true => ''); 276 $DisabledTextArea = array(false => ' readonly="yes"', true => ''); 277 $Output = '<h3>Obecná nastavení</h3>'; 278 $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']); 279 $Export = $DbRows->fetch_assoc(); 280 if($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true; 281 else $Editable = false; 282 283 if(array_key_exists('Operation', $_POST)) 284 if($_POST['Operation'] == 'Save') if($Editable and array_key_exists('Title', $_POST) and array_key_exists('Description', $_POST)) 285 { 286 if(array_key_exists('WithDiacritic', $_POST)) $WithDiacritic = 1; 287 else $WithDiacritic = 0; 288 if (array_key_exists('Featured', $_POST)) $Export['Featured'] = 1; 289 $this->System->Database->query('UPDATE `Export` SET `Title`="'.$_POST['Title'].'", `Featured`='.$Export['Featured'].', `Description`="'.$_POST['Description'].'", `WithDiacritic`='.$WithDiacritic.' WHERE Id='.$Export['Id']); 290 $Export['Title'] = $_POST['Title']; 291 $Export['Description'] = $_POST['Description']; 292 $Export['WithDiacritic'] = $WithDiacritic; 293 $Output .= ShowMessage('Nastavení uloženo.'); 294 } 295 296 if($Export['WithDiacritic'] == 1) $WithDiacritic = ' checked="checked"'; 297 else $WithDiacritic = ''; 298 $Output .= '<form action="?Action=View&Tab=0&ExportId='.$Export['Id'].'" method="post">'. 299 '<table>'; 300 if($this->System->User->Id != null) 301 { 302 $Output .= '<input type="hidden" name="Operation" value="Save"/>'. 303 '<tr><td colspan="2">'; 304 304 if($Editable) $Output .= ' <input type="submit" value="Uložit" '.$DisabledInput[$Editable].'/>'; 305 305 $Output .= ' <a href="?Action=Clone&ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy clone item?').'\');">'.T('Clone').'</a> '; 306 306 if($this->System->User->Licence(LICENCE_ADMIN)) 307 307 $Output .= CheckBox('Featured', $Export['Featured'], '', 'CheckBox', !$Editable). ' '.T('Recommended').' '; 308 308 $Output .= '</td></tr>'; 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 foreach($TranslationTree as $Group) 447 448 309 } 310 $Output .= '<tr><td>'.T('Identification').':</td><td><input type="text" style="width: 400px" name="Title" value="'.$Export['Title'].'"'.$DisabledInput[$Editable].'/></td></tr>'. 311 '<tr><td>Popis:</td><td><textarea name="Description" cols="54" rows="10"'.$DisabledTextArea[$Editable].'>'.$Export['Description'].'</textarea></td></tr>'. 312 '<tr><td>'.T('With diacritics').'</td><td><input type="checkbox" name="WithDiacritic" '.$WithDiacritic.''.$DisabledInput[$Editable].'/></td></tr>'. 313 '</table></form>'; 314 return($Output); 315 } 316 317 function ExportViewLanguages() 318 { 319 global $TranslationTree; 320 321 $Output = ''; 322 $DisabledInput = array(false => ' disabled="disabled"', true => ''); 323 $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']); 324 $Export = $DbRows->fetch_assoc(); 325 if($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true; 326 else $Editable = false; 327 328 if(array_key_exists('Operation', $_POST)) 329 { 330 if($_POST['Operation'] == 'Save') 331 { 332 //print_r($_POST); 333 // Update user selection page 334 foreach($_POST as $Index => $Value) 335 { 336 if(substr($Index, 0, 3) == 'seq') 337 { 338 $LanguageId = substr($Index, 3) * 1; 339 if(array_key_exists('sel'.$LanguageId, $_POST)) $Selected = true; 340 else $Selected = false; 341 $Condition = ' WHERE Export='.$_GET['ExportId'].' AND `Language`='.$LanguageId; 342 $DbResult = $this->System->Database->query('SELECT * FROM `ExportLanguage` '.$Condition); 343 if($DbResult->num_rows > 0) 344 { 345 if(!$Selected) $this->System->Database->query('DELETE FROM `ExportLanguage` '.$Condition); 346 else $this->System->Database->query('UPDATE `ExportLanguage` SET `Sequence`='.$Value.$Condition); 347 } else 348 { 349 if($Selected) $this->System->Database->query('INSERT INTO `ExportLanguage` (`Export`, `Language`, `Sequence`) VALUES ('.$_GET['ExportId'].', '.$LanguageId.', '.$Value.')'); 350 } 351 } 352 } 353 354 // Recalculate sequence number 355 $this->System->Database->query('SET @I = 0'); 356 $this->System->Database->query('UPDATE `ExportLanguage` SET `Sequence` = (@I := @I + 1) WHERE `Export`='.$_GET['ExportId'].' ORDER BY `Sequence`;'); 357 $Output .= ShowMessage('Výběr uložen.'); 358 } 359 } 360 361 $Query = 'SELECT (@I := @I + 1) AS `Sequence2`, `Sequence`, `Language`.`Id`, `Name` FROM `Language`'; 362 $Query .=' LEFT JOIN `ExportLanguage` ON `ExportLanguage`.`Export` = '.$_GET['ExportId'].' AND `ExportLanguage`.`Language`=`Language`.`Id`'; 363 $Query .=' WHERE `Language`.`Enabled` = 1 ORDER BY COALESCE(`Sequence`, 100)'; 364 365 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS X'); 366 $DbRow = $DbResult->fetch_row(); 367 $PageList = GetPageList($DbRow[0]); 368 369 $TableColumns = array( 370 array('Name' => 'Name', 'Title' => T('Name')), 371 array('Name' => '', 'Title' => T('Select')), 372 array('Name' => 'Sequence2', 'Title' => T('Order')), 373 ); 374 $Order = GetOrderTableHeader($TableColumns, 'Sequence2'); 375 $Output .= '<form action="?Action=View&ExportId='.$_GET['ExportId'].'" method="post">'. 376 '<h3>'.T('Languages').'</h3>'; 377 if($Editable) 378 { 379 $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'. 380 '<input type="hidden" name="Operation" value="Save"/>'. 381 '<br />'. 382 T('Select languades from list witch you want to export from. And edit theirs order.').'<br />'. 383 T('Order is done by numeric value which is can be edit to desirable order. Lines with same number will be renumbered in ascending order.'); 384 } 385 386 $Output .= $PageList['Output']. 387 '<table class="BaseTable">'. 388 $Order['Output']; 389 390 $Query = 'SELECT * FROM ('.$Query.') AS TX '.$Order['SQL'].$PageList['SQLLimit']; 391 $this->System->Database->query('SET @I = 0'); 392 $DbResult = $this->System->Database->query($Query); 393 while($Langugage = $DbResult->fetch_assoc()) 394 { 395 $Checked = $Langugage['Sequence'] != ''; 396 $Selection = CheckBox('sel'.$Langugage['Id'], $Checked, '', 'CheckBox', !$Editable); 397 $Sequence = '<input type="text" name="seq'.$Langugage['Id'].'" style="text-align: center; width: 40px;" value="'.$Langugage['Sequence2'].'"'.$DisabledInput[$Editable].'/>'; 398 $Output .= '<tr> 399 <td>'.$Langugage['Name'].'</td> 400 <td>'.$Selection.'</td><td>'.$Sequence.'</td></tr>'; 401 } 402 $Output .= '</table>'. 403 '</form>'. 404 $PageList['Output']; 405 return($Output); 406 } 407 408 function ExportViewGroups() 409 { 410 global $TranslationTree; 411 412 $Output = ''; 413 $DisabledInput = array(false => ' disabled="disabled"', true => ''); 414 $DbRows = $this->System->Database->query('SELECT * FROM Export WHERE Id='.$_GET['ExportId']); 415 $Export = $DbRows->fetch_assoc(); 416 if($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true; 417 else $Editable = false; 418 419 if(array_key_exists('Operation', $_POST)) 420 { 421 if($_POST['Operation'] == 'Save') 422 { 423 //print_r($_POST); 424 // Update user selection page 425 foreach($_POST as $Index => $Value) 426 { 427 if(substr($Index, 0, 3) == 'seq') 428 { 429 $GroupId = substr($Index, 3) * 1; 430 if(array_key_exists('sel'.$GroupId, $_POST)) $Selected = true; 431 else $Selected = false; 432 $Condition = ' WHERE `Export`='.$_GET['ExportId'].' AND `Group`='.$GroupId; 433 $DbResult = $this->System->Database->query('SELECT * FROM `ExportGroup` '.$Condition); 434 if($DbResult->num_rows > 0) 435 { 436 if(!$Selected) $this->System->Database->query('DELETE FROM `ExportGroup` '.$Condition); 437 } else 438 { 439 if($Selected) $this->System->Database->query('INSERT INTO `ExportGroup` (`Export`, `Group`) VALUES ('.$_GET['ExportId'].', '.$GroupId.')'); 440 } 441 } 442 } 443 $Output .= ShowMessage(T('Select saved.')); 444 } 445 //items 446 foreach($TranslationTree as $Group) 447 { 448 // echo $Group['Id'].' '; 449 449 foreach($TranslationTree[$Group['Id']]['Items'] as $Column) { 450 450 if(array_key_exists('item'.$Column['Id'], $_POST)) $Selected = true; … … 452 452 //we will save only forbitten collums and need to be visible 453 453 $Selected = !$Selected; 454 if (!$Column['Visible']) $Selected = false; 455 456 457 458 459 460 461 462 463 464 454 if (!$Column['Visible']) $Selected = false; 455 456 $Condition = ' WHERE `Export`='.$_GET['ExportId'].' AND `GroupItem`='.$Column['Id']; 457 $DbResult = $this->System->Database->query('SELECT * FROM `ExportGroupItem` '.$Condition); 458 if($DbResult->num_rows > 0) 459 { 460 if(!$Selected) $this->System->Database->query('DELETE FROM `ExportGroupItem` '.$Condition); 461 } else 462 { 463 if($Selected) $this->System->Database->query('INSERT INTO `ExportGroupItem` (`Export`, `GroupItem`) VALUES ('.$_GET['ExportId'].', '.$Column['Id'].')'); 464 } 465 465 466 466 } 467 467 } 468 469 470 471 472 473 474 475 476 477 478 479 480 //array('Name' => 'DBCFileName', 'Title' => 'DBC soubor'),481 //array('Name' => 'LuaFileName', 'Title' => 'Lua soubor'),482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 } 505 506 507 508 509 468 } 469 470 $Query = 'SELECT `Group`.*, `ExportGroup`.`Id` AS `ExportGroupId` FROM `Group` LEFT JOIN `ExportGroup` ON `ExportGroup`.`Export`='.$_GET['ExportId'].' AND `Group`=`Group`.`Id`'; 471 472 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS X'); 473 $DbRow = $DbResult->fetch_row(); 474 $PageList = GetPageList($DbRow[0]); 475 476 $TableColumns = array( 477 array('Name' => '', 'Title' => T('Select')), 478 array('Name' => 'Name', 'Title' => T('Name')), 479 array('Name' => 'MangosTable', 'Title' => 'Mangos/DBC/Lua'), 480 // array('Name' => 'DBCFileName', 'Title' => 'DBC soubor'), 481 // array('Name' => 'LuaFileName', 'Title' => 'Lua soubor'), 482 array('Name' => '', 'Title' => T('Items of tranlation')), 483 ); 484 $Order = GetOrderTableHeader($TableColumns, 'Name'); 485 $Output .= '<form action="?Action=View&ExportId='.$_GET['ExportId'].'" method="post">'. 486 '<h3>Překladové skupiny</h3>'; 487 if($Editable) 488 { 489 $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'. 490 '<input type="hidden" name="Operation" value="Save"/>'. 491 ' <span onclick="CheckAllCheckbox();">'.CheckBox('CheckAll', False, 'CheckAll').' '.T('Select all').'</span> '. 492 '<br />'. 493 T('Select translation groups witch you want to export.').'<br />'; 494 } 495 496 $Output .= $PageList['Output']. 497 '<table class="BaseTable">'. 498 $Order['Output']; 499 500 $DbResultItem = $this->System->Database->query('SELECT * FROM `ExportGroupItem` WHERE `Export`='.$_GET['ExportId']); 501 while($GroupItem = $DbResultItem->fetch_assoc()) 502 { 503 $GroupItems[$GroupItem['GroupItem']] = 1; 504 } 505 506 $Query = 'SELECT * FROM ('.$Query.') AS TX '.$Order['SQL'].$PageList['SQLLimit']; 507 $DbResult = $this->System->Database->query($Query); 508 while($Group = $DbResult->fetch_assoc()) 509 { 510 510 $Columns = ''; 511 511 foreach($TranslationTree[$Group['Id']]['Items'] as $Column) { 512 512 if ($Column['Visible']) $Columns .= CheckBox('item'.$Column['Id'], !isset($GroupItems[$Column['Id']]), '', 'CheckBox', !$Editable).' '.$Column['Name'].' <br />'; 513 513 } 514 515 516 517 518 519 520 521 522 523 524 525 526 $Output .= 527 $Output .= $Columns.'</td>';514 $Checked = $Group['ExportGroupId'] != ''; 515 $Selection = CheckBox('sel'.$Group['Id'], $Checked, '', 'CheckBox', !$Editable); 516 $Output .= '<tr>'. 517 '<td>'.$Selection.'<input type="hidden" name="seq'.$Group['Id'].'"/></td>'. 518 '<td>'.$Group['Name'].'</td><td>'; 519 if ($Group['MangosTable'] <> '') 520 $Output .= $Group['MangosTable'].'.sql '; 521 if ($Group['LuaFileName'] <> '') 522 $Output .= $Group['LuaFileName'].'.lua '; 523 if ($Group['DBCFileName'] <> '') 524 $Output .= $Group['DBCFileName'].'.dbc '; 525 526 $Output .= '</td><td>'; 527 $Output .= $Columns. '</td>'; 528 528 $Output .= '</tr>'; 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 if (array_key_exists('Auto', $_GET) == false) 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 $DbRow['User'] = $this->System->User->Id; 788 789 529 } 530 $Output .= '</table>'. 531 '</form>'. 532 $PageList['Output']; 533 return($Output); 534 } 535 536 function ExportViewOutputFormat() 537 { 538 $Output = ''; 539 $DisabledInput = array(false => ' disabled="disabled"', true => ''); 540 if(array_key_exists('ExportId', $_GET)) 541 { 542 $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']); 543 if($DbRows->num_rows > 0) 544 { 545 $Export = $DbRows->fetch_assoc(); 546 if($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true; 547 else $Editable = false; 548 549 if(array_key_exists('Operation', $_POST)) 550 if($_POST['Operation'] == 'Save') 551 { 552 if(array_key_exists('OutputType', $_POST) and ($_POST['OutputType'] * 1 > 0)) 553 { 554 $this->System->Database->query('UPDATE Export SET OutputType='.$_POST['OutputType'].' WHERE Id='.$_GET['ExportId']); 555 $Output .= ShowMessage(T('Select saved.')); 556 } else $Output .= ShowMessage(T('Format wasn\'t selected'), MESSAGE_CRITICAL); 557 } 558 559 $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']); 560 $Export = $DbResult->fetch_assoc(); 561 562 $Output .= '<h3>'.T('Format the generated output').'</h3>'. 563 '<form action="?Action=View&ExportId='.$_GET['ExportId'].'" method="post">'; 564 if($Editable) 565 { 566 $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'. 567 '<input type="hidden" name="Operation" value="Save"/>'. 568 '<br />'; 569 } 570 $DbResult = $this->System->Database->query('SELECT * FROM `ExportOutputType` ORDER BY `Name`'); 571 while($ExportFormat = $DbResult->fetch_assoc()) 572 { 573 $Output .= RadioButton('OutputType', $ExportFormat['Id'], $Export['OutputType'] == $ExportFormat['Id'], '', !$Editable).' '.$ExportFormat['Name'].'<br/>'; 574 } 575 $Output .= '</form>'; 576 } else $Output .= ShowMessage(T('Item not found'), MESSAGE_CRITICAL); 577 } else $Output .= ShowMessage(T('Is isn\'t select'), MESSAGE_CRITICAL); 578 return($Output); 579 } 580 581 function ExportViewVersion() 582 { 583 $Output = ''; 584 $DisabledInput = array(false => ' disabled="disabled"', true => ''); 585 $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']); 586 $Export = $DbRows->fetch_assoc(); 587 if($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true; 588 else $Editable = false; 589 590 if(array_key_exists('Operation', $_POST)) 591 if(($_POST['Operation'] == 'Save') and (array_key_exists('ClientVersion', $_POST))) 592 { 593 $this->System->Database->query('UPDATE `Export` SET `ClientVersion`='.$_POST['ClientVersion'].' WHERE `Id`='.$_GET['ExportId']); 594 $Output .= ShowMessage(T('Select saved.')); 595 } 596 597 $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']); 598 $Export = $DbResult->fetch_assoc(); 599 600 if($Export['OutputType'] == '') $Output .= ShowMessage('Nevybrán typ exportu', MESSAGE_CRITICAL); 601 else { 602 $Query = 'SELECT `ClientVersion`.* FROM `ExportVersion` '. 603 'LEFT JOIN `ClientVersion` ON `ClientVersion`.`Id`=`ExportVersion`.`ClientVersion` WHERE `ExportType`='.$Export['OutputType']; 604 605 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS `X`'); 606 $DbRow = $DbResult->fetch_row(); 607 $PageList = GetPageList($DbRow[0]); 608 609 $TableColumns = array( 610 array('Name' => 'Version', 'Title' => T('Version')), 611 array('Name' => 'BuildNumber', 'Title' => T('Build')), 612 array('Name' => 'ReleaseDate', 'Title' => T('Release date')), 613 array('Name' => 'Title', 'Title' => T('Name2')), 614 array('Name' => '', 'Title' => T('Select')), 615 ); 616 $Order = GetOrderTableHeader($TableColumns, 'BuildNumber', 1); 617 $Output .= '<form action="?Action=View&ExportId='.$_GET['ExportId'].'" method="post">'. 618 '<h3>'.T('Client version').'</h3>'; 619 620 if($Editable) 621 { 622 $Output .= '<input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'. 623 '<input type="hidden" name="Operation" value="Save"/>'. 624 '<br />'. 625 T('Select version of game client witch you want to export.').'<br />'; 626 } 627 $Output .= $PageList['Output']. 628 '<table class="BaseTable">'. 629 $Order['Output']; 630 631 $Query = 'SELECT * FROM ('.$Query.') AS `TX` '.$Order['SQL'].$PageList['SQLLimit']; 632 $DbResult = $this->System->Database->query($Query); 633 while($Version = $DbResult->fetch_assoc()) 634 { 635 $Output .= '<tr><td><a href="'.$this->System->Link('/client-version/?action=item&id='.$Version['Id']).'">'. 636 $Version['Version'].'</a></td><td>'.$Version['BuildNumber'].'</td><td>'. 637 HumanDate($Version['ReleaseDate']).'</td><td>'.$Version['Title'].'</td><td>'. 638 RadioButton('ClientVersion', $Version['Id'], $Export['ClientVersion'] == $Version['Id'], '', !$Editable 639 ).'</td></tr>'; 640 641 } 642 $Output .= '</table>'. 643 '</form>'. 644 $PageList['Output']; 645 } 646 return($Output); 647 } 648 649 function ExportViewOutput() 650 { 651 $Output = ''; 652 $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']); 653 $Export = $DbResult->fetch_assoc(); 654 if($Export['OutputType'] == '') $Output .= ShowMessage('Nevybrán typ exportu', MESSAGE_CRITICAL); 655 else if($Export['ClientVersion'] == '') $Output .= ShowMessage(T('Export don\'t have selected version of client'), MESSAGE_CRITICAL); 656 else { 657 $DbResult = $this->System->Database->query('SELECT * FROM `ExportOutputType` WHERE `Id`='.$Export['OutputType']); 658 if($DbResult->num_rows > 0) 659 { 660 $DbResult = $this->System->Database->query('SELECT * FROM `ExportVersion` WHERE (`ExportType`='.$Export['OutputType'].') AND (`ClientVersion`='.$Export['ClientVersion'].')'); 661 if($DbResult->num_rows > 0) 662 { 663 if (array_key_exists('Auto', $_GET) == false) 664 $this->System->Database->query('UPDATE `Export` SET `UsedCount` = `UsedCount` + 1 WHERE `Id`='.$Export['Id']); 665 $Output = ExportOutput($Export['Id'], $Export['OutputType']); 666 } else $Output = ShowMessage(T('Export don\'t have selected version of client'), MESSAGE_CRITICAL); 667 } else $Output = ShowMessage(T('Format output isn\'t select').'.', MESSAGE_CRITICAL); 668 } 669 return($Output); 670 } 671 672 function ExportViewStat($Where = '') 673 { 674 $Export = new Export($this->System); 675 $Export->Id = $_GET['ExportId']; 676 $Export->Init(); 677 $Export->LoadFilters(); 678 679 if(($Export->Export['ClientVersion'] == '') or ($Export->ClientVersion['BuildNumber'] == '')) 680 $Output = ShowMessage(T('Export don\'t have selected version of client'), MESSAGE_CRITICAL); 681 else { 682 $GroupListQuery = 'SELECT `Group`.* FROM `Group` '. 683 ' JOIN `ExportGroup` ON (`ExportGroup`.`Export`='.$Export->Id.') AND (`ExportGroup`.`Group`=`Group`.`Id`)'; 684 $Query = ''; 685 $UnionItems = array(); 686 $DbResult = $this->System->Database->query($GroupListQuery.$Where); 687 while($DbRow = $DbResult->fetch_assoc()) 688 { 689 $UnionItems[] = 'SELECT (SELECT COUNT(DISTINCT(`Entry`)) FROM ('. 690 ' SELECT `T`.* FROM `'.$DbRow['TablePrefix'].'` AS `T`'. 691 ' JOIN `ExportUser` ON (`ExportUser`.`User`=`T`.`User`) AND (`ExportUser`.`Export`='.$Export->Id.') '. 692 ' JOIN `ExportLanguage` ON (`ExportLanguage`.`Export`='.$Export->Id.')'. 693 ' WHERE (`Complete` = 1) AND (`VersionStart` <= '.$Export->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$Export->ClientVersion['BuildNumber'].')'. 694 ') AS `C1`) AS `Translated`, '. 695 '(SELECT COUNT(DISTINCT(`Entry`)) FROM ('. 696 ' SELECT `T`.* FROM `'.$DbRow['TablePrefix'].'` AS `T`'. 697 ' WHERE (`Language` = '.$this->System->Config['OriginalLanguage'].') AND (`VersionStart` <= '.$Export->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$Export->ClientVersion['BuildNumber'].')'. 698 ') AS `C2`) AS `Total`, "'.$DbRow['Name'].'" AS `Name`'; 699 } 700 $Query = substr($Query, 0, - 6); 701 702 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$GroupListQuery.') AS `T`'); 703 $DbRow = $DbResult->fetch_row(); 704 $PageList = GetPageList($DbRow[0]); 705 $Output = '<h3>'.T('Statistic of coplection selected groups').'</h3>'. 706 $PageList['Output']; 707 708 $Output .= '<table class="BaseTable">'; 709 $TableColumns = array( 710 array('Name' => 'Name', 'Title' => T('Name')), 711 array('Name' => 'Translated', 'Title' => T('Translated count')), 712 array('Name' => 'Total', 'Title' => T('English')), 713 array('Name' => 'Percent', 'Title' => T('Percent')), 714 ); 715 716 $Order = GetOrderTableHeader($TableColumns, 'Name', 0); 717 $Output .= $Order['Output']; 718 719 $Translated = 0; 720 $Total = 0; 721 if(count($UnionItems) > 0) 722 { 723 $ID = $this->System->Database->query('SELECT *, ROUND(`Translated` / `Total` * 100, 2) AS `Percent` FROM ('.implode(' UNION ALL ', $UnionItems).') AS `C3` '.$Order['SQL'].$PageList['SQLLimit']); 724 while($Group = $ID->fetch_assoc()) 725 { 726 $Output .= '<tr><td>'.$Group['Name'].'</td><td>'.$Group['Translated'].'</td><td>'.$Group['Total'].'</td><td>'.ProgressBar(150, $Group['Percent']).'</td></tr>'; 727 $Translated += $Group['Translated']; 728 $Total += $Group['Total']; 729 } 730 } 731 if($Total > 0) $Percent = $Translated / $Total * 100; 732 else $Percent = 100; 733 734 $Output .= '<tr><td><strong>'.T('Altogether').'</strong></td><td><strong>'.$Translated.'</strong></td><td><strong>'.$Total.'</strong></td><td><strong>'.ProgressBar(150, round($Percent, 2)).'</strong></td></tr>'; 735 $Output .= '</table>'; 736 } 737 return($Output); 738 } 739 740 function ExportView() 741 { 742 $Output = ''; 743 if(array_key_exists('ExportId', $_GET) and is_numeric($_GET['ExportId'])) 744 { 745 $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']); 746 if($DbResult->num_rows > 0) 747 { 748 $Export = $DbResult->fetch_assoc(); 749 750 $DbResult = $this->System->Database->query('SELECT * FROM `User` WHERE `ID`='.$Export['User']); 751 $UserLine = $DbResult->fetch_assoc(); 752 $Output .= 'Export <strong><a href="?Action=View&Tab=6&ExportId='.$Export['Id'].'">'.$_GET['ExportId'].'</a></strong> překladatele <strong>'.$UserLine['Name'].'</strong> s označením <strong>'.$Export['Title'].'</strong>'; 753 $Output .= ShowTabs(array(T('General'), T('Translators'), 'Překlady', T('Languages'), T('Format'), T('Version'), T('Statistic'), T('Output'))); 754 $Output .= '<div id="content">'; 755 if($_SESSION['Tab'] == TAB_GENERAL) $Output .= $this->ExportViewGeneral(); 756 else if($_SESSION['Tab'] == TAB_TRANSLATORS) $Output .= $this->ExportViewTranslators(); 757 else if($_SESSION['Tab'] == TAB_GROUPS) $Output .= $this->ExportViewGroups(); 758 else if($_SESSION['Tab'] == TAB_LANGUAGES) $Output .= $this->ExportViewLanguages(); 759 else if($_SESSION['Tab'] == TAB_OUTPUT_FORMAT) $Output .= $this->ExportViewOutputFormat(); 760 else if($_SESSION['Tab'] == TAB_VERSION) $Output .= $this->ExportViewVersion(); 761 else if($_SESSION['Tab'] == TAB_STAT) $Output .= $this->ExportViewStat(); 762 else if($_SESSION['Tab'] == TAB_OUTPUT) $Output .= $this->ExportViewOutput(); 763 else $Output .= $this->ExportViewGeneral(); 764 765 $Output .= '</div>'; 766 } else $Output .= ShowMessage(T('Export not found.'), MESSAGE_CRITICAL); 767 } else $Output .= ShowMessage(T('Is isn\'t select'), MESSAGE_CRITICAL); 768 return($Output); 769 } 770 771 function ExportClone() 772 { 773 if($this->System->User->Licence(LICENCE_USER)) 774 { 775 if(array_key_exists('ExportId', $_GET) and is_numeric($_GET['ExportId'])) 776 { 777 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$this->System->User->Id); 778 $DbRow = $DbResult->fetch_row(); 779 if($DbRow[0] < $this->System->Config['MaxExportPerUser']) 780 { 781 $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']); 782 if($DbResult->num_rows > 0) 783 { 784 $DbRow = $DbResult->fetch_assoc(); 785 unset($DbRow['Id']); 786 $DbRow['UsedCount'] = '0'; 787 $DbRow['User'] = $this->System->User->Id; 788 $DbRow['TimeCreate'] = 'NOW()'; 789 $DbRow['Title'] .= ' - '.T('clone'); 790 790 $DbRow['Featured'] = 0; 791 792 $ExportId = $this->System->Database->insert_id; 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 { 811 791 $this->System->Database->insert('Export', $DbRow); 792 $ExportId = $this->System->Database->insert_id; 793 $this->System->Database->query('INSERT INTO `ExportGroup` (SELECT NULL AS `Id`, '.$ExportId.' AS `Export`, `Group` FROM `ExportGroup` WHERE `Export`='.$_GET['ExportId'].')'); 794 $this->System->Database->query('INSERT INTO `ExportGroupItem` (SELECT NULL AS `Id`, '.$ExportId.' AS `Export`, `GroupItem` FROM `ExportGroupItem` WHERE `Export`='.$_GET['ExportId'].')'); 795 $this->System->Database->query('INSERT INTO `ExportLanguage` (SELECT NULL AS `Id`, '.$ExportId.' AS `Export`, `Language`, `Sequence` FROM `ExportLanguage` WHERE `Export`='.$_GET['ExportId'].')'); 796 $this->System->Database->query('INSERT INTO `ExportUser` (SELECT NULL AS `Id`, '.$ExportId.' AS `Export`, `User`, `Sequence` FROM `ExportUser` WHERE `Export`='.$_GET['ExportId'].')'); 797 $Output = ShowMessage(T('Clone export created.<br />Direct link to export').': <a href="?Action=View&ExportId='.$ExportId.'">zde</a>'); 798 $this->System->ModuleManager->Modules['Log']->WriteLog(T('Clone export created').' <a href="'.$this->System->Link('/export/?Action=View&ExportId='.$ExportId).'">'.$ExportId.'</a>.', LOG_TYPE_EXPORT); 799 $_GET['Filter'] = 'my'; 800 $this->ExportList(); 801 } else $Output = ShowMessage('Zdrojový export nenalezen', MESSAGE_CRITICAL); 802 } else $Output = ShowMessage('Nemůžete vytvářet další export. Max. počet na uživatele je '. 803 $this->System->Config['MaxExportPerUser'].'.', MESSAGE_CRITICAL); 804 } else $Output = ShowMessage(T('Export not found.'), MESSAGE_CRITICAL); 805 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 806 return($Output); 807 } 808 809 function Show() 810 { 811 $this->Title = T('Export'); 812 812 if(array_key_exists('Action', $_GET)) 813 813 { … … 820 820 } else $Output = $this->ExportList(); 821 821 return($Output); 822 } 822 } 823 823 } -
trunk/Modules/Export/ProcessAoWoWExport.php
r805 r816 5 5 include_once('../../includes/global.php'); 6 6 //include_once('../../includes/dbc.php'); 7 include_once('Export.php'); 8 include_once('Page.php'); 7 include_once('Export.php'); 8 include_once('Page.php'); 9 9 10 10 $System = new System(); 11 11 $System->DoNotShowPage = true; 12 12 $System->Run(); 13 13 14 14 $Output = ''; 15 15 16 if(defined('STDIN') == false) 16 if(defined('STDIN') == false) 17 17 { 18 18 $Output = T('Access denied'); 19 19 exit($Output); 20 } 20 } 21 21 22 22 foreach($_SERVER['argv'] as $parameter) … … 36 36 $Export->Id = $Config['AoWoWExportId']; 37 37 } else $Export->Id = 37; 38 $Output .= $Export->Init(); 38 $Output .= $Export->Init(); 39 39 $SQL = $Export->ExportToAoWoWSQL(); 40 40 echo 'Hotovo … … 89 89 } 90 90 $Files = scandir(dirname(__FILE__).'/../../aowow/cache/templates/wowhead'); 91 foreach($Files as $File) 91 foreach($Files as $File) 92 92 { 93 93 $End = substr($File, strlen($File) - 3); -
trunk/Modules/Export/ProcessTask.php
r811 r816 12 12 $System = new System(); 13 13 $System->DoNotShowPage = true; 14 14 $System->Run(); 15 15 16 16 function SetProgress($Export,$per) { -
trunk/Modules/Export/Progress.php
r743 r816 2 2 3 3 include_once(dirname(__FILE__).'/../../includes/global.php'); 4 4 5 5 $System = new System(); 6 6 $System->DoNotShowPage = true; 7 7 $System->Run(); 8 8 9 9 10 10 $Output = ''; … … 12 12 ' LEFT JOIN `Export` ON `Export`.`Id` = `ExportTask`.`Export` WHERE (`Export`.`OutputType` = 9 OR `Export`.`OutputType` = 10 ) AND `TimeFinish` IS NULL OR `Export` ='.$_GET['RedirectId'].' ORDER BY `Progress` DESC');// `Export`='.$Export->Id 13 13 while($Task = $DbResult->fetch_assoc()) { 14 $Export = '<a href="'.$System->Link('/export/?Action=View&ExportId='.$Task['Export']).'">'.$Task['Export'].'</a>'; 14 $Export = '<a href="'.$System->Link('/export/?Action=View&ExportId='.$Task['Export']).'">'.$Task['Export'].'</a>'; 15 15 if ($_GET['RedirectId'] == $Task['Export']) 16 16 $Export = ''.$Export.' (tento)'; … … 19 19 'setTimeout("parent.location.href=\''.$System->Link('/export/?Action=View&Tab=7&ExportId='.$_GET['RedirectId']).'\'", 500)'. 20 20 '</script>'; 21 } 21 } 22 22 23 23 echo $Output; -
trunk/Modules/Export/cmdmpqexport.php
r805 r816 5 5 include_once(dirname(__FILE__).'/../../includes/global.php'); 6 6 //include_once('../../includes/dbc.php'); 7 include_once('Export.php'); 8 include_once('Page.php'); 7 include_once('Export.php'); 8 include_once('Page.php'); 9 9 10 10 $System = new System(); 11 11 $System->DoNotShowPage = true; 12 12 $System->Run(); 13 13 $PageExport = new PageExport($System); 14 14 … … 17 17 $Output = ''; 18 18 19 if(defined('STDIN') == false) 19 if(defined('STDIN') == false) 20 20 { 21 21 $Output = T('Access denied'); 22 22 exit($Output); 23 } 23 } 24 24 25 25 foreach($_SERVER['argv'] as $parameter) … … 37 37 $Output .= 'Usage ExportId=id_export - for write export info<br />'; 38 38 $Output .= 'Usage needgeneration=id_export - for write export info<br />'; 39 39 40 40 $Output .= 'type_export={lua,dbc,addon} <br />'; 41 41 $Output = str_replace('<br />',' … … 46 46 $Export = new Export($System); 47 47 $Export->Id = $_GET['lua']; 48 $Output .= $Export->Init(); 48 $Output .= $Export->Init(); 49 49 $Output .= $Export->ExportToLua(); 50 50 $Output = str_replace('<br/>',' … … 56 56 $Export = new Export($System); 57 57 $Export->Id = $_GET['version']; 58 $Export->LoadFilters(); 58 $Export->LoadFilters(); 59 59 $Output .= $Export->ClientVersion['Version']; 60 60 $Output = str_replace('<br/>',' … … 66 66 $Export = new Export($System); 67 67 $Export->Id = $_GET['dbc']; 68 $Output .= $Export->Init(); 68 $Output .= $Export->Init(); 69 69 $Output .= $Export->ExportToDbc(); 70 70 $Output = str_replace('<br/>',' … … 85 85 86 86 if(array_key_exists('needgeneration', $_GET)) { 87 87 $DbRows = $System->Database->query('SELECT `ClientVersion`.`Version` as Version, `Export`.`Id`,`Export`.`ClientVersion`,`Export`.`OutputType`,`Export`.`Title`,`Export`.`Description` FROM `Export` JOIN `ClientVersion` as `ClientVersion` ON `ClientVersion`.`Id`=`Export`.`ClientVersion` WHERE `Featured`=1 ORDER BY `ClientVersion`.`BuildNumber` DESC'); 88 88 while ($DbExport = $DbRows->fetch_assoc()) { 89 89 $Export = new Export($System); 90 90 $Export->Id = $DbExport['Id']; 91 $Output .= $Export->Init(); 91 $Output .= $Export->Init(); 92 92 if ($Export->NeedGeneration()) { 93 93 $DbResult = $System->Database->query('SELECT * FROM ExportTask WHERE Export = '.$Export->Id); … … 95 95 { 96 96 $System->Database->query('INSERT INTO ExportTask (`Export` ,`TimeStart` ) VALUES ('.$Export->Id.', NOW())'); 97 } else 97 } else 98 98 $System->Database->query('UPDATE ExportTask SET `TimeStart` = NOW(), `Progress` = 0, `TimeFinish` = NULL WHERE Export = '.$Export->Id); 99 99 … … 113 113 $Export = new Export($System); 114 114 $Export->Id = $_GET['ExportId']; 115 $Export->LoadFilters(); 116 115 $Export->LoadFilters(); 116 117 117 //generation readme 118 118 $Output .= '<?xml version="1.0" encoding="utf-8"?\>'. … … 129 129 '<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />'. 130 130 '<title>Čeština pro WoW</title>'. 131 '</head><body>'. 131 '</head><body>'. 132 132 '<h1>České WoW - čestina pro klienta hry World of Warcraft</h1>'. 133 133 134 134 '<table cellspacing="10"><tr><td valign="top">'. 135 135 136 136 '<p>Texty přebírány z projektu <a href="http://wowpreklad.zdechov.net/">wowpreklad.zdechov.net</a><br>'. 137 137 '<a href="http://wowpreklad.zdechov.net/export/?Action=View&ExportId='.$_GET['ExportId'].'&Tab=0">Export '.$_GET['ExportId'].'</a></p><br>'. 138 139 138 139 140 140 '<p><strong>Vlastnosti</strong>'. 141 141 '<ul>'. … … 148 148 '</p>'. 149 149 '<br>'. 150 150 151 151 '<h2>Nejčastější otázky</h2>'. 152 152 '<p><strong>Jak mám hru spustit?</strong><br>'. … … 155 155 '<p><strong>Mohu použít tuto češtinu na oficiálních serverech?</strong><br>'. 156 156 'Ne úplně, protože se vystavujete riziku zablokování vašeho účtu z důvodu použití upravené hry. Na oficiálním serveru lze využít pouze Addon s češtinou CzWoW.</p>'. 157 157 158 158 '<p><strong>Mám nainstalovánu češtinu a nejde mi spustit Wow.exe.</strong><br>'. 159 159 'Pokud chcete opět spouštět hru přes původní Wow.exe v angličtině, musíte češtinu nejprve odinstalovat ze systému. Především se jedná o soubor Data/enGB/patch-enGB-5.MPQ či Data/enUS/patch-enUS-5.MPQ, který je nutno smazat.</p>'. 160 160 161 161 '<p><strong>Nedaří se mi provést aktualizaci klienta s nainstalovanou češtinou.</strong><br>'. 162 162 'Před aktualizací na novější verzi klienta musíte nejprve češtinu odinstalovat. Čeština totiž mění v rámci patch MPQ souboru některé soubory hry, což oficiální instalátory vyhodnotí jako poškození hry.</p>'. 163 163 164 164 '</td><td>'; 165 165 … … 167 167 168 168 $Output .= '</td></tr></table>'. 169 170 169 170 171 171 '</body></html>'; 172 172 173 173 } 174 174 //$_GET['ExportId'] -
trunk/Modules/Forum/Forum.php
r805 r816 3 3 class ModuleForum extends AppModule 4 4 { 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 'Title' => T('Forum'), 'Channel' => 'forum', 'Callback' => array('PageForum', 'ShowRSS'),21 'Permission' => LICENCE_ANONYMOUS));22 5 function __construct($System) 6 { 7 parent::__construct($System); 8 $this->Name = 'Forum'; 9 $this->Version = '1.0'; 10 $this->Creator = 'Maron'; 11 $this->License = 'GNU/GPL'; 12 $this->Description = ''; 13 $this->Dependencies = array(); 14 } 15 16 function Start() 17 { 18 $this->System->RegisterPage('forum', 'PageForum'); 19 $this->System->ModuleManager->Modules['News']->RegisterRSS(array( 20 'Title' => T('Forum'), 'Channel' => 'forum', 'Callback' => array('PageForum', 'ShowRSS'), 21 'Permission' => LICENCE_ANONYMOUS)); 22 23 23 if(array_key_exists('Search', $this->System->ModuleManager->Modules)) 24 24 $this->System->ModuleManager->Modules['Search']->RegisterSearch('forum', … … 27 27 $this->System->ModuleManager->Modules['Search']->RegisterSearch('forumthread', 28 28 T('Name of thread forum'), array('UserName', 'Text'), '`ForumThread`', $this->System->Link('/forum/?search=')); 29 29 30 30 $this->System->RegisterMenuItem(array( 31 31 'Title' => T('Forum'), … … 35 35 'Icon' => '', 36 36 ), 17); 37 37 } 38 38 } 39 39 40 40 class PageForum extends Page 41 41 { 42 43 44 $Output = ''; 45 46 47 42 function Show() 43 { 44 $Output = ''; 45 $this->Title = T('Forum'); 46 if(array_key_exists('a', $_POST)) $Action = $_POST['a']; 47 else if(array_key_exists('a', $_GET)) $Action = $_GET['a']; 48 48 else $Action = ''; 49 49 if (array_key_exists('Edit', $_GET)) { 50 if (array_key_exists('text', $_POST)) 51 $Output .= $this->Edit(); 50 if (array_key_exists('text', $_POST)) 51 $Output .= $this->Edit(); 52 52 $Output .= $this->ShowEditForm(); 53 53 54 54 } else 55 55 if (array_key_exists('search', $_GET)) … … 57 57 else 58 58 if (array_key_exists('Thread', $_GET)) { 59 60 61 62 59 $Output .= '<h3>'.T('Forum - Thread').'</h3>'; 60 if($Action == 'add2') $Output .= $this->AddFinish(); 61 if($this->System->User->Licence(LICENCE_USER)) $Output .= $this->ShowAddForm(); 62 $Output .= $this->ShowList(); 63 63 } else { 64 65 66 64 $Output .= '<h3>'.T('Forum - List of Thread').'</h3>'; 65 if($Action == 'add2') $Output .= $this->AddFinish('ForumThread'); 66 if($this->System->User->Licence(LICENCE_USER)) $Output .= $this->ShowAddFormThread(); 67 67 $Output .= $this->ShowListThread(); 68 68 } 69 70 71 72 function Edit() 73 { 74 $Output = ''; 75 76 77 78 79 69 return($Output); 70 } 71 72 function Edit() 73 { 74 $Output = ''; 75 76 $Text = $_POST['text']; 77 78 $DbResult = $this->System->Database->query('UPDATE `ForumText` SET `Text`="'.$_POST['text'].'" WHERE `User` = '.$this->System->User->Id.' AND `ID` = '.$_GET['Edit']); 79 80 80 $Output .= ShowMessage(T('Text edited.')); 81 81 82 82 83 83 return ($Output); 84 84 } 85 86 87 88 89 90 91 85 86 function ShowEditForm() 87 { 88 $Output = ''; 89 if($this->System->User->Licence(LICENCE_USER)) 90 { 91 $DbResult = $this->System->Database->query('SELECT * FROM `ForumText` WHERE `User` = '.$this->System->User->Id.' AND `ID` = '.$_GET['Edit']); 92 92 if ( $DbResult->num_rows > 0) { 93 93 $DbRow = $DbResult->fetch_assoc(); 94 95 96 97 98 99 $Output .= T('Message text').': ('.T('You can use').' <a href="http://www.bbcode.org/reference.php">'.T('BB code').'</a>)<br/>'.100 101 102 103 104 }else $Output .= ShowMessage(T('You have to be registered for adding message.'), MESSAGE_CRITICAL);105 } 106 return($Output); 107 108 109 94 $Output .= '<form action="?Edit='.$_GET['Edit'].'" method="post">'. 95 '<fieldset><legend>'.T('Edit message').'</legend>'. 96 T('User').': '; 97 if($this->System->User->Licence(LICENCE_USER)) $Output .= '<b>'.$this->System->User->Name.'</b><br />'; 98 else $Output .= '<input type="text" name="user" /><br />'; 99 $Output .= T('Message text').': ('.T('You can use').' <a href="http://www.bbcode.org/reference.php">'.T('BB code').'</a>)<br/>'. 100 '<textarea onkeydown="ResizeTextArea(this)" rows="8" name="text" cols="80">'.$DbRow['Text'].'</textarea> <br/>'. 101 '<input type="hidden" name="a" value="add2"/>'. 102 '<input type="submit" value="'.T('Send').'" /><br /></fieldset>'. 103 '</form>'; 104 } else $Output .= ShowMessage(T('You have to be registered for adding message.'), MESSAGE_CRITICAL); 105 } else $Output .= ShowMessage(T('You can edit only your own message.'), MESSAGE_CRITICAL); 106 return($Output); 107 } 108 109 function ShowSearchForum() 110 110 { 111 111 $parser = new HTML_BBCodeParser2(array('filters' => array('Basic','Extended','Images','Links','Lists','Email'))); 112 113 114 115 112 $Count = 20; 113 $Output = ''; 114 115 $Output .= '<div class="shoutbox">'; 116 116 $where = '`ForumText`.`Text` LIKE "%'.($_GET['search'] ).'%" OR '. 117 117 ' `ForumThread`.`Text` LIKE "%'.($_GET['search'] ).'%" OR `ForumThread`.`UserName` LIKE "%'.($_GET['search'] ).'%" OR '. … … 119 119 $join = ' JOIN `ForumThread` ON `ForumThread`.`ID` = `ForumText`.`Thread`'; 120 120 121 122 123 $PageList = GetPageList($DbRow[0]); 124 125 126 127 121 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `ForumText` '.$join.' WHERE '.$where); 122 $DbRow = $DbResult->fetch_row(); 123 $PageList = GetPageList($DbRow[0]); 124 125 $Output .= $PageList['Output']; 126 127 $DbResult = $this->System->Database->query('SELECT `ForumText`.`Text`, `ForumText`.`Date`, `ForumText`.`UserName`,'. 128 128 '`ForumThread`.`Text` as `ThreadName`,`ForumText`.`Thread` FROM `ForumText` '.$join.' WHERE '.$where.' ORDER BY `ForumText`.`Date` DESC '.$PageList['SQLLimit']); 129 130 131 132 133 } 134 135 136 137 138 139 140 141 $PageList = GetPageList($DbRow[0]); 142 143 144 145 146 147 148 149 150 151 152 153 154 155 129 while($Line = $DbResult->fetch_assoc()) 130 $Output .= '<div><a href="'.$this->System->Link('/forum/?Thread='.$Line['Thread']).'">'.$Line['ThreadName'].'</a><br /><strong>'.$Line['UserName'].'</strong> ('.HumanDate($Line['Date']).'): '.$parser->qparse($Line['Text']).'</div> '; 131 $Output .= '</div>'.$PageList['Output']; 132 return($Output); 133 } 134 135 function ShowListThread() 136 { 137 $Output = ''; 138 139 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `ForumThread` WHERE 1'); 140 $DbRow = $DbResult->fetch_row(); 141 $PageList = GetPageList($DbRow[0]); 142 143 $Output .= $PageList['Output']; 144 $Output .= '<div class="shoutbox">'; 145 $DbResult = $this->System->Database->query('SELECT * FROM `ForumThread` WHERE 1 ORDER BY `ID` DESC '.$PageList['SQLLimit']); 146 while($Line = $DbResult->fetch_assoc()) 147 $Output .= '<div><span style="float:right;"><strong>'.$Line['UserName'].'</strong> - ('.HumanDate($Line['Date']).')</span> <a href="?Thread='.$Line['ID'].'">'.str_replace("\n", '',$Line['Text']).'</a> </div>'; 148 $Output .= '</div>'.$PageList['Output']; 149 return($Output); 150 } 151 152 function ShowList() 153 { 154 $Output = ''; 155 156 156 $parser = new HTML_BBCodeParser2(array('filters' => array('Basic','Extended','Images','Links','Lists','Email'))); 157 // echo $parser->qparse('[youtube]http://www.youtube.com/watch?v=hwgO6p2Jh-A[/youtube][img]http://www.bbcode.org/images/lubeck_small.jpg[/img]normal [i][b]bold[/b][/i] [img]http://imageshack.com/a/img203/7462/6ctg.jpg[/img] and normal again'); 158 159 160 161 162 163 164 165 166 } else $SearchQuery = ''; 167 168 169 170 171 157 // echo $parser->qparse('[youtube]http://www.youtube.com/watch?v=hwgO6p2Jh-A[/youtube][img]http://www.bbcode.org/images/lubeck_small.jpg[/img]normal [i][b]bold[/b][/i] [img]http://imageshack.com/a/img203/7462/6ctg.jpg[/img] and normal again'); 158 159 if(array_key_exists('search', $_GET)) $_SESSION['search'] = $_GET['search']; 160 else if(!array_key_exists('search', $_SESSION)) $_SESSION['search'] = ''; 161 if(array_key_exists('search', $_GET) and ($_GET['search'] == '')) $_SESSION['search'] = ''; 162 if($_SESSION['search'] != '') 163 { 164 $SearchQuery = ' AND (`Text` LIKE "%'.$_SESSION['search'].'%")'; 165 $Output .= '<div><a href="?search=">'.sprintf(T('Disable filter "%s"'), $_SESSION['search']).'</a></div>'; 166 } else $SearchQuery = ''; 167 168 $DbResult = $this->System->Database->query('SELECT * FROM `ForumThread` WHERE ID='.($_GET['Thread']*1).' LIMIT 1'); 169 if($DbResult->num_rows > 0) 170 { 171 $Thread = $DbResult->fetch_assoc(); 172 172 $Output .= '<h3>'.$Thread['Text'].'</h3>'; 173 173 174 175 176 $PageList = GetPageList($DbRow[0]); 177 178 179 180 181 182 183 174 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `ForumText` WHERE `Thread` = '.($_GET['Thread']*1).' '.$SearchQuery); 175 $DbRow = $DbResult->fetch_row(); 176 $PageList = GetPageList($DbRow[0]); 177 178 $Output .= $PageList['Output']; 179 $Output .= '<div class="shoutbox">'; 180 $DbResult = $this->System->Database->query('SELECT * FROM `ForumText` WHERE `Thread` = '. 181 ($_GET['Thread']*1).' '.$SearchQuery.' ORDER BY `ID` DESC '.$PageList['SQLLimit']); 182 while($Line = $DbResult->fetch_assoc()) { 183 if ($this->System->User->Id == $Line['User']) 184 184 $edit = '<a href="?Edit='.$Line['ID'].'">editovat</a>'; 185 185 else $edit = ''; … … 187 187 ')</span><strong>'.$Line['UserName'].'</strong>: '.str_replace("\n", '<br />',$parser->qparse($Line['Text'])).' </div> '; 188 188 } 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 $Output .= T('Message text').': ('.T('You can use').' <a href="http://www.bbcode.org/reference.php">'.T('BB code').'</a>)<br/>'.205 206 207 208 209 }else $Output .= ShowMessage(T('You have to be registered for adding message.'), MESSAGE_CRITICAL);210 return($Output); 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 }else $Output .= ShowMessage(T('You have to be registered for adding message.'), MESSAGE_CRITICAL);229 return($Output); 230 231 232 233 234 235 236 237 238 239 240 241 242 243 189 $Output .= '</div>'.$PageList['Output']; 190 } else $Output .= ShowMessage(T('Item not found'), MESSAGE_CRITICAL); 191 return($Output); 192 } 193 194 function ShowAddForm() 195 { 196 $Output = ''; 197 if($this->System->User->Licence(LICENCE_USER)) 198 { 199 $Output .= '<form action="?Thread='.$_GET['Thread'].'" method="post">'. 200 '<fieldset><legend>'.T('New Forum Message').'</legend>'. 201 'Uživatel: '; 202 if($this->System->User->Licence(LICENCE_USER)) $Output .= '<b>'.$this->System->User->Name.'</b><br />'; 203 else $Output .= '<input type="text" name="user" /><br />'; 204 $Output .= T('Message text').': ('.T('You can use').' <a href="http://www.bbcode.org/reference.php">'.T('BB code').'</a>)<br/>'. 205 '<textarea onkeydown="ResizeTextArea(this)" name="text" cols="80"></textarea> <br/>'. 206 '<input type="hidden" name="a" value="add2"/>'. 207 '<input type="submit" value="'.T('Send').'" /><br /></fieldset>'. 208 '</form>'; 209 } else $Output .= ShowMessage(T('You have to be registered for adding message.'), MESSAGE_CRITICAL); 210 return($Output); 211 } 212 213 function ShowAddFormThread() 214 { 215 $Output = ''; 216 if($this->System->User->Licence(LICENCE_USER)) 217 { 218 $Output .= '<form action="?" method="post">'. 219 '<fieldset><legend>'.T('New thread').'</legend>'. 220 'Uživatel: '; 221 if($this->System->User->Licence(LICENCE_USER)) $Output .= '<b>'.$this->System->User->Name.'</b><br />'; 222 else $Output .= '<input type="text" name="user" /><br />'; 223 $Output .= T('Name of thread').': <br />'. 224 '<textarea onkeydown="ResizeTextArea(this)" name="text" rows="1" cols="30"></textarea> <br/>'. 225 '<input type="hidden" name="a" value="add2"/>'. 226 '<input type="submit" value="'.T('Send').'" /><br /></fieldset>'. 227 '</form>'; 228 } else $Output .= ShowMessage(T('You have to be registered for adding message.'), MESSAGE_CRITICAL); 229 return($Output); 230 } 231 232 function AddFinish($Table = 'ForumText') 233 { 234 $Output = ''; 235 if($this->System->User->Licence(LICENCE_USER)) 236 { 237 if(array_key_exists('text', $_POST)) 238 { 239 $Text = $_POST['text']; 240 if(trim($Text) == '') $Output .= ShowMessage('Nelze vložit prázdnou zprávu.', MESSAGE_WARNING); 241 else 242 { 243 // Protection against mutiple post of same message 244 244 $Thread = ''; 245 if ($Table == 'ForumText') $Thread = 'AND `Thread` = '.$_GET['Thread']; 246 $DbResult = $this->System->Database->query('SELECT `Text` FROM `'.$Table.'` WHERE 1 '.$Thread.' AND (`User` = "'. 247 248 249 250 251 252 253 254 255 256 257 258 259 260 245 if ($Table == 'ForumText') $Thread = 'AND `Thread` = '.$_GET['Thread']; 246 $DbResult = $this->System->Database->query('SELECT `Text` FROM `'.$Table.'` WHERE 1 '.$Thread.' AND (`User` = "'. 247 $this->System->User->Id.'") ORDER BY `Date` DESC LIMIT 1'); 248 if($DbResult->num_rows > 0) 249 { 250 $DbRow = $DbResult->fetch_assoc(); 251 } else $DbRow['Text'] = ''; 252 253 if($DbRow['Text'] == $Text) $Output .= ShowMessage(T('You can\' add same message twice.'), MESSAGE_WARNING); 254 else 255 { 256 if ($Table == 'ForumText') { 257 258 $DbResult = $this->System->Database->query('SELECT * FROM `ForumThread` WHERE ID='.($_GET['Thread']*1).' LIMIT 1'); 259 if($DbResult->num_rows > 0) 260 { 261 261 $this->System->Database->query('INSERT INTO `'.$Table.'` ( `User`, `UserName` , `Text` , `Date` , `IP` , `Thread` ) '. 262 263 262 ' VALUES ('.$this->System->User->Id.', "'.$this->System->User->Name. 263 '", "'.$Text.'", NOW(), "'.GetRemoteAddress().'","'.$_GET['Thread'].'")'); 264 264 } else $Output .= ShowMessage(T('Item not found'), MESSAGE_CRITICAL); 265 265 } else 266 266 $this->System->Database->query('INSERT INTO `'.$Table.'` ( `User`, `UserName` , `Text` , `Date` , `IP`) '. 267 268 269 270 271 272 } else $Output .= ShowMessage(T('You have to specified new message.'), MESSAGE_CRITICAL); 273 274 275 276 } 277 278 279 267 ' VALUES ('.$this->System->User->Id.', "'.$this->System->User->Name. 268 '", "'.$Text.'", NOW(), "'.GetRemoteAddress().'")'); 269 $Output .= ShowMessage(T('Added.')); 270 } 271 } 272 } else $Output .= ShowMessage(T('You have to specified new message.'), MESSAGE_CRITICAL); 273 $Output .= '<br/>'; 274 } else $Output .= ShowMessage(T('You have to be registered for adding message.'), MESSAGE_CRITICAL); 275 return($Output); 276 } 277 278 function ShowRSS() 279 { 280 280 $parser = new HTML_BBCodeParser2(array('filters' => array('Basic','Extended','Images','Links','Lists','Email'))); 281 281 282 282 $Items = array(); 283 284 285 283 $TitleLength = 50; 284 mb_internal_encoding('utf-8'); 285 $DbResult = $this->Database->query('SELECT `Thread`, `ID`, UNIX_TIMESTAMP(`Date`) AS `UnixDate`, '. 286 286 '`User`, `UserName`, `Text`, ( SELECT `Text` FROM `ForumThread` '. 287 287 'WHERE `ID` = `ForumText`.`Thread`) AS `ThreadText` FROM `ForumText` ORDER BY `ID` DESC LIMIT 20'); 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 288 while($DbRow = $DbResult->fetch_assoc()) 289 { 290 $Title = mb_substr($DbRow['Text'], 0, $TitleLength); 291 if(mb_strlen($Title) == $TitleLength) $Title .= '...'; 292 $Items[] = array 293 ( 294 'Title' => $DbRow['ThreadText'].' - '.$DbRow['UserName'].': ', 295 'Link' => 'http://'.$this->System->Config['Web']['Host'].$this->System->Link('/forum/?Thread='.$DbRow['Thread']), 296 'Description' => $parser->qparse($DbRow['Text']), 297 'Time' => $DbRow['UnixDate'], 298 ); 299 } 300 $Output = GenerateRSS(array 301 ( 302 'Title' => $this->System->Config['Web']['Title'].' - '.T('Forum'), 303 'Link' => 'http://'.$this->System->Config['Web']['Host'].$this->System->Link('/forum/'), 304 'Description' => $this->System->Config['Web']['Description'], 305 305 'WebmasterEmail' => $this->System->Config['Web']['AdminEmail'], 306 306 'Items' => $Items, 307 307 )); 308 308 return($Output); 309 309 } 310 310 } -
trunk/Modules/FrontPage/FrontPage.php
r809 r816 28 28 function HandleLoginForm() 29 29 { 30 30 global $Message, $MessageType; 31 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 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 74 global $Message, $MessageType; 75 75 76 77 78 79 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 82 83 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 87 88 89 90 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 96 95 $Count = 40; 96 $Output = '<strong>'.T('Last translated').':</strong>'; 97 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 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 135 136 137 138 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 143 if($_GET['Action'] == 'UnHideWelcome') 144 144 { 145 145 $_COOKIE['HideWelcome'] = 0; 146 146 setcookie('HideWelcome', $_COOKIE['HideWelcome'], time() + 3600 * 24 * 365); 147 148 147 } 148 } 149 149 150 151 152 153 154 155 156 157 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 161 162 163 164 165 166 167 168 169 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 172 171 '<li>Texty lze překládat do dvou jazyků, češtiny a slovenštiny.</li>'. 172 '</ul></div>'.$Action); 173 173 } 174 174 } -
trunk/Modules/Import/Import.php
r756 r816 7 7 class ModuleImport extends AppModule 8 8 { 9 10 11 12 13 14 15 16 17 $this->Dependencies = array(); 18 19 20 21 22 $this->System->RegisterPage('import', 'PageImport'); 23 9 function __construct($System) 10 { 11 parent::__construct($System); 12 $this->Name = 'Import'; 13 $this->Version = '1.0'; 14 $this->Creator = 'Chronos'; 15 $this->License = 'GNU/GPL'; 16 $this->Description = 'Support for import of data.'; 17 $this->Dependencies = array(); 18 } 19 20 function Start() 21 { 22 $this->System->RegisterPage('import', 'PageImport'); 23 } 24 24 } 25 25 26 26 class Import 27 27 { 28 var $Version; 28 var $Version; 29 29 var $Group; 30 30 var $NewItemCount; 31 31 var $System; 32 32 33 33 function __construct($System) 34 34 { 35 35 $this->System = &$System; 36 36 } 37 37 38 38 function SetVersion($Version) 39 39 { 40 40 global $System; 41 41 42 42 $DbResult = $System->Database->query('SELECT * FROM `ClientVersion` WHERE `Version` = "'.$Version.'"'); 43 $this->Version = $DbResult->fetch_assoc(); 44 } 45 43 $this->Version = $DbResult->fetch_assoc(); 44 } 45 46 46 function InsertItem($Value) 47 { 47 { 48 48 $insert = true; 49 49 $Columns = ''; … … 58 58 $Where = ' (`'.$this->Group['PrimaryKeyItem'].'` = "'.$Value[$this->Group['PrimaryKeyItem']].'") AND (`Language`=0) ' ; 59 59 //print_r($Value); 60 61 $DbResultMiddle = $this->System->Database->query('SELECT `VersionEnd`,`VersionStart`, `ID`, `Entry`, '.$Columns.' FROM `'.$this->Group['TablePrefix'].'` WHERE '.$Where.' AND `VersionStart` <= '.$this->Version['BuildNumber'].' AND `VersionEnd` >= '.$this->Version['BuildNumber'].' ORDER BY `VersionEnd` DESC LIMIT 1'); 60 61 $DbResultMiddle = $this->System->Database->query('SELECT `VersionEnd`,`VersionStart`, `ID`, `Entry`, '.$Columns.' FROM `'.$this->Group['TablePrefix'].'` WHERE '.$Where.' AND `VersionStart` <= '.$this->Version['BuildNumber'].' AND `VersionEnd` >= '.$this->Version['BuildNumber'].' ORDER BY `VersionEnd` DESC LIMIT 1'); 62 62 $DbResultBefore = $this->System->Database->query('SELECT `VersionEnd`,`VersionStart`, `ID`, `Entry`, '.$Columns.' FROM `'.$this->Group['TablePrefix'].'` WHERE '.$Where.' AND `VersionEnd` <= '.$this->Version['BuildNumber'].' ORDER BY `VersionEnd` DESC LIMIT 1'); 63 63 $DbResultAfter = $this->System->Database->query('SELECT `VersionEnd`,`VersionStart`, `ID`, `Entry`, '.$Columns.' FROM `'.$this->Group['TablePrefix'].'` WHERE '.$Where.' AND `VersionStart` >= '.$this->Version['BuildNumber'].' ORDER BY `VersionStart` LIMIT 1'); … … 69 69 $DbRowAfter = $DbResultAfter->fetch_assoc(); 70 70 $DbRowBefore = $DbResultBefore->fetch_assoc(); 71 72 if($this->HaveSameText($this->Group, $DbRowBefore, $Value) and ($DbResultBefore->num_rows > 0) ) 71 72 if($this->HaveSameText($this->Group, $DbRowBefore, $Value) and ($DbResultBefore->num_rows > 0) ) 73 73 { 74 74 $insert = false; 75 75 if ($this->Group['Id'] == 1) { 76 76 $set = ' , EndText = "'.$Value['EndText'].'" , ObjectiveText1 = "'.$Value['ObjectiveText1'].'"'.' , ObjectiveText2 = "'.$Value['ObjectiveText2'].'"'.' , ObjectiveText3 = "'.$Value['ObjectiveText3'].'"'.' , ObjectiveText4 = "'.$Value['ObjectiveText4'].'"'; 77 } else $set = ''; 77 } else $set = ''; 78 78 $this->System->Database->query('UPDATE `'.$this->Group['TablePrefix'].'` SET `VersionEnd` = "'.$this->Version['BuildNumber'].'" '.$set.' WHERE `ID`='.$DbRowBefore['ID']); 79 echo('b '); 80 81 } else 82 if($this->HaveSameText($this->Group, $DbRowAfter, $Value) and ($DbResultAfter->num_rows > 0)) 79 echo('b '); 80 81 } else 82 if($this->HaveSameText($this->Group, $DbRowAfter, $Value) and ($DbResultAfter->num_rows > 0)) 83 83 { 84 84 $insert = false; 85 85 if ($this->Group['Id'] == 1) { 86 86 $set = ' , EndText = "'.$Value['EndText'].'" , ObjectiveText1 = "'.$Value['ObjectiveText1'].'"'.' , ObjectiveText2 = "'.$Value['ObjectiveText2'].'"'.' , ObjectiveText3 = "'.$Value['ObjectiveText3'].'"'.' , ObjectiveText4 = "'.$Value['ObjectiveText4'].'"'; 87 } else $set = ''; 87 } else $set = ''; 88 88 $this->System->Database->query('UPDATE `'.$this->Group['TablePrefix'].'` SET `VersionStart` = "'.$this->Version['BuildNumber'].'" '.$set.' WHERE `ID`='.$DbRowAfter['ID']); 89 echo('a '); 90 91 } else 92 { 93 94 if (isset($DbRowAfter['VersionStart'])) { 89 echo('a '); 90 91 } else 92 { 93 94 if (isset($DbRowAfter['VersionStart'])) { 95 95 if ($DbRowAfter['VersionStart'] <= $this->Version['BuildNumber']) { 96 96 echo('Allready imported '.$DbRowBefore['Entry'].' '); … … 103 103 $inserted = false; 104 104 } 105 } 106 105 } 106 107 107 //if [DEPRECATED] do not import 108 foreach($this->Group['Items'] as $GroupItem) { 108 foreach($this->Group['Items'] as $GroupItem) { 109 109 if (false !== strpos($Value[$GroupItem['Column']],'[DEPRECATED')) { 110 110 echo('d '.$DbRowBefore['Entry'].' '); 111 111 $insert = false; 112 } 113 } 112 } 113 } 114 114 115 115 if ($insert) { 116 116 $insert = false; 117 117 foreach($this->Group['Items'] as $GroupItem) 118 { 118 { 119 119 if ($Value[$GroupItem['Column']] <> '') $insert = true; 120 120 } 121 121 } 122 122 123 123 if (isset($DbRowMiddle['Entry'])) $insert = false; 124 124 if (isset($DbRowAfter['Entry'])) $Value['Entry'] = $DbRowAfter['Entry']; 125 125 if (isset($DbRowBefore['Entry'])) $Value['Entry'] = $DbRowBefore['Entry']; 126 126 127 if ($insert) 128 { 129 127 if ($insert) 128 { 129 130 130 $Columns = '`Entry`, `Language`, `VersionStart`, `VersionEnd`'; 131 131 $Values = $Value['Entry'].', 0, '.$this->Version['BuildNumber'].', '.$this->Version['BuildNumber']; 132 foreach($this->Group['Items'] as $GroupItem) 133 { 132 foreach($this->Group['Items'] as $GroupItem) 133 { 134 134 $Columns .= ', `'.$GroupItem['Column'].'`'; 135 135 $Values .= ', "'.$Value[$GroupItem['Column']].'"'; 136 136 } 137 137 $this->System->Database->query('INSERT `'.$this->Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')'); 138 138 139 139 echo ' 140 '.$Value['Entry'].' = '.$DbRowBefore['VersionStart'].'.'.$DbRowBefore['VersionEnd'].'< '.$this->Version['BuildNumber'].' <'.$DbRowAfter['VersionStart'].'.'.$DbRowAfter['VersionEnd'].'... '.$DbRowMiddle['VersionStart'].' '.$DbRowMiddle['VersionEnd'].' 140 '.$Value['Entry'].' = '.$DbRowBefore['VersionStart'].'.'.$DbRowBefore['VersionEnd'].'< '.$this->Version['BuildNumber'].' <'.$DbRowAfter['VersionStart'].'.'.$DbRowAfter['VersionEnd'].'... '.$DbRowMiddle['VersionStart'].' '.$DbRowMiddle['VersionEnd'].' 141 141 '; 142 143 if (false !== strpos($Values,'[DEPRECATED')) 142 143 if (false !== strpos($Values,'[DEPRECATED')) 144 144 echo $Values; 145 145 146 146 echo('# '); 147 147 $InsertId = $this->System->Database->insert_id; 148 148 $this->System->ModuleManager->Modules['Log']->WriteLog('Text <a href="form.php?group='.$this->Group['Id'].'&ID='.$InsertId.'">'.$InsertId.'</a> ('.$Value['Entry'].') ze skupiny '.$this->Group['Name'].' byl v nové verzi '.$this->Version['Version'].' změněn.', LOG_TYPE_IMPORT); 149 149 } 150 } 151 } else 150 } 151 } else 152 152 { 153 153 // Insert new text … … 162 162 $DbRow = $DbResult->fetch_row(); 163 163 $Value['Entry'] += $DbRow[0]; 164 } 164 } 165 165 } 166 166 $Columns = '`Entry`, `Language`, `VersionStart`, `VersionEnd`'; … … 168 168 $insert = false; 169 169 foreach($this->Group['Items'] as $GroupItem) 170 { 170 { 171 171 $Columns .= ', `'.$GroupItem['Column'].'`'; 172 172 $Values .= ', "'.$Value[$GroupItem['Column']].'"'; … … 182 182 } 183 183 } 184 184 185 185 function ImportLUA() 186 186 { 187 187 global $TranslationTree, $PatchVersion; 188 188 $Output = 'Načítání textů z LUA souboru...'; 189 189 190 190 if(($this->Group['LuaFileName'] != '') and ($this->Group['TablePrefix'] != '')) 191 191 { 192 192 193 $Output .= '<br />'.$this->Group['Name'].'<br />'; 193 $Output .= '<br />'.$this->Group['Name'].'<br />'; 194 194 // if($this->Group['LastVersion'] < $this->Version['BuildNumber'] + 1) 195 195 { 196 196 $File = new FileStream(); 197 197 198 198 $File->OpenFile(dirname(__FILE__).'/../../source/'.$this->Version['Version'].'/lua/'.$this->Group['LuaFileName'].'.lua'); 199 199 $this->NewItemCount = 0; … … 215 215 $Value['Text'] = str_replace('\n', "\n", $Value['Text']); 216 216 $Value['Text'] = addslashes(stripslashes($Value['Text'])); 217 $Line = trim(substr($Line, strpos($TempLine, '"') + 1)); // Skip closing quote and semicolon 218 } else 217 $Line = trim(substr($Line, strpos($TempLine, '"') + 1)); // Skip closing quote and semicolon 218 } else 219 219 { 220 220 // Nonstring value … … 224 224 $Value['Comment'] = addslashes(stripslashes(substr($Line, 3))); // Skip " --" 225 225 //print_r($Value); 226 226 227 227 $this->InsertItem($Value); 228 }; 228 }; 229 229 $Count++; 230 230 } … … 237 237 return ($Output); 238 238 } 239 239 240 240 function UpdateTranslated() 241 241 { 242 242 global $TranslationTree, $PatchVersion, $Config; 243 243 244 244 $Output = '<br /><br />Začínám se synchronizací VersionEnd u přeložených textů<br />'; 245 foreach($TranslationTree as $Group) 246 { 247 $Output .= '<br />'.$Group['Name'].' '; 248 $do = true; 249 while($do) 245 foreach($TranslationTree as $Group) 246 { 247 $Output .= '<br />'.$Group['Name'].' '; 248 $do = true; 249 while($do) 250 250 { 251 251 $DbResult = $this->System->Database->query('SELECT `gs_tran`.`ID`, '. 252 253 254 255 256 257 258 259 260 while($DbRow = $DbResult->fetch_assoc()) 261 { 252 '`gs_tran`.`VersionEnd` AS `VersionEnd_tran`, '. 253 '`gs_tran`.`VersionStart` AS `VersionStart_tran`, '. 254 '`gs_orig`.`VersionEnd` AS `VersionEnd_orig`, '. 255 '`gs_orig`.`VersionStart` AS `VersionStart_orig` FROM `'. 256 $Group['TablePrefix'].'` AS `gs_tran` JOIN `'.$Group['TablePrefix']. 257 '` AS `gs_orig` ON `gs_orig`.`ID` = `gs_tran`.`Take` WHERE '. 258 '`gs_tran`.`VersionEnd` <> `gs_orig`.`VersionEnd` OR `gs_tran`.`VersionStart` <> `gs_orig`.`VersionStart`'); 259 $do = ($DbResult->num_rows > 0); 260 while($DbRow = $DbResult->fetch_assoc()) 261 { 262 262 echo '`'; 263 263 $this->System->Database->query('UPDATE `'.$Group['TablePrefix'].'` SET `VersionEnd` = '.$DbRow['VersionEnd_orig'].', `VersionStart` = '.$DbRow['VersionStart_orig'].' WHERE `ID` = '.$DbRow['ID']); 264 $Output .= '. '; 265 } 266 } 264 $Output .= '. '; 265 } 266 } 267 267 $Output .= '<strong>Dokončeno.</strong>'; 268 268 } 269 269 return($Output); 270 270 } 271 271 272 272 function HaveSameText($Group, $DbRow2, $Value) 273 273 { 274 274 $result = true; 275 foreach($Group['Items'] as $GroupItem) 276 { 275 foreach($Group['Items'] as $GroupItem) 276 { 277 277 $old = $DbRow2[$GroupItem['Column']]; 278 278 $old = str_replace(chr(10), '', $old); … … 291 291 $old = strtolower($old); 292 292 $old = str_replace('$b', '', $old); 293 294 if ($this->Group['Id'] == 1) 293 294 if ($this->Group['Id'] == 1) 295 295 while ($part = substr($old, strpos($old, '<'), strpos($old, '>')-strpos($old, '<'))) 296 if ($part <> '') { 296 if ($part <> '') { 297 297 $old = str_replace($part.'>', '', $old); 298 298 } 299 299 300 300 if (($GroupItem['MangosColumn'] <> '') and ($Group['MangosDatabase'] == 'mangos')) 301 301 $new = $Value[$GroupItem['MangosColumn']]; 302 302 else $new = $Value[$GroupItem['Column']]; 303 303 304 304 $new = str_replace(chr(10), '', $new); 305 305 $new = str_replace(chr(13), '', $new); … … 318 318 $new = str_replace('$b', '', $new); 319 319 320 if ($this->Group['Id'] == 1) 320 if ($this->Group['Id'] == 1) 321 321 while ($part = substr($new, strpos($new, '<'), strpos($new, '>')-strpos($new, '<'))) 322 if ($part <> '') { 322 if ($part <> '') { 323 323 $new = str_replace($part.'>', '', $new); 324 324 } 325 325 326 326 if(($old == 'null') or ($old == 'NULL')) $old = ''; 327 327 if(($new == 'null') or ($new == 'NULL')) $new = ''; 328 329 if(($new <> '') and ($old <> $new) and ($GroupItem['Column'] <> 'Comment')) 328 329 if(($new <> '') and ($old <> $new) and ($GroupItem['Column'] <> 'Comment')) 330 330 { 331 331 // echo $old.'X'.$new; 332 if ( ($GroupItem['Column'] <> 'EndText') 333 and ($GroupItem['Column'] <> 'ObjectiveText1') 334 and ($GroupItem['Column'] <> 'ObjectiveText2') 335 and ($GroupItem['Column'] <> 'ObjectiveText3') 336 and ($GroupItem['Column'] <> 'ObjectiveText4') ) 332 if ( ($GroupItem['Column'] <> 'EndText') 333 and ($GroupItem['Column'] <> 'ObjectiveText1') 334 and ($GroupItem['Column'] <> 'ObjectiveText2') 335 and ($GroupItem['Column'] <> 'ObjectiveText3') 336 and ($GroupItem['Column'] <> 'ObjectiveText4') ) 337 337 $result = false; 338 338 } 339 339 } 340 340 341 341 return($result); 342 342 } 343 343 344 344 function ImportDBC() 345 345 { 346 346 global $System, $TranslationTree, $Config; 347 347 348 348 $Output = 'Načítání textů z DBC souboru...'; 349 349 if(($this->Group['DBCFileName'] != '') and ($this->Group['TablePrefix'] != '')) 350 350 { 351 $Output .= '<br />'.$this->Group['Name'].'<br />'; 351 $Output .= '<br />'.$this->Group['Name'].'<br />'; 352 352 353 353 // Load string column index list 354 $DbResult = $System->Database->query('SELECT * FROM `GroupItem` JOIN `GroupItemDBC` ON `GroupItem`.`Id` = `GroupItemDBC`.`GroupItem` AND `GroupItemDBC`.`ClientVersion` = '.$this->Version['Id'].' WHERE `GroupItem`.`Group` = '.$this->Group['Id']); 355 354 $DbResult = $System->Database->query('SELECT * FROM `GroupItem` JOIN `GroupItemDBC` ON `GroupItem`.`Id` = `GroupItemDBC`.`GroupItem` AND `GroupItemDBC`.`ClientVersion` = '.$this->Version['Id'].' WHERE `GroupItem`.`Group` = '.$this->Group['Id']); 355 356 356 $ColumnIndexes = array(); 357 357 $ColumnFormat = array(); … … 361 361 $ColumnIndexes[$DbRow['GroupItem']] = $DbRow['ColumnIndex']; 362 362 } 363 363 364 364 $DBCFile = new DBCFile(); 365 365 $DBCFile->OpenFile(dirname(__FILE__).'/../../source/'.$this->Version['Version'].'/dbc/'.$this->Group['DBCFileName'].'.dbc', $ColumnFormat); 366 366 $ItemCount = $DBCFile->GetRecordCount(); 367 367 $this->NewItemCount = 0; 368 $Count = 0; 369 368 $Count = 0; 369 370 370 for($I = 0; $I < $ItemCount; $I++) 371 371 { … … 373 373 if(array_key_exists($GroupItem['Id'], $ColumnIndexes)) 374 374 { 375 $Value[$GroupItem['Column']] = addslashes($DBCFile->GetString($I, $ColumnIndexes[$GroupItem['Id']])); 376 } 377 375 $Value[$GroupItem['Column']] = addslashes($DBCFile->GetString($I, $ColumnIndexes[$GroupItem['Id']])); 376 } 377 378 378 // Get multicolumn value 379 379 $Columns = explode(',', $this->Group['DBCIndex']); … … 381 381 foreach($Columns as $Column) 382 382 $ColumnValue .= '_'.$DBCFile->GetUint($I, $Column); 383 $ColumnValue = substr($ColumnValue, 1); 384 $Value[$this->Group['PrimaryKeyItem']] = $ColumnValue; 383 $ColumnValue = substr($ColumnValue, 1); 384 $Value[$this->Group['PrimaryKeyItem']] = $ColumnValue; 385 385 $this->InsertItem($Value); 386 386 $Count++; 387 } 387 } 388 388 $Output .= '<br />Celkem: '.$Count.' Nových: '.$this->NewItemCount.'<br />'; 389 389 $this->UpdateLastVersion(); … … 396 396 { 397 397 global $TranslationTree; 398 398 399 399 $this->Group = $TranslationTree[$GroupId]; 400 400 401 401 if($this->Group['SourceType'] == 'dbc') $Output = $this->ImportDBC(); 402 402 else if($this->Group['SourceType'] == 'sql') $Output = $this->ImportSQL(); … … 406 406 return($Output); 407 407 } 408 408 409 409 function ImportSQL() 410 410 { 411 411 global $TranslationTree, $PatchVersion; 412 412 413 413 $Output= ''; 414 414 $File = new FileStream(); … … 422 422 $Line = $File->ReadLine(); 423 423 // Struktura 424 if(strpos($Line, 'CREATE TABLE `'.$this->Group['MangosTable'].'`') !== false) 424 if(strpos($Line, 'CREATE TABLE `'.$this->Group['MangosTable'].'`') !== false) 425 425 { 426 426 $Line = ''; … … 428 428 $i = 0; 429 429 } 430 if((strpos($Line, ';') !== false) and ($folow_structure == true)) 430 if((strpos($Line, ';') !== false) and ($folow_structure == true)) 431 431 { 432 432 $folow_structure = false; … … 443 443 $i++; 444 444 } 445 445 446 446 //data 447 447 if((strpos($Line, 'INSERT INTO `'.$this->Group['MangosTable'].'`') !== false) and (isset($structure))) 448 { 448 { 449 449 while ((strpos($Line, ');') === false) or ($File->EOF())) 450 450 $Line = $Line.$File->ReadLine(); 451 451 $Line = str_replace("),\n(", '),(', $Line); 452 452 453 453 $Line = substr($Line, strpos($Line, '(') + 1); 454 454 $Line = substr($Line, 0, strpos($Line, ');')); 455 455 $LineParts = explode('),(', $Line); 456 456 457 457 unset($Line); 458 458 459 459 $value_buff = ''; 460 460 $Value = ''; 461 461 foreach($LineParts as $LinePart) 462 462 { 463 463 464 464 unset($Value, $value_buff); 465 465 foreach($structure as $i => $column) … … 469 469 $value_buff = substr($LinePart, 0, strpos($LinePart, ',')); 470 470 $LinePart = substr($LinePart, strlen($value_buff) + 1); 471 } else 471 } else 472 472 { 473 473 $LinePart = substr($LinePart, 1); 474 474 $value_buff = substr($LinePart, 0, strpos($LinePart, "'")); 475 while(substr($value_buff, strlen($value_buff) - 1, 1) == "\\") 475 while(substr($value_buff, strlen($value_buff) - 1, 1) == "\\") 476 476 { 477 477 $str = substr($LinePart, strlen($value_buff)); … … 479 479 $value_buff = $value_buff.$str2; 480 480 $str = substr($str, strlen($str2)); 481 } 481 } 482 482 $LinePart = substr($LinePart, strlen($value_buff) + 2); 483 } 483 } 484 484 if(($value_buff != 'null') and ($value_buff != 'NULL')) 485 485 { 486 486 $str = ''; 487 while(substr($value_buff, strlen($value_buff) - 1,1) == " ") 487 while(substr($value_buff, strlen($value_buff) - 1,1) == " ") 488 488 { 489 489 $value_buff = substr($value_buff, 0, strlen($value_buff) - 1); … … 491 491 } 492 492 $str2 = ''; 493 while(substr($value_buff, 0, 1) == ' ') 493 while(substr($value_buff, 0, 1) == ' ') 494 494 { 495 495 $value_buff = substr($value_buff, 1, strlen($value_buff) - 1); … … 497 497 } 498 498 $Value[$column] = $str2.trim($value_buff).$str; 499 } else 500 { 499 } else 500 { 501 501 $Value[$column] = ''; 502 502 } … … 513 513 } 514 514 } 515 515 516 516 // Get multicolumn value 517 517 $Columns = explode(',', $this->Group['MangosTableIndex']); … … 519 519 foreach($Columns as $Column) 520 520 $ColumnValue .= '_'.$Value[$Column]; 521 $ColumnValue = substr($ColumnValue, 1); 521 $ColumnValue = substr($ColumnValue, 1); 522 522 $Value[$this->Group['PrimaryKeyItem']] = $ColumnValue; 523 523 $this->InsertItem($Value); 524 524 $Count++; 525 525 } 526 } 526 } 527 527 } 528 528 $Output = '<br />Celkem: '.$Count.' Nových: '.$this->NewItemCount.'<br />'; … … 530 530 return($Output); 531 531 } 532 532 533 533 function UpdateLastVersion() { 534 534 $DbResult = $this->System->Database->query('SELECT * FROM `Group` WHERE `Id`='.$this->Group['Id']); 535 $Version = $DbResult->fetch_assoc(); 535 $Version = $DbResult->fetch_assoc(); 536 536 if ($Version['LastVersion'] < $this->Version['BuildNumber']) 537 537 $this->System->Database->query('UPDATE `Group` SET `LastVersion` = "'.$this->Version['BuildNumber'].'", `LastImport` = NOW() WHERE `Id`='.$this->Group['Id']); -
trunk/Modules/Import/Manage.php
r636 r816 26 26 { 27 27 global $System; 28 29 if(array_key_exists('id', $_GET)) 28 29 if(array_key_exists('id', $_GET)) 30 30 { 31 31 $Output = '<div style="font-size: xx-small;">'; 32 32 33 33 $GroupId = (int)$_GET['id']; 34 34 $Import = new Import($System); 35 35 $Import->SetVersion($System->Config['Web']['GameVersion']); 36 36 $Output .= $Import->ImportGroup($GroupId); 37 37 38 38 $this->System->ModuleManager->Modules['Log']->WriteLog('Plnění databáze', LOG_TYPE_MODERATOR); 39 39 $Output .= '</div>'; … … 45 45 { 46 46 global $TranslationTree, $System; 47 48 $Output = '</div><div><strong>Import zdrojů:</strong></div>'. 47 48 $Output = '</div><div><strong>Import zdrojů:</strong></div>'. 49 49 '<div><a href="?action=instructions">Instrukce pro přípravu zdrojových souborů</a></div>'. 50 50 '<div><a href="?action=update_translated">Zaktualizovat verze přeložených</a></div><br/>'. … … 52 52 $DbResult = $System->Database->query('SELECT COUNT(*) FROM `Group`'); 53 53 $DbRow = $DbResult->fetch_row(); 54 $PageList = GetPageList($DbRow[0]); 54 $PageList = GetPageList($DbRow[0]); 55 55 $Output .= '<h3>Seznam překladových skupin</h3>'; 56 56 $Output .= $PageList['Output']; 57 57 58 58 $Output .= '<table class="BaseTable">'; 59 59 $TableColumns = array( 60 array('Name' => 'Name', 'Title' => 'Jméno'), 61 array('Name' => 'SourceType', 'Title' => 'Typ zdroje'), 62 array('Name' => 'SourceName', 'Title' => 'Jméno zdroje'), 63 array('Name' => 'LastImport', 'Title' => 'Datum'), 60 array('Name' => 'Name', 'Title' => 'Jméno'), 61 array('Name' => 'SourceType', 'Title' => 'Typ zdroje'), 62 array('Name' => 'SourceName', 'Title' => 'Jméno zdroje'), 63 array('Name' => 'LastImport', 'Title' => 'Datum'), 64 64 array('Name' => 'LastVersion', 'Title' => 'Verze'), 65 array('Name' => '', 'Title' => 'Akce'), 65 array('Name' => '', 'Title' => 'Akce'), 66 66 ); 67 67 … … 70 70 71 71 $DbResult = $System->Database->query('SELECT * FROM `Group`'.$Order['SQL'].$PageList['SQLLimit']); 72 while($Group = $DbResult->fetch_assoc()) 72 while($Group = $DbResult->fetch_assoc()) 73 73 { 74 74 $Output .= '<tr><td>'.$Group['Name'].'</td><td>'.$Group['SourceType'].'</td><td>'; … … 85 85 { 86 86 global $System; 87 87 88 88 $Output = '<div style="font-size: xx-small;">'; 89 89 $Import = new Import($System); … … 93 93 } 94 94 95 96 97 95 function Show() 96 { 97 $this->Title = T('Import'); 98 98 $Output = ''; 99 99 if($this->System->User->Licence(LICENCE_ADMIN)) … … 104 104 else if($_GET['action'] == 'importgroup') $Output .= $this->ShowImportGroup(); 105 105 else if($_GET['action'] == 'update_translated') $Output .= $this->UpdateTranslated(); 106 else $Output .= $this->ShowMenu(); 106 else $Output .= $this->ShowMenu(); 107 107 } else $Output .= $this->ShowMenu(); 108 } else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 108 } else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 109 109 return($Output); 110 110 } 111 111 } -
trunk/Modules/Import/cmd.php
r805 r816 7 7 $System = new System(); 8 8 $System->DoNotShowPage = true; 9 9 $System->Run(); 10 10 $Import = new Import($System); 11 11 12 12 $Output = ''; 13 13 14 if(defined('STDIN') == false) 14 if(defined('STDIN') == false) 15 15 { 16 16 $Output = T('Access denied'); 17 17 exit($Output); 18 } 18 } 19 19 20 20 foreach($_SERVER['argv'] as $parameter) … … 32 32 { 33 33 $Output .= ' 34 34 35 35 1. Pripojíme se pres SSH na server (wowpreklad.zdechov.net) napríklad pres program putty.exe nebo terminál v linuxu. 36 2. Nejprve je potreba získat zdrojová data. Není zapotrebí mít všechny typy textu. 36 2. Nejprve je potreba získat zdrojová data. Není zapotrebí mít všechny typy textu. 37 37 a) SQL databázi UDB seženeme na fóru: http://udbforums.kicks-ass.net/index.php?board=5.0 , sobor rozbalíme a uložíme do adresáre "wowpreklad/source/císlo_verze/sql/" 38 38 b) DBC a LUA soubory exportujeme přímo ze hry z souboru "World of Warcraft\Data\enGB\locale-enGB.MPQ" a všechny soubory "wow-update-enGB-<buildnumber>.MPQ". Tyto soubory je nutné otevřít najednou v merge modu programu "MPQEditor.exe", který je ke stažení v adresáři "wowpreklad/download". DBC soubory jsou v MPQ souboru uloženy ve složce "DBFilesClient". Lua ve složce "Interface". Tyto soubory zkopírujte do složky "wowpreklad/source/císlo_verze/dbc/" nebo "lua" … … 41 41 5. Až máme všechno pripraveno spustíme v konzoli script príkazem "php wowpreklad/import/cmd.php" kde jsou popsané možnosti paremetu s kterýma se tento script spoucí pro ruzné importy. 42 42 6. Po provedení importu je potreba nekolikrát spustit script na aktualizaci verze u prekladu. Je potreba ho prováde opakovane dokud nezmizí tecky oznacující že byly provedeny zmeny. 43 44 43 44 45 45 Parametry: 46 46 '; … … 48 48 $Output .= ' version=<version> - nastaví verzi importu default: '.$System->Config['Web']['GameVersion'].'<br /><br />'; 49 49 $Output .= ' <id_import_group>:'; 50 foreach($TranslationTree as $Group) 50 foreach($TranslationTree as $Group) 51 51 { 52 $Output .= '<br /> '.$Group['Id'].' '; 53 $Output .= ' '.$Group['Name'].' '; 52 $Output .= '<br /> '.$Group['Id'].' '; 53 $Output .= ' '.$Group['Name'].' '; 54 54 } 55 55 … … 61 61 else 62 62 $Import->SetVersion($System->Config['Web']['GameVersion']); 63 63 64 64 $Output .= $Import->ImportGroup($_GET['id']); //$Config['Web']['GameVersion'] 65 65 // $Import->UpdateTranslated(); … … 72 72 $Output .= '<br />'. 73 73 'aktuálně nastavená importovávaná verze: '.$_GET['version'].'<br />'; 74 else 74 else 75 75 $Output .= '<br />'. 76 76 'aktuálně nastavená importovávaná verze: '.$Config['Web']['GameVersion'].'<br />'; … … 79 79 $Output = str_replace('<br />',' 80 80 ',$Output); 81 echo($Output); 82 //ShowFooter(); 81 echo($Output); 82 //ShowFooter(); -
trunk/Modules/Log/Log.php
r808 r816 3 3 class ModuleLog extends AppModule 4 4 { 5 6 5 var $Excludes; 6 7 7 function __construct($System) 8 8 { … … 14 14 $this->Description = 'Log various application events'; 15 15 $this->Dependencies = array('Error', 'News'); 16 16 17 17 $this->Excludes = array(); 18 18 } 19 19 20 20 function Start() 21 21 { 22 23 24 $this->System->ModuleManager->Modules['News']->RegisterRSS(array('Title' => T('Logs'),25 26 } 27 22 $this->System->RegisterPage('log.php', 'PageLog'); 23 $this->System->ModuleManager->Modules['Error']->OnError[] = array($this, 'DoAddItem'); 24 $this->System->ModuleManager->Modules['News']->RegisterRSS(array('Title' => T('Logs'), 25 'Channel' => 'log', 'Callback' => array('PageLog', 'ShowRSS'), 'Permission' => LICENCE_ADMIN)); 26 } 27 28 28 function DoAddItem($Message) 29 29 { 30 30 $this->WriteLog($Message, LOG_TYPE_ERROR); 31 31 } 32 32 33 33 function WriteLog($Text, $Type) 34 34 { 35 if(isset($this->System->User) and !is_null($this->System->User->Id))36 37 38 39 40 41 35 if(isset($this->System->User) and !is_null($this->System->User->Id)) 36 $UserId = $this->System->User->Id; 37 else $UserId = 'NULL'; 38 $Query = 'INSERT INTO `Log` ( `User` , `Type` , `Text` , `Date` , `IP`, `URL` ) '. 39 'VALUES ('.$UserId.', '.$Type.', "'.addslashes($Text).'", NOW(), "'. 40 GetRemoteAddress().'", "'.GetRequestURI().'")'; 41 $this->System->Database->query($Query); 42 42 } 43 43 } … … 55 55 define('LOG_TYPE_PAGE_NOT_FOUND', 15); 56 56 57 // TODO: Change global function to module class local method 57 // TODO: Change global function to module class local method 58 58 function WriteLog($Text, $Type) 59 59 { 60 61 62 63 64 65 60 global $System, $User; 61 62 if(isset($User) and !is_null($User->Id)) $UserId = $User->Id; 63 else $UserId = 'NULL'; 64 $Query = 'INSERT INTO `Log` ( `User` , `Type` , `Text` , `Date` , `IP`, `URL` ) '. 65 'VALUES ('.$UserId.', '.$Type.', "'.addslashes($Text).'", NOW(), "'. 66 66 GetRemoteAddress().'", "'.GetRequestURI().'")'; 67 67 $System->Database->query($Query); 68 68 } 69 69 … … 72 72 function ShowRSS() 73 73 { 74 75 74 $this->RawPage = true; 75 $Output = ''; 76 76 $Items = array(); 77 if(array_key_exists('type', $_GET)) $Where = ' WHERE `Type` = "'.($_GET['type'] * 1).'"'; 77 if(array_key_exists('type', $_GET)) $Where = ' WHERE `Type` = "'.($_GET['type'] * 1).'"'; 78 78 else $Where = ''; 79 79 $sql = 'SELECT *, UNIX_TIMESTAMP(`Date`) AS `TimeCreate`, (SELECT `User`.`Name` FROM `User` WHERE `User`.`ID` = `Log`.`User`) AS `UserName`, `Date` FROM `Log`'. 80 80 $Where.' ORDER BY `Date` DESC LIMIT 100'; 81 81 $DbResult = $this->System->Database->query($sql); 82 while($Line = $DbResult->fetch_assoc()) 82 while($Line = $DbResult->fetch_assoc()) 83 83 { 84 84 $DbResult2 = $this->System->Database->query('SELECT * FROM `LogType` WHERE `Id`='.$Line['Type']); 85 85 $LogType = $DbResult2->fetch_assoc(); 86 86 87 87 if($Line['Type'] == LOG_TYPE_ERROR) $Line['Text'] = htmlspecialchars($Line['Text']); 88 88 $Line['Text'] = str_replace("\n", '<br>', $Line['Text']); 89 89 90 90 $Items[] = array 91 91 ( … … 96 96 'Time' => $Line['TimeCreate'], 97 97 ); 98 } 98 } 99 99 100 100 $Output .= GenerateRSS(array … … 108 108 return($Output); 109 109 } 110 110 111 111 function Show() 112 112 { 113 114 115 else $Action = ''; 116 117 118 119 } 120 113 if(array_key_exists('a', $_POST)) $Action = $_POST['a']; 114 else if(array_key_exists('a', $_GET)) $Action = $_GET['a']; 115 else $Action = ''; 116 if($Action == 'delerrlog') $Output = $this->DeleteErrorLog(); 117 else $Output = $this->ShowList(); 118 return($Output); 119 } 120 121 121 function ShowList() 122 122 { 123 123 global $TranslationTree; 124 124 125 125 $this->Title = T('System log'); 126 126 $Output = ''; 127 if(array_key_exists('type', $_GET)) $_SESSION['type'] = $_GET['type'] * 1; 127 if(array_key_exists('type', $_GET)) $_SESSION['type'] = $_GET['type'] * 1; 128 128 else if(!array_key_exists('type', $_SESSION)) $_SESSION['type'] = ''; 129 129 130 130 if(array_key_exists('group', $_GET)) $_SESSION['group'] = $_GET['group']; 131 131 132 if($_SESSION['type'] != '') $WhereType = ' (`Type`='.$_SESSION['type'].')'; 132 if($_SESSION['type'] != '') $WhereType = ' (`Type`='.$_SESSION['type'].')'; 133 133 else $WhereType = '1=1'; 134 134 135 135 $RSSChannels = array( 136 136 array('Title' => 'Záznamy změn', 'Channel' => 'log&type='.$_SESSION['type']) 137 137 ); 138 138 139 139 // Show category filter 140 140 if($this->System->User->Licence(LICENCE_MODERATOR)) … … 154 154 $Output .= '<br /><br />'; 155 155 156 if(array_key_exists('type', $_SESSION)) $Where = ' WHERE '.$WhereType; 156 if(array_key_exists('type', $_SESSION)) $Where = ' WHERE '.$WhereType; 157 157 else 158 158 { 159 159 if(array_key_exists('group', $_SESSION)) $Where = ' WHERE `Text` LIKE "%'.$TranslationTree[$_SESSION['group']]['Name'].'%"'; 160 160 else $Where = ''; 161 } 161 } 162 162 //if(($Where != '') and (array_key_exists('group', $_SESSION))) $Where .= ' AND text LIKE "%'.$TranslationTree[$_SESSION['group']]['Name'].'%"'; 163 163 164 164 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Log` '.$Where); 165 165 $DbRow = $DbResult->fetch_row(); 166 $PageList = GetPageList($DbRow[0]); 167 166 $PageList = GetPageList($DbRow[0]); 167 168 168 $Output .= $PageList['Output']; 169 169 170 170 $TableColumns = array( 171 171 array('Name' => 'Date', 'Title' => 'Čas'), 172 172 ); 173 if($_SESSION['type'] == '') $TableColumns[] = 173 if($_SESSION['type'] == '') $TableColumns[] = 174 174 array('Name' => 'LogName', 'Title' => 'Typ'); 175 $TableColumns = array_merge($TableColumns, array( 176 array('Name' => 'Text', 'Title' => 'Text'),177 array('Name' => 'UserName', 'Title' => 'Uživatel'), 178 array('Name' => 'IP', 'Title' => 'Adresa'), 175 $TableColumns = array_merge($TableColumns, array( 176 array('Name' => 'Text', 'Title' => 'Text'), 177 array('Name' => 'UserName', 'Title' => 'Uživatel'), 178 array('Name' => 'IP', 'Title' => 'Adresa'), 179 179 array('Name' => 'URL', 'Title' => 'URL'), 180 180 )); … … 182 182 $Output .= '<table width="98%" class="BaseTable">'. 183 183 $Order['Output']; 184 184 185 185 $sql = 'SELECT *, `LogType`.`Color` AS `LogColor`, `LogType`.`Name` AS `LogName`, '. 186 186 '(SELECT `User`.`Name` FROM `User` WHERE `User`.`ID` = `Log`.`User`) AS `UserName` FROM `Log` LEFT JOIN `LogType` ON `LogType`.`Id`=`Log`.`Type` '.$Where.$Order['SQL'].$PageList['SQLLimit']; 187 187 $DbResult = $this->System->Database->query($sql); 188 while($Line = $DbResult->fetch_assoc()) 189 { 190 188 while($Line = $DbResult->fetch_assoc()) 189 { 190 if($Line['Type'] == LOG_TYPE_ERROR) $Line['Text'] = htmlspecialchars($Line['Text']); 191 191 $Line['Text'] = str_replace("\n", '<br>', $Line['Text']); 192 193 192 $Output .= '<tr><td>'.$Line['Date'].'</td>'; 193 if($_SESSION['type'] == '') $Output .= '<td>'.$Line['LogName'].'</td>'; 194 194 $Output .= '<td><span style="color: '.$Line['LogColor'].'">'.$Line['Text'].'</span></td>'. 195 195 '<td><a href="'.$this->System->Link('/user.php?user='.$Line['User']).'">'.$Line['UserName'].'</a></td>'. 196 196 '<td>'.$Line['IP'].'</td>'. 197 197 '<td>'.$Line['URL'].'</td></tr>'; 198 198 } 199 199 $Output .= '</table>'. … … 203 203 $Output .= '<div>Vymazat: <a href="'.$this->System->Link('/log.php?a=delerrlog&type='.LOG_TYPE_ERROR).'">Chybové záznamy</a> '. 204 204 '<a href="'.$this->System->Link('/log.php?a=delerrlog&type='.LOG_TYPE_PAGE_NOT_FOUND).'">Neznámé stránky</a></div>'; 205 } 205 } 206 206 } else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 207 208 return($Output); 209 } 210 207 208 return($Output); 209 } 210 211 211 function DeleteErrorLog() 212 212 { 213 if($this->System->User->Licence(LICENCE_ADMIN) and214 215 216 217 218 219 220 221 222 223 224 225 213 if($this->System->User->Licence(LICENCE_ADMIN) and 214 (($_GET['type'] == LOG_TYPE_ERROR) or ($_GET['type'] == LOG_TYPE_PAGE_NOT_FOUND))) 215 { 216 $DbResult = $this->System->Database->select('LogType', '*', 'Id='.$_GET['type']); 217 $LogType = $DbResult->fetch_assoc(); 218 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Log` WHERE `Type`='.$_GET['type']); 219 $DbRow = $DbResult->fetch_row(); 220 $this->System->Database->query('DELETE FROM `Log` WHERE `Type`='.$_GET['type']); 221 $this->System->ModuleManager->Modules['Log']->WriteLog('Vymazáno záznamů z '.$LogType['Description'].'.', LOG_TYPE_ADMINISTRATION); 222 $Output = ShowMessage('Smazáno všech '.$DbRow[0].' záznamů z '.$LogType['Description'].'.'); 223 $Output .= $this->ShowList(); 224 return($Output); 225 } else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 226 226 } 227 227 } -
trunk/Modules/News/News.php
r815 r816 20 20 function Start() 21 21 { 22 23 24 25 22 $this->System->RegisterPage('news', 'PageNews'); 23 $this->System->RegisterPage('rss', 'PageRSS'); 24 $this->RegisterRSS(array('Title' => T('News'), 'Channel' => 'news', 25 'Callback' => array('PageNews', 'ShowRSS'), 'Permission' => LICENCE_ANONYMOUS)); 26 26 } 27 27 28 28 function ShowBox() 29 29 { 30 31 32 33 34 35 36 $Output .= '</div>';37 30 $Output = '<strong>'.T('System changes').':</strong><div class="NewsBox">'; 31 $DbResult = $this->Database->query('SELECT `News`.`Time`, `User`.`Name`, `News`.`Text`,`News`.`Title`'. 32 ' FROM `News` JOIN `User` ON `User`.`ID` = `News`.`User` ORDER BY `Time` DESC LIMIT 10'); 33 while($DbRow = $DbResult->fetch_assoc()) 34 $Output .= '<div><strong>'.$DbRow['Title'].' ('.HumanDate($DbRow['Time']).')</strong> <br />'.$DbRow['Text'].' ('.$DbRow['Name'].')</div>'; 35 $Output .= '<a href="'.$this->System->Link('/news/').'">'.T('All news').'</a>'; 36 $Output .= '</div>'; 37 return($Output); 38 38 } 39 39 … … 41 41 { 42 42 $this->RSSChannels[$Channel['Channel']] = $Channel; 43 43 44 44 if(is_null($Pos)) $this->RSSChannelsPos[] = $Channel['Channel']; 45 45 else { … … 52 52 $Output = ''; 53 53 foreach($this->RSSChannels as $Channel) 54 55 56 57 58 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 59 return($Output); 60 60 } … … 63 63 class PageNews extends Page 64 64 { 65 66 67 68 69 70 71 72 73 74 75 65 function Show() 66 { 67 $this->Title = T('News'); 68 if(array_key_exists('a', $_POST)) $Action = $_POST['a']; 69 else if(array_key_exists('a', $_GET)) $Action = $_GET['a']; 70 else $Action = ''; 71 if($Action == 'add2') $Output = $this->SaveNew(); 72 if($Action == 'add') $Output = $this->ShowAddForm(); 73 else $Output = $this->ShowList(); 74 return($Output); 75 } 76 76 77 function ShowList() 78 { 79 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `News`'); 80 $DbRow = $DbResult->fetch_row(); 81 $PageList = GetPageList($DbRow[0]); 82 83 $Output = '<h3>'.T('News').'</h3>'.$PageList['Output']; 84 if($this->System->User->Licence(LICENCE_ADMIN)) 85 $Output .= ' <a href="?a=add">'.T('Add').'</a>'; 86 $Output .= '<div class="shoutbox">'; 87 $DbResult = $this->System->Database->query('SELECT `News`.`Time`, `News`.`Text`, `News`.`Title`, '. 88 '`User`.`Name` AS `User` FROM `News` JOIN `User` ON `User`.`Id`=`News`.`User` ORDER BY `News`.`Time` DESC '.$PageList['SQLLimit']); 89 while($Line = $DbResult->fetch_assoc()) 90 $Output .= '<div><strong>'.$Line['Title'].' ('.HumanDate($Line['Time']).')</strong><br/> '.$Line['Text'].' ('.$Line['User'].')</div>'; 91 $Output .= '</div>'.$PageList['Output']; 92 return($Output); 93 } 77 function ShowList() 78 { 79 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `News`'); 80 $DbRow = $DbResult->fetch_row(); 81 $PageList = GetPageList($DbRow[0]); 94 82 95 function ShowAddForm() 96 { 97 if($this->System->User->Licence(LICENCE_ADMIN)) 98 { 99 $Output = '<form action="?" method="POST">'. 100 T('User').': '.$this->System->User->Name.'('.$this->System->User->Id.')<br/> '. 101 T('Title').': <input type="text" name="title" size="40"/><br/>'. 102 T('Content').': <textarea rows="8" cols="40" onkeydown="ResizeTextArea(this)" class="textedit" id="Text" name="text"></textarea><br/>'. 103 '<input type="hidden" name="a" value="add2"/>'. 104 '<input type="submit" value="'.T('Save').'"/><br/>'. 105 '</form>'; 106 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 107 return($Output); 108 } 109 110 function SaveNew() 111 { 112 if($this->System->User->Licence(LICENCE_ADMIN)) 113 { 114 if(array_key_exists('text', $_POST) and array_key_exists('title', $_POST)) 115 { 116 $querty = 'INSERT INTO `News` (`Title`, `Time` ,`User` ,`Text`) VALUES ( "'.$_POST['title'].'", NOW( ) , '. 117 $this->System->User->Id.', "'.$_POST['text'].'")'; 118 $this->System->Database->query($querty); 119 $Output = ShowMessage(T('News added')); 120 $this->System->ModuleManager->Modules['Log']->WriteLog('Vložena nová aktualita', LOG_TYPE_ADMINISTRATION); 121 $Output .= $this->ShowList(); 122 } else $Output = ShowMessage(T('Data not specified'), MESSAGE_CRITICAL); 123 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 124 return($Output); 125 } 83 $Output = '<h3>'.T('News').'</h3>'.$PageList['Output']; 84 if($this->System->User->Licence(LICENCE_ADMIN)) 85 $Output .= ' <a href="?a=add">'.T('Add').'</a>'; 86 $Output .= '<div class="shoutbox">'; 87 $DbResult = $this->System->Database->query('SELECT `News`.`Time`, `News`.`Text`, `News`.`Title`, '. 88 '`User`.`Name` AS `User` FROM `News` JOIN `User` ON `User`.`Id`=`News`.`User` ORDER BY `News`.`Time` DESC '.$PageList['SQLLimit']); 89 while($Line = $DbResult->fetch_assoc()) 90 $Output .= '<div><strong>'.$Line['Title'].' ('.HumanDate($Line['Time']).')</strong><br/> '.$Line['Text'].' ('.$Line['User'].')</div>'; 91 $Output .= '</div>'.$PageList['Output']; 92 return($Output); 93 } 126 94 127 function ShowRSS() 128 { 129 $Items = array(); 95 function ShowAddForm() 96 { 97 if($this->System->User->Licence(LICENCE_ADMIN)) 98 { 99 $Output = '<form action="?" method="POST">'. 100 T('User').': '.$this->System->User->Name.'('.$this->System->User->Id.')<br/> '. 101 T('Title').': <input type="text" name="title" size="40"/><br/>'. 102 T('Content').': <textarea rows="8" cols="40" onkeydown="ResizeTextArea(this)" class="textedit" id="Text" name="text"></textarea><br/>'. 103 '<input type="hidden" name="a" value="add2"/>'. 104 '<input type="submit" value="'.T('Save').'"/><br/>'. 105 '</form>'; 106 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 107 return($Output); 108 } 109 110 function SaveNew() 111 { 112 if($this->System->User->Licence(LICENCE_ADMIN)) 113 { 114 if(array_key_exists('text', $_POST) and array_key_exists('title', $_POST)) 115 { 116 $querty = 'INSERT INTO `News` (`Title`, `Time` ,`User` ,`Text`) VALUES ( "'.$_POST['title'].'", NOW( ) , '. 117 $this->System->User->Id.', "'.$_POST['text'].'")'; 118 $this->System->Database->query($querty); 119 $Output = ShowMessage(T('News added')); 120 $this->System->ModuleManager->Modules['Log']->WriteLog('Vložena nová aktualita', LOG_TYPE_ADMINISTRATION); 121 $Output .= $this->ShowList(); 122 } else $Output = ShowMessage(T('Data not specified'), MESSAGE_CRITICAL); 123 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 124 return($Output); 125 } 126 127 function ShowRSS() 128 { 129 $Items = array(); 130 130 $DbResult = $this->Database->query('SELECT UNIX_TIMESTAMP(`News`.`Time`) AS `UnixTime`, '. 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 131 '`News`.`Title`, `News`.`Time`, `User`.`Name`, `News`.`Text` '. 132 'FROM `News` JOIN `User` ON `User`.`ID` = `News`.`User` ORDER BY `Time` DESC LIMIT 10'); 133 while($DbRow = $DbResult->fetch_assoc()) 134 { 135 $Items[] = array 136 ( 137 'Title' => $DbRow['Title'], 138 'Link' => 'http://'.$this->System->Config['Web']['Host'].$this->System->Link('/news/'), 139 'Description' => $DbRow['Text'].' ('.$DbRow['Name'].')', 140 'Time' => $DbRow['UnixTime'], 141 ); 142 } 143 $Output = GenerateRSS(array 144 ( 145 'Title' => $this->System->Config['Web']['Title'].' - '.T('System changes'), 146 'Link' => 'http://'.$this->System->Config['Web']['Host'].$this->System->Link('/news/'), 147 'Description' => $this->System->Config['Web']['Description'], 148 'WebmasterEmail' => $this->System->Config['Web']['AdminEmail'], 149 'Items' => $Items, 150 )); 151 return($Output); 152 } 153 153 } -
trunk/Modules/News/RSS.php
r609 r816 3 3 function GenerateRSS($Data) 4 4 { 5 5 global $Config; 6 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 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 29 } 30 30 31 31 class PageRSS extends Page 32 32 { 33 34 { 35 36 37 38 39 40 41 42 43 $Channel = $this->System->ModuleManager->Modules['News']->RSSChannels[$ChannelName]; 44 if($this->System->User->Licence($Channel['Permission']) or 45 46 47 48 49 50 51 52 53 33 function Show() 34 { 35 $this->RawPage = true; 36 37 if(array_key_exists('channel', $_GET)) $ChannelName = $_GET['channel']; 38 else $ChannelName = ''; 39 if(array_key_exists('token', $_GET)) $Token = $_GET['token']; 40 else $Token = ''; 41 if(array_key_exists($ChannelName, $this->System->ModuleManager->Modules['News']->RSSChannels)) 42 { 43 $Channel = $this->System->ModuleManager->Modules['News']->RSSChannels[$ChannelName]; 44 if($this->System->User->Licence($Channel['Permission']) or 45 $this->System->User->CheckToken($Channel['Permission'], $Token)) 46 { 47 if(is_string($Channel['Callback'][0])) 48 { 49 $Class = new $Channel['Callback'][0]($this->System); 50 $Output = $Class->$Channel['Callback'][1](); 51 } else $Output = call_user_func($Channel['Callback']); 52 } else $Output = T('Access denied'); 53 } else $Output = 'Nezadán žádný kanál'; 54 54 return($Output); 55 55 } 56 56 } -
trunk/Modules/Redirection/Redirection.php
r812 r816 17 17 function Start() 18 18 { 19 19 $this->System->OnPageNotFound = array($this, 'ShowRedirect'); 20 20 } 21 21 22 22 function Redirect($Location) 23 23 { 24 24 Header($_SERVER['SERVER_PROTOCOL'].' 301 Moved Permanently'); 25 25 Header('Location: '.$Location); 26 26 return('<h3 align="center">Požadovaná stránka byla přesunuta do nového umístění.</h3>'); … … 32 32 if(count($this->System->PathItems) > 0) 33 33 { 34 34 if($this->System->PathItems[0] == 'team.php') $Output = $this->Redirect($this->System->Link('/team/')); 35 35 if($this->System->PathItems[0] == 'version.php') $Output = $this->Redirect($this->System->Link('/client-version/')); 36 36 if($this->System->PathItems[0] == 'phpBB3') $Output = $this->Redirect($this->System->Link('/forum/')); -
trunk/Modules/Referrer/Referrer.php
r811 r816 3 3 class ModuleReferrer extends AppModule 4 4 { 5 5 var $Excludes; 6 6 7 7 function __construct($System) … … 20 20 function Start() 21 21 { 22 23 24 25 26 27 28 29 22 $this->Log(); 23 $this->System->RegisterPage('referrer', 'PageReferrer'); 24 $this->System->RegisterMenuItem(array( 25 'Title' => T('Promotion'), 26 'Hint' => 'Informace k propagaci tohoto projektu', 27 'Link' => $this->System->Link('/referrer/'), 28 'Permission' => LICENCE_ANONYMOUS, 29 'Icon' => '', 30 30 )); 31 31 } … … 40 40 if(!in_array($HostName, $this->Excludes)) 41 41 { 42 42 $IP = GetRemoteAddress(); 43 43 44 44 // Check if client IP is not blaclisted as spam source. If yes then add new referrer as invisible … … 65 65 { 66 66 $this->System->Database->query('INSERT INTO `Referrer` (`Web`, `DateFirst`, `DateLast`, `LastURL`, `Hits`, `LastIP`, `Visible`, `Description`) '. 67 67 'VALUES ("'.$HostName.'", NOW(), NOW( ), "'.addslashes($Referrer).'", 1, "'.$IP.'", '.$Visible.', "'.$Description.'")'); 68 68 } 69 69 } … … 93 93 $MonthAge = 3; 94 94 $YesNo = array('Ne', 'Ano'); 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 95 $Output .= '<br/><strong>'.T('Servers referring to us').':</strong> <br /> 96 <div style="font-size: 10px;">Seznam je automaticky aktualizován a zobrazeny jsou servery, ze kterých přišli uživatelé během posledních třech měsíců řazený sestupně dle nejnovějších.</div><br />'; 97 98 if(!$this->System->User->Licence(LICENCE_ADMIN)) $Where = ' WHERE (`Visible`=1) AND (`Parent` IS NULL)'; 99 else $Where = ''; 100 $Query = 'SELECT *, (SELECT Web FROM `Referrer` AS T4 WHERE T4.Id = T3.Parent) AS ParentName '. 101 'FROM (SELECT *, '. 102 '(`Hits` + COALESCE((SELECT SUM(`Hits`) FROM '. 103 '`Referrer` AS `T1` WHERE `T1`.`Parent` = `T2`.`Id`), 0)) AS `TotalHits`, '. 104 'GREATEST(`DateLast`, COALESCE((SELECT MAX(`DateLast`) FROM '. 105 '`Referrer` AS `T1` WHERE `T1`.`Parent` = `T2`.`Id`), 0)) AS `MaxDateLast` FROM '. 106 '`Referrer` AS `T2` '.$Where.') AS `T3` '. 107 'WHERE (`T3`.`MaxDateLast` > (NOW() - INTERVAL '.$MonthAge.' MONTH))'; 108 109 110 $DbResult = $this->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS T'); 111 $DbRow = $DbResult->fetch_row(); 112 $PageList = GetPageList($DbRow[0]); 113 114 $Output .= $PageList['Output']. 115 '<table class="BaseTable">'; 116 117 $TableColumns = array( 118 array('Name' => 'Web', 'Title' => T('Address')), 119 array('Name' => 'MaxDateLast', 'Title' => T('Last visit')), 120 array('Name' => 'TotalHits', 'Title' => T('Hits')), 121 ); 122 if($this->System->User->Licence(LICENCE_ADMIN)) 123 { 124 $TableColumns[] = array('Name' => 'Visible', 'Title' => T('Visible')); 125 $TableColumns[] = array('Name' => 'Parent', 'Title' => T('Parent')); 126 $TableColumns[] = array('Name' => 'Description', 'Title' => T('Comment')); 127 127 $TableColumns[] = array('Name' => 'LastIP', 'Title' => T('Last IP address')); 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 128 $TableColumns[] = array('Name' => 'Action', 'Title' => T('Actions')); 129 } 130 $Order = GetOrderTableHeader($TableColumns, 'MaxDateLast', 1); 131 $Output .= $Order['Output']; 132 133 $Query .= $Order['SQL'].$PageList['SQLLimit']; 134 135 $DbResult = $this->Database->query($Query); 136 while($Line = $DbResult->fetch_assoc()) 137 { 138 $Output .= '<tr><td><a href="'.$Line['LastURL'].'">'.$Line['Web'].'</a></td>'. 139 '<td>'.HumanDate($Line['MaxDateLast']).'</td>'. 140 '<td>'.$Line['TotalHits'].'</td>'; 141 if($this->System->User->Licence(LICENCE_ADMIN)) 142 { 143 $Output .= 144 '<td>'.$YesNo[$Line['Visible']].'</td>'. 145 '<td>'.$Line['ParentName'].'</td>'. 146 '<td>'.$Line['Description'].'</td>'. 147 147 '<td>'.$Line['LastIP'].'</td>'. 148 148 '<td><a href="?action=edit&id='.$Line['Id'].'">'.T('Modify').'</a> '. 149 149 '<a href="?action=spam&id='.$Line['Id'].'">'.T('Spam').'</a></td>'; 150 151 152 153 154 155 150 } 151 $Output .= '</tr>'; 152 } 153 $Output .= '</table>'; 154 $Output .= $PageList['Output']; 155 return($Output); 156 156 } 157 157 … … 203 203 { 204 204 if($this->System->User->Licence(LICENCE_ADMIN)) 205 206 207 205 { 206 if(array_key_exists('id', $_GET)) 207 { 208 208 $DbResult = $this->Database->select('Referrer', '*', 'Id='.$_GET['id']); 209 210 211 212 213 214 215 216 217 218 209 if($DbResult->num_rows > 0) 210 { 211 $Item = $DbResult->fetch_assoc(); 212 if($Item['Visible'] == 1) $Visible = ' checked '; 213 else $Visible = ''; 214 $Output = '<form action="?action=editsave&id='.$_GET['id'].'" method="post"><table>'. 215 '<tr><td>'.T('Web').'</td><td>'.$Item['Web'].'</td></tr>'. 216 '<tr><td>'.T('Visible').'</td><td><input type="checkbox" name="Visible" '.$Visible.'/></td></tr>'. 217 '<tr><td>'.T('Description').'</td><td><input type="text" name="Description" value="'.$Item['Description'].'"/></td></tr>'. 218 '<tr><td>'.T('Parent item').'</td><td>'.$this->SelectParentItem($Item['Parent'], $Item['Id']).'</td></tr>'. 219 219 '<tr><td>'.T('Last IP address').'</td><td><input type="text" name="LastIP" value="'.$Item['LastIP'].'"/></td></tr>'. 220 221 222 223 224 220 '<tr><td colspan="2"><input type="submit" value="Uložit"/></td></tr></table></form>'; 221 } else $Output = ShowMessage(T('Item not found'), MESSAGE_CRITICAL); 222 } else $Output = ShowMessage(T('Item not specified'), MESSAGE_CRITICAL); 223 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 224 return($Output); 225 225 } 226 226 227 227 function EditSave() 228 228 { 229 230 231 232 233 234 235 236 237 229 if($this->System->User->Licence(LICENCE_ADMIN)) 230 { 231 if($_POST['Parent'] == '') $_POST['Parent'] = null; 232 $_POST['Visible'] = array_key_exists('Visible', $_POST); 233 $DbResult = $this->Database->update('Referrer', 'Id='.$_GET['id'], array( 234 'Visible' => $_POST['Visible'], 'LastIP' => $_POST['LastIP'], 235 'Parent' => $_POST['Parent'], 'Description' => $_POST['Description'])); 236 $_SERVER['QUERY_STRING'] = ''; 237 $Output = ShowMessage(T('Settings saved')); 238 238 $Output .= $this->ShowList(); 239 240 239 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 240 return($Output); 241 241 } 242 242 243 243 function Show() 244 244 { 245 245 $this->Title = T('Promotion'); 246 246 if(array_key_exists('action', $_GET)) 247 247 { -
trunk/Modules/Search/Search.php
r760 r816 3 3 class ModuleSearch extends AppModule 4 4 { 5 var $SearchItems; 6 7 function __construct($System) 8 { 9 parent::__construct($System); 10 $this->Name = 'Search'; 11 $this->Version = '1.0'; 12 $this->Creator = 'Chronos'; 13 $this->License = 'GNU/GPL'; 14 $this->Description = 'Allow test search in other modules content.'; 15 $this->Dependencies = array(); 16 $this->SearchItems = array(); 17 } 5 var $SearchItems; 18 6 19 function Start()20 21 $this->System->RegisterPage('search', 'PageSearch');22 } 23 24 function RegisterSearch($Name, $Title, $Columns, $Query, $Link) 25 { 26 // Query can be table name or subselect query 27 $this->SearchItems[$Name] = array('Name' => $Title, 'Columns' => $Columns, 28 'Query' => $Query, 'Link' => $Link);29 7 function __construct($System) 8 { 9 parent::__construct($System); 10 $this->Name = 'Search'; 11 $this->Version = '1.0'; 12 $this->Creator = 'Chronos'; 13 $this->License = 'GNU/GPL'; 14 $this->Description = 'Allow test search in other modules content.'; 15 $this->Dependencies = array(); 16 $this->SearchItems = array(); 17 } 30 18 31 function UnregisterSearch($Name) 32 { 33 unset($this->SearchItems[$Name]); 34 } 19 function Start() 20 { 21 $this->System->RegisterPage('search', 'PageSearch'); 22 } 23 24 function RegisterSearch($Name, $Title, $Columns, $Query, $Link) 25 { 26 // Query can be table name or subselect query 27 $this->SearchItems[$Name] = array('Name' => $Title, 'Columns' => $Columns, 28 'Query' => $Query, 'Link' => $Link); 29 } 30 31 function UnregisterSearch($Name) 32 { 33 unset($this->SearchItems[$Name]); 34 } 35 35 } 36 36 37 37 class PageSearch extends Page 38 38 { 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 } 55 56 57 { 58 59 60 61 39 function Show() 40 { 41 $this->Title = T('Search'); 42 if(array_key_exists('text', $_GET)) $Search = $_GET['text']; 43 else if(array_key_exists('text', $_POST)) $Search = $_POST['text']; 44 else $Search = ''; 45 $SearchHTML = urlencode($Search); 46 47 $Output = '<table class="BaseTable"><tr><th>'.T('Section').'</th><th>'.T('Found count').'</th></tr>'; 48 foreach($this->System->ModuleManager->Modules['Search']->SearchItems as $SearchItem) 49 { 50 $ColumnQuery = array(); 51 foreach($SearchItem['Columns'] as $Column) 52 { 53 $ColumnQuery[] = '(`'.$Column.'` LIKE "%'.$Search.'%")'; 54 } 55 $ColumnQuery = implode(' OR ', $ColumnQuery); 56 if($SearchItem['Query'] != '') 57 { 58 $DbResult = $this->Database->query('SELECT COUNT(*) FROM '.$SearchItem['Query'].' WHERE '.$ColumnQuery); 59 $Line = $DbResult->fetch_row(); 60 $Line = $Line[0]; 61 } else $Line = ''; 62 62 if ($Line <> 0) 63 64 65 66 67 68 63 $Output .= '<tr><td><a href="'.$SearchItem['Link'].$SearchHTML.'">'.$SearchItem['Name'].'</a></td><td>'.$Line.'</td></tr>'; 64 } 65 66 $Output .= '</table>'; 67 return($Output); 68 } 69 69 } -
trunk/Modules/Server/Server.php
r766 r816 3 3 class ModuleServer extends AppModule 4 4 { 5 6 7 8 9 10 11 12 13 14 5 function __construct($System) 6 { 7 parent::__construct($System); 8 $this->Name = 'Server'; 9 $this->Version = '1.0'; 10 $this->Creator = 'Chronos'; 11 $this->License = 'GNU/GPL'; 12 $this->Description = 'Show list of WoW servers which supports translated texts.'; 13 $this->Dependencies = array(); 14 } 15 15 16 17 18 19 16 function Start() 17 { 18 $this->System->RegisterPage('server', 'PageServerList'); 19 $this->System->RegisterMenuItem(array( 20 20 'Title' => T('Servers'), 21 21 'Hint' => 'Seznam serverů, kde je nasazena čeština v praxi', … … 24 24 'Icon' => '', 25 25 ), 5); 26 26 } 27 27 } 28 28 29 29 class PageServerList extends PageEdit 30 30 { 31 32 33 34 35 31 function __construct($System) 32 { 33 parent::__construct($System); 34 $this->Table = 'Server'; 35 $this->TableSQL = 'SELECT `Server`.`Id`, `Name`, `URL`, `Parts`, `XPRate`, `GameplayStyle`, `Description`, `CheckIP`, `CheckPort`, '. 36 36 '`ClientVersion`.`Version` AS `ClientVersion` FROM `Server` '. 37 37 'LEFT JOIN `ClientVersion` ON `ClientVersion`.`Id` = `Server`.`ClientVersion`'; 38 39 40 'URL' => array('Type' => 'URL', 'Title' => T('URL'), 'InList' => true), 41 'Parts' => array('Type' => 'String', 'Title' => T('Translated'), 'InList' => true), 38 $this->Definition = array( 39 'Name' => array('Type' => 'String', 'Title' => T('Name'), 'InList' => true), 40 'URL' => array('Type' => 'URL', 'Title' => T('URL'), 'InList' => true), 41 'Parts' => array('Type' => 'String', 'Title' => T('Translated'), 'InList' => true), 42 42 'XPRate' => array('Type' => 'String', 'Title' => T('XP rate'), 'InList' => true), 43 43 'GameplayStyle' => array('Type' => 'String', 'Title' => T('Style'), 'InList' => true), 44 'ClientVersion' => array('Type' => 'String', 'Title' => T('Client version'), 'InList' => true), 44 'ClientVersion' => array('Type' => 'String', 'Title' => T('Client version'), 'InList' => true), 45 45 'Description' => array('Type' => 'Text', 'Title' => T('Description'), 'InList' => false), 46 46 'CheckIP' => array('Type' => 'Text', 'Title' => T('Online check IP'), 'InList' => false), 47 47 'CheckPort' => array('Type' => 'Text', 'Title' => T('Online check port'), 'InList' => false), 48 ); 49 50 51 52 53 48 ); 49 } 50 51 function ViewList() 52 { 53 $this->Title = T('Servers'); 54 54 $Output = '<p>'.T('There are servers listed which are in fact offering translated game. '. 55 55 'There is resoluted if translation is offered either on client side, on server side or both. '. 56 56 'Term "Czech server" doesn\'t mean that server is operated by Czech people but that it is possible to play in Czech.').'.</p>'; 57 57 $Output .= '<h3>'.T('Translated server list').'</h3>'; 58 59 60 58 $Output .= parent::ViewList(); 59 return($Output); 60 } 61 61 } -
trunk/Modules/ShoutBox/ShoutBox.php
r815 r816 16 16 function Start() 17 17 { 18 19 20 21 18 $this->System->RegisterPage('shoutbox', 'PageShoutBox'); 19 $this->System->ModuleManager->Modules['News']->RegisterRSS(array( 20 'Title' => T('Shoutbox'), 'Channel' => 'shoutbox', 'Callback' => array('PageShoutBox', 'ShowRSS'), 21 'Permission' => LICENCE_ANONYMOUS)); 22 22 if(array_key_exists('Search', $this->System->ModuleManager->Modules)) 23 23 $this->System->ModuleManager->Modules['Search']->RegisterSearch('shoutbox', … … 27 27 function ShowBox() 28 28 { 29 30 31 32 33 34 35 36 37 38 29 $Output = '<strong><a href="'.$this->System->Link('/shoutbox/').'">'.T('Shoutbox').':</a></strong>'; 30 31 if($this->System->User->Licence(LICENCE_USER)) 32 $Output .= ' <a href="'.$this->System->Link('/shoutbox/?a=add').'">'.T('Add').'</a>'; 33 $Output .= '<div class="box"><table>'; 34 $DbResult = $this->Database->query('SELECT * FROM `ShoutBox` ORDER BY `ID` DESC LIMIT 30'); 35 while($Line = $DbResult->fetch_assoc()) 36 $Output .= '<tr><td><strong>'.$Line['UserName'].'</strong>: '.MakeActiveLinks($Line['Text']).'</td></tr>'; 37 $Output .= '</table></div>'; 38 return($Output); 39 39 } 40 40 } … … 42 42 class PageShoutBox extends Page 43 43 { 44 45 46 47 48 49 50 51 52 53 54 44 function Show() 45 { 46 $this->Title = T('Shoutbox'); 47 if(array_key_exists('a', $_POST)) $Action = $_POST['a']; 48 else if(array_key_exists('a', $_GET)) $Action = $_GET['a']; 49 else $Action = ''; 50 if($Action == 'add2') $Output = $this->AddFinish(); 51 if($Action == 'add') $Output = $this->ShowAddForm(); 52 else $Output = $this->ShowList(); 53 return($Output); 54 } 55 55 56 57 58 59 60 61 62 63 64 65 66 56 function ShowList() 57 { 58 $Output = ''; 59 if(array_key_exists('search', $_GET)) $_SESSION['search'] = $_GET['search']; 60 else if(!array_key_exists('search', $_SESSION)) $_SESSION['search'] = ''; 61 if(array_key_exists('search', $_GET) and ($_GET['search'] == '')) $_SESSION['search'] = ''; 62 if($_SESSION['search'] != '') 63 { 64 $SearchQuery = ' AND (`Text` LIKE "%'.$_SESSION['search'].'%")'; 65 $Output .= '<div><a href="?search=">'.sprintf(T('Disable filter "%s"'), $_SESSION['search']).'</a></div>'; 66 } else $SearchQuery = ''; 67 67 68 69 70 $PageList = GetPageList($DbRow[0]); 68 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `ShoutBox` WHERE 1'.$SearchQuery); 69 $DbRow = $DbResult->fetch_row(); 70 $PageList = GetPageList($DbRow[0]); 71 71 72 73 74 75 76 77 78 79 80 81 72 $Output .= '<h3>'.T('Shoutbox').'</h3>'.$PageList['Output']; 73 if($this->System->User->Licence(LICENCE_USER)) 74 $Output .= ' <a href="'.$this->System->Link('/shoutbox/?a=add').'">'.T('Add').'</a>'; 75 $Output .= '<div class="shoutbox">'; 76 $DbResult = $this->System->Database->query('SELECT * FROM `ShoutBox` WHERE 1'.$SearchQuery.' ORDER BY `ID` DESC '.$PageList['SQLLimit']); 77 while($Line = $DbResult->fetch_assoc()) 78 $Output .= '<div><strong>'.$Line['UserName'].'</strong>: '.MakeActiveLinks($Line['Text']).'</div>'; 79 $Output .= '</div>'.$PageList['Output']; 80 return($Output); 81 } 82 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 }else $Output .= ShowMessage('Pro vkládaní zpráv musíte byt registrováni.', MESSAGE_CRITICAL);99 100 101 83 function ShowAddForm() 84 { 85 $Output = ''; 86 if($this->System->User->Licence(LICENCE_USER)) 87 { 88 $Output .= '<form action="?" method="post">'. 89 '<fieldset><legend>'.T('New message').'</legend>'. 90 'Uživatel: '; 91 if($this->System->User->Licence(LICENCE_USER)) $Output .= '<b>'.$this->System->User->Name.'</b><br />'; 92 else $Output .= '<input type="text" name="user" /><br />'; 93 $Output .= 'Text zprávy: <br/>'. 94 '<textarea onkeydown="ResizeTextArea(this)" name="text" cols="40"></textarea> <br/>'. 95 '<input type="hidden" name="a" value="add2"/>'. 96 '<input type="submit" value="Odeslat" /><br /></fieldset>'. 97 '</form>'; 98 } else $Output .= ShowMessage('Pro vkládaní zpráv musíte byt registrováni.', MESSAGE_CRITICAL); 99 $Output .= $this->ShowList(); 100 return($Output); 101 } 102 102 103 function AddFinish() 104 { 105 $Output = ''; 106 if($this->System->User->Licence(LICENCE_USER)) 107 { 108 if(array_key_exists('text', $_POST)) 109 { 110 $Text = $_POST['text']; 111 if(trim($Text) == '') $Output .= ShowMessage('Nelze vložit prázdnou zprávu.', MESSAGE_WARNING); 112 else 113 { 114 // Protection against mutiple post of same message 115 $DbResult = $this->System->Database->query('SELECT `Text` FROM `ShoutBox` WHERE (`User` = "'. 116 $this->System->User->Id.'") ORDER BY `Date` DESC LIMIT 1'); 117 if($DbResult->num_rows > 0) 118 { 119 $DbRow = $DbResult->fetch_assoc(); 120 } else $DbRow['Text'] = ''; 121 122 if($DbRow['Text'] == $Text) $Output .= ShowMessage('Nelze vložit stejnou zprávu vícekrát za sebou.', MESSAGE_WARNING); 123 else 124 { 125 $this->System->Database->query('INSERT INTO `ShoutBox` ( `User`, `UserName` , `Text` , `Date` , `IP` ) '. 126 ' VALUES ('.$this->System->User->Id.', "'.$this->System->User->Name. 127 '", "'.$Text.'", NOW(), "'.GetRemoteAddress().'")'); 128 $Output .= ShowMessage('Zpráva vložena.'); 129 } 130 } 131 } else $Output .= ShowMessage('Nezadán text pro novou zprávu.', MESSAGE_CRITICAL); 132 $Output .= '<br/>'; 133 } else $Output .= ShowMessage('Pro vkládaní zpráv musíte byt registrováni.', MESSAGE_CRITICAL); 134 $Output .= $this->ShowList(); 135 return($Output); 136 } 103 function AddFinish() 104 { 105 $Output = ''; 106 if($this->System->User->Licence(LICENCE_USER)) 107 { 108 if(array_key_exists('text', $_POST)) 109 { 110 $Text = $_POST['text']; 111 if(trim($Text) == '') $Output .= ShowMessage('Nelze vložit prázdnou zprávu.', MESSAGE_WARNING); 112 else 113 { 114 // Protection against mutiple post of same message 115 $DbResult = $this->System->Database->query('SELECT `Text` FROM `ShoutBox` WHERE (`User` = "'. 116 $this->System->User->Id.'") ORDER BY `Date` DESC LIMIT 1'); 117 if($DbResult->num_rows > 0) 118 { 119 $DbRow = $DbResult->fetch_assoc(); 120 } else $DbRow['Text'] = ''; 137 121 138 function ShowRSS() 139 { 140 $Items = array(); 141 $TitleLength = 50; 142 mb_internal_encoding('utf-8'); 143 $DbResult = $this->Database->query('SELECT UNIX_TIMESTAMP(`Date`) AS `UnixDate`, `User`, `UserName`, `Text` FROM `ShoutBox` ORDER BY `ID` DESC LIMIT 20'); 144 while($DbRow = $DbResult->fetch_assoc()) 145 { 146 $Title = mb_substr($DbRow['Text'], 0, $TitleLength); 147 if(mb_strlen($Title) == $TitleLength) $Title .= '...'; 148 $Items[] = array 149 ( 150 'Title' => $DbRow['UserName'].': '.$Title, 151 'Link' => 'http://'.$this->System->Config['Web']['Host'].$this->System->Link('/shoutbox/'), 152 'Description' => $DbRow['Text'], 153 'Time' => $DbRow['UnixDate'], 154 ); 155 } 156 $Output = GenerateRSS(array 122 if($DbRow['Text'] == $Text) $Output .= ShowMessage('Nelze vložit stejnou zprávu vícekrát za sebou.', MESSAGE_WARNING); 123 else 124 { 125 $this->System->Database->query('INSERT INTO `ShoutBox` ( `User`, `UserName` , `Text` , `Date` , `IP` ) '. 126 ' VALUES ('.$this->System->User->Id.', "'.$this->System->User->Name. 127 '", "'.$Text.'", NOW(), "'.GetRemoteAddress().'")'); 128 $Output .= ShowMessage('Zpráva vložena.'); 129 } 130 } 131 } else $Output .= ShowMessage('Nezadán text pro novou zprávu.', MESSAGE_CRITICAL); 132 $Output .= '<br/>'; 133 } else $Output .= ShowMessage('Pro vkládaní zpráv musíte byt registrováni.', MESSAGE_CRITICAL); 134 $Output .= $this->ShowList(); 135 return($Output); 136 } 137 138 function ShowRSS() 139 { 140 $Items = array(); 141 $TitleLength = 50; 142 mb_internal_encoding('utf-8'); 143 $DbResult = $this->Database->query('SELECT UNIX_TIMESTAMP(`Date`) AS `UnixDate`, `User`, `UserName`, `Text` FROM `ShoutBox` ORDER BY `ID` DESC LIMIT 20'); 144 while($DbRow = $DbResult->fetch_assoc()) 145 { 146 $Title = mb_substr($DbRow['Text'], 0, $TitleLength); 147 if(mb_strlen($Title) == $TitleLength) $Title .= '...'; 148 $Items[] = array 149 ( 150 'Title' => $DbRow['UserName'].': '.$Title, 151 'Link' => 'http://'.$this->System->Config['Web']['Host'].$this->System->Link('/shoutbox/'), 152 'Description' => $DbRow['Text'], 153 'Time' => $DbRow['UnixDate'], 154 ); 155 } 156 $Output = GenerateRSS(array 157 157 ( 158 158 'Title' => $this->System->Config['Web']['Title'].' - '.T('Shoutbox'), … … 163 163 )); 164 164 return($Output); 165 165 } 166 166 } -
trunk/Modules/Team/Team.php
r636 r816 13 13 $this->Dependencies = array('User'); 14 14 } 15 15 16 16 function Start() 17 17 { 18 19 18 $this->System->RegisterPage('team', 'PageTeam'); 19 $this->System->RegisterMenuItem(array( 20 20 'Title' => T('Teams'), 21 'Hint' => T('List of translating teams'), 21 'Hint' => T('List of translating teams'), 22 22 'Link' => $this->System->Link('/team/'), 23 'Permission' => LICENCE_ANONYMOUS, 24 'Icon' => '', 23 'Permission' => LICENCE_ANONYMOUS, 24 'Icon' => '', 25 25 ), 1); 26 26 if(array_key_exists('Search', $this->System->ModuleManager->Modules)) … … 34 34 class PageTeam extends Page 35 35 { 36 37 38 39 40 36 function ShowTeamList() 37 { 38 $this->Title = T('Teams'); 39 $Output = '<h3>'.T('List of translating teams').'</h3>'; 40 $Output .= 'Týmy jsou seskupení překladatelů, kteří se hlásí k něčemu společnému jako např. WoW serveru, způsobu překladu, ke stejnému hernímu spolku, aj. Být členem týmu samo o sobě nemá žádný zásadní důsledek a spíše to může pomoci se lépe orientovat mezi překladateli někomu, kdo sestavuje export.<br/>'; 41 41 42 42 if(array_key_exists('search', $_GET)) $_SESSION['search'] = $_GET['search']; 43 44 45 46 47 48 49 50 $SearchQuery = ' AND ((`Name` LIKE "%'.$_SESSION['search'].'%") OR (`Description` LIKE "%'.$_SESSION['search'].'%"))'; 51 52 } else $SearchQuery = ''; 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 $Output .= $Order['Output']; 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 43 else if(!array_key_exists('search', $_SESSION)) $_SESSION['search'] = ''; 44 if (array_key_exists('search', $_GET) and ($_GET['search'] == '')) $_SESSION['search'] = ''; 45 46 if($this->System->User->Licence(LICENCE_USER)) 47 $Output .= '<br /><div style="text-align: center;"><a href="?action=create">'.T('Create translating team').'</a></div><br/>'; 48 if($_SESSION['search'] != '') 49 { 50 $SearchQuery = ' AND ((`Name` LIKE "%'.$_SESSION['search'].'%") OR (`Description` LIKE "%'.$_SESSION['search'].'%"))'; 51 $Output .= '<div><a href="?search=">'.sprintf(T('Disable filter "%s"'), $_SESSION['search']).'</a></div>'; 52 } else $SearchQuery = ''; 53 54 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Team` WHERE 1'.$SearchQuery); 55 $DbRow = $DbResult->fetch_row(); 56 $PageList = GetPageList($DbRow[0]); 57 58 $Output .= $PageList['Output']; 59 $Output .= '<table class="BaseTable">'; 60 61 $TableColumns = array( 62 array('Name' => 'Name', 'Title' => T('Name')), 63 array('Name' => 'URL', 'Title' => T('Web pages')), 64 array('Name' => 'LeaderName', 'Title' => T('Leader')), 65 array('Name' => 'NumberUser', 'Title' => T('Member count')), 66 array('Name' => 'TimeCreate', 'Title' => T('Founding date')), 67 ); 68 if($this->System->User->Licence(LICENCE_USER)) $TableColumns[] = array('Name' => '', 'Title' => T('User actions')); 69 70 $Order = GetOrderTableHeader($TableColumns, 'NumberUser', 1); 71 $Output .= $Order['Output']; 72 73 $DbResult = $this->Database->query('SELECT *, (SELECT COUNT(*) FROM `User` WHERE `User`.`Team` = `Team`.`Id`) AS `NumberUser`, '. 74 '(SELECT `Name` FROM `User` WHERE `User`.`ID`=`Team`.`Leader`) AS `LeaderName` '. 75 'FROM `Team` WHERE 1'.$SearchQuery.$Order['SQL'].$PageList['SQLLimit']); 76 while($Team = $DbResult->fetch_assoc()) 77 { 78 $Output .= '<tr>'. 79 '<td><a href="?action=team&id='.$Team['Id'].'">'.$Team['Name'].'</a></td>'. 80 '<td><a href="http://'.$Team['URL'].'">'.$Team['URL'].'</a></td>'. 81 '<td><a href="'.$this->System->Link('/user.php?user='.$Team['Leader']).'">'.$Team['LeaderName'].'</a></td>'. 82 '<td><a href="'.$this->System->Link('/userlist.php?team='.$Team['Id']).'" title="Zobrazit členy týmu">'.$Team['NumberUser'].'</a></td>'. 83 '<td>'.HumanDate($Team['TimeCreate']).'</td>'; 84 if($this->System->User->Licence(LICENCE_USER)) 85 { 86 if($Team['Leader'] == $this->System->User->Id) $Action = ' <a href="?action=modify&id='.$Team['Id'].'">Upravit</a>'; 87 else $Action = ''; 88 if($Team['Id'] == $this->System->User->Team) $Action = ' <a href="?action=leave">Opustit</a>'; 89 $Output .= '<td><a href="?action=gointeam&id='.$Team['Id'].'">Vstoupit</a>'.$Action.'</td>'; 90 } 91 $Output .= '</tr>'; 92 } 93 $Output .= '</table>'. 94 $PageList['Output']; 95 96 return($Output); 97 } 98 99 function TeamJoin() 100 { 101 if($this->System->User->Licence(LICENCE_USER)) 102 { 103 if(array_key_exists('id', $_GET)) 104 { 105 $this->Database->query('UPDATE `User` SET `Team` = '.$_GET['id'].' WHERE `ID` = '.$this->System->User->Id); 106 $Output = ShowMessage('Vstoupil jsi do týmu.'); 107 $this->System->ModuleManager->Modules['Log']->WriteLog('Uživatel vstoupil do týmu '.$_GET['id'], LOG_TYPE_USER); 108 109 // Delete all teams without users 110 $this->Database->query('DELETE FROM `Team` WHERE (SELECT COUNT(*) FROM `User` WHERE `User`.`Team` = `Team`.`Id`) = 0'); 111 112 // Set new leader for teams where old leader went to other team 113 $this->Database->query('UPDATE `Team` SET `Leader`=(SELECT `Id` FROM `User` WHERE `User`.`Team`=`Team`.`Id` ORDER BY `User`.`RegistrationTime` LIMIT 1) WHERE `Leader` NOT IN (SELECT `ID` FROM `User` WHERE `User`.`Team`=`Team`.`Id`);'); 114 115 $Output .= $this->ShowTeamList(); 116 } else $Output = ShowMessage('Nutno zadat id týmu.', MESSAGE_CRITICAL); 117 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 118 return($Output); 119 } 120 121 function TeamCreateFinish() 122 { 123 $Output = ''; 124 if($this->System->User->Licence(LICENCE_USER)) 125 { 126 if(array_key_exists('Name', $_POST) and array_key_exists('Description', $_POST)) 127 { 128 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Team` WHERE `Name` = "'.trim($_POST['Name']).'"'); 129 $DbRow = $DbResult->fetch_row(); 130 $Count = $DbRow[0]; 131 if(($Count == 0) and ($_POST['Name'] != '')) 132 { 133 $this->Database->query('INSERT INTO `Team` (`Name` ,`Description`, `URL`, `TimeCreate`, `Leader`)'. 134 ' VALUES ("'.trim($_POST['Name']).'", "'.trim($_POST['Description']).'", "'. 135 $_POST['URL'].'", NOW(), '.$this->System->User->Id.')'); 136 $this->Database->query('UPDATE `User` SET `Team` = '.$this->Database->insert_id.' WHERE `ID` = '.$this->System->User->Id); 137 $Output .= ShowMessage('Překladatelský tým vytvořen.'); 138 $this->System->ModuleManager->Modules['Log']->WriteLog('Překladatelský tým vytvořen '.$_POST['Name'], LOG_TYPE_USER); 139 140 // Delete all teams without users 141 $this->Database->query('DELETE FROM `Team` WHERE (SELECT COUNT(*) FROM `User` WHERE `User`.`Team` = `Team`.`Id`) = 0'); 142 } else $Output .= ShowMessage('Již existuje tým se stejným jménem', MESSAGE_CRITICAL); 143 } else $Output .= ShowMessage('Chybí údaje formuláře', MESSAGE_CRITICAL); 144 } else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 145 $Output .= $this->ShowTeamList(); 146 return($Output); 147 } 148 149 function TeamModify() 150 { 151 if($this->System->User->Licence(LICENCE_USER)) 152 { 153 if(array_key_exists('id', $_GET)) 154 { 155 $DbResult = $this->Database->query('SELECT * FROM `Team` WHERE `Id`='.$_GET['id'].' AND `Leader`='.$this->System->User->Id); 156 if($DbResult->num_rows > 0) 157 { 158 $Team = $DbResult->fetch_assoc(); 159 $Output = '<form action="?action=finish_modify&id='.$_GET['id'].'" method="post">'. 160 '<fieldset><legend>Nastavení týmu</legend>'. 161 '<table><tr><td>Jméno:</td><td><input type="text" name="Name" value="'.$Team['Name'].'"/></td></tr>'. 162 '<tr><td>Webové stránky:</td><td>http://<input type="text" name="URL" value="'.$Team['URL'].'"/></td></tr>'. 163 '<tr><td>Popis:</td><td><input type="text" name="Description" value="'.$Team['Description'].'"/></td></tr>'. 164 '<tr><td colspan="2"><input type="submit" value="Uložit" /></td></tr>'. 165 '</table></fieldset></form>'; 166 } else $Output = ShowMesage('Tým nenalezen.', MESSAGE_CRITICAL); 167 } else $Output = ShowMessage('Nezadáno id týmu', MESSAGE_CRITICAL); 168 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 169 return($Output); 170 } 171 172 function TeamModifyFinish() 173 { 174 $Output = ''; 175 if($this->System->User->Licence(LICENCE_USER)) 176 { 177 if(array_key_exists('id', $_GET) and array_key_exists('Name', $_POST) and array_key_exists('Description', $_POST) and array_key_exists('URL', $_POST)) 178 { 179 $DbResult = $this->Database->query('SELECT * FROM `Team` WHERE `Id`='.$_GET['id'].' AND `Leader`='.$this->System->User->Id); 180 if($DbResult->num_rows > 0) 181 { 182 $Team = $DbResult->fetch_assoc(); 183 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Team` WHERE `Name` = "'.trim($_POST['Name']).'"'); 184 $DbRow = $DbResult->fetch_row(); 185 $Count = $DbRow[0]; 186 if(($Count == 0) and ($_POST['Name'] != '')) 187 { 188 $this->Database->query('UPDATE `Team` SET `Name`="'.$_POST['Name'].'", `Description`="'.$_POST['Description'].'", `URL`="'.$_POST['URL'].'" WHERE Id='.$Team['Id']); 189 $Output .= ShowMessage('Nastavení týmu uloženo.'); 190 $this->System->ModuleManager->Modules['Log']->WriteLog('Překladatelský tým upraven '.$_POST['Name'], LOG_TYPE_USER); 191 } else $Output .= ShowMessage('Již existuje tým se stejným jménem.', MESSAGE_CRITICAL); 192 } else $Output .= ShowMessage('Tým nenalezen nebo nemáte oprávnění.', MESSAGE_CRITICAL); 193 } else $Output .= ShowMessage('Nezadáno id týmu nebo některé položky formuláře.', MESSAGE_CRITICAL); 194 } else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 195 $Output .= $this->ShowTeamList(); 196 return($Output); 197 } 198 199 function TeamCreate() 200 { 201 if($this->System->User->Licence(LICENCE_USER)) 202 { 203 $Output ='<form action="?action=finish_create" method="post">'. 204 '<fieldset><legend>Vytvoření nového týmu</legend>'. 205 '<table><tr><td>Jméno:</td><td><input type="text" name="Name" /></td></tr>'. 206 '<tr><td>Webové stránky:</td><td>http://<input type="text" name="URL" value=""/></td></tr>'. 207 '<tr><td>Popis:</td><td><input type="text" name="Description" /></td></tr>'. 208 '<tr><td colspan="2"><input type="submit" value="Vytvořit a vstoupit" /></td></tr>'. 209 '</table></fieldset></form>'; 210 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 211 return($Output); 212 } 213 214 function TeamShow() 215 { 216 $Output = ''; 217 if(array_key_exists('id', $_GET) and is_numeric($_GET['id'])) 218 { 219 ImgLevelUpdate(); 220 221 $DbResult = $this->Database->query('SELECT `Id`, `Name`, `Description`, `URL`, `Leader`, '. 222 '(SELECT COUNT(*) FROM `User` WHERE '. 223 '`Team` = `Team`.`Id`) AS `NumberUser`, (SELECT SUM(`TranslatedCount`) FROM `User` WHERE '. 224 '`Team` = `Team`.`Id`) AS `NumberTranslate` FROM '. 225 '`Team` WHERE `Id`='.($_GET['id'] * 1)); 226 if($DbResult->num_rows > 0) 227 { 228 $Team = $DbResult->fetch_assoc(); 229 $DbResult2 = $this->Database->query('SELECT `Name`, `Id` FROM `User` WHERE `ID`='.$Team['Leader']); 230 if($DbResult2->num_rows > 0) 231 { 232 $Leader = $DbResult2->fetch_assoc(); 233 } else $Leader = array('Name' => '', 'Id' => 0); 234 235 $Output .='<strong>Překladatelský tým '.$Team['Name'].'</strong><br />'. 236 'Webové stránky: <a href="http://'.$Team['URL'].'">'.$Team['URL'].'</a><br/>'. 237 'Vedoucí: <a href="'.$this->System->Link('/user.php?user='.$Leader['Id']).'">'.$Leader['Name'].'</a><br/>'. 238 'Popis: '.$Team['Description'].'<br /><br />'; 239 //$Output .= '<a href="export/?team='.$Team['Id'].'">Exportovat překlad týmu</a> '; 240 if($this->System->User->Licence(LICENCE_USER)) 241 $Output .='<a href="?action=gointeam&id='.$Team['Id'].'">Vstoupit do týmu</a><br /><br />'; 242 $Output .='<fieldset><legend>Statistika</legend>'. 243 'Počet členů týmu: <a href="'.$this->System->Link('/userlist.php?team='.$Team['Id']).'" title="Zobrazit členy týmu">'.$Team['NumberUser'].'</a><br />'. 244 'Počet přeložených textů týmu: <strong>'.$Team['NumberTranslate'].'</strong><br />'. 245 'Průměrná úroveň překladatelů v týmu: <img src="'.$this->System->Link('/tmp/team/'.$Team['Name'].'/level.png').'" /><br /><br />'. 246 '<strong>Stav dokončení týmu pro verzi '.$this->System->Config['Web']['GameVersion'].'</strong><br />'; 247 248 $BuildNumber = GetBuildNumber($this->System->Config['Web']['GameVersion']); 249 250 $GroupListQuery = 'SELECT `Group`.* FROM `Group`'; 251 $Query = ''; 252 $DbResult = $this->Database->query($GroupListQuery); 253 if($DbResult->num_rows > 0) 254 { 255 while($DbRow = $DbResult->fetch_assoc()) 256 { 257 $Query .= 'SELECT (SELECT COUNT(DISTINCT(`Entry`)) FROM ('. 258 'SELECT `T`.`Entry` FROM `'.$DbRow['TablePrefix'].'` AS `T` '. 259 'WHERE (`User` IN (SELECT `ID` FROM `User` WHERE `Team` = '.$Team['Id'].')) '. 260 'AND (`Complete` = 1) AND (`T`.`Language`!='.$this->System->Config['OriginalLanguage'].') '. 261 'AND (`VersionStart` <= '.$BuildNumber.') AND (`VersionEnd` >= '.$BuildNumber.')'. 262 ') AS `C1`) AS `Translated`, '. 263 '(SELECT COUNT(DISTINCT(`Entry`)) FROM ('. 264 'SELECT `T`.`Entry` FROM `'.$DbRow['TablePrefix'].'` AS `T` '. 265 'WHERE (`Language` = '.$this->System->Config['OriginalLanguage'].') '. 266 'AND (`VersionStart` <= '.$BuildNumber.') AND (`VersionEnd` >= '.$BuildNumber.')'. 267 ') AS `C2`) AS `Total`, "'.$DbRow['Name'].'" AS `Name` UNION '; 268 } 269 $Query = substr($Query, 0, - 6); 270 271 $DbResult = $this->Database->query('SELECT COUNT(*) FROM ('.$GroupListQuery.') AS `T`'); 272 $DbRow = $DbResult->fetch_row(); 273 $PageList = GetPageList($DbRow[0]); 274 $Output .= $PageList['Output']; 275 276 $Output .='<table class="BaseTable">'; 277 $TableColumns = array( 278 array('Name' => 'Name', 'Title' => 'Jméno'), 279 array('Name' => 'Translated', 'Title' => 'Přeložených'), 280 array('Name' => 'Total', 'Title' => 'Anglických'), 281 array('Name' => 'Percent', 'Title' => 'Procenta'), 282 ); 283 284 $Order = GetOrderTableHeader($TableColumns, 'Name', 0); 285 $Output .= $Order['Output']; 286 287 $Translated = 0; 288 $Total = 0; 289 $DbResult = $this->Database->query('SELECT *, ROUND(`Translated` / `Total` * 100, 2) AS `Percent` FROM ('.$Query.') AS `C3` '.$Order['SQL'].$PageList['SQLLimit']); 290 while($Group = $DbResult->fetch_assoc()) 291 { 292 $Output .='<tr><td>'.$Group['Name'].'</td><td>'.$Group['Translated'].'</td><td>'.$Group['Total'].'</td><td>'.ProgressBar(150, $Group['Percent']).'</td></tr>'; 293 $Translated += $Group['Translated']; 294 $Total += $Group['Total']; 295 } 296 if($Total > 0) $Progress = round($Translated / $Total * 100, 2); 297 else $Progress = 0; 298 $Output .='<tr><td><strong>Celkem</strong></td><td><strong>'.$Translated.'</strong></td><td><strong>'.$Total.'</strong></td><td><strong>'.ProgressBar(150, $Progress).'</strong></td></tr>'; 299 $Output .='</table>'; 300 } 301 $Output .='</fieldset>'; 302 } else $Output .= ShowMessage('Tým nenalezen', MESSAGE_CRITICAL); 303 } else $Output .= ShowMessage('Musíte zadat id týmu', MESSAGE_CRITICAL); 304 return($Output); 305 } 306 307 function TeamLeave() 308 { 309 if($this->System->User->Licence(LICENCE_USER)) 310 { 311 $this->Database->query('UPDATE `User` SET `Team` = NULL WHERE `ID` = '.$this->System->User->Id); 312 $Output = ShowMessage('Nyní nejste členem žádného týmu.'); 313 $this->System->ModuleManager->Modules['Log']->WriteLog('Uživatel vystoupil z týmu', LOG_TYPE_USER); 314 315 // Delete all teams without users 316 $this->Database->query('DELETE FROM `Team` WHERE (SELECT COUNT(*) FROM `User` WHERE `User`.`Team` = `Team`.`Id`) = 0'); 317 318 // Set new leader for teams where old leader went to other team 319 $this->Database->query('UPDATE `Team` SET `Leader`=(SELECT `Id` FROM `User` WHERE `User`.`Team`=`Team`.`Id` ORDER BY `User`.`RegistrationTime` LIMIT 1) WHERE `Leader` NOT IN (SELECT `ID` FROM `User` WHERE `User`.`Team`=`Team`.`Id`);'); 320 321 $Output .= $this->ShowTeamList(); 322 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 323 return($Output); 324 } 325 326 function Show() 327 { 328 if(array_key_exists('action', $_GET)) 329 { 330 if($_GET['action'] == 'gointeam') $Output = $this->TeamJoin(); 331 else if($_GET['action'] == 'finish_create') $Output = $this->TeamCreateFinish(); 332 else if($_GET['action'] == 'modify') $Output = $this->TeamModify(); 333 else if($_GET['action'] == 'finish_modify') $Output = $this->TeamModifyFinish(); 334 else if($_GET['action'] == 'create') $Output = $this->TeamCreate(); 335 else if($_GET['action'] == 'team') $Output = $this->TeamShow(); 336 else if($_GET['action'] == 'leave') $Output = $this->TeamLeave(); 337 else $Output = $this->ShowTeamList(); 338 } else $Output = $this->ShowTeamList(); 339 return($Output); 340 } 341 341 } -
trunk/Modules/Translation/Comparison.php
r752 r816 3 3 class PageTranslationComparison extends Page 4 4 { 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 5 function CompareString($String1, $String2) 6 { 7 $Result = ''; 8 //TODO: Implement colored comparison 9 //strcasecmp($String1, $String2) == 0 je totožné 10 // echo $String1.'<br /><br />'; 11 $ArrStr1 = explode(' ', $String1); 12 $ArrStr2 = explode(' ', $String2); 13 14 for($i = 0; $i < count($ArrStr1); $i++) 15 { 16 if(isset($ArrStr2[$i])) 17 { 18 if($ArrStr1[$i] == $ArrStr2[$i]) 19 { 20 $Result .= $ArrStr1[$i].' '; 21 } else 22 { 23 $find = false; 24 for($j = 0; $j < count($ArrStr2); $j++) 25 { 26 if(($ArrStr1[$i] == $ArrStr2[$j]) and ($find == false)) 27 { 28 $Result .= $ArrStr1[$i].' '; 29 $find = true; 30 } 31 } 32 if($find == false) 33 $Result .= '<span class="edit">'.$ArrStr1[$i].' </span>'; 34 } 35 } else $Result .= '<span class="edit">'.$ArrStr1[$i].' </span>'; 36 } 37 return($Result); 38 } 39 40 function Show() 41 { 42 global $TranslationTree; 43 44 44 $Output = ''; 45 45 46 47 46 if($this->System->User->Licence(LICENCE_USER)) 47 { 48 48 $Output = 'Text je porovnáván vždy ku předešlému (vlevo). Změny jsou zvýrazněny <span class="edit">barvou.</span><br /><br />'; 49 50 $GroupId = LoadGroupIdParameter();51 $Table = $TranslationTree[$GroupId]['TablePrefix'];52 53 if(array_key_exists('entry', $_GET))54 {55 $Textentry = $_GET['entry'];56 if((array_key_exists('ID1', $_GET)) and ($_GET['ID1'] <> -1)) //porovnání pouze 2 textů57 {58 $TextID1 = $_GET['ID1'];59 $TextID2 = $_GET['ID2'];60 $WhereID = ' AND ((`'.$Table.'`.`ID` = '.$TextID1.') OR (`'.$Table.'`.`ID` = '.$TextID2.'))';61 } else $WhereID = '';62 63 $DataID = $this->Database->query('SELECT `'.$Table.'`.*, `User`.`Name` AS `UserName`, '.64 '`Language`.`Name` AS `LanguageName` '.65 'FROM '.$Table.' LEFT JOIN `User` ON `User`.`Id` = `'.$Table.'`.`User` '.66 ' LEFT JOIN `Language` ON `Language`.`Id` = `'.$Table.'`.`Language` '.67 'WHERE `Entry` = '.$Textentry.' '.$WhereID.' ORDER BY `Language`');68 while($Line[] = $DataID->fetch_assoc());69 array_pop($Line);70 71 $Output .= 'Počet porovnávaných textů: <strong>'.count($Line).'</strong><br /> ';72 73 $Output .= '<strong>Číslo textu: <a href="http://www.wowhead.com/?quest='.$Textentry.'">'.$Textentry.'</a></strong>'.74 '<table class="BaseTable">'.75 '<tr><th>Přeložil</th>';76 foreach($Line as $Index => $LineItem)77 $Output .= '<th>'.$LineItem['UserName'].'</th>';78 $Output .= '</tr>'.79 '<tr>'.80 '<th>ID textu</th>';81 foreach($Line as $Index => $LineItem)82 $Output .= '<td><a href="form.php?group='.$GroupId.'&ID='.$LineItem['ID'].'">'.$LineItem['ID'].'</a></td>';83 $Output .= '</tr>'.84 '<tr><th>Převzato</th>';85 foreach($Line as $Index => $LineItem)86 $Output .= '<td><a href="form.php?group='.$GroupId.'&ID='.$LineItem['Take'].'">'.$LineItem['Take'].'</a></td>';87 $Output .= '</tr>'.88 '<tr><th>Jazyk</th>';89 foreach($Line as $Index => $LineItem)90 $Output .= '<td>'.$LineItem['LanguageName'].'</td>';91 $Output .= '</tr>'.92 '<tr><th>Verze</th>';93 foreach($Line as $Index => $LineItem)94 $Output .= '<td>'.GetVersionWOW($LineItem['VersionStart']).' - '.GetVersionWOW($LineItem['VersionEnd']).'</td>';95 $Output .= '</tr>';96 foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)97 {98 $writethis = false;99 for($i = 0; $i < count($Line); $i++)100 {101 if($Line[$i][$TextItem['Column']] <> '') $writethis = true;102 }103 if($writethis)104 {105 $Output .= '<tr><th>'.$TextItem['Name'].'</th>';106 for($i = 0; $i < count($Line); $i++)107 {108 if($i > 0)109 {110 $Output .= '<td>';111 $Output .= str_replace("\n", '<br/>', $this->CompareString(htmlspecialchars($Line[$i][$TextItem['Column']]),htmlspecialchars($Line[$i - 1][$TextItem['Column']])));112 $Output .= '</td>';113 } else $Output .= '<td>'.htmlspecialchars($Line[$i][$TextItem['Column']]).'</td>';114 }115 $Output .= '</tr>';116 }117 }118 $Output .= '</table>';119 } else $Output .= ShowMessage('Nebylo zadáno ID.', MESSAGE_CRITICAL);120 } else $Output .= ShowMessage('Porovnávat můžou pouze překladatelé!', MESSAGE_CRITICAL);121 49 122 return($Output); 123 } 50 $GroupId = LoadGroupIdParameter(); 51 $Table = $TranslationTree[$GroupId]['TablePrefix']; 52 53 if(array_key_exists('entry', $_GET)) 54 { 55 $Textentry = $_GET['entry']; 56 if((array_key_exists('ID1', $_GET)) and ($_GET['ID1'] <> -1)) //porovnání pouze 2 textů 57 { 58 $TextID1 = $_GET['ID1']; 59 $TextID2 = $_GET['ID2']; 60 $WhereID = ' AND ((`'.$Table.'`.`ID` = '.$TextID1.') OR (`'.$Table.'`.`ID` = '.$TextID2.'))'; 61 } else $WhereID = ''; 62 63 $DataID = $this->Database->query('SELECT `'.$Table.'`.*, `User`.`Name` AS `UserName`, '. 64 '`Language`.`Name` AS `LanguageName` '. 65 'FROM '.$Table.' LEFT JOIN `User` ON `User`.`Id` = `'.$Table.'`.`User` '. 66 ' LEFT JOIN `Language` ON `Language`.`Id` = `'.$Table.'`.`Language` '. 67 'WHERE `Entry` = '.$Textentry.' '.$WhereID.' ORDER BY `Language`'); 68 while($Line[] = $DataID->fetch_assoc()); 69 array_pop($Line); 70 71 $Output .= 'Počet porovnávaných textů: <strong>'.count($Line).'</strong><br /> '; 72 73 $Output .= '<strong>Číslo textu: <a href="http://www.wowhead.com/?quest='.$Textentry.'">'.$Textentry.'</a></strong>'. 74 '<table class="BaseTable">'. 75 '<tr><th>Přeložil</th>'; 76 foreach($Line as $Index => $LineItem) 77 $Output .= '<th>'.$LineItem['UserName'].'</th>'; 78 $Output .= '</tr>'. 79 '<tr>'. 80 '<th>ID textu</th>'; 81 foreach($Line as $Index => $LineItem) 82 $Output .= '<td><a href="form.php?group='.$GroupId.'&ID='.$LineItem['ID'].'">'.$LineItem['ID'].'</a></td>'; 83 $Output .= '</tr>'. 84 '<tr><th>Převzato</th>'; 85 foreach($Line as $Index => $LineItem) 86 $Output .= '<td><a href="form.php?group='.$GroupId.'&ID='.$LineItem['Take'].'">'.$LineItem['Take'].'</a></td>'; 87 $Output .= '</tr>'. 88 '<tr><th>Jazyk</th>'; 89 foreach($Line as $Index => $LineItem) 90 $Output .= '<td>'.$LineItem['LanguageName'].'</td>'; 91 $Output .= '</tr>'. 92 '<tr><th>Verze</th>'; 93 foreach($Line as $Index => $LineItem) 94 $Output .= '<td>'.GetVersionWOW($LineItem['VersionStart']).' - '.GetVersionWOW($LineItem['VersionEnd']).'</td>'; 95 $Output .= '</tr>'; 96 foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) 97 { 98 $writethis = false; 99 for($i = 0; $i < count($Line); $i++) 100 { 101 if($Line[$i][$TextItem['Column']] <> '') $writethis = true; 102 } 103 if($writethis) 104 { 105 $Output .= '<tr><th>'.$TextItem['Name'].'</th>'; 106 for($i = 0; $i < count($Line); $i++) 107 { 108 if($i > 0) 109 { 110 $Output .= '<td>'; 111 $Output .= str_replace("\n", '<br/>', $this->CompareString(htmlspecialchars($Line[$i][$TextItem['Column']]),htmlspecialchars($Line[$i - 1][$TextItem['Column']]))); 112 $Output .= '</td>'; 113 } else $Output .= '<td>'.htmlspecialchars($Line[$i][$TextItem['Column']]).'</td>'; 114 } 115 $Output .= '</tr>'; 116 } 117 } 118 $Output .= '</table>'; 119 } else $Output .= ShowMessage('Nebylo zadáno ID.', MESSAGE_CRITICAL); 120 } else $Output .= ShowMessage('Porovnávat můžou pouze překladatelé!', MESSAGE_CRITICAL); 121 122 return($Output); 123 } 124 124 } -
trunk/Modules/Translation/Form.php
r813 r816 6 6 var $ID; 7 7 8 9 10 11 8 function Show() 9 { 10 $this->Title = T('Translation'); 11 $Action = ''; 12 12 if(array_key_exists('action', $_GET)) $Action = $_GET['action']; 13 13 14 14 if($Action == 'delete') $Output = $this->Delete(); 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 15 else $Output = $this->ShowForm(); 16 return($Output); 17 } 18 19 function ShowForm() 20 { 21 global $TranslationTree; 22 23 $Output = ''; 24 25 $GroupId = LoadGroupIdParameter(); 26 $this->GroupId = $GroupId; 27 $Table = $TranslationTree[$GroupId]['TablePrefix']; 28 if(array_key_exists('action', $_GET)) $Action = $_GET['action']; 29 else $Action = ''; 30 31 if(array_key_exists('ID', $_GET)) 32 { 33 $TextID = $_GET['ID'] * 1; 34 $this->ID = $TextID; 35 36 $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE `ID` = '.$TextID); 37 $Line = $DbResult->fetch_assoc(); 38 if(!$Line) 39 { 40 $Output .= ShowMessage('Překlad nenalezen.', MESSAGE_CRITICAL); 41 } else 42 { 43 if ($this->System->Config['OriginalLanguage'] == $Line['Language']){ 44 44 $LineAJ = $Line; 45 45 … … 51 51 52 52 53 53 $sql = 'SELECT '.$Columns.' Tran.`Entry` FROM `'.$Table.'` as Tran'; 54 54 $join = ' JOIN `'.$Table.'` as `Orig` ON `Orig`.`Language` = 0 AND `Tran`.`Entry` = `Orig`.`Entry` AND `Tran`.`VersionEnd` = `Orig`.`VersionEnd` '; 55 55 $where = ' WHERE '.'( `Tran`.'.$Language.' ) AND '.'(`Tran`.`Entry` = '.$Line['Entry'].') ORDER BY `Tran`.`ModifyTime` DESC'; 56 56 $DbResult = $this->Database->query($sql.$join.$where); 57 57 while ($LineSearch = $DbResult->fetch_assoc()) { 58 59 60 58 foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) 59 if($TextItem['Visible'] == 1) 60 if (($LineAJ[$TextItem['Column']] <> '') and 61 61 ($LineSearch[$TextItem['Column']] <> '') and 62 62 ($LineSearch['Orig_'.$TextItem['Column']] <> $LineSearch[$TextItem['Column']]) and … … 65 65 { 66 66 $Line[$TextItem['Column']] = $LineSearch[$TextItem['Column']]; 67 67 // echo $Line[$TextItem['Column']].'<br />'; 68 68 } 69 69 } 70 70 71 71 } else { 72 73 74 75 72 $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE '. 73 '(`Language` = '.$this->System->Config['OriginalLanguage'].') AND '. 74 '(`Entry` = '.$Line['Entry'].') AND (`VersionEnd` = '.$Line['VersionEnd'].') LIMIT 1'); 75 $LineAJ = $DbResult->fetch_assoc(); 76 76 } 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 77 if(!$LineAJ) 78 { 79 $Output .= ShowMessage('Anglický originál k překladu nenalezen.', MESSAGE_CRITICAL); 80 } else 81 { 82 83 if($Line['User'] != '') 84 { 85 $IDUser = $this->Database->query('SELECT * FROM `User` WHERE `ID` = '.$Line['User']); 86 $LineUser = $IDUser->fetch_array(); 87 } else 88 $LineUser = array('Name' => ''); 89 90 $Output .= 'Skupina: <strong>'.$TranslationTree[$GroupId]['Name'].'</strong><br />'; 91 92 if(($Line['Language'] <> 0) and ($LineUser['Name'] <> '')) 93 $Output .= 'Přeložil: <strong>'.$LineUser['Name'].'</strong> dne '.HumanDate($Line['ModifyTime']).'<br />'; 94 if(($Line['Take'] <> 0) and ($Line['Take'] <> $Line['ID'])) 95 { 96 $DbResult = $this->Database->query('SELECT `Language`,`VersionStart`,`VersionEnd` FROM `'.$Table.'` WHERE `ID` = '.$Line['Take']); 97 $Language = $DbResult->fetch_assoc(); 98 // echo $Language['Language'].' '.$Line['Take']; 99 100 $DbResult = $this->Database->query('SELECT `Name` FROM `Language` WHERE `Id` ='.$Language['Language']); 101 $Lang = $DbResult->fetch_assoc(); 102 103 $Output .= 'Původní text: <strong>'. 104 ' ID <a href="form.php?group='.$GroupId.'&ID='.$Line['Take'].'">'.$Line['Take'].'</a></strong>'. 105 ' ('.$Lang['Name'].')'. 106 ' <br />'; 107 } 108 $Output .= 'Text: '; 109 if($Line['Language'] <> 0) 110 { 111 if($Line['Complete'] == 1) $Output .= ' <b>Hotov</b>'; 112 else $Output .= ' <b> Uložen v rozepsaných</b> '; 113 } else $Output .= ' <b>Anglická, původní verze</b> '; 114 115 $Output .= '<br />'. 116 'Verze: <b><a href="'.$this->System->Link('/client-version/?action=item&id='.GetVersionWOWId($Line['VersionStart'])).'">'.GetVersionWOW($Line['VersionStart']). 117 117 '</a> - <a href="'.$this->System->Link('/client-version/?action=item&id='.GetVersionWOWId($Line['VersionEnd'])).'">'.GetVersionWOW($Line['VersionEnd']).'</a></b>'. 118 119 120 121 122 123 124 125 126 127 128 129 130 118 '<br />'; 119 120 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `'.$Table.'` WHERE '. 121 '(`Entry` = '.$Line['Entry'].')'); 122 $Version = $DbResult->fetch_row(); 123 $Version = $Version[0]; 124 if($Version > 0) 125 { 126 $Output .= '<form action="comparison.php" method="get"><a href="TranslationList.php?group='. 127 $GroupId.'&user=0&state=2&entry='.$Line['Entry'].'&text=">Počet verzí: <strong>'.$Version.'</strong></a> 128 <input type="hidden" name="group" value="'.$GroupId.'" /> 129 <input type="hidden" name="entry" value="'.$Line['Entry'].'" /> 130 <input type="hidden" name="ID2" value="'.$TextID.'" />'; 131 131 132 132 if($this->System->User->Licence(LICENCE_USER)) { //allow to compare only to user 133 133 $Output .= '<select onchange="this.form.submit();" name="ID1"> 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 134 <option value="-1">Vyberte text k porovnání</option> 135 <option value="-1">Zobrazit/porovnat všechny</option>'; 136 $DataID = $this->Database->query('SELECT *, (SELECT `User`.`Name` AS `UserName` FROM `User` WHERE `User`.`ID` = `'.$Table.'`.`User`) AS `UserName` FROM `'.$Table.'` WHERE (`Entry` = '.$Line['Entry'].') AND (`ID` <> '.$Line['ID'].')'); 137 while($Version = $DataID->fetch_array()) 138 { 139 if($Version['ID'] == $Line['Take']) $Output .= '<option value="'. 140 $Version['ID'].'">'.$Version['ID'].' - '.$Version['User'].' (převzato)</option>'; 141 else 142 { 143 if($Version['Language'] == 0) $Version['UserName'] = 'Předloha'; 144 $Output .= '<option value="'.$Version['ID'].'">'.$Version['ID'].' - '. 145 $Version['UserName'].' ('.GetVersionWOW($Version['VersionStart']).' - '. 146 GetVersionWOW($Version['VersionEnd']).')</option>'; 147 } 148 } 149 $Output .= '</select>'; 150 150 } 151 151 $Output .= '</form>'; 152 153 154 155 156 157 158 159 160 161 162 163 //if(($GroupId < 4) or ($GroupId == 10) or ($GroupId == 11))164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 152 } else 153 { 154 $Output .= '<a href="TranslationList.php?group='.$GroupId.'&user=0&state=2&entry='. 155 $Line['Entry'].'&text=">Počet verzí: <strong>'.$Version.'</strong></a>'; 156 } 157 158 // Special characters: $B - New line, $N - Name, $C - profession 159 if($this->System->User->Licence(LICENCE_USER)) 160 { 161 $Output .= '<form action="save.php?group='.$GroupId.'" method="post"><div>'; 162 // TODO: Remove fixed group id condition 163 // if(($GroupId < 4) or ($GroupId == 10) or ($GroupId == 11)) 164 $Output .= '<a href="'.$this->System->Link('/dictionary/?action=group&group='.$GroupId.'&ID='.$LineAJ['ID']).'" target="_blank" title="Zobrazit přeložené názvy věci, postav, a herních objektů k tomuto překladu">Vyhledat v názvech</a>'; 165 $Output .= ' <input type="submit" value="Uložit do rozepsaných" name="save" title="Klikněte na uložit pro pozdější dokončení překladu" />'. 166 '<input type="submit" value="Dokončeno" name="End" title="Klikněte na Dokončeno jesli jsou všechny texty hotové a chcete již publikovat" /> '; 167 FollowingTran($TextID, $Table, $GroupId, true); 168 FollowingTran($TextID, $Table, $GroupId); 169 } 170 171 if($TranslationTree[$GroupId]['WowheadName'] != '') 172 $WowheadLink = '<a href="http://www.wowhead.com/?'.$TranslationTree[$GroupId]['WowheadName'].'='.$LineAJ['Entry'].'">'.$LineAJ['Entry'].'</a>'; 173 else $WowheadLink = $LineAJ['Entry']; 174 175 $Output .= '<input type="hidden" name="entry" value="'.$LineAJ['Entry'].'" /> 176 <input type="hidden" name="user" value="'.$this->System->User->Id.'" /> 177 <input type="hidden" name="ID" value="'.$TextID.'" /> 178 <table class="BaseTable"> 179 <tr> 180 <th>Číslo textu: '.$WowheadLink.'</th> 181 <th>Nepřeložené</th> 182 <th>Přeložené</th> 183 </tr> 184 <tr> 185 <th>Jazyk</th> 186 <td>Anglický</td> 187 <td>'; 188 if($Line['Language'] <> 0) $Language = $Line['Language']; 189 else if($this->System->User->Id != 0) 190 { 191 $Language = $this->System->User->Language; 192 } else $Language = 0; 193 if($this->System->User->Licence(LICENCE_USER)) $Output .= WriteLanguages($Language); 194 else { 195 $DbResult3 = $this->Database->select('Language', '`Id`, `Name`', '(`Enabled` = 1) AND (`Id`='.$Language.')'); 196 if($DbResult3->num_rows > 0) 197 { 198 $Language = $DbResult3->fetch_assoc(); 199 $Output .= $Language['Name']; 200 } 201 } 202 203 $Output .= '</td></tr>'; 204 204 205 205 //todo javascript 206 206 207 207 $Output .= '<script src="http://code.jquery.com/jquery-latest.js"></script>'. 208 208 '<script>'; 209 209 $Output .= '$(document).ready(function() {'; 210 210 foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) 211 211 $Output .= '$("#'.$TextItem['Column'].'").load("'.$this->System->Link('/LoadNames.php?ID='.$LineAJ['ID'].'&Column='.$TextItem['Column'].'&GroupId='.$GroupId).'");'; 212 212 … … 214 214 '</script>'; 215 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 216 foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) 217 if($TextItem['Visible'] == 1) 218 { 219 if(($LineAJ[$TextItem['Column']] <> '') or ($Line[$TextItem['Column']] <> '')) 220 { 221 if(($TextItem['Name'] == 'Text') and (($Table == 'global_strings') or ($Table == 'glue_strings'))) 222 $Output .= '<tr><th>'.$LineAJ['ShortCut'].'</th>'; 223 else $Output .= '<tr><th>'.$TextItem['Name'].'</th>'; 224 $Output .= '<td id="'.$TextItem['Column'].'">'.str_replace("\n", '<br/>', htmlspecialchars($LineAJ[$TextItem['Column']])).'</td> 225 <td>'; 226 if($this->System->User->Licence(LICENCE_USER)) 227 $Output .= '<textarea rows="8" cols="40" onkeydown="ResizeTextArea(this)" class="textedit" id="'.$TextItem['Column'].'" name="'.$TextItem['Column'].'">'; 228 $Output .= htmlspecialchars($Line[$TextItem['Column']]); 229 if($this->System->User->Licence(LICENCE_USER)) $Output .= '</textarea></td></tr>'; 230 } 231 } else 232 { 233 $Output .= '<input id="'.$TextItem['Column'].'" name="'.$TextItem['Column'].'" type="hidden" value="'.htmlspecialchars($Line[$TextItem['Column']]).'" />'; 234 } 235 $Output .= '</table></div>'; 236 if($this->System->User->Licence(LICENCE_USER)) { 237 237 $Output .= '</form>'; 238 238 239 239 $Output .= '<table class="BaseTable">'. 240 241 242 243 240 '<tr><th>Překladač:</th><th>Nepřeložené</th><th>Přeložené</th>'; 241 foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) 242 if($TextItem['Visible'] == 1) 243 if ($LineAJ[$TextItem['Column']] <> '') 244 244 $Output .= '<tr><td>'.$TextItem['Column'].'</td><td>'.$LineAJ[$TextItem['Column']].'</td><td>'.GetTranslateGoogle($LineAJ[$TextItem['Column']]).'</td></tr>'; 245 245 … … 247 247 $Output .= '</table>'; 248 248 } 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 249 } 250 } 251 } else $Output = ShowMessage('Nebylo zadáno ID.', MESSAGE_CRITICAL); 252 return($Output); 253 } 254 255 function Delete() 256 { 257 global $TranslationTree; 258 259 if($this->System->User->Licence(LICENCE_MODERATOR)) 260 { 261 $GroupId = LoadGroupIdParameter(); 262 $this->GroupId = $GroupId; 263 $Table = $TranslationTree[$GroupId]['TablePrefix']; 264 $TextID = $_GET['ID']; 265 $this->Database->query('DELETE FROM `'.$Table.'` WHERE `ID` = '.$TextID.' AND `Language` <> '.$this->System->Config['OriginalLanguage']); 266 $Output = ShowMessage('Překlad byl smazán.'); 267 $this->System->ModuleManager->Modules['Log']->WriteLog('Překlad byl smazán! <a href="'.$this->System->Link('/form.php?group='.$this->GroupId.'&ID='.$TextID).'">'.$TextID.'</a>', LOG_TYPE_MODERATOR); 268 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 269 return($Output); 270 } 271 271 } -
trunk/Modules/Translation/LoadNames.php
r806 r816 3 3 class PageLoadNames extends Page 4 4 { 5 function ReplaceTranslated($orig,$tran,$Text,$ID,$Group) 5 function ReplaceTranslated($orig,$tran,$Text,$ID,$Group) 6 6 { 7 7 $tran_replace = str_replace(' ',' ',htmlspecialchars($tran)); … … 9 9 10 10 // if (strlen($orig) < strlen($Text)-1) { 11 if ($Group <> '') 11 if ($Group <> '') 12 12 { 13 13 $Text = str_replace(' '.$orig,' <span Title="Přelož jako: '.$tran_replace. 14 14 '" class="edit"><a class="edit" target="_NEW2" href="'.$this->System->Link('/form.php?group='.$Group.'&ID='.$ID).'">'.$orig_replace.'</a></span>',$Text); 15 } else { 15 } else { 16 16 $Text = str_replace(' '.$orig,' <span Title="Přelož jako: '.$tran_replace. 17 17 '" class="edit"><a class="edit" target="_NEW2" href="'.$this->System->Link('/dictionary/?search='.$tran).'">'.$orig_replace.'</a></span>',$Text); 18 18 } 19 //}19 // } 20 20 return ($Text); 21 21 } 22 function ReplaceNotTranslated($orig,$tran,$Text,$ID,$Group) 22 function ReplaceNotTranslated($orig,$tran,$Text,$ID,$Group) 23 23 { 24 24 $orig_replace = str_replace(' ',' ',htmlspecialchars($orig)); 25 25 26 26 $Text = str_replace(' '.$orig,' <span title="Kliknutím přeložíš" class="needtran"><a class="needtran" target="_NEW2" href="'. 27 27 $this->System->Link('/form.php?group='.$Group.'&ID='.$ID).'">'.$orig_replace.'</a></span>',$Text); 28 28 return ($Text); 29 29 } 30 31 32 30 31 function ColorNames($Text, $names) 32 { 33 33 $Text = ' '.$Text; 34 34 $Text = str_replace('$B$B','$B$B ',$Text); 35 36 37 38 39 40 41 42 43 44 45 46 47 if (($_GET['ID'] <> $Line[0]) or ($Line[1] <> $_GET['GroupId'])) 35 36 $Text = str_replace('$B','<span Title="Znamená odřádkování, překladu zachovej na stejné pozici." class="edit">$B</span>',$Text); 37 $Text = str_replace('$N','<span Title="Znamená jméno hráče, překladu zachovej na stejné pozici." class="edit">$N</span>',$Text); 38 $Text = str_replace('$R','<span Title="Znamená rasu hráče, překladu zachovej na stejné pozici." class="edit">$R</span>',$Text); 39 $Text = str_replace('$C','<span Title="Znamená povolání hráče, překladu zachovej na stejné pozici." class="edit">$C</span>',$Text); 40 $Text = str_replace('$G','<span Title="Vybere oslovení podle pohlaví hráče, překladu zachovej na stejné pozici." class="edit">$G</span>',$Text); 41 $Text = str_replace('$b','<span Title="Znamená odřádkování, překladu zachovej na stejné pozici." class="edit">$B</span>',$Text); 42 $Text = str_replace('$n','<span Title="Znamená jméno hráče, překladu zachovej na stejné pozici." class="edit">$N</span>',$Text); 43 $Text = str_replace('$c','<span Title="Znamená povolání hráče, překladu zachovej na stejné pozici." class="edit">$c</span>',$Text); 44 $Text = str_replace('$r','<span Title="Znamená rasu hráče, překladu zachovej na stejné pozici." class="edit">$R</span>',$Text); 45 $Text = str_replace('$g','<span Title="Vybere oslovení podle pohlaví hráče, překladu zachovej na stejné pozici." class="edit">$G</span>',$Text); 46 foreach($names as $Line) { 47 if (($_GET['ID'] <> $Line[0]) or ($Line[1] <> $_GET['GroupId'])) 48 48 if ($Line[3] <> '') { 49 49 $Text = $this->ReplaceTranslated($Line[2],$Line[3],$Text,$Line[0],$Line[1]); 50 51 50 51 } else { 52 52 $Text = $this->ReplaceNotTranslated($Line[2],$Line[3],$Text,$Line[0],$Line[1]); 53 54 55 56 } 53 } 54 } 55 return $Text; 56 } 57 57 58 function LoadNames() 58 function LoadNames() 59 59 { 60 60 global $TranslationTree; 61 61 62 62 $Output = ''; 63 63 if(array_key_exists('GroupId', $_GET)) $GroupId = $_GET['GroupId']; … … 71 71 //$Text = $LineAJ[$TranslationTree[$GroupId]['Items'][$_GET['Item']]]; 72 72 $Text = $LineAJ[$Column]; 73 74 75 if(($GroupId < 4) or ($GroupId == 10) or ($GroupId == 11)) 73 $names = array(); 74 if ($this->System->User->Licence(LICENCE_USER)) 75 if(($GroupId < 4) or ($GroupId == 10) or ($GroupId == 11)) 76 76 { 77 78 79 80 81 77 //<span class="edit">barvou.</span> 78 $names = GetTranslatNames($Text, 0, GetTranslatNamesArray()); 79 } else { 80 if(($GroupId == 13)) { 81 $names = GetTranslatNames($Text, 0, array('Dictionary' => 'Text', 'TextGlobalString' => 'Text', 'TextArea' => 'Name', 'TextItemSubClass' => 'Name', 'TextCharacterRace' => 'Name1',),false); 82 82 } else { 83 84 85 86 87 83 $names = GetTranslatNames($Text, 0, GetTranslatNamesArray()); 84 } 85 } 86 //$LineAJ[$Column] 87 return ($this->ColorNames(htmlspecialchars($Text),$names)); 88 88 } 89 89 90 90 function Show() 91 91 { 92 92 $this->RawPage = true; 93 93 return(str_replace("\n", '<br/>', $this->LoadNames())); 94 94 } -
trunk/Modules/Translation/Progress.php
r793 r816 6 6 { 7 7 $Output = ''; 8 8 9 9 $BuildNumber = GetBuildNumber($_SESSION['StatVersion']); 10 10 if(is_numeric($_SESSION['language'])) $LanguageFilter = 'AND (`Language`='.$_SESSION['language'].')'; 11 11 else $LanguageFilter = ' AND (`Language`!='.$this->System->Config['OriginalLanguage'].')'; 12 12 13 13 $GroupListQuery = 'SELECT `Id`, `TablePrefix`, `Name` FROM `Group`'; 14 14 $Query = ''; … … 30 30 } 31 31 $Query = substr($Query, 0, - 6); 32 32 33 33 $DbResult = $this->Database->query('SELECT COUNT(*) FROM ('.$GroupListQuery.') AS `T`'); 34 34 $DbRow = $DbResult->fetch_row(); 35 35 $PageList = GetPageList($DbRow[0]); 36 36 $Output .= $PageList['Output']; 37 37 38 38 $Output .= '<table class="BaseTable">'; 39 39 $TableColumns = array( … … 43 43 array('Name' => 'Percent', 'Title' => 'Procenta'), 44 44 ); 45 45 46 46 $Order = GetOrderTableHeader($TableColumns, 'Name', 0); 47 47 $Output .= $Order['Output']; 48 48 49 49 $Translated = 0; 50 50 $Total = 0; … … 62 62 } 63 63 return($Output); 64 } 64 } 65 65 66 66 function Show() 67 67 { 68 68 $this->Title = T('Progress'); 69 69 $LanguageList = GetLanguageList(); 70 70 71 71 if(array_key_exists('Version', $_GET)) $_SESSION['StatVersion'] = $_GET['Version']; 72 if(!array_key_exists('StatVersion', $_SESSION)) 73 { 72 if(!array_key_exists('StatVersion', $_SESSION)) 73 { 74 74 if($this->System->User->Licence(LICENCE_USER) and ($this->System->User->PreferredVersionGame != '')) 75 75 { 76 76 $_SESSION['StatVersion'] = $this->System->User->PreferredVersionGame; 77 77 } else 78 78 $_SESSION['StatVersion'] = $this->System->Config['Web']['GameVersion']; 79 } 79 } 80 80 81 81 if(!isset($_SESSION['language'])) 82 82 { 83 84 85 83 if($this->System->User->Licence(LICENCE_USER)) 84 { 85 $_SESSION['language'] = $this->System->User->Language; 86 86 } else $_SESSION['language'] = ''; 87 87 } 88 88 if(array_key_exists('language', $_GET)) { 89 89 if($_GET['language'] == '') $_SESSION['language'] = ''; 90 91 92 90 else { 91 $_SESSION['language'] = $_GET['language'] * 1; 92 } 93 93 } 94 94 if(!array_key_exists($_SESSION['language'], $LanguageList)) $_SESSION['language'] = ''; … … 109 109 if($Language['Enabled'] == 1) 110 110 { 111 111 $Lang = ' <a href="?language='.$Language['Id'].'">'.$Language['Name'].'</a>'; 112 112 if($Language['Id'] == $_SESSION['language']) $Output .= '<strong>'.$Lang.'</strong> '; 113 113 else $Output .= $Lang; -
trunk/Modules/Translation/Save.php
r800 r816 5 5 function Show() 6 6 { 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 //JOIN `TextSpell` as sub1 ON sub1.Language = 0 AND T.`Entry` = sub1.`Entry` AND T.`VersionStart` = sub1.`VersionStart` 7 global $TranslationTree, $Message, $MessageType; 8 9 $Output = ''; 10 $CompleteText = array('nedokončený', 'dokončený'); 11 12 unset($Message); 13 $this->System->ModuleManager->Modules['FrontPage']->HandleLoginForm(); 14 if(isset($Message)) $Output .= ShowMessage($Message, $MessageType); 15 16 $GroupId = LoadGroupIdParameter(); 17 $Group = $TranslationTree[$GroupId]; 18 $Table = $Group['TablePrefix']; 19 if($this->System->User->Licence(LICENCE_USER)) 20 { 21 if(array_key_exists('ID', $_POST) and is_numeric($_POST['ID'])) 22 { 23 $Entry = $_POST['entry'] * 1; 24 $TextID = $_POST['ID'] * 1; 25 $Language = $_POST['Language'] * 1; 26 if(array_key_exists('End', $_POST)) $Complete = 1; 27 else $Complete = 0; 28 29 // Get source text record from database by ID 30 $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE `ID`='.$TextID); 31 if($DbResult->num_rows > 0) 32 { 33 $SourceText = $DbResult->fetch_assoc(); 34 35 // Get data for english original 36 $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE (`Entry`='.$SourceText['Entry'].') '. 37 'AND (`Language` = '.$this->System->Config['OriginalLanguage'].') AND (`VersionStart` = '.$SourceText['VersionStart'].') '. 38 'AND (`VersionEnd` = '.$SourceText['VersionEnd'].')'); 39 if($DbResult->num_rows > 0) 40 { 41 $EnglishText = $DbResult->fetch_assoc(); 42 43 // Get all similar english texts 44 $Filter = ''; 45 foreach($Group['Items'] as $GroupItem) 46 if(($GroupItem['Visible'] == 1) and ($EnglishText[$GroupItem['Column']] != '')) 47 $Filter .= ' OR (`'.$GroupItem['Column'].'` = "'.addslashes($EnglishText[$GroupItem['Column']]).'")'; 48 if(substr($Filter, 0, 3) == ' OR') $Filter = ' AND ('.substr($Filter, 3).')'; 49 50 $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE (`Language` = '.$this->System->Config['OriginalLanguage'].')'.$Filter); 51 while($EnglishFound = $DbResult->fetch_assoc()) 52 { 53 // Get user translation paired to found english item entry 54 //TODO: and need update sql 55 //SELECT T.ID,T.Take,sub1.ID,T.`VersionStart`,T.`VersionEnd`,sub1.`VersionStart` as OrigStart,sub1.`VersionEnd` as OrigEnd FROM `TextSpell` as T 56 //JOIN `TextSpell` as sub1 ON sub1.Language = 0 AND T.`Entry` = sub1.`Entry` AND T.`VersionStart` = sub1.`VersionStart` 57 57 //WHERE T.Language != 0 AND T.`VersionEnd` != sub1.`VersionEnd` 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 if((($CompleteParts & (1 << ($GroupItem['Sequence'] - 1))) == 0) and86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 58 $DbResult2 = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE (`User` = '.$this->System->User->Id. 59 ') AND (`Entry` = '.$EnglishFound['Entry'].') AND (`VersionStart` = '.$EnglishFound['VersionStart']. 60 ') AND (`VersionEnd` = '.$EnglishFound['VersionEnd'].')'); 61 if($DbResult2->num_rows > 0) 62 { 63 // Update existed user translation 64 $ExistedText = $DbResult2->fetch_assoc(); 65 $Values = '`Language` = '.$Language; 66 67 $UpdateModifyTime = false; 68 $Completable = true; 69 $CompleteParts = $ExistedText['CompleteParts']; 70 foreach($Group['Items'] as $GroupItem) 71 { 72 if($GroupItem['Visible'] == 1) 73 { 74 if($SourceText[$GroupItem['Column']] != $ExistedText[$GroupItem['Column']]) 75 $UpdateModifyTime = true; 76 77 if($EnglishFound[$GroupItem['Column']] == $EnglishText[$GroupItem['Column']]) 78 { 79 if(array_key_exists($GroupItem['Column'], $_POST)) 80 { 81 $Values .= ', `'.$GroupItem['Column'].'` = "'.$_POST[$GroupItem['Column']].'"'; 82 $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1)); 83 } 84 } 85 if((($CompleteParts & (1 << ($GroupItem['Sequence'] - 1))) == 0) and 86 ($EnglishFound[$GroupItem['Column']] != '')) $Completable = false; 87 } 88 } 89 if($Completable) $NewComplete = 1; // All parts of text are completed. Make entire text as completed 90 else $NewComplete = 0; 91 if($SourceText['ID'] == $ExistedText['ID']) 92 { 93 $NewComplete = $Complete; // Our original user text, set complete according user choice 94 if($Complete == 1) 95 { 96 foreach($Group['Items'] as $GroupItem) 97 if($GroupItem['Visible'] == 1) $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1)); 98 } 99 } 100 $Values .= ', `Complete`='.$NewComplete.', `CompleteParts` = '.$CompleteParts; 101 102 if($UpdateModifyTime) $Values .= ', `ModifyTime` = NOW()'; 103 104 // Update user translation 105 $this->Database->query('UPDATE `'.$Table.'` SET '.$Values.' WHERE `ID` = '.$ExistedText['ID']); 106 107 $Output .= 'Změny v překladu <a href="'.$this->System->Link('/form.php?group='. 108 $GroupId.'&ID='.$ExistedText['ID']).'">'.$ExistedText['ID'].'</a> ('. 109 $ExistedText['Entry'].') uloženy jako '.$CompleteText[$NewComplete].'.<br />'; 110 $this->System->ModuleManager->Modules['Log']->WriteLog('Změny v překladu <a href="'. 111 $this->System->Link('/form.php?group='.$GroupId.'&ID='.$ExistedText['ID']).'">'. 112 $ExistedText['ID'].'</a> ('.$ExistedText['Entry'].') uloženy jako '.$CompleteText[$NewComplete].'.', LOG_TYPE_TRANSLATION); 113 } else 114 { 115 // Insert new user translation 116 $Columns = '`Entry`, `VersionStart`, `VersionEnd`, `Language`, `User`, `Take`, `ModifyTime`'; 117 $Values = $EnglishFound['Entry'].', '.$EnglishFound['VersionStart'].', '. 118 $EnglishFound['VersionEnd'].', '.$Language.', '.$this->System->User->Id.', '.$EnglishFound['ID'].', NOW()'; 119 120 $CompleteParts = 0; 121 $Completable = true; 122 122 $OnlyRank = true; 123 124 125 126 127 128 129 130 131 132 133 if (44 <> $GroupItem['Id']) $OnlyRank = false; 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 if (!$OnlyRank) 160 { 161 162 163 164 165 166 167 168 169 170 171 172 173 174 } 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 }244 return($Output); 123 foreach($Group['Items'] as $GroupItem) 124 { 125 $Columns .= ', `'.$GroupItem['Column'].'`'; 126 if($GroupItem['Visible'] == 1) 127 { 128 if($EnglishFound[$GroupItem['Column']] == $EnglishText[$GroupItem['Column']]) 129 { 130 // Read form user data 131 if(array_key_exists($GroupItem['Column'], $_POST)) 132 { 133 if (44 <> $GroupItem['Id']) $OnlyRank = false; 134 $Values .= ', "'.$_POST[$GroupItem['Column']].'"'; 135 $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1)); 136 } else $Values .= ', "'.addslashes($EnglishFound[$GroupItem['Column']]).'"'; 137 } else $Values .= ', "'.addslashes($EnglishFound[$GroupItem['Column']]).'"'; 138 if((($CompleteParts & (1 << ($GroupItem['Sequence'] - 1))) == 0) and ($EnglishFound[$GroupItem['Column']] != '')) $Completable = false; 139 } else 140 { 141 // Read from english text 142 $Values .= ', "'.$EnglishFound[$GroupItem['Column']].'"'; 143 } 144 } 145 if($Completable) $NewComplete = 1; // All parts of text are completed. Make entire text as completed 146 else $NewComplete = 0; 147 if($SourceText['ID'] == $EnglishFound['ID']) 148 { 149 $NewComplete = $Complete; // Our original user text, set complete according user choice 150 if($Complete == 1) 151 { 152 foreach($Group['Items'] as $GroupItem) 153 if($GroupItem['Visible'] == 1) $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1)); 154 } 155 } 156 $Columns .= ', `Complete`, `CompleteParts`'; 157 $Values .= ', '.$NewComplete.', '.$CompleteParts; 158 159 if (!$OnlyRank) 160 { 161 $this->Database->query('INSERT INTO `'.$Table.'` ('.$Columns.') VALUES ('.$Values.')'); 162 $LastID = $this->Database->insert_id; 163 164 $Output .= 'Text <a href="'.$this->System->Link('/form.php?group='. 165 $GroupId.'&ID='.$LastID).'">'.$LastID.'</a> ze skupiny <a href="TranslationList.php?group='. 166 $GroupId.'&user=0&action=filter">'.$TranslationTree[$GroupId]['Name'].'</a> uložen jako '. 167 $CompleteText[$NewComplete].'. Převzat z <a href="form.php?group='.$GroupId.'&ID='.$TextID.'">'.$TextID.'</a>.<br/>'; 168 $this->System->ModuleManager->Modules['Log']->WriteLog('Text <a href="'. 169 $this->System->Link('/form.php?group='.$GroupId.'&ID='.$LastID).'">'. 170 $LastID.'</a> ze skupiny <a href="TranslationList.php?group='. 171 $GroupId.'&user=0&text=&entry=&action=filter">'. 172 $TranslationTree[$GroupId]['Name'].'</a> uložen jako '.$CompleteText[$NewComplete]. 173 '. Převzat z <a href="form.php?group='.$GroupId.'&ID='.$TextID.'">'.$TextID.'</a>.', LOG_TYPE_TRANSLATION); 174 } 175 } 176 } 177 } else $Output .= ShowMessage('Anglický originál k překladu nenalezen.', MESSAGE_CRITICAL); 178 } else $Output .= ShowMessage('Zadaná položka nenalezena.', MESSAGE_CRITICAL); 179 180 181 // Address and redirecting 182 $Output .= '<br />Překládat: <a href="TranslationList.php?group='.$GroupId.'&state=1&user=0&entry=">Nepřeložené</a> '; 183 184 $prev = FollowingTran($TextID, $Table, $GroupId, True); 185 $next = FollowingTran($TextID, $Table, $GroupId); 186 $Output .= '<br /><br />'; 187 $DbResult = $this->Database->query('SELECT `Redirecting` FROM `User` WHERE `ID`='.$this->System->User->Id); 188 $redirecting = $DbResult->fetch_assoc(); 189 190 switch($redirecting['Redirecting']) 191 { 192 case 1: 193 $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'. 194 'setTimeout("parent.location.href=\''.htmlspecialchars_decode('TranslationList.php?group='.$GroupId.'&state=1&user=0').'\'", 1500)'. 195 '</script>'; 196 break; 197 case 2: 198 if($next <> '') 199 $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'. 200 'setTimeout("parent.location.href=\''.htmlspecialchars_decode($next).'\'", 1500)'. 201 '</script>'; 202 break; 203 case 3: 204 if($prev <> '') 205 $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'. 206 'setTimeout("parent.location.href=\''.htmlspecialchars_decode($prev).'\'", 1500)'. 207 '</script>'; 208 break; 209 } 210 211 $Output .= 'Z této stránky můžete být automaticky přesměrování. Nastavit kam chcete být přesměrování si můžete v <a href="'. 212 $this->System->Link('/Options.php').'" title="Nastavení uživatele">Nastavení</a>'; 213 214 // Update flag for experience info load 215 $this->Database->query('UPDATE `User` SET `NeedUpdate` = 1 WHERE `ID` = '.$this->System->User->Id); 216 } else $Output .= ShowMessage('Položka nenalezena', MESSAGE_CRITICAL); 217 } else 218 { 219 if(array_key_exists('ID', $_POST) and array_key_exists('entry', $_POST) and array_key_exists('Language', $_POST) and array_key_exists('user', $_POST)) 220 { 221 $Output .= 'Byli jste automaticky odhlášeni. Pro <strong>Uložení překladu</strong> se musíte přihlásit zde:<br /><br />'. 222 '<form action="save.php?action=login&group='.$GroupId.'" method="post"><div>'. 223 '<input type="hidden" name="entry" value="'.$_POST['entry'].'" />'. 224 '<input type="hidden" name="user" value="'.$_POST['user'].'" />'. 225 '<input type="hidden" name="ID" value="'.$_POST['ID'].'" />'. 226 '<input type="hidden" name="Language" value="'.$_POST['Language'].'" />'; 227 228 foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) 229 { 230 if(array_key_exists($TextItem['Column'], $_POST)) $Value = $_POST[$TextItem['Column']]; else $Value = ''; 231 $Output .= '<input id="'.$TextItem['Column'].'" name="'.$TextItem['Column'].'" type="hidden" value="'.htmlspecialchars($Value).'" />'; 232 } 233 $Output .= '<table>'. 234 '<tr>'. 235 '<td>Jméno: <input type="text" name="LoginUser" size="13" /></td>'. 236 '</tr><tr>'. 237 '<td>Heslo: <input type="password" name="LoginPass" size="13" /></td>'. 238 '</tr><tr>'. 239 '<th><input type="submit" value="Přihlásit a uložit překlad" /></th>'. 240 '</tr>'. 241 '</table>'; 242 } else $Output = ShowMessage('Nezadány požadované údaje.', MESSAGE_CRITICAL); 243 } 244 return($Output); 245 245 } 246 246 } -
trunk/Modules/Translation/Translation.php
r815 r816 23 23 function Start() 24 24 { 25 25 global $TranslationTree; 26 26 27 28 29 30 27 $this->System->RegisterPage('comparison.php', 'PageTranslationComparison'); 28 $this->System->RegisterPage('form.php', 'PageTranslationForm'); 29 $this->System->RegisterPage('save.php', 'PageTranslationSave'); 30 $this->System->RegisterPage('progress', 'PageProgress'); 31 31 $this->System->RegisterPage('TranslationList.php', 'PageTranslationList'); 32 32 $this->System->RegisterPage('LoadNames.php', 'PageLoadNames'); … … 42 42 if(array_key_exists('Search', $this->System->ModuleManager->Modules)) 43 43 { 44 45 46 44 foreach($TranslationTree as $Group) 45 { 46 $Table = $Group['TablePrefix']; 47 47 48 49 50 51 52 48 $Columns = array('ID', 'Entry'); 49 foreach($Group['Items'] as $Item) 50 { 51 if($Item['Column'] != '') $Columns[] = $Item['Column']; 52 } 53 53 54 54 $this->System->ModuleManager->Modules['Search']->RegisterSearch('group'.$Group['Id'], 55 55 sprintf(T('Translation group "%s"'), $Group['Name']), $Columns, '`'.$Table.'`', $this->System->Link('/TranslationList.php?group='. 56 56 $Group['Id'].'&user=0&state=0&entry=&text=')); 57 57 } 58 58 } 59 59 } … … 61 61 function ShowRSS() 62 62 { 63 63 $Items = array(); 64 64 $DbResult = $this->Database->query('SELECT UNIX_TIMESTAMP(`Date`) AS `Date`, `User`.`Name` AS `UserName`, `Text` FROM `Log` '. 65 65 'JOIN `User` ON `User`.`ID` = `Log`.`User` WHERE `Type` = 1 ORDER BY `Date` DESC LIMIT 100'); … … 81 81 'WebmasterEmail' => $this->System->Config['Web']['AdminEmail'], 82 82 'Items' => $Items, 83 83 )); 84 84 return($Output); 85 85 } -
trunk/Modules/Translation/TranslationList.php
r791 r816 3 3 class CompletionState 4 4 { 5 6 7 8 9 10 11 12 5 const All = 0; 6 const NotTranslated = 1; 7 const Translated = 2; 8 const NotFinished = 3; 9 const Original = 4; 10 const NotFinishedNotTranslated = 5; 11 const Missing1 = 6; 12 const Missing2 = 7; 13 13 } 14 14 … … 16 16 class PageTranslationList extends Page 17 17 { 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 18 function ShowFilter($GroupId = 0) 19 { 20 global $TranslationTree; 21 22 $Filter = array('SQL' => ''); 23 24 $Output = '<form action="?" method="post">'. 25 '<table class="BaseTable"><tr>'. 26 '<th>Zpracování</th>'. 27 '<th>Skupina</th>'. 28 '<th>Verze</th>'. 29 '<th>Jazyk</th>'. 30 '<th>Překladatel</th>'. 31 '<th>Slova</th>'. 32 '<th>Položka</th>'. 33 '<th></th></tr><tr>'; 34 35 // State 36 $Filter['State'] = GetParameter('state', 0, true, true); 37 $Output .= '<td><select name="state">'; 38 $StateTypes = array( 39 CompletionState::All => 'Všechny', 40 40 CompletionState::NotTranslated => 'Nepřeložené', 41 41 CompletionState::Translated => 'Přeložené', … … 46 46 CompletionState::Missing2 => 'Chybějící $-Neopravený' 47 47 ); 48 49 50 51 52 } 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 48 foreach ($StateTypes as $index=>$StateType) { 49 if($Filter['State'] == $index) $Selected = ' selected="selected"'; 50 else $Selected = ''; 51 $Output .= '<option value="'.$index.'"'.$Selected.'>'.$StateType.'</option>'; 52 } 53 $Output .= '</select></td>'; 54 55 // Translation group 56 if($GroupId == 0) 57 { 58 $Filter['Group'] = GetParameter('group', 0, true, true); 59 if($Filter['Group'] != 0) 60 { 61 if(isset($TranslationTree[$Filter['Group']]) == false) ErrorMessage('Překladová skupina dle zadaného Id neexistuje.'); 62 $Table = $TranslationTree[$Filter['Group']]['TablePrefix']; 63 } 64 } else 65 { 66 $Filter['Group'] = $GroupId; 67 $Table = $TranslationTree[$Filter['Group']]['TablePrefix']; 68 } 69 70 $Output .= '<td><select name="group" style="width: 80px">'; 71 if($Filter['Group'] == 0) $Selected = ' selected="selected"'; 72 else $Selected = ''; 73 $Output .= '<option value="0"'.$Selected.'>Všechny</option>'; 74 $DbResult = $this->Database->query('SELECT `Id`,`Name` FROM `Group` ORDER BY `Name`'); 75 while($Group = $DbResult->fetch_assoc()) 76 { 77 if($Group['Id'] == $Filter['Group']) $Selected = ' selected="selected"'; 78 else $Selected = ''; 79 $Output .= '<option value="'.$Group['Id'].'"'.$Selected.'>'.$Group['Name'].'</option>'; 80 } 81 $Output .= '</select></td>'; 82 82 83 83 if ($this->System->User->Licence(LICENCE_USER)) 84 85 else 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 84 $Filter['Version'] = GetParameter('version', $this->System->User->PreferredVersion, true, true); 85 else 86 $Filter['Version'] = GetParameter('version', 0, true, true); 87 if($Filter['Version'] != 0) 88 { 89 $DbResult = $this->Database->query('SELECT `Id`, `BuildNumber`,`Version` FROM `ClientVersion` WHERE (`Imported` = 1) AND (`Id` ='.$Filter['Version'].')'); 90 if($DbResult->num_rows > 0) 91 { 92 $DbRow = $DbResult->fetch_assoc(); 93 $Filter['BuildNumber'] = $DbRow['BuildNumber']; 94 } else ErrorMessage('Zadaná verze klienta nenalezena'); 95 } 96 $Output .= '<td><select name="version">'; 97 if($Filter['Version'] == 0) $Selected = ' selected="selected"'; 98 else $Selected = ''; 99 $Output .= '<option value="0"'.$Selected.'>Všechny</option>'; 100 $DbResult = $this->Database->query('SELECT `Id`, `BuildNumber`,`Version` FROM `ClientVersion` WHERE `Imported` = 1 ORDER BY `BuildNumber` DESC'); 101 while($Version = $DbResult->fetch_assoc()) 102 { 103 if($Version['Id'] == $Filter['Version']) $Selected = ' selected="selected"'; 104 else $Selected = ''; 105 $Output .= '<option value="'.$Version['Id'].'"'.$Selected.'>'.$Version['Version'].'</option>'; 106 } 107 $Output .= '</select></td>'; 108 if($Filter['Version'] != 0) $VersionFilter = ' AND (`VersionStart` <= '.$Filter['BuildNumber'].') AND (`VersionEnd` >= '.$Filter['BuildNumber'].')'; 109 else $VersionFilter = ''; 110 //else $Filter['SQL'] .= ' AND '; DISTINCT(Entry) 111 112 // Language 113 $Filter['Language'] = GetParameter('lang', 0, true, true); 114 $Output .= '<td><select name="lang">'; 115 if($Filter['Language'] == 0) $Selected = ' selected="selected"'; 116 else $Selected = ''; 117 $Output .= '<option value="0"'.$Selected.'>Všechny</option>'; 118 $DbResult = $this->Database->query('SELECT `Id`, `Name` FROM `Language` WHERE `Enabled` = 1 ORDER BY `Name`'); 119 while($Language = $DbResult->fetch_assoc()) 120 { 121 if($Language['Id'] == $Filter['Language']) $Selected = ' selected="selected"'; 122 else $Selected = ''; 123 $Output .= '<option value="'.$Language['Id'].'"'.$Selected.'>'.$Language['Name'].'</option>'; 124 } 125 $Output .= '</select></td>'; 126 $LanguageFilter = ''; 127 $LanguageFilterSub = ''; 128 if($Filter['Language'] != 0) { 129 129 $LanguageFilter = ' AND (`T`.`Language` = '.$Filter['Language'].')'; 130 130 $LanguageFilterSub = ' AND (`Sub`.`Language` = '.$Filter['Language'].')'; 131 131 } 132 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 133 // User 134 $Filter['User'] = GetParameter('user', 0, true, true); 135 $Output .= '<td><select name="user" style="width: 80px">'; 136 if($Filter['User'] == 0) $Selected = ' selected="selected"'; 137 else $Selected = ''; 138 $Output .= '<option value="0"'.$Selected.'>Všichni</option>'; 139 $DbResult = $this->Database->query('SELECT `Id`, `Name` FROM `User` ORDER BY `Name`'); 140 while($User = $DbResult->fetch_assoc()) 141 { 142 if($User['Id'] == $Filter['User']) $Selected = ' selected="selected"'; 143 else $Selected = ''; 144 $Output .= '<option value="'.$User['Id'].'"'.$Selected.'>'.$User['Name'].'</option>'; 145 } 146 $Output .= '</select></td>'; 147 if($Filter['User'] != 0) $UserFilter = ' AND (`User` = '.$Filter['User'].')'; 148 else $UserFilter = ''; 149 150 // Words 151 $Filter['Text'] = GetParameter('text', '', false, true); 152 $Output .= '<td><input name="text" type="text" style="width: 60px;" value="'.htmlentities($Filter['Text']).'"></td>'; 153 if($Filter['Text'] != '') 154 { 155 $Items = array('(`T`.`ID` LIKE "%'.$Filter['Text'].'%")', '(`T`.`Entry` LIKE "%'.$Filter['Text'].'%")'); 156 if($Filter['Group'] != 0) 157 foreach($TranslationTree[$Filter['Group']]['Items'] as $GroupItem) 158 if($GroupItem['Visible'] == 1) 159 $Items[] = '(`T`.`'.$GroupItem['Column'].'` LIKE "%'.$Filter['Text'].'%")'; 160 $Filter['SQL'] .= ' AND ('.implode(' OR ', $Items).')'; 161 } 162 163 // Entry 164 $Filter['Entry'] = GetParameter('entry', '', false, true); 165 $Output .= '<td><input name="entry" type="text" style="width: 60px;" value="'.htmlentities($Filter['Entry']).'"></td>'; 166 if($Filter['Entry'] != '') 167 { 168 $Filter['SQL'] .= ' AND (`Entry` = "'.$Filter['Entry'].'")'; 169 } 170 171 if($Filter['Group'] != 0) 172 { 173 $WithoutAlter = ' AND NOT EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE '. 174 '(`Sub`.`Language` <> '.$this->System->Config['OriginalLanguage'].')'.$LanguageFilterSub. 175 ' AND (`Sub`.`Entry` = `T`.`Entry`) AND (`Sub`.`ID` != `T`.`ID`) AND (`Sub`.`Complete` = 1) AND '. 176 '(`Sub`.`VersionStart` = `T`.`VersionStart`) AND (`Sub`.`VersionEnd` = `T`.`VersionEnd`) LIMIT 1 ) '; 177 foreach($TranslationTree[$Filter['Group']]['Items'] as $GroupItem) 178 if($GroupItem['Visible'] == 1) { 179 $ItemsVar[] = 'LENGTH(`T`.`'.$GroupItem['Column'].'`) - LENGTH( REPLACE( `T`.`'.$GroupItem['Column'].'`, \'$\', \'\' ) ) '. 180 180 ' < ('. 181 181 'SELECT LENGTH(`Sub`.`'.$GroupItem['Column'].'`) - LENGTH( REPLACE( `Sub`.`'.$GroupItem['Column'].'`, \'$\', \'\' ) ) FROM `'.$Table.'` AS `Sub` WHERE '. 182 183 182 ' `Sub`.`Entry` = `T`.`Entry` AND `Sub`.`Language` = '.$this->System->Config['OriginalLanguage'].' AND '. 183 '`Sub`.`VersionStart` = `T`.`VersionStart` AND `Sub`.`VersionEnd` = `T`.`VersionEnd` LIMIT 1 '. 184 184 ')'; 185 186 187 188 189 190 191 192 193 194 195 196 185 } 186 if($Filter['State'] == CompletionState::All) $Filter['SQL'] .= $UserFilter.$VersionFilter.''; 187 else if($Filter['State'] == CompletionState::NotTranslated) $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.$this->System->Config['OriginalLanguage'].') '. 188 'AND NOT EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE '. 189 '(`Sub`.`Language` <> '.$this->System->Config['OriginalLanguage'].') '.$LanguageFilterSub.$UserFilter. 190 ' AND (`Sub`.`Entry` = `T`.`Entry`) AND (`Sub`.`Complete` = 1) AND '. 191 '(`Sub`.`VersionStart` = `T`.`VersionStart`) AND (`Sub`.`VersionEnd` = `T`.`VersionEnd`))'; 192 else if($Filter['State'] == CompletionState::Translated) $Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Complete` = 1)'; 193 else if($Filter['State'] == CompletionState::NotFinished) $Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Language` != '.$this->System->Config['OriginalLanguage']. 194 ') AND (`T`.`Complete` = 0)'; 195 else if($Filter['State'] == CompletionState::Original) $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.$this->System->Config['OriginalLanguage'].')'; 196 else if($Filter['State'] == CompletionState::NotFinishedNotTranslated) $Filter['SQL'] .= $UserFilter.$VersionFilter.$WithoutAlter. 197 197 ' AND (`T`.`Language` != '.$this->System->Config['OriginalLanguage']. 198 198 ') AND (`T`.`Complete` = 0)'. 199 199 ''; 200 200 else if($Filter['State'] == CompletionState::Missing1) { 201 201 $Filter['SQL'] .= $UserFilter.$VersionFilter.' AND (`T`.`Complete` = 1) AND `T`.`Language` != '.$this->System->Config['OriginalLanguage']; 202 202 $Filter['SQL'] .= ' AND ('.implode(' OR ', $ItemsVar).') '; 203 204 203 } 204 else if($Filter['State'] == CompletionState::Missing2) { 205 205 $Filter['SQL'] .= $UserFilter.$VersionFilter.' AND (`T`.`Complete` = 1) AND `T`.`Language` != '.$this->System->Config['OriginalLanguage']; 206 206 $Filter['SQL'] .= ' '. $WithoutAlter; 207 207 $Filter['SQL'] .= ' AND ('.implode(' OR ', $ItemsVar).') '; 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 208 } 209 } 210 211 /* 212 // Ownership 213 if(array_key_exists('owner', $_GET) and is_numeric($_GET['owner'])) $Filter['Owner'] = $_GET['owner']; 214 else $Filter['Owner'] = 0; 215 $Output .= ' <td><select name="owner">'; 216 if($Filter['Owner'] == 0) $Selected = ' selected="selected"'; 217 else $Selected = ''; 218 $Output .= '<option value="0"'.$Selected.'>Všech</option>'; 219 if($Filter['Owner'] == 1) $Selected = ' selected="selected"'; 220 else $Selected = ''; 221 $Output .= '<option value="1"'.$Selected.'>Překladatelův tým</option>'; 222 if($Filter['Owner'] == 2) $Selected = ' selected="selected"'; 223 else $Selected = ''; 224 $Output .= '<option value="2"'.$Selected.'>Překladatele</option>'; 225 $Output .= '</select></td>'; 226 if(($Filter['Owner'] == 2) AND ($Filter['User'] != 0)) $Filter['SQL'] .= ' AND (`User` = '.$Filter['User'].')'; 227 */ 228 229 $Output .= '<td><input type="submit" value="Filtrovat"/></td>'; 230 $Output .= '</tr></table>'; 231 $Output .= '</form><br/>'; 232 $Filter['Output'] = $Output; 233 return($Filter); 234 } 235 236 function ShowTranslationList($Filter) 237 { 238 global $TranslationTree; 239 240 $Output = $Filter['Output']; 241 $Table = $TranslationTree[$Filter['Group']]['TablePrefix']; 242 243 $Query = 'SELECT `T`.`ModifyTime`, `T`.`ID`, `T`.`Entry`, `T`.`VersionStart`, `T`.`VersionEnd`, '. 244 '`T`.`'.$TranslationTree[$Filter['Group']]['Items'][0]['Column'].'`, '. 245 '`User`.`Name` AS `UserName`, `User`.`ID` AS `UserId`, '. 246 '`Language`.`Name` AS `LanguageName`, `TS`.`Version` AS `VersionStartText`, `TE`.`Version` AS `VersionEndText` '. 247 'FROM `'.$Table.'` AS `T` '. 248 'LEFT JOIN `User` ON `User`.`ID` = `T`.`User` '. 249 'LEFT JOIN `Language` ON `Language`.`ID` = `T`.`Language` '. 250 'LEFT JOIN `ClientVersion` AS `TS` ON `TS`.`BuildNumber` = `T`.`VersionStart` '. 251 'LEFT JOIN `ClientVersion` AS `TE` ON `TE`.`BuildNumber` = `T`.`VersionEnd` '. 252 'WHERE 1 '.$Filter['SQL']; 253 254 // Get total item count 255 $DbResult = $this->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS `TT`'); 256 $DbRow = $DbResult->fetch_row(); 257 $PageList = GetPageList($DbRow[0]); 258 259 $Output .= $PageList['Output']; 260 $TableColumns = array( 261 array('Name' => 'ID', 'Title' => 'Číslo'), 262 array('Name' => 'Entry', 'Title' => 'Položka'), 263 array('Name' => $TranslationTree[$Filter['Group']]['Items'][0]['Column'], 'Title' => 'Název'), 264 array('Name' => 'VersionStart', 'Title' => 'Verze'), 265 array('Name' => 'LanguageName', 'Title' => 'Jazyk'), 266 array('Name' => 'UserName', 'Title' => 'Překladatel'), 267 array('Name' => 'ModifyTime', 'Title' => 'Datum'), 268 ); 269 270 $Order = GetOrderTableHeader($TableColumns, 'VersionStart', 1); 271 $Output .= '<table class="BaseTable">'. 272 $Order['Output']; 273 274 $DbResult = $this->Database->query($Query.' '.$Order['SQL'].' '.$PageList['SQLLimit']); 275 while($Line = $DbResult->fetch_assoc()) 276 { 277 $Output .= '<tr><td><a href="form.php?group='.$Filter['Group'].'&ID='.$Line['ID'].'">'.$Line['ID'].'</a></td><td>'.$Line['Entry'].'</td>'. 278 '<td>'.htmlspecialchars($Line[$TranslationTree[$Filter['Group']]['Items'][0]['Column']]).'</td>'. 279 '<td>'.$Line['VersionStartText'].'-'.$Line['VersionEndText'].'</td>'. 280 '<td>'.$Line['LanguageName'].'</td>'. 281 '<td><a href="user.php?user='.$Line['UserId'].'">'.$Line['UserName'].'</a></td>'. 282 '<td>'.HumanDate($Line['ModifyTime']).'</td>' 283 283 ; 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 284 '</tr>'; 285 } 286 $Output .= '</table>'. 287 $PageList['Output']; 288 return($Output); 289 } 290 291 function ShowGroupList($Filter) 292 { 293 global $TranslationTree; 294 295 $Output = $Filter['Output']; 296 297 $Output .= '<table class="BaseTable"><tr><th>Skupina</th><th>Počet</th></tr>'; 298 $Total = 0; 299 foreach($TranslationTree as $Group) 300 if($Group['TablePrefix'] != '') 301 { 302 $Filter = $this->ShowFilter($Group['Id']); 303 $ID = $this->Database->query('SELECT COUNT(*) FROM `'.$Group['TablePrefix'].'` AS `T` WHERE 1 '.$Filter['SQL']); 304 $Line = $ID->fetch_row(); 305 if ($Line[0] <> '0') 306 $Output .= '<tr><td><a href="?group='.$Group['Id'].'">'.$Group['Name'].'</td><td>'.$Line[0].'</a></tr>'; 307 $Total += $Line[0]; 308 } 309 $Output .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$Total.'</strong></td></tr>'. 310 '</table>'; 311 return($Output); 312 } 313 314 function ShowGroupTypeList() 315 { 316 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Group`'); 317 $DbRow = $DbResult->fetch_row(); 318 $PageList = GetPageList($DbRow[0]); 319 $Output = '<h3>Seznam překladových skupin</h3>'. 320 $PageList['Output']; 321 322 $Output .= '<table class="BaseTable">'; 323 $TableColumns = array( 324 array('Name' => 'Name', 'Title' => 'Jméno'), 325 array('Name' => 'SourceType', 'Title' => 'Typ zdroje'), 326 array('Name' => '', 'Title' => 'Zdroje'), 327 array('Name' => 'LastImport', 'Title' => 'Datum posledního importu'), 328 array('Name' => 'LastVersion', 'Title' => 'Verze posledního importu'), 329 ); 330 if($this->System->User->Licence(LICENCE_ADMIN)) 331 $TableColumns[] = array('Name' => '', 'Title' => 'Akce'); 332 333 $Order = GetOrderTableHeader($TableColumns, 'Name', 0); 334 $Output .= $Order['Output']; 335 336 $DbResult = $this->Database->query('SELECT * FROM `Group`'.$Order['SQL'].$PageList['SQLLimit']); 337 while($Group = $DbResult->fetch_assoc()) 338 { 339 $Output .= '<tr><td><a href="?group='.$Group['Id'].'&action=filter">'.$Group['Name'].'</a></td><td>'.$Group['SourceType'].'</td><td>'; 340 if($Group['MangosTable'] != '') $Output .= $Group['MangosTable'].'.sql '; 341 if($Group['DBCFileName'] != '') $Output .= $Group['DBCFileName'].'.dbc '; 342 if($Group['LuaFileName'] != '') $Output .= $Group['LuaFileName'].'.lua '; 343 $Output .= '</td>'; 344 344 if($this->System->User->Licence(LICENCE_ADMIN)) 345 345 $Output .= '<td><a title="Změny po posledním importu u vybrané překladové skupiny" href="log.php?group='. 346 346 $Group['Id'].'&type=11">'.HumanDate($Group['LastImport']).'</a></td>'; 347 347 else $Output .= '<td>'.HumanDate($Group['LastImport']).'</td>'; 348 348 $Output .= '<td><a href="'.$this->System->Link('/client-version/?action=item&id='. 349 349 GetVersionWOWId($Group['LastVersion'])).'">'.GetVersionWOW($Group['LastVersion']).'</a></td>'; 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 350 if($this->System->User->Licence(LICENCE_ADMIN)) 351 $Output .= '<td><a href="?action=groupdelete&id='.$Group['Id'].'">Smazat</a></td>'; 352 $Output .= '</tr>'; 353 354 } 355 $Output .= '</table>'. 356 '<br /><a title="Záznam změn po importu" href="log.php?type=11">Záznam změn v textech při importu</a><br/>'; 357 if($this->System->User->Licence(LICENCE_ADMIN)) $Output .= '<a href="?action=groupadd">Přidat překladovou skupinu</a>'; 358 return($Output); 359 } 360 361 function ShowMenu() 362 { 363 global $TranslationTree; 364 365 $GroupId = GetParameter('group', 0, true); 366 if($GroupId == 0) $Output = ShowMessage('Skupina nenalezena', MESSAGE_CRITICAL); 367 else { 368 $Table = $TranslationTree[$GroupId]['TablePrefix']; 369 370 $Output = '<h3>Základní filtrování textů</h3><br/>'. 371 '<table class="BaseTable"><tr><th>Odkaz</th><th>Popis</th></tr>'. 372 '<tr><td><a title="Všechny dostupné texty ve skupině" href="?group='.$GroupId.'&state=4">Všechny</a></td>'. 373 '<td>Zobrazit všechny dostupné anglické texty ve skupině.</td></tr>'. 374 '<tr><td><a title="Přeložené texty, můžete zde hlasovat, nebo text opravovat" href="?group='.$GroupId.'&state=2">Přeložené</a></td>'. 375 '<td>Zobrazit pouze již přeložené texty.</td></tr>'. 376 '<tr><td><a title="Nepřeložené texty" href="?group='.$GroupId.'&state=1">Nepřeložené</a></td>'. 377 '<td>Dosud nepřeložené texty, které je potřeba přeložit.</td></tr>'. 378 '<tr><td><a title="Nedokončené texty" href="?group='.$GroupId.'&state=3">Nedokončené</a></td>'. 379 '<td>Texty označené jako rozpracované.</td></tr>'; 380 381 if($this->System->User->Licence(LICENCE_USER)) 382 { 383 $Output .= '<tr><td><a title="Nedokončené texty" href="?group='.$GroupId.'&state=3&user='.$this->System->User->Id.'">Moje nedokončené</a></td> 384 <td>Nedokončené texty přihlášeného uživatele</td></tr> 385 <tr><td><a title="Přeložené texty přihlášeného uživatele" href="?group='.$GroupId.'&state=2&user='.$this->System->User->Id.'">Moje přeložené</a></td> 386 <td>Přeložené texty přihlášeného uživatele</td></tr>'; 387 } 388 389 $Output .= '<tr><td><form action="?group='.$GroupId.'&entry=" method="post"><div>'. 390 '<input type="text" name="text" size="8" />'. 391 '<input type="submit" value="Hledat" />'. 392 '</div></form>'. 393 '</td><td>Vyhledat pomocí textu</td></tr>'; 394 395 $Output .= '<tr><td><form action="?group='.$GroupId.'&text=" method="post"><div>'. 396 '<input type="text" name="entry" size="8" />'. 397 '<input type="submit" value="Hledat" />'. 398 '</div></form>'. 399 '</td><td>Zobrazit podle ID textu v databázi MaNGOSu</td></tr>'; 400 401 $Output .= '</table>'; 402 } 403 return($Output); 404 } 405 406 function ShowGroupAdd() 407 { 408 if($this->System->User->Licence(LICENCE_ADMIN)) 409 { 410 $Output = '<h3>Vložení nové překladové skupiny</h3>'. 411 '<form action="?action=groupaddfinish" method="post">'. 412 '<table>'. 413 '<tr><td>Název:</td><td><input type="text" name="Name"/></td></tr>'. 414 '<tr><td>Název tabulky v databázi:</td><td>Text<input type="text" name="TablePrefix"/></td></tr>'. 415 '<tr><td colspan="2"><input type="submit" name="add" value="Přidat"/></td></tr>'. 416 '</table></form>'; 417 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 418 return($Output); 419 } 420 421 function ShowGroupAddFinish() 422 { 423 if($this->System->User->Licence(LICENCE_ADMIN)) 424 { 425 $TableName = 'Text'.$_POST['TablePrefix']; 426 $DbResult = $this->System->Database->select('Group', 'Id', 'TablePrefix="'.$TableName.'"'); 427 if($DbResult->num_rows == 0) 428 { 429 430 $this->System->Database->query('CREATE TABLE IF NOT EXISTS `'.$TableName.'` ( 431 431 `ID` int(11) NOT NULL AUTO_INCREMENT, 432 432 `Entry` int(11) NOT NULL, … … 455 455 ADD CONSTRAINT `'.$TableName.'_ibfk_2` FOREIGN KEY (`User`) REFERENCES `User` (`ID`), 456 456 ADD CONSTRAINT `'.$TableName.'_ibfk_3` FOREIGN KEY (`Take`) REFERENCES `'.$TableName.'` (`ID`);'); 457 458 459 460 457 $DbResult = $this->System->Database->insert('Group', array('Name' => $_POST['Name'], 458 'TablePrefix' => $TableName, 'PrimaryKeyItem' => 'Entry')); 459 $Group = $this->System->Database->insert_id; 460 $this->System->Database->insert('GroupItem', array('Group' => $Group, 461 461 'Name' => 'Jméno', 'Column' => 'Name', 'Visible' => 1)); 462 462 $Output = ShowMessage('Překladová skupina vytvořena', MESSAGE_INFORMATION); 463 463 } else $Output = ShowMessage('Překladová skupina '.$TableName.' již existuje', MESSAGE_CRITICAL); 464 464 $Output .= $this->ShowGroupTypeList(); 465 466 return($Output); 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 465 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 466 return($Output); 467 } 468 469 function ShowGroupDelete() 470 { 471 if($this->System->User->Licence(LICENCE_ADMIN)) 472 { 473 $DbResult = $this->System->Database->select('Group', '*', 'Id='.$_GET['id']); 474 if($DbResult->num_rows == 1) 475 { 476 $Group = $DbResult->fetch_assoc(); 477 $this->Database->query('DROP TABLE `'.$Group['TablePrefix'].'`'); 478 $this->Database->query('DELETE FROM `GroupItem` WHERE `Group`='.$Group['Id']); 479 $this->Database->query('DELETE FROM `Group` WHERE `Id`='.$Group['Id']); 480 $Output = ShowMessage('Překladová skupina '.$Group['Name'].' smazána', MESSAGE_INFORMATION); 481 } else $Output = ShowMessage('Překladová skupina nenalezena', MESSAGE_CRITICAL); 482 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 483 $Output .= $this->ShowGroupTypeList(); 484 return($Output); 485 } 486 487 function Show() 488 { 489 $this->Title = T('Translation groups'); 490 $Action = GetParameter('action', ''); 491 if($Action == 'filter') $Output = $this->ShowMenu(); 492 else if($Action == 'grouplist') $Output = $this->ShowGroupTypeList(); 493 else if($Action == 'groupadd') $Output = $this->ShowGroupAdd(); 494 else if($Action == 'groupdelete') $Output = $this->ShowGroupDelete(); 495 else if($Action == 'groupaddfinish') $Output = $this->ShowGroupAddFinish(); 496 else 497 { 498 $Filter = $this->ShowFilter(); 499 if($Filter['Group'] > 0) $Output = $this->ShowTranslationList($Filter); 500 else $Output = $this->ShowGroupList($Filter); 501 } 502 return($Output); 503 } 504 504 } -
trunk/Modules/User/Options.php
r787 r816 3 3 class PageUserOptions extends Page 4 4 { 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 5 function UserOptionsFrom() 6 { 7 $Output = '<form action="Options.php?action=save" method="post"> 8 <fieldset><legend>Nastavení uživatele</legend> 9 <table> 10 <tr><td>Email:</td><td><input type="text" name="Email" value="'.$this->System->User->Email.'" /></td></tr> 11 <tr><td>Původní heslo:</td><td><input type="password" name="OldPass" /></td></tr> 12 <tr><td>Nové heslo:</td><td><input type="password" name="NewPass" /></td></tr> 13 <tr><td>Nové heslo pro potvrzení: </td><td><input type="password" name="NewPass2" /></td></tr> 14 <tr><td>Normálně budu překládat do: </td><td>'.WriteLanguages($this->System->User->Language).'</td></tr> 15 <tr><td>Po uložení překladu přesměrovat: </td><td>'; 16 $Output .= '<select name="redirecting">'. 17 '<option value="0">Nikam</option>'. 18 '<option value="1"'; 19 if($this->System->User->Redirecting == '1') $Output .= ' selected="selected"'; 20 $Output .= '>Na nepřeložené</option>'; 21 $Output .= '<option value="2"'; 22 if($this->System->User->Redirecting == '2') $Output .= ' selected="selected"'; 23 $Output .= '>Na další překlad</option>'; 24 $Output .= '<option value="3"'; 25 if($this->System->User->Redirecting == '3') $Output .= ' selected="selected"'; 26 $Output .= '>Na předchozí překlad</option>'; 27 $Output .= '</select>'; 28 29 $Output .= '</td></tr>'. 30 '<tr><td>Upřednostněná verze klienta: </td><td>'.ClientVersionSelection($this->System->User->PreferredVersion).'</td></tr>'. 31 '<tr><td>Veřejný text profilu:</td><td>'. 32 '<textarea name="info" cols="60" rows="10">'.$this->System->User->Info.'</textarea></td></tr>'; 33 34 35 35 $Output .= '<tr><td>'; 36 37 36 $Query = 'SELECT * FROM UserTagType'; 37 $DbResult = $this->Database->query($Query); 38 38 $Output .= 'Překladatel se řídí zaškrtnutými pravidly:</td><td>'; 39 while ($UserTag = $DbResult->fetch_array()) { 40 39 while ($UserTag = $DbResult->fetch_array()) { 40 $Query = 'SELECT * FROM `UserTag` '. 41 41 //'LEFT JOIN `UserTagType` ON `UserTagType`.`ID` = `UserTag`.`UserTagType` '. 42 42 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($this->System->User->Id * 1); 43 43 $DbResult2 = $this->Database->query($Query); 44 44 if ($DbResult2->num_rows != 0) $checked = true; 45 else $checked = false; 46 47 $Output .= CheckBox('Tag'.$UserTag['ID'], $checked, 'CheckBox'); 45 else $checked = false; 46 47 $Output .= CheckBox('Tag'.$UserTag['ID'], $checked, 'CheckBox'); 48 48 $Output .= ''.$UserTag['Text'].'<br />'; 49 49 } 50 50 $Output .= '</td></tr>'; 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 51 52 $Output .= '<tr><td colspan="2"><input type="submit" value="Uložit" /></td></tr>'. 53 '</table></fieldset>'. 54 '</form>'; 55 56 $Output .= ' <fieldset><legend>Překladatelský tým</legend>'; 57 $DbResult = $this->Database->query('SELECT `Id`, `Name` FROM `Team`'); 58 $Output .= '<a href="team/?action=create">Vytvořit tým</a><br />'. 59 '<a href="team/?action=leave">Opustit tým</a><br />'. 60 '<br /><form action="team/" method="get">'. 61 '<input type="hidden" name="action" value="gointeam"/>'. 62 '<select name="id">'; 63 while($LineTeam = $DbResult->fetch_assoc()) 64 { 65 $Output .= '<option value="'.$LineTeam['Id'].'"'; 66 if ($LineTeam['Id'] == $this->System->User->Team) $Output .= ' selected="selected"'; 67 $Output .= '>'.$LineTeam['Name'].'</option>'; 68 } 69 $Output .= '</select> <input type="submit" value="Vstoupit" /> 70 </form>'; 71 $Output .= '</fieldset>'; 72 return($Output); 73 } 74 75 function UserOptionsSave() 76 { 77 $Output = ''; 78 if(array_key_exists('Email', $_POST)) 79 { 80 $Email = $_POST['Email']; 81 $OldPass = $_POST['OldPass']; 82 $NewPass = $_POST['NewPass']; 83 $NewPass2 = $_POST['NewPass2']; 84 $Language = $_POST['Language']; 85 $Redirecting = $_POST['redirecting']; 86 $PreferredVersion = $_POST['ClientVersion']; 87 if($PreferredVersion == '') $PreferredVersion = null; 88 $Info = $_POST['info']; 89 90 // Do user want to change password? 91 if(($OldPass != '') or ($NewPass != '') or ($NewPass2 != '')) 92 { 93 if($NewPass == $NewPass2) 94 { 95 $DbResult = $this->System->Database->query('SELECT `Pass`, '.$this->System->User->CryptPasswordSQL('"'.$OldPass.'"', '`Salt`').' AS `Hash` FROM `User` WHERE `ID`= '.$this->System->User->Id); 96 $DbRow = $DbResult->fetch_assoc(); 97 if($DbRow['Hash'] == $DbRow['Pass']) 98 { 99 // Update password 100 $Salt = $this->System->User->GetPasswordSalt(); 101 $this->Database->query('UPDATE `User` SET `Pass` = '.$this->System->User->CryptPasswordSQL('"'.$NewPass.'"', '"'.$Salt.'"').', `Salt`="'.$Salt.'" WHERE `ID` = '.$this->System->User->Id); 102 $Output .= ShowMessage('Heslo změněno.'); 103 } else $Output .= ShowMessage('Staré heslo neodpovídá.', MESSAGE_CRITICAL); 104 } else $Output .= ShowMessage('Hesla se neshodují.', MESSAGE_CRITICAL); 105 } 106 106 //tag 107 108 109 while ($UserTag = $DbResult->fetch_array()) { 107 $Query = 'SELECT * FROM UserTagType'; 108 $DbResult = $this->Database->query($Query); 109 while ($UserTag = $DbResult->fetch_array()) { 110 110 if (array_key_exists('Tag'.$UserTag['ID'], $_POST)) { 111 111 $Query = 'SELECT * FROM `UserTag` '. 112 112 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($this->System->User->Id * 1); 113 113 $DbResult2 = $this->Database->query($Query); 114 114 if ($DbResult2->num_rows == 0) { 115 115 $Query = 'INSERT INTO `UserTag` (`ID` ,`UserTagType`,`User` ) '. 116 116 'VALUES (NULL, '.$UserTag['ID'].' , '.($this->System->User->Id * 1).')'; 117 117 $DbResult2 = $this->Database->query($Query); 118 118 } 119 119 } else { 120 120 $Query = 'DELETE FROM `UserTag` '. 121 121 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($this->System->User->Id * 1); 122 122 $DbResult2 = $this->Database->query($Query); 123 123 } 124 124 } 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 } 150 } 125 126 $this->Database->update('User', '`ID` = '.$this->System->User->Id, array('Email' => $Email, 127 'Language' => $Language, 'Redirecting' => $Redirecting, 'Info' => $Info, 128 'PreferredVersion' => $PreferredVersion)); 129 $Output .= ShowMessage('Úprava nastavení proběhla v pořádku, Email: <b>'.$Email.'</b> Uživatel: <b>'.$this->System->User->Name.'</b>'); 130 $this->System->ModuleManager->Modules['Log']->WriteLog('Úprava nastavení!', LOG_TYPE_USER); 131 $this->System->User->Load(); 132 } else $Output .= ShowMessage('Nezadány údaje.', MESSAGE_CRITICAL); 133 return($Output); 134 } 135 136 function Show() 137 { 138 $this->Title = T('User settings'); 139 $Output = ''; 140 if($this->System->User->Licence(LICENCE_USER)) 141 { 142 if(array_key_exists('action', $_GET) and ($_GET['action'] == 'save')) 143 { 144 $Output .= $this->UserOptionsSave(); 145 } 146 $Output .= $this->UserOptionsFrom(); 147 } else $Output .= ShowMessage('Nejste přihlášený.', MESSAGE_CRITICAL); 148 return($Output); 149 } 150 } -
trunk/Modules/User/Profile.php
r797 r816 3 3 class PageUserProfile extends Page 4 4 { 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 5 function SendMail() 6 { 7 $Output = ''; 8 if(array_key_exists('text', $_POST)) 9 if($this->System->User->Licence(LICENCE_ADMIN)) 10 { 11 $Text = $_POST['text']; 12 $Email = $_POST['email']; 13 $Subject = $_POST['subject']; 14 $Output = 'Email: <strong>'.$Email.'</strong><br />'. 15 'Předmět: <strong>'.$Subject.'</strong><br />'. 16 'Text: <strong>'.$Text.'</strong><br />'; 17 18 if(@mail($Email, $Subject, $Text, 'From: '.$this->System->Config['Web']['AdminEmail'].'\nReply-To: '.$this->System->Config['Web']['AdminEmail'].'\nX-Mailer: PHP/')) 19 { 20 $Output .= ShowMessage(T('Message was sent')); 21 } 22 else $Output .= ShowMessage('Nepodařilo se odesat E-mail.', MESSAGE_CRITICAL); 23 } else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 24 return($Output); 25 } 26 27 function ExportList() 28 { 29 $Output = ''; 30 $Filter = ' WHERE `Export`.`User` = '.($_GET['user'] * 1); 31 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` '.$Filter); 32 $DbRow = $DbResult->fetch_row(); 33 $PageList = GetPageList($DbRow[0]); 34 35 $Output .= '<h3>Exporty</h3>'. 36 $PageList['Output']; 37 38 $TableColumns = array( 39 array('Name' => 'TimeCreate', 'Title' => 'Čas vytvoření'), 40 array('Name' => 'Title', 'Title' => 'Označení'), 41 // array('Name' => 'UserCount', 'Title' => 'Vybraných překladatelů'), 42 // array('Name' => 'GroupCount', 'Title' => 'Překladových skupin'), 43 array('Name' => 'OutputType', 'Title' => 'Typ výstupu'), 44 array('Name' => 'ClientVersion', 'Title' => 'Verze klienta'), 45 array('Name' => 'UsedCount', 'Title' => 'Prohlédnutí výstupu'), 46 array('Name' => '', 'Title' => 'Akce'), 47 ); 48 $Order = GetOrderTableHeader($TableColumns, 'TimeCreate', 1); 49 $Output .= '<table class="BaseTable">'. 50 $Order['Output']; 51 52 $DbResult = $this->System->Database->query('SELECT `User`.`Name` AS `UserName`, `Export`.`Id`, `Export`.`TimeCreate`, `Export`.`Title`, `Export`.`User`, `Export`.`UsedCount`, `Export`.`ClientVersion` AS `ClientVersionId`, '. 53 53 '(SELECT Version FROM `ClientVersion` WHERE `ClientVersion`.`Id`=`Export`.`ClientVersion`) AS `ClientVersion`, '. 54 54 '(SELECT Name FROM `ExportOutputType` WHERE `ExportOutputType`.`Id`=`Export`.`OutputType`) AS `OutputType`, '. … … 56 56 '(SELECT COUNT(*) FROM `ExportUser` WHERE `ExportUser`.`Export`=`Export`.`Id`) AS `UserCount` FROM `Export` '. 57 57 'LEFT JOIN `User` ON `User`.`ID`=`Export`.`User` '.$Filter.$Order['SQL'].$PageList['SQLLimit']); 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 { 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 } 118 119 58 while($Export = $DbResult->fetch_assoc()) 59 { 60 $Action = '<a href="'.$this->System->Link('/export/?Action=View&ExportId='.$Export['Id'].'&Tab=0').'">Zobrazit</a> '. 61 '<a href="'.$this->System->Link('/export/?Action=View&ExportId='.$Export['Id'].'&Tab=7').'">Exportovat</a>'; 62 if($Export['User'] == $this->System->User->Id) $Action .= ' <a href="?Action=Delete&ExportId='.$Export['Id'].'" onclick="return confirmAction(\'Opravdu smazat položku?\');">Smazat</a>'; 63 if($this->System->User->Id != null) $Action .= ' <a href="'.$this->System->Link('/export/?Action=Clone&ExportId='.$Export['Id']).'" onclick="return confirmAction(\'Opravdu klonovat položku?\');">Klonovat</a>'; 64 $Output .= '<tr><td>'.HumanDate($Export['TimeCreate']).'</td>'. 65 '<td>'.$Export['Title'].'</td>'. 66 '<td>'.$Export['OutputType'].'</td>'. 67 '<td><a href="'.$this->System->Link('/client-version/?action=item&id='.$Export['ClientVersionId']).'">'.$Export['ClientVersion'].'</a></td>'. 68 '<td>'.$Export['UsedCount'].'</td>'. 69 '<td>'.$Action.'</td></tr>'; 70 } 71 $Output .= '</table>'. 72 $PageList['Output']; 73 74 $Output .= '<div style="text-align: center;"><a href="'.$this->System->Link('/export/').'">Stránka exportů</a></div>'; 75 return($Output); 76 } 77 78 function ShowLastTranslated() 79 { 80 $Count = 20; 81 $Output = '<strong>Poslední překlady:</strong>'; 82 83 $GroupListQuery = 'SELECT `Group`.* FROM `Group`'; 84 $Query = ''; 85 $UnionItems = array(); 86 $DbResult = $this->Database->query($GroupListQuery); 87 if($DbResult->num_rows > 0) 88 { 89 while($DbRow = $DbResult->fetch_assoc()) 90 { 91 $UnionItems[] = 'SELECT `T`.`ID`, `T`.`Take`, `T`.`User`, `T`.`ModifyTime`, `T`.`Group`, `T`.`GroupName` '. 92 'FROM (SELECT `T`.`User`, `T`.`ID`, `T`.`ModifyTime`, '. 93 $DbRow['Id'].' AS `Group`, "'.addslashes($DbRow['Name']).'" AS `GroupName`, `T`.`Take` FROM `'. 94 $DbRow['TablePrefix'].'` AS `T` '. 95 'WHERE (`T`.`Complete` = 1) AND '. 96 '(`T`.`Language` != '.$this->System->Config['OriginalLanguage'].') AND '. 97 '(`T`.`User` = '.($_GET['user'] * 1).') ORDER BY `T`.`ModifyTime` DESC LIMIT '. 98 $Count.') AS `T`'; 99 } 100 $Query = 'SELECT `TT`.*, `User`.`Name` AS `UserName`, `User`.`Id` AS `UserId` '. 101 'FROM ('.implode(' UNION ', $UnionItems).') AS `TT` '. 102 'JOIN `User` ON `User`.`Id` = `TT`.`User` '. 103 'ORDER BY `ModifyTime` DESC LIMIT '.$Count; 104 $DbResult = $this->Database->query($Query); 105 $Output .= '<table class="BaseTable"><tr>'. 106 '<th>Datum</th><th>Nový</th><th>Zdroj</th><th>Skupina</th></tr>'; 107 while($DbRow = $DbResult->fetch_assoc()) 108 { 109 $Output .= '<tr><td>'.HumanDate($DbRow['ModifyTime']).'</td>'. 110 '<td><a href="form.php?group='.$DbRow['Group'].'&ID='.$DbRow['ID'].'">'.$DbRow['ID'].'</a></td>'. 111 '<td><a href="form.php?group='.$DbRow['Group'].'&ID='.$DbRow['Take'].'">'.$DbRow['Take'].'</a></td>'. 112 '<td><a href="TranslationList.php?group='.$DbRow['Group'].'&action=filter">'.$DbRow['GroupName'].'</a></td></tr>'; 113 } 114 $Output .= '</table>'; 115 } 116 return($Output); 117 } 118 119 function ShowLastForum() 120 120 { 121 121 $parser = new HTML_BBCodeParser2(array('filters' => array('Basic','Extended','Images','Links','Lists','Email'))); 122 123 124 125 126 127 128 129 130 131 } 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 122 $Count = 20; 123 $Output = '<strong>Poslední příspěvky ve fóru:</strong>'; 124 125 $Output .= '<div class="shoutbox">'; 126 $DbResult = $this->System->Database->query('SELECT `ForumText`.`Text`, `ForumText`.`Date`, `ForumText`.`UserName`,`ForumThread`.`Text` as `ThreadName`,`ForumText`.`Thread` FROM `ForumText` JOIN `ForumThread` ON `ForumThread`.`ID` = `ForumText`.`Thread` WHERE `ForumText`.`User` = '.($_GET['user'] * 1).' ORDER BY `ForumText`.`Date` DESC LIMIT '.$Count); 127 while($Line = $DbResult->fetch_assoc()) 128 $Output .= '<div><a href="'.$this->System->Link('/forum/?Thread='.$Line['Thread']).'">'.$Line['ThreadName'].'</a><br /><strong>'.$Line['UserName'].'</strong> ('.HumanDate($Line['Date']).'): '.$parser->qparse($Line['Text']).'</div> '; 129 $Output .= '</div>'; 130 return($Output); 131 } 132 133 function ShowProfile() 134 { 135 $Output = ''; 136 $Query = 'SELECT `User`.`Name`, `UserTrace`.`LastLogin`, `UserTrace`.`LastIP`, '. 137 '`User`.`Email`, `UserTrace`.`UserAgent`, `User`.`PreferredVersion`, '. 138 '`User`.`TranslatedCount`, `User`.`Team`, `User`.`ID`, `User`.`Info`, '. 139 '`Team`.`Name` AS `TeamName`, `Language`.`Name` AS `LanguageName`, '. 140 '`ClientVersion`.`Version` AS `Version` FROM `User` '. 141 'LEFT JOIN `UserTrace` ON `UserTrace`.`User` = `User`.`Id` '. 142 'LEFT JOIN `Language` ON `Language`.`Id` = `User`.`Language` '. 143 'LEFT JOIN `Team` ON `Team`.`Id` = `User`.`Team` '. 144 'LEFT JOIN `ClientVersion` ON `ClientVersion`.`Id` = `User`.`PreferredVersion` '. 145 'WHERE `User`.`Id` = '.($_GET['user'] * 1); 146 $DbResult = $this->Database->query($Query); 147 if($DbResult->num_rows > 0) 148 { 149 $UserLine = $DbResult->fetch_array(); 150 151 $Output .= 152 '<h3>Překladatel '.$UserLine['Name'].'</h3>'. 153 'Výchozí jazyk: <strong>'.$UserLine['LanguageName'].'</strong><br />'. 154 'Výchozí verze klienta: <a href="'.$this->System->Link('/client-version/?action=item&id='.$UserLine['PreferredVersion']).'"><strong>'.$UserLine['Version'].'</strong></a><br />'. 155 'Poslední připojení: <strong>'.HumanDateTime($UserLine['LastLogin']).'</strong><br />'. 156 'Počet přeložených: <a href="TranslationList.php?user='.$UserLine['ID'].'&state=2&group=0" title="Zobrazit Všechny jeho přeložené texty"><strong>'.$UserLine['TranslatedCount'].'</strong></a><br />'; 157 if($UserLine['TeamName'] != '') 158 $Output .= 'Člen týmu: <a href="team/?action=team&id='.$UserLine['Team'].'"><strong>'.$UserLine['TeamName'].'</strong></a><br />'; 159 //user tags 160 $Query = 'SELECT * FROM `UserTag` '. 161 161 'LEFT JOIN `UserTagType` ON `UserTagType`.`ID` = `UserTag`.`UserTagType` '. 162 162 'WHERE `User` = '.($_GET['user'] * 1); 163 163 $DbResult = $this->Database->query($Query); 164 164 if ($DbResult->num_rows != 0) { 165 165 $Output .= 'Překladatel se řídí těmito pravidly:<br />'; … … 174 174 $Output .= '<br /><fieldset><legend>Text profilu:</legend>'.str_replace("\n", '<br/>', $UserLine['Info']).'</fieldset><br/>'; 175 175 176 177 178 179 180 181 182 183 176 $Output .= '<table class="Home"><tr>'. 177 '<td>'.$this->ShowLastTranslated().'</td>'. 178 '<td>'.$this->ExportList().'</td>'. 179 '</tr></table>'; 180 $Output .= '<br />'.$this->ShowLastForum().'<br />'; 181 if($this->System->User->Licence(LICENCE_MODERATOR)) 182 { 183 $Output .= '<fieldset><legend>Moderování</legend>'; 184 184 185 185 $Output .= '<form action="?user='.($_GET['user'] * 1).'" method="post">Přidání tagu uživateli:<br />'; 186 187 186 $Query = 'SELECT * FROM UserTagType'; 187 $DbResult = $this->Database->query($Query); 188 188 while ($UserTag = $DbResult->fetch_array()) { 189 189 //save: 190 190 if (array_key_exists('save', $_POST)) { 191 191 if (array_key_exists('Tag'.$UserTag['ID'], $_POST)) { 192 192 $Query = 'SELECT * FROM `UserTag` '. 193 193 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($_GET['user']*1); 194 194 $DbResult2 = $this->Database->query($Query); 195 195 if ($DbResult2->num_rows == 0) { 196 196 $Query = 'INSERT INTO `UserTag` (`ID` ,`UserTagType`,`User` ) '. 197 197 'VALUES (NULL, '.$UserTag['ID'].' , '.($_GET['user']*1).')'; 198 198 $DbResult2 = $this->Database->query($Query); 199 199 } 200 200 } else { 201 201 $Query = 'DELETE FROM `UserTag` '. 202 202 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($_GET['user'] * 1); 203 203 $DbResult2 = $this->Database->query($Query); 204 204 } 205 205 } 206 206 207 207 $Query = 'SELECT * FROM `UserTag` '. 208 208 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($_GET['user'] * 1); 209 209 $DbResult2 = $this->Database->query($Query); 210 210 if ($DbResult2->num_rows != 0) $checked = true; 211 211 else $checked = false; … … 216 216 $Output .= '<input name="save" type="submit" value="Uložit" /></form>'; 217 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 218 $Output .= ' PosledníIP: <strong>'.$UserLine['LastIP'].'</strong><br />'. 219 'Prohlížeč: <strong>'.$UserLine['UserAgent'].'</strong><br />'. 220 'Email: <strong>'.$UserLine['Email'].'</strong><br />'; 221 $Output .= '<br/><form action="user.php" method="post"><div>'. 222 'Napsat E-mail:'. 223 '<input type="text" name="email" value="'.$UserLine['Email'].'" /><br/>'. 224 'Předmět:'. 225 '<input type="text" name="subject" value="'.$this->System->Config['Web']['Title'].'" />'. 226 '<br />'. 227 '<textarea name="text" rows="20" cols="62">'. 228 ''."\n". 229 'S pozdravem '.$this->System->User->Name."\n". 230 '--------------------------------------------------------'."\n". 231 $this->System->Config['Web']['Title'].' '.$this->System->Config['Web']['Host'].$this->System->Link('/')."\n". 232 '</textarea><br/>'. 233 '<input type="submit" value="Odeslat" />'. 234 '</div></form></fieldset>'; 235 } 236 } else $Output .= ShowMessage('Uživatel nenalezen', MESSAGE_CRITICAL); 237 return($Output); 238 } 239 240 function Show() 241 { 242 $this->Title = T('User profile'); 243 $Output = $this->SendMail(); 244 if(array_key_exists('user', $_GET)) 245 { 246 $Output .= $this->ShowProfile(); 247 } else $Output .= ShowMessage('Nevybrán uživatel', MESSAGE_CRITICAL); 248 return($Output); 249 } 250 250 } -
trunk/Modules/User/Registration.php
r801 r816 3 3 class PageUserRegistration extends Page 4 4 { 5 6 7 5 function ShowForm() 6 { 7 if(array_key_exists('sc', $_POST)) $Human = true; 8 8 else $Human = false; 9 10 11 12 13 14 15 16 9 if(array_key_exists('user', $_POST)) $UserName = $_POST['user']; 10 else $UserName = ''; 11 if(array_key_exists('Email', $_POST)) $Email = $_POST['Email']; 12 else $Email = ''; 13 if(array_key_exists('Team', $_POST)) $Team = $_POST['Team']; 14 else $Team = ''; 15 if(array_key_exists('Language', $_POST)) $Language = $_POST['Language']; 16 else $Language = 1; 17 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 18 $Output = '<form action="?" method="post"> 19 <fieldset><legend>'.T('New user registration').'</legend> 20 <table> 21 <tr><td colspan="2">Pozorně si přečtěte <a href="info.php">pokyny k překladu</a> a řiďte se jimi. Překládat je nutno včetně háčků a čárek!<br/><br/></td></tr> 22 <tr> 23 <td>Jsi člověk? </td>'; 24 if($Human) $Checked = ' checked="checked"'; 25 else $Checked = ''; 26 $Output .= '<td><input type="checkbox" name="sc" '.$Checked.'/></td> 27 </tr> 28 <tr> 29 <td>Jméno:</td> 30 <td><input type="text" name="user" value="'.$UserName.'"/></td> 31 </tr> 32 <tr> 33 <td>Heslo:</td> 34 <td><input type="password" name="pass" /></td> 35 </tr> 36 <tr> 37 <td>Potvrzení Hesla: </td> 38 <td><input type="password" name="pass2" /></td> 39 </tr> 40 <tr> 41 <td>Email: </td> 42 <td><input type="text" name="Email" value="'.$Email.'"/></td> 43 </tr> 44 <tr> 45 <td>Normálně budu překládat do: </td> 46 <td>'.WriteLanguages($Language).'</td> 47 </tr> 48 <tr> 49 <td>Patřím do týmu: </td>'; 50 if($Team == '') $Selected = ' selected="selected"'; 51 else $Selected = ''; 52 $Output .= '<td><select name="Team"><option value="0"'.$Selected.'>Žádného</option> 53 '; 54 $DbResult = $this->Database->query('SELECT `Name`, `Id` FROM `Team`'); 55 while($Line = $DbResult->fetch_assoc()) 56 { 57 if($Team == $Line['Id']) $Selected = ' selected="selected"'; 58 else $Selected = ''; 59 $Output .= '<option value="0'.$Line['Id'].'"'.$Selected.'>'.$Line['Name'].'</option>'; 60 } 61 $Output .= '</select></td> 62 </tr>'; 63 $Output .= '</td></tr>'. 64 '<tr><td>Upřednostněná verze klienta: </td><td>'.ClientVersionSelection('').'</td></tr>'; 65 65 66 66 $Output .= '<tr><td>'; 67 68 67 $Query = 'SELECT * FROM UserTagType'; 68 $DbResult = $this->Database->query($Query); 69 69 $Output .= 'Vyberte pravidla, kterými se při překladu chcete řídit:</td><td>'; 70 70 while ($UserTag = $DbResult->fetch_array()) { 71 71 $checked = false; 72 72 73 73 $Output .= CheckBox('Tag'.$UserTag['ID'], $checked, 'CheckBox'); … … 77 77 78 78 $Output .= '<tr> 79 80 81 82 83 79 <th><input type="submit" value="Registrovat" /></th> 80 </tr> 81 </table></fieldset></form>'; 82 return($Output); 83 } 84 84 85 85 function CheckRegistration() … … 157 157 } 158 158 159 160 161 162 163 164 159 function Show() 160 { 161 $this->Title = T('User registration'); 162 $Output = ''; 163 if(array_key_exists('user', $_POST)) 164 { 165 165 $Output .= $this->CheckRegistration(); 166 167 168 166 } else $Output .= $this->ShowForm(); 167 return($Output); 168 } 169 169 } -
trunk/Modules/User/User.php
r805 r816 8 8 class ModuleUser extends AppModule 9 9 { 10 11 12 13 14 15 16 17 18 19 20 21 22 23 10 function __construct($System) 11 { 12 parent::__construct($System); 13 $this->Name = 'User'; 14 $this->Version = '1.1'; 15 $this->Creator = 'Chronos'; 16 $this->License = 'GNU/GPL'; 17 $this->Description = 'User and permission management'; 18 $this->Dependencies = array(); 19 } 20 21 function Start() 22 { 23 $this->System->User = new User($this->System); 24 24 $this->System->RegisterPage('userlist.php', 'PageUserList'); 25 26 27 28 29 30 31 32 33 34 25 $this->System->RegisterPage('Options.php', 'PageUserOptions'); 26 $this->System->RegisterPage('registrace.php', 'PageUserRegistration'); 27 $this->System->RegisterPage('user.php', 'PageUserProfile'); 28 $this->System->RegisterPage('login', 'PageUserLogin'); 29 $this->System->RegisterMenuItem(array( 30 'Title' => T('Translators'), 31 'Hint' => 'Seznam registrovaných uživatelů', 32 'Link' => $this->System->Link('/userlist.php'), 33 'Permission' => LICENCE_ANONYMOUS, 34 'Icon' => '', 35 35 ), 0); 36 36 if(array_key_exists('Search', $this->System->ModuleManager->Modules)) 37 37 $this->System->ModuleManager->Modules['Search']->RegisterSearch('user', 38 38 T('Translators'), array('Name'), '`User`', $this->System->Link('/userlist.php?search=')); 39 40 41 42 43 44 39 } 40 41 function ShowOnlineList() 42 { 43 $Output = T('Online translators').':<br />'; 44 $DbResult = $this->System->Database->query('SELECT * FROM ('. 45 45 'SELECT `User`.`Name`, `User`.`ID` FROM `UserOnline` '. 46 47 48 49 50 51 52 53 54 55 46 'JOIN `User` ON `User`.`ID` = `UserOnline`.`User` '. 47 'WHERE (`ActivityTime` >= NOW() - 300) '. 48 'ORDER BY `ActivityTime` DESC ) AS `T` GROUP BY `Name`'); 49 while($DbUser = $DbResult->fetch_assoc()) 50 { 51 $Name = '<a href="'.$this->System->Link('/user.php?user='.$DbUser['ID']).'">'.$DbUser['Name'].'</a>'; 52 $Output .= $Name.'<br />'; 53 } 54 return($Output); 55 } 56 56 } 57 57 58 58 class PageUserLogin extends Page 59 59 { 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 60 function Show() 61 { 62 $Output = '<form action="'.$this->System->Link('/?action=login').'" method="post">'. 63 '<fieldset><legend>'.T('Login').'</legend> 64 <table> 65 <tr> 66 <td>'.T('Name').':</td><td><input type="text" name="LoginUser" size="13" /></td> 67 </tr> 68 <tr> 69 <td>'.T('Password').':</td><td><input type="password" name="LoginPass" size="13" /></td> 70 </tr> 71 <tr> 72 <td>'.T('Stay logged').':</td><td><input type="checkbox" name="StayLogged" /></td> 73 </tr> 74 <tr> 75 <th><input type="submit" value="'.T('Do login').'" /></th> 76 </tr> 77 </table> 78 </fieldset></form>'; 79 return($Output); 80 } 81 81 } 82 82 … … 114 114 function Login($Name, $Password, $StayLogged = false) 115 115 { 116 116 $SID = session_id(); 117 117 $DbResult = $this->Database->query('SELECT `ID` FROM `User` WHERE '. 118 118 'LOWER(`Name`) = LOWER("'.$Name.'") AND `Pass` = '.$this->CryptPasswordSQL('"'.$Password.'"', '`Salt`')); … … 147 147 function Logout() 148 148 { 149 149 $SID = session_id(); 150 150 if($this->Role != LICENCE_ANONYMOUS) 151 151 { … … 162 162 $DbResult = $this->Database->query('SELECT `User`.`PreferredVersion`,`User`.`ID`,`User`.`Team`,`User`.`Redirecting`,`User`.`Email`,`User`.`Info`,'. 163 163 '`User`.`Language`,`User`.`Name`,`User`.`GM`,`ClientVersion`.`Version` AS `PreferredVersionGame` FROM `User` '. 164 164 'LEFT JOIN `ClientVersion` ON `ClientVersion`.`Id` = `User`.`PreferredVersion` '. 165 165 'WHERE `User`.`ID` = '.$this->Id); 166 166 if($DbResult->num_rows > 0) … … 230 230 $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('ActivityTime' => 'NOW()')); 231 231 } else { 232 233 234 232 if(GetRemoteAddress() != '') $HostName = gethostbyaddr(GetRemoteAddress()); 233 else $HostName = ''; 234 $this->Database->insert('UserOnline', array('SessionId' => $SID, 235 235 'User' => null, 'LoginTime' => 'NOW()', 'ActivityTime' => 'NOW()', 236 236 'IpAddress' => GetRemoteAddress(), 'HostName' => $HostName, 237 237 'ScriptName' => GetRequestURI())); 238 238 } 239 239 240 240 // Logged permanently? 241 242 243 244 245 246 247 248 249 250 251 252 253 254 } 255 256 241 if(array_key_exists('LoginHash', $_COOKIE)) 242 { 243 $DbResult = $this->Database->query('SELECT * FROM `UserOnline` WHERE `User`='.$_COOKIE['LoginUserId']. 244 ' AND `StayLogged`=1 AND SessionId!="'.$SID.'"'); 245 if($DbResult->num_rows > 0) 246 { 247 $DbRow = $DbResult->fetch_assoc(); 248 if(sha1($_COOKIE['LoginUserId'].$DbRow['StayLoggedHash']) == $_COOKIE['LoginHash']) 249 { 250 $this->Database->query('DELETE FROM `UserOnline` WHERE `SessionId`="'.$SID.'"'); 251 $this->Database->query('UPDATE `UserOnline` SET `SessionId`="'.$SID.'" WHERE `Id`='.$DbRow['Id']); 252 } 253 } 254 } 255 256 // Check login 257 257 $Query = $this->Database->select('UserOnline', '*', '`SessionId`="'.$SID.'"'); 258 258 $Row = $Query->fetch_assoc(); 259 259 if($Row['User'] != '') 260 260 { 261 261 $this->Id = $Row['User']; 262 262 $this->Load(); 263 263 } else -
trunk/Modules/User/UserList.php
r637 r816 5 5 class PageUserList extends Page 6 6 { 7 8 9 10 11 12 13 14 15 16 17 18 19 20 } else $SearchQuery = ''; 7 function Show() 8 { 9 $this->Title = T('Translators'); 10 ImgLevelUpdate(); 11 12 $Output = ''; 13 if(array_key_exists('search', $_GET)) $_SESSION['search'] = $_GET['search']; 14 else if(!array_key_exists('search', $_SESSION)) $_SESSION['search'] = ''; 15 if(array_key_exists('search', $_GET) and ($_GET['search'] == '')) $_SESSION['search'] = ''; 16 if($_SESSION['search'] != '') 17 { 18 $SearchQuery = ' AND (`User`.`Name` LIKE "%'.$_SESSION['search'].'%")'; 19 $Output .= '<div><a href="?search=">'.sprintf(T('Disable filter "%s"'), $_SESSION['search']).'</a></div>'; 20 } else $SearchQuery = ''; 21 21 22 22 $TeamFilter = ''; 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 $Output .= $Order['Output']; 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 } 23 if(array_key_exists('team', $_GET)) 24 { 25 $TeamId = $_GET['team'] * 1; 26 $DbResult = $this->Database->select('Team', 'Name', 'Id='.$TeamId); 27 if($DbResult->num_rows > 0) 28 { 29 $Team = $DbResult->fetch_assoc(); 30 $Output .= '<h3>'.sprintf(T('Users in team %s'), $Team['Name']).'</h3>'; 31 $TeamFilter = ' AND (`Team`='.$_GET['team'].')'; 32 } else { 33 $Output .= ShowMessage(sprintf(T('Team %d not found'), $TeamId), MESSAGE_CRITICAL); 34 } 35 } else 36 { 37 $Output .= '<h3>'.T('User list').'</h3>'; 38 } 39 40 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `User` WHERE 1'.$SearchQuery.$TeamFilter); 41 $DbRow = $DbResult->fetch_row(); 42 $PageList = GetPageList($DbRow[0]); 43 44 $Output .= $PageList['Output']. 45 '<table class="BaseTable">'; 46 47 $TableColumns = array( 48 array('Name' => 'Name', 'Title' => T('Name')), 49 array('Name' => 'TranslatedCount', 'Title' => T('Translated count')), 50 array('Name' => 'XP', 'Title' => T('Level')), 51 array('Name' => 'XP', 'Title' => T('Experience')), 52 //array('Name' => 'GM', 'Title' => T('GM')), 53 array('Name' => 'LastLogin', 'Title' => T('Last logged in')), 54 array('Name' => 'RegistrationTime', 'Title' => T('Registration time')), 55 ); 56 $Order = GetOrderTableHeader($TableColumns, 'TranslatedCount', 1); 57 $Output .= $Order['Output']; 58 59 $Query = 'SELECT `User`.`ID`, `User`.`Name`, `LastLogin`, `GM`, `XP`, `TranslatedCount`, `RegistrationTime` '. 60 'FROM `User` '. 61 'LEFT JOIN `UserTrace` ON `UserTrace`.`User` = `User`.`Id` '. 62 'WHERE 1'.$SearchQuery.$TeamFilter.$Order['SQL'].$PageList['SQLLimit']; 63 64 $DbResult = $this->Database->query($Query); 65 while($Line = $DbResult->fetch_assoc()) 66 { 67 $XP = GetLevelMinMax($Line['XP']); 68 $Output .= '<tr><td><a href="user.php?user='.$Line['ID'].'">'.$Line['Name'].'</a></td>'. 69 '<td style="text-align: center;"><a href="TranslationList.php?user='.$Line['ID'].'&group=0&state=2" title="Zobrazit Všechny jeho přeložené texty">'.$Line['TranslatedCount'].'</a></td>'. 70 '<td>'.$XP['Level'].'</td>'. 71 '<td>'.ProgressBar(150, round($XP['XP'] / $XP['MaxXP'] * 100, 2), $XP['XP'].' / '.$XP['MaxXP']).'</td>'. 72 //<td>'.$Moderators[$Line['GM']].'</td> 73 '<td>'.HumanDate($Line['LastLogin']).'</td>'. 74 '<td>'.HumanDate($Line['RegistrationTime']).'</td></tr>'; 75 } 76 $Output .= '</table>'. 77 $PageList['Output']; 78 79 return($Output); 80 } 81 81 } -
trunk/Modules/Wiki/Wiki.php
r609 r816 13 13 $this->Dependencies = array(); 14 14 } 15 15 16 16 function Install() 17 17 { … … 22 22 { 23 23 parent::UnInstall(); 24 } 25 24 } 25 26 26 function Start() 27 27 { … … 29 29 $this->LoadPages(); 30 30 } 31 31 32 32 function Stop() 33 33 { 34 35 } 36 34 parent::Stop(); 35 } 36 37 37 function LoadPages() 38 38 { 39 40 41 42 43 44 45 46 47 48 49 50 39 $DbResult = $this->Database->select('WikiPage', '*', 'VisibleInMenu=1'); 40 while($DbRow = $DbResult->fetch_assoc()) 41 { 42 $this->System->RegisterPage($DbRow['NormalizedName'], 'PageWiki'); 43 $this->System->RegisterMenuItem(array( 44 'Title' => $DbRow['Name'], 45 'Hint' => '', 46 'Link' => $this->System->Link('/'.$DbRow['NormalizedName'].'/'), 47 'Permission' => LICENCE_ANONYMOUS, 48 'Icon' => '', 49 ), 6); 50 } 51 51 } 52 52 } … … 54 54 class PageWiki extends Page 55 55 { 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 } else 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 $Output = ShowMessage('Wiki stránka uložena', MESSAGE_INFORMATION); 141 142 143 144 145 146 147 148 149 { 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 '<td><a href="'.$this->System->Link('/user.php?user='.$PageContent['User']).'">'.$PageContent['UserName'].'</a></td>'.183 184 185 } 186 187 188 189 190 191 192 193 194 56 function Show() 57 { 58 if(array_key_exists('Action', $_GET)) 59 { 60 if($_GET['Action'] == 'Edit') $Output = $this->EditContent(); 61 else if($_GET['Action'] == 'EditSave') $Output = $this->SaveContent(); 62 else if($_GET['Action'] == 'History') $Output = $this->ShowHistory(); 63 else $Output = $this->ShowContent(); 64 } else $Output = $this->ShowContent(); 65 return($Output); 66 } 67 68 function ShowContent() 69 { 70 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; 71 $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); 72 if($DbResult->num_rows > 0) 73 { 74 $DbRow = $DbResult->fetch_assoc(); 75 if(array_key_exists('ver', $_GET)) 76 { 77 $DbResult2 = $this->Database->select('WikiPageContent', '*', 'Page='.$DbRow['Id'].' AND Id='.$_GET['ver']*1); 78 if($DbResult2->num_rows > 0) 79 { 80 $DbRow2 = $DbResult2->fetch_assoc(); 81 $Output = '<h3>Archív stránky '.$DbRow['Name'].' ('.HumanDateTime($DbRow2['Time']).')</h3>'; 82 $Output .= $DbRow2['Content']; 83 if($this->System->User->Licence(LICENCE_MODERATOR)) 84 $Output .= '<div><a href="?Action=Edit">Upravit nejnovější</a> <a href="?Action=History">Historie</a></div>'; 85 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 86 } else 87 { 88 $DbResult2 = $this->Database->select('WikiPageContent', '*', 'Page='.$DbRow['Id'].' ORDER BY Time DESC LIMIT 1'); 89 if($DbResult2->num_rows > 0) 90 { 91 $DbRow2 = $DbResult2->fetch_assoc(); 92 $Output = '<h3>'.$DbRow['Name'].'</h3>'; 93 $Output .= $DbRow2['Content']; 94 if($this->System->User->Licence(LICENCE_MODERATOR)) 95 $Output .= '<hr><div><a href="?Action=Edit">Upravit</a> <a href="?Action=History">Historie</a></div>'; 96 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 97 } 98 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 99 return($Output); 100 } 101 102 function EditContent() 103 { 104 if($this->System->User->Licence(LICENCE_MODERATOR)) 105 { 106 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; 107 $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); 108 if($DbResult->num_rows > 0) 109 { 110 $DbRow = $DbResult->fetch_assoc(); 111 $Output = '<h3>Úprava '.$DbRow['Name'].'</h3>'; 112 $DbResult2 = $this->Database->select('WikiPageContent', '*', 'Page='.$DbRow['Id'].' ORDER BY Time DESC LIMIT 1'); 113 if($DbResult2->num_rows > 0) 114 { 115 $DbRow2 = $DbResult2->fetch_assoc(); 116 $Output .= '<form action="?Action=EditSave" method="post">'. 117 '<textarea name="content" rows="8" cols="80" onkeydown="ResizeTextArea(this)" class="textedit">'.$DbRow2['Content'].'</textarea><br/>'. 118 '<input type="submit" name="save" value="Uložit"/> '. 119 '<input type="button" name="cancel" value="Zrušit" onclick="location.href=\'?\'"/>'. 120 '</form>'; 121 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 122 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 123 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 124 return($Output); 125 } 126 127 function SaveContent() 128 { 129 if($this->System->User->Licence(LICENCE_MODERATOR)) 130 { 131 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; 132 $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); 133 if($DbResult->num_rows > 0) 134 { 135 $DbRow = $DbResult->fetch_assoc(); 136 if(array_key_exists('content', $_POST) and array_key_exists('save', $_POST)) 137 { 138 $DbResult2 = $this->Database->insert('WikiPageContent', array('Content' => stripslashes($_POST['content']), 139 'User' => $this->System->User->Id, 'Time' => 'NOW()', 'Page' => $DbRow['Id'])); 140 $Output = ShowMessage('Wiki stránka uložena', MESSAGE_INFORMATION); 141 } else $Output = ShowMessage('Nezadána platná data', MESSAGE_CRITICAL); 142 $Output .= $this->ShowContent(); 143 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 144 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 145 return($Output); 146 } 147 148 function ShowHistory() 149 { 150 if($this->System->User->Licence(LICENCE_MODERATOR)) 151 { 152 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; 153 $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); 154 if($DbResult->num_rows > 0) 155 { 156 $DbRow = $DbResult->fetch_assoc(); 157 158 $Output = '<h3>Historie stránky '.$DbRow['Name'].'</h3>'; 159 $DbResult2 = $this->Database->query('SELECT COUNT(*) FROM `WikiPageContent` WHERE Page='.$DbRow['Id']); 160 $DbRow2 = $DbResult2->fetch_row(); 161 $PageList = GetPageList($DbRow2[0]); 162 163 $Output .= $PageList['Output']; 164 $Output .= '<table class="BaseTable">'; 165 166 $TableColumns = array( 167 array('Name' => 'Time', 'Title' => 'Čas'), 168 array('Name' => 'User', 'Title' => 'Uživatel'), 169 array('Name' => 'Action', 'Title' => 'Akce'), 170 ); 171 172 $Order = GetOrderTableHeader($TableColumns, 'Time', 1); 173 $Output .= $Order['Output']; 174 175 $DbResult2 = $this->Database->query('SELECT *, (SELECT `Name` FROM `User` WHERE `User`.`ID`=`WikiPageContent`.`User`) AS `UserName` '. 176 ' FROM `WikiPageContent` WHERE Page='. 177 $DbRow['Id'].' '.$Order['SQL'].$PageList['SQLLimit']); 178 while($PageContent = $DbResult2->fetch_assoc()) 179 { 180 $Output .= '<tr>'. 181 '<td>'.HumanDateTime($PageContent['Time']).'</td>'. 182 '<td><a href="'.$this->System->Link('/user.php?user='.$PageContent['User']).'">'.$PageContent['UserName'].'</a></td>'. 183 '<td><a href="?id='.$PageContent['Id'].'&ver='.$PageContent['Id'].'">Zobrazit</a></td>'; 184 $Output .= '</tr>'; 185 } 186 187 $Output .= '</table>'. 188 $PageList['Output']; 189 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 190 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 191 return($Output); 192 } 193 194 function ToHtml($text) 195 195 { 196 196 $text = preg_replace('/<source lang="(.*?)">(.*?)<\/source>/', '<pre lang="$1">$2</pre>', $text);
Note:
See TracChangeset
for help on using the changeset viewer.