Changeset 560 for trunk/Modules/Export
- Timestamp:
- Aug 13, 2013, 10:47:43 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Export/Page.php
r558 r560 5 5 class PageExport extends Page 6 6 { 7 function ExportList()8 {9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 $PageList = GetPageList($DbRow[0]); 28 29 30 31 32 33 array('Name' => 'TimeCreate', 'Title' => 'Čas vytvoření'), 34 array('Name' => 'UserName', 'Title' => 'Překladatel'), 35 array('Name' => 'Title', 'Title' => 'Označení'), 36 // array('Name' => 'UserCount', 'Title' => 'Vybraných překladatelů'), 37 // array('Name' => 'GroupCount', 'Title' => 'Překladových skupin'), 38 array('Name' => 'OutputType', 'Title' => 'Typ výstupu'), 39 array('Name' => 'ClientVersion', 'Title' => 'Verze klienta'), 40 array('Name' => 'UsedCount', 'Title' => 'Prohlédnutí výstupu'), 41 array('Name' => '', 'Title' => 'Akce'), 42 ); 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 if($User->Licence(LICENCE_USER)) 64 65 66 }67 68 function ExportCreate()69 {70 71 72 73 { 74 75 76 77 78 79 80 81 82 83 84 85 86 87 }88 89 function ExportCreateFinish()90 {91 92 93 94 { 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 }112 113 function ExportDelete()114 {115 116 117 118 { 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 }136 137 function ExportViewTranslators()138 {139 140 141 142 143 144 145 if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true; 146 else $Editable = false; 147 148 149 150 151 152 153 154 155 156 if(substr($Index, 0, 3) == 'seq') 157 158 159 if(array_key_exists('sel'.$UserId, $_POST)) $Selected = true; 160 161 162 163 164 165 166 167 168 169 170 } 171 172 173 174 175 176 177 178 179 180 181 182 array('Name' => 'Name', 'Title' => 'Jméno'), 183 array('Name' => 'TranslatedCount', 'Title' => 'Překladů'), 184 array('Name' => 'XP', 'Title' => 'Úroveň'), 185 array('Name' => 'XP', 'Title' => 'Zkušenost'), 186 array('Name' => '', 'Title' => 'Výběr'), 187 array('Name' => 'Sequence2', 'Title' => 'Pořadí'), 188 ); 189 190 191 192 193 194 195 196 197 198 199 $PageList = GetPageList($DbRow[0]); 200 201 202 203 204 205 206 207 208 '<br />'. 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 function ExportViewGeneral()240 {241 242 243 244 245 246 247 248 if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true; 249 250 251 252 253 254 if(array_key_exists('WithDiacritic', $_POST)) $WithDiacritic = 1; 255 256 257 258 259 260 261 262 263 if($Export['WithDiacritic'] == 1) $WithDiacritic = ' checked="checked"'; 264 265 266 267 268 { 269 270 271 272 273 274 275 276 277 }278 279 function ExportViewLanguages()280 {281 282 283 284 285 286 287 if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true; 288 289 290 291 292 293 294 295 296 297 298 if(substr($Index, 0, 3) == 'seq') 299 300 301 if(array_key_exists('sel'.$LanguageId, $_POST)) $Selected = true; 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 $PageList = GetPageList($DbRow[0]); 330 331 332 array('Name' => 'Name', 'Title' => 'Název'), 333 array('Name' => '', 'Title' => 'Výběr'), 334 array('Name' => 'Sequence2', 'Title' => 'Pořadí'), 335 ); 336 337 338 339 340 341 342 343 '<br />'. 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 function ExportViewGroups()371 {372 373 374 375 376 377 378 if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true; 379 380 381 382 383 384 385 386 387 388 389 if(substr($Index, 0, 3) == 'seq') 390 391 392 if(array_key_exists('sel'.$GroupId, $_POST)) $Selected = true; 393 394 395 396 397 398 399 400 401 402 } 403 404 405 406 407 408 409 410 411 412 413 $PageList = GetPageList($DbRow[0]); 414 415 416 array('Name' => 'Name', 'Title' => 'Jméno'), 417 array('Name' => 'MangosTable', 'Title' => 'Tabulka MaNGOSu'), 418 array('Name' => 'DBCFileName', 'Title' => 'DBC soubor'), 419 array('Name' => 'LuaFileName', 'Title' => 'Lua soubor'), 420 array('Name' => '', 'Title' => 'Výběr'), 421 ); 422 423 424 425 426 427 428 429 430 '<br />'. 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 }456 457 function ExportViewOutputFormat()458 {459 460 461 462 463 464 465 466 467 { 468 469 if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true; 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 function ExportViewVersion()502 {503 504 505 506 507 508 509 if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true; 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 $PageList = GetPageList($DbRow[0]); 529 530 531 array('Name' => 'Version', 'Title' => 'Verze'), 532 array('Name' => 'BuildNumber', 'Title' => 'Sestavení'), 533 array('Name' => 'ReleaseDate', 'Title' => 'Datum uvolnění'), 534 array('Name' => 'Title', 'Title' => 'Titutek'), 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 function ExportViewOutput()571 {572 573 574 575 576 577 578 579 580 581 582 583 { 584 585 586 587 588 589 590 }591 592 function ExportViewStat()593 {594 595 596 597 598 599 600 601 if(($Export->Export['ClientVersion'] == '') or ($Export->ClientVersion['BuildNumber'] == '')) 602 603 604 $GroupListQuery = 'SELECT `Group`.* FROM `Group` '.605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 $PageList = GetPageList($DbRow[0]); 627 628 629 630 631 632 array('Name' => 'Name', 'Title' => 'Jméno'), 633 array('Name' => 'Translated', 'Title' => 'Přeložených'), 634 array('Name' => 'Total', 'Title' => 'Anglických'), 635 array('Name' => 'Percent', 'Title' => 'Procenta'), 636 637 638 639 640 641 642 643 644 645 646 while($Group = $ID->fetch_assoc()) 647 648 649 650 651 652 653 654 655 656 657 658 659 660 }661 662 function ExportView()663 {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 7 function ExportList() 8 { 9 global $User; 10 11 $Output = '<a href="?Action=ViewList">Všechny</a>'; 12 if($User->Licence(LICENCE_USER)) 13 { 14 $Output .= ' <a href="?Action=ViewList&Filter=Others">Ostatních</a>'. 15 ' <a href="?Action=ViewList&Filter=My">Moje</a>'; 16 } 17 18 $Filter = ''; 19 if(array_key_exists('Filter', $_GET)) 20 { 21 if($_GET['Filter'] == 'My') $Filter = ' WHERE `Export`.`User` = '.$User->Id; 22 if($_GET['Filter'] == 'Others') $Filter = ' WHERE `Export`.`User` != '.$User->Id; 23 } 24 25 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` '.$Filter); 26 $DbRow = $DbResult->fetch_row(); 27 $PageList = GetPageList($DbRow[0]); 28 29 $Output .= '<h3>Seznam exportů</h3>'. 30 $PageList['Output']; 31 32 $TableColumns = array( 33 array('Name' => 'TimeCreate', 'Title' => 'Čas vytvoření'), 34 array('Name' => 'UserName', 'Title' => 'Překladatel'), 35 array('Name' => 'Title', 'Title' => 'Označení'), 36 // array('Name' => 'UserCount', 'Title' => 'Vybraných překladatelů'), 37 // array('Name' => 'GroupCount', 'Title' => 'Překladových skupin'), 38 array('Name' => 'OutputType', 'Title' => 'Typ výstupu'), 39 array('Name' => 'ClientVersion', 'Title' => 'Verze klienta'), 40 array('Name' => 'UsedCount', 'Title' => 'Prohlédnutí výstupu'), 41 array('Name' => '', 'Title' => 'Akce'), 42 ); 43 $Order = GetOrderTableHeader($TableColumns, 'TimeCreate', 1); 44 $Output .= '<table class="BaseTable">'. 45 $Order['Output']; 46 47 $DbResult = $this->System->Database->query('SELECT `User`.`Name` AS `UserName`, `Export`.`Id`, `Export`.`TimeCreate`, `Export`.`Title`, `Export`.`User`, `Export`.`UsedCount`, (SELECT Version FROM `ClientVersion` WHERE `ClientVersion`.`Id`=`Export`.`ClientVersion`) AS `ClientVersion`,(SELECT Name FROM `ExportOutputType` WHERE `ExportOutputType`.`Id`=`Export`.`OutputType`) AS `OutputType`, (SELECT COUNT(*) FROM `ExportGroup` WHERE `ExportGroup`.`Export`=`Export`.`Id`) AS `GroupCount`, (SELECT COUNT(*) FROM `ExportUser` WHERE `ExportUser`.`Export`=`Export`.`Id`) AS `UserCount` FROM `Export` LEFT JOIN `User` ON `User`.`ID`=`Export`.`User` '.$Filter.$Order['SQL'].$PageList['SQLLimit']); 48 while($Export = $DbResult->fetch_assoc()) 49 { 50 $Action = '<a href="?Action=View&ExportId='.$Export['Id'].'&Tab=0">Zobrazit</a> <a href="?Action=View&ExportId='.$Export['Id'].'&Tab=7">Exportovat</a>'; 51 if($Export['User'] == $User->Id) $Action .= ' <a href="?Action=Delete&ExportId='.$Export['Id'].'" onclick="return confirmAction(\'Opravdu smazat položku?\');">Smazat</a>'; 52 $Output .= '<tr><td>'.HumanDate($Export['TimeCreate']).'</td>'. 53 '<td><a href="'.$this->System->Link('/user.php?user='.$Export['User']).'">'.$Export['UserName'].'</a></td>'. 54 '<td>'.$Export['Title'].'</td>'. 55 '<td>'.$Export['OutputType'].'</td>'. 56 '<td>'.$Export['ClientVersion'].'</td>'. 57 '<td>'.$Export['UsedCount'].'</td>'. 58 '<td>'.$Action.'</td></tr>'; 59 } 60 $Output .= '</table>'. 61 $PageList['Output']; 62 63 if($User->Licence(LICENCE_USER)) 64 $Output .= '<br/><div style="text-align: center;"><a href="?Action=Create">Vytvořit nový export</a></div>'; 65 return($Output); 66 } 67 68 function ExportCreate() 69 { 70 global $User; 71 72 if($User->Licence(LICENCE_USER)) 73 { 74 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$User->Id); 75 $DbRow = $DbResult->fetch_row(); 76 if($DbRow[0] < $this->System->Config['MaxExportPerUser']) 77 { 78 $Output = '<form action="?Action=CreateFinish" method="post">'. 79 '<fieldset><legend>Vytvoření nového exportu</legend>'. 80 '<table><tr><td>Označení:</td><td><input type="text" name="Title" /></td></tr>'. 81 '<tr><td>Popis:</td><td><textarea name="Description" cols="54" rows="10"></textarea></td></tr>'. 82 '<tr><td colspan="2"><input type="submit" value="Vytvořit" /></td></tr>'. 83 '</table></fieldset></form>'; 84 } else $Output = ShowMessage('Nemůžete vytvářet další export. Max. počet na uživatele je '.$this->System->Config['MaxExportPerUser'].'.', MESSAGE_CRITICAL); 85 } else $Output = ShowMessage('Nemáte oprávnění.', MESSAGE_CRITICAL); 86 return($Output); 87 } 88 89 function ExportCreateFinish() 90 { 91 global $User; 92 93 if($User->Licence(LICENCE_USER)) 94 { 95 if(array_key_exists('Title', $_POST) and array_key_exists('Description', $_POST)) 96 { 97 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$User->Id); 98 $DbRow = $DbResult->fetch_row(); 99 if($DbRow[0] < $this->System->Config['MaxExportPerUser']) 100 { 101 $this->System->Database->query('INSERT INTO `Export` (`Title`, `User`, `TimeCreate`, `WithDiacritic`, `Description`) VALUES ("'.$_POST['Title'].'", '.$User->Id.', NOW(), 1, "'.$_POST['Description'].'")'); 102 $ExportId = $this->System->Database->insert_id; 103 $Output = ShowMessage('Nový export vytvořen.<br/>Přímý odkaz na tento export: <a href="?Action=View&ExportId='.$ExportId.'">zde</a>'); 104 WriteLog('Vytvořen nový export <a href="'.$this->System->Link('/export/?Action=View&ExportId='.$ExportId).'">'.$ExportId.'</a>.', LOG_TYPE_EXPORT); 105 $_GET['Filter'] = 'my'; 106 ExportList(); 107 } else $Output = ShowMessage('Nemůžete vytvářet další export. Max. počet na uživatele je '.$this->System->Config['MaxExportPerUser'].'.', MESSAGE_CRITICAL); 108 } else $Output = ShowMessage('Chybí údaje formuláře.', MESSAGE_CRITICAL); 109 } else $Output = ShowMessage('Nemáte oprávnění.', MESSAGE_CRITICAL); 110 return($Output); 111 } 112 113 function ExportDelete() 114 { 115 global $User; 116 117 if($User->Licence(LICENCE_USER)) 118 { 119 $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE (`Id`='.($_GET['ExportId'] * 1).') AND (`User`='.$User->Id.')'); 120 if($DbResult->num_rows > 0) 121 { 122 $this->System->Database->query('DELETE FROM `ExportGroup` WHERE `Export`='.$_GET['ExportId']); 123 $this->System->Database->query('DELETE FROM `ExportLanguage` WHERE `Export`='.$_GET['ExportId']); 124 $this->System->Database->query('DELETE FROM `ExportTask` WHERE `Export`='.$_GET['ExportId']); 125 $this->System->Database->query('DELETE FROM `ExportUser` WHERE `Export`='.$_GET['ExportId']); 126 $this->System->Database->query('DELETE FROM `Export` WHERE `Id`='.$_GET['ExportId']); 127 DeleteDirectory('../tmp/Export/'.$_GET['ExportId'].'/'); 128 $Output = ShowMessage('Export smazán.'); 129 $_GET['Filter'] = 'my'; 130 WriteLog('Smazán export '.$_GET['ExportId'], LOG_TYPE_EXPORT); 131 $Output .= ExportList(); 132 } else $Output = ShowMessage('Export nenalezen.', MESSAGE_CRITICAL); 133 } else $Output = ShowMessage('Nemáte oprávnění.', MESSAGE_CRITICAL); 134 return($Output); 135 } 136 137 function ExportViewTranslators() 138 { 139 global $TranslationTree, $User; 140 141 $Output = ''; 142 $DisabledInput = array(false => ' disabled="disabled"', true => ''); 143 $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']); 144 $Export = $DbResult->fetch_assoc(); 145 if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true; 146 else $Editable = false; 147 148 if(array_key_exists('Operation', $_POST)) 149 { 150 if($_POST['Operation'] == 'Save') 151 { 152 //print_r($_POST); 153 // Update user selection page 154 foreach($_POST as $Index => $Value) 155 { 156 if(substr($Index, 0, 3) == 'seq') 157 { 158 $UserId = substr($Index, 3) * 1; 159 if(array_key_exists('sel'.$UserId, $_POST)) $Selected = true; 160 else $Selected = false; 161 $Condition = ' WHERE `Export`='.$_GET['ExportId'].' AND `User`='.$UserId; 162 $DbResult = $this->System->Database->query('SELECT * FROM `ExportUser` '.$Condition); 163 if($DbResult->num_rows > 0) 164 { 165 if(!$Selected) $this->System->Database->query('DELETE FROM `ExportUser` '.$Condition); 166 else $this->System->Database->query('UPDATE `ExportUser` SET `Sequence`='.$Value.$Condition); 167 } else 168 { 169 if($Selected) $this->System->Database->query('INSERT INTO `ExportUser` (`Export`, `User`, `Sequence`) VALUES ('.$_GET['ExportId'].', '.$UserId.', '.$Value.')'); 170 } 171 } 172 } 173 174 // Recalculate sequence number 175 $this->System->Database->query('SET @I = 0'); 176 $this->System->Database->query('UPDATE `ExportUser` SET `Sequence` = (@I := @I + 1) WHERE `Export`='.$_GET['ExportId'].' ORDER BY `Sequence`;'); 177 $Output .= ShowMessage('Výběr uložen.'); 178 } 179 } 180 181 $TableColumns = array( 182 array('Name' => 'Name', 'Title' => 'Jméno'), 183 array('Name' => 'TranslatedCount', 'Title' => 'Překladů'), 184 array('Name' => 'XP', 'Title' => 'Úroveň'), 185 array('Name' => 'XP', 'Title' => 'Zkušenost'), 186 array('Name' => '', 'Title' => 'Výběr'), 187 array('Name' => 'Sequence2', 'Title' => 'Pořadí'), 188 ); 189 $Order = GetOrderTableHeader($TableColumns, 'TranslatedCount', 1); 190 if($Order['Column'] != 'Sequence2') $InitialOrder = ', '.substr($Order['SQL'], 10); 191 else $InitialOrder = ''; 192 193 $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'; 194 $Query .=' LEFT JOIN `ExportUser` ON `ExportUser`.`Export` = '.$_GET['ExportId'].' AND `ExportUser`.`User`=`T`.`ID`'; 195 $Query .=' WHERE `T`.`TranslatedCount` > 0 ORDER BY COALESCE(`ExportUser`.`Sequence`, 100000000)'.$InitialOrder.') AS `TT`'; 196 197 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS `X`'); 198 $DbRow = $DbResult->fetch_row(); 199 $PageList = GetPageList($DbRow[0]); 200 201 $Output .= '<form name="Translators" action="?Action=View&ExportId='.$_GET['ExportId'].'" method="post">'. 202 '<h3>Překladatelé</h3>'; 203 if($Editable) 204 { 205 $Output .= '<input type="submit" value="Uložit" '.$DisabledInput[$Editable].'/>'. 206 '<input type="hidden" name="Operation" value="Save"/>'. 207 ' <span onclick="CheckAllCheckbox();">'.CheckBox('CheckAll', False, 'CheckAll').' Zatrhnout vše</span> '. 208 '<br />'. 209 'Zvolte ze seznamu uživatele, od kterých chcete načítat překlady a upravte jejich pořadí.<br />'. 210 'Pořadí řádků je dáno číselnou hodnotou, kterou lze změnit na požadované pořadí. Řádky se stejným pořadovým číslem budou přečíslovány vzestupně.'; 211 } 212 213 $Output .= $PageList['Output']. 214 '<table class="BaseTable">'. 215 $Order['Output']; 216 217 $Query = 'SELECT * FROM ('.$Query.') AS `TX` '.$Order['SQL'].$PageList['SQLLimit']; 218 $this->System->Database->query('SET @I = 0'); 219 $DbResult = $this->System->Database->query($Query); 220 while($UserLine = $DbResult->fetch_assoc()) 221 { 222 $XP = GetLevelMinMax($UserLine['XP']); 223 $Checked = $UserLine['Sequence'] != ''; 224 $Selection = CheckBox('sel'.$UserLine['ID'], $Checked, '', 'CheckBox', !$Editable); 225 $Sequence = '<input type="text" name="seq'.$UserLine['ID'].'" style="text-align: center; width: 40px;" value="'.$UserLine['Sequence2'].'"'.$DisabledInput[$Editable].'/>'; 226 $Output .= '<tr>'. 227 '<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>'. 228 '<td>'.$UserLine['TranslatedCount'].'</td>'. 229 '<td>'.$XP['Level'].'</td>'. 230 '<td>'.ProgressBar(150, round($XP['XP'] / $XP['MaxXP'] * 100, 2), $XP['XP'].' / '.$XP['MaxXP']).'</td>'. 231 '<td>'.$Selection.'</td><td>'.$Sequence.'</td></tr>'; 232 } 233 $Output .= '</table>'. 234 '</form>'. 235 $PageList['Output']; 236 return($Output); 237 } 238 239 function ExportViewGeneral() 240 { 241 global $User; 242 243 $DisabledInput = array(false => ' disabled="disabled"', true => ''); 244 $DisabledTextArea = array(false => ' readonly="yes"', true => ''); 245 $Output = '<h3>Obecná nastavení</h3>'; 246 $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']); 247 $Export = $DbRows->fetch_assoc(); 248 if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true; 249 else $Editable = false; 250 251 if(array_key_exists('Operation', $_POST)) 252 if($_POST['Operation'] == 'Save') if($Editable and array_key_exists('Title', $_POST) and array_key_exists('Description', $_POST)) 253 { 254 if(array_key_exists('WithDiacritic', $_POST)) $WithDiacritic = 1; 255 else $WithDiacritic = 0; 256 $this->System->Database->query('UPDATE `Export` SET `Title`="'.$_POST['Title'].'", `Description`="'.$_POST['Description'].'", `WithDiacritic`='.$WithDiacritic.' WHERE Id='.$Export['Id']); 257 $Export['Title'] = $_POST['Title']; 258 $Export['Description'] = $_POST['Description']; 259 $Export['WithDiacritic'] = $WithDiacritic; 260 $Output .= ShowMessage('Nastavení uloženo.'); 261 } 262 263 if($Export['WithDiacritic'] == 1) $WithDiacritic = ' checked="checked"'; 264 else $WithDiacritic = ''; 265 $Output .= '<form action="?Action=View&Tab=0&ExportId='.$Export['Id'].'" method="post">'. 266 '<table>'; 267 if($Editable) 268 { 269 $Output .= '<input type="hidden" name="Operation" value="Save"/>'. 270 '<tr><td colspan="2"><input type="submit" value="Uložit" '.$DisabledInput[$Editable].'/></td></tr>'; 271 } 272 $Output .= '<tr><td>Označení:</td><td><input type="text" style="width: 400px" name="Title" value="'.$Export['Title'].'"'.$DisabledInput[$Editable].'/></td></tr>'. 273 '<tr><td>Popis:</td><td><textarea name="Description" cols="54" rows="10"'.$DisabledTextArea[$Editable].'>'.$Export['Description'].'</textarea></td></tr>'. 274 '<tr><td>Včetně háčků a čárek</td><td><input type="checkbox" name="WithDiacritic" '.$WithDiacritic.''.$DisabledInput[$Editable].'/></td></tr>'. 275 '</table></form>'; 276 return($Output); 277 } 278 279 function ExportViewLanguages() 280 { 281 global $TranslationTree, $User; 282 283 $Output = ''; 284 $DisabledInput = array(false => ' disabled="disabled"', true => ''); 285 $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']); 286 $Export = $DbRows->fetch_assoc(); 287 if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true; 288 else $Editable = false; 289 290 if(array_key_exists('Operation', $_POST)) 291 { 292 if($_POST['Operation'] == 'Save') 293 { 294 //print_r($_POST); 295 // Update user selection page 296 foreach($_POST as $Index => $Value) 297 { 298 if(substr($Index, 0, 3) == 'seq') 299 { 300 $LanguageId = substr($Index, 3) * 1; 301 if(array_key_exists('sel'.$LanguageId, $_POST)) $Selected = true; 302 else $Selected = false; 303 $Condition = ' WHERE Export='.$_GET['ExportId'].' AND `Language`='.$LanguageId; 304 $DbResult = $this->System->Database->query('SELECT * FROM `ExportLanguage` '.$Condition); 305 if($DbResult->num_rows > 0) 306 { 307 if(!$Selected) $this->System->Database->query('DELETE FROM `ExportLanguage` '.$Condition); 308 else $this->System->Database->query('UPDATE `ExportLanguage` SET `Sequence`='.$Value.$Condition); 309 } else 310 { 311 if($Selected) $this->System->Database->query('INSERT INTO `ExportLanguage` (`Export`, `Language`, `Sequence`) VALUES ('.$_GET['ExportId'].', '.$LanguageId.', '.$Value.')'); 312 } 313 } 314 } 315 316 // Recalculate sequence number 317 $this->System->Database->query('SET @I = 0'); 318 $this->System->Database->query('UPDATE `ExportLanguage` SET `Sequence` = (@I := @I + 1) WHERE `Export`='.$_GET['ExportId'].' ORDER BY `Sequence`;'); 319 $Output .= ShowMessage('Výběr uložen.'); 320 } 321 } 322 323 $Query = 'SELECT (@I := @I + 1) AS `Sequence2`, `Sequence`, `Language`.`Id`, `Name` FROM `Language`'; 324 $Query .=' LEFT JOIN `ExportLanguage` ON `ExportLanguage`.`Export` = '.$_GET['ExportId'].' AND `ExportLanguage`.`Language`=`Language`.`Id`'; 325 $Query .=' WHERE `Language`.`Enabled` = 1 ORDER BY COALESCE(`Sequence`, 100)'; 326 327 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS X'); 328 $DbRow = $DbResult->fetch_row(); 329 $PageList = GetPageList($DbRow[0]); 330 331 $TableColumns = array( 332 array('Name' => 'Name', 'Title' => 'Název'), 333 array('Name' => '', 'Title' => 'Výběr'), 334 array('Name' => 'Sequence2', 'Title' => 'Pořadí'), 335 ); 336 $Order = GetOrderTableHeader($TableColumns, 'Sequence2'); 337 $Output .= '<form action="?Action=View&ExportId='.$_GET['ExportId'].'" method="post">'. 338 '<h3>Jazyky</h3>'; 339 if($Editable) 340 { 341 $Output .= '<input type="submit" value="Uložit" '.$DisabledInput[$Editable].'/>'. 342 '<input type="hidden" name="Operation" value="Save"/>'. 343 '<br />'. 344 'Zvolte ze seznamu dostupných jazyků, ze kterých chcete sestavit překlady a upravte jejich pořadí.<br />'. 345 'Pořadí řádků je dáno číselnou hodnotou, kterou lze změnit na požadované pořadí. Řádky se stejným pořadovým číslem budou přečíslovány vzestupně.'; 346 } 347 348 $Output .= $PageList['Output']. 349 '<table class="BaseTable">'. 350 $Order['Output']; 351 352 $Query = 'SELECT * FROM ('.$Query.') AS TX '.$Order['SQL'].$PageList['SQLLimit']; 353 $this->System->Database->query('SET @I = 0'); 354 $DbResult = $this->System->Database->query($Query); 355 while($Langugage = $DbResult->fetch_assoc()) 356 { 357 $Checked = $Langugage['Sequence'] != ''; 358 $Selection = CheckBox('sel'.$Langugage['Id'], $Checked, '', 'CheckBox', !$Editable); 359 $Sequence = '<input type="text" name="seq'.$Langugage['Id'].'" style="text-align: center; width: 40px;" value="'.$Langugage['Sequence2'].'"'.$DisabledInput[$Editable].'/>'; 360 $Output .= '<tr> 361 <td>'.$Langugage['Name'].'</a></td> 362 <td>'.$Selection.'</td><td>'.$Sequence.'</td></tr>'; 363 } 364 $Output .= '</table>'. 365 '</form>'. 366 $PageList['Output']; 367 return($Output); 368 } 369 370 function ExportViewGroups() 371 { 372 global $TranslationTree, $User; 373 374 $Output = ''; 375 $DisabledInput = array(false => ' disabled="disabled"', true => ''); 376 $DbRows = $this->System->Database->query('SELECT * FROM Export WHERE Id='.$_GET['ExportId']); 377 $Export = $DbRows->fetch_assoc(); 378 if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true; 379 else $Editable = false; 380 381 if(array_key_exists('Operation', $_POST)) 382 { 383 if($_POST['Operation'] == 'Save') 384 { 385 //print_r($_POST); 386 // Update user selection page 387 foreach($_POST as $Index => $Value) 388 { 389 if(substr($Index, 0, 3) == 'seq') 390 { 391 $GroupId = substr($Index, 3) * 1; 392 if(array_key_exists('sel'.$GroupId, $_POST)) $Selected = true; 393 else $Selected = false; 394 $Condition = ' WHERE `Export`='.$_GET['ExportId'].' AND `Group`='.$GroupId; 395 $DbResult = $this->System->Database->query('SELECT * FROM `ExportGroup` '.$Condition); 396 if($DbResult->num_rows > 0) 397 { 398 if(!$Selected) $this->System->Database->query('DELETE FROM `ExportGroup` '.$Condition); 399 } else 400 { 401 if($Selected) $this->System->Database->query('INSERT INTO `ExportGroup` (`Export`, `Group`) VALUES ('.$_GET['ExportId'].', '.$GroupId.')'); 402 } 403 } 404 } 405 $Output .= ShowMessage('Výběr uložen.'); 406 } 407 } 408 409 $Query = 'SELECT `Group`.*, `ExportGroup`.`Id` AS `ExportGroupId` FROM `Group` LEFT JOIN `ExportGroup` ON `ExportGroup`.`Export`='.$_GET['ExportId'].' AND `Group`=`Group`.`Id`'; 410 411 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS X'); 412 $DbRow = $DbResult->fetch_row(); 413 $PageList = GetPageList($DbRow[0]); 414 415 $TableColumns = array( 416 array('Name' => 'Name', 'Title' => 'Jméno'), 417 array('Name' => 'MangosTable', 'Title' => 'Tabulka MaNGOSu'), 418 array('Name' => 'DBCFileName', 'Title' => 'DBC soubor'), 419 array('Name' => 'LuaFileName', 'Title' => 'Lua soubor'), 420 array('Name' => '', 'Title' => 'Výběr'), 421 ); 422 $Order = GetOrderTableHeader($TableColumns, 'Name'); 423 $Output .= '<form action="?Action=View&ExportId='.$_GET['ExportId'].'" method="post">'. 424 '<h3>Překladové skupiny</h3>'; 425 if($Editable) 426 { 427 $Output .= '<input type="submit" value="Uložit" '.$DisabledInput[$Editable].'/>'. 428 '<input type="hidden" name="Operation" value="Save"/>'. 429 ' <span onclick="CheckAllCheckbox();">'.CheckBox('CheckAll', False, 'CheckAll').' Zatrhnout vše</span> '. 430 '<br />'. 431 'Zvolte ze překladových skupin, ze kterých chcete načítat překlady.<br />'; 432 } 433 434 $Output .= $PageList['Output']. 435 '<table class="BaseTable">'. 436 $Order['Output']; 437 438 $Query = 'SELECT * FROM ('.$Query.') AS TX '.$Order['SQL'].$PageList['SQLLimit']; 439 $DbResult = $this->System->Database->query($Query); 440 while($Group = $DbResult->fetch_assoc()) 441 { 442 $Checked = $Group['ExportGroupId'] != ''; 443 $Selection = CheckBox('sel'.$Group['Id'], $Checked, '', 'CheckBox', !$Editable); 444 $Output .= '<tr>'. 445 '<td>'.$Group['Name'].'</td>'. 446 '<td>'.$Group['MangosTable'].'</td>'. 447 '<td>'.$Group['DBCFileName'].'</td>'. 448 '<td>'.$Group['LuaFileName'].'</td>'. 449 '<td>'.$Selection.'<input type="hidden" name="seq'.$Group['Id'].'"/></td></tr>'; 450 } 451 $Output .= '</table>'. 452 '</form>'. 453 $PageList['Output']; 454 return($Output); 455 } 456 457 function ExportViewOutputFormat() 458 { 459 global $User; 460 461 $Output = ''; 462 $DisabledInput = array(false => ' disabled="disabled"', true => ''); 463 if(array_key_exists('ExportId', $_GET)) 464 { 465 $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']); 466 if($DbRows->num_rows > 0) 467 { 468 $Export = $DbRows->fetch_assoc(); 469 if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true; 470 else $Editable = false; 471 472 if(array_key_exists('Operation', $_POST)) 473 if($_POST['Operation'] == 'Save') 474 { 475 $this->System->Database->query('UPDATE Export SET OutputType='.$_POST['OutputType'].' WHERE Id='.$_GET['ExportId']); 476 $Output .= ShowMessage('Výběr uložen.'); 477 } 478 479 $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']); 480 $Export = $DbResult->fetch_assoc(); 481 482 $Output .= '<h3>Formát generovaného výstupu</h3>'. 483 '<form action="?Action=View&ExportId='.$_GET['ExportId'].'" method="post">'; 484 if($Editable) 485 { 486 $Output .= '<input type="submit" value="Uložit" '.$DisabledInput[$Editable].'/>'. 487 '<input type="hidden" name="Operation" value="Save"/>'. 488 '<br />'; 489 } 490 $DbResult = $this->System->Database->query('SELECT * FROM `ExportOutputType` ORDER BY `Name`'); 491 while($ExportFormat = $DbResult->fetch_assoc()) 492 { 493 $Output .= RadioButton('OutputType', $ExportFormat['Id'], $Export['OutputType'] == $ExportFormat['Id'], '', !$Editable).' '.$ExportFormat['Name'].'<br/>'; 494 } 495 $Output .= '</form>'; 496 } else $Output .= ShowMessage('Položka nenalezena.', MESSAGE_CRITICAL); 497 } else $Output .= ShowMessage('Nebylo zadáno Id.', MESSAGE_CRITICAL); 498 return($Output); 499 } 500 501 function ExportViewVersion() 502 { 503 global $User; 504 505 $Output = ''; 506 $DisabledInput = array(false => ' disabled="disabled"', true => ''); 507 $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']); 508 $Export = $DbRows->fetch_assoc(); 509 if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true; 510 else $Editable = false; 511 512 if(array_key_exists('Operation', $_POST)) 513 if(($_POST['Operation'] == 'Save') and (array_key_exists('ClientVersion', $_POST))) 514 { 515 $this->System->Database->query('UPDATE `Export` SET `ClientVersion`='.$_POST['ClientVersion'].' WHERE `Id`='.$_GET['ExportId']); 516 $Output .= ShowMessage('Výběr uložen.'); 517 } 518 519 $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']); 520 $Export = $DbResult->fetch_assoc(); 521 522 if($Export['OutputType'] == '') $Output .= ShowMessage('Nevybrán typ exportu', MESSAGE_CRITICAL); 523 else { 524 $Query = 'SELECT `ClientVersion`.* FROM `ExportVersion` LEFT JOIN `ClientVersion` ON `ClientVersion`.`Id`=`ExportVersion`.`ClientVersion` WHERE `ExportType`='.$Export['OutputType']; 525 526 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS `X`'); 527 $DbRow = $DbResult->fetch_row(); 528 $PageList = GetPageList($DbRow[0]); 529 530 $TableColumns = array( 531 array('Name' => 'Version', 'Title' => 'Verze'), 532 array('Name' => 'BuildNumber', 'Title' => 'Sestavení'), 533 array('Name' => 'ReleaseDate', 'Title' => 'Datum uvolnění'), 534 array('Name' => 'Title', 'Title' => 'Titutek'), 535 array('Name' => '', 'Title' => 'Výběr'), 536 ); 537 $Order = GetOrderTableHeader($TableColumns, 'BuildNumber', 1); 538 $Output .= '<form action="?Action=View&ExportId='.$_GET['ExportId'].'" method="post">'. 539 '<h3>Verze klienta</h3>'; 540 541 if($Editable) 542 { 543 $Output .= '<input type="submit" value="Uložit" '.$DisabledInput[$Editable].'/>'. 544 '<input type="hidden" name="Operation" value="Save"/>'. 545 '<br />'. 546 'Vyberte pro jakou verzi herního klienta se budou texty exportovat.<br />'; 547 } 548 $Output .= $PageList['Output']. 549 '<table class="BaseTable">'. 550 $Order['Output']; 551 552 $Query = 'SELECT * FROM ('.$Query.') AS `TX` '.$Order['SQL'].$PageList['SQLLimit']; 553 $DbResult = $this->System->Database->query($Query); 554 while($Version = $DbResult->fetch_assoc()) 555 { 556 $Output .= '<tr><td><a href="http://www.wowwiki.com/Patch_'.$Version['Version'].'">'. 557 $Version['Version'].'</a></td><td>'.$Version['BuildNumber'].'</td><td>'. 558 HumanDate($Version['ReleaseDate']).'</td><td>'.$Version['Title'].'</td><td>'. 559 RadioButton('ClientVersion', $Version['Id'], $Export['ClientVersion'] == $Version['Id'], '', !$Editable 560 ).'</td></tr>'; 561 562 } 563 $Output .= '</table>'. 564 '</form>'. 565 $PageList['Output']; 566 } 567 return($Output); 568 } 569 570 function ExportViewOutput() 571 { 572 $Output = ''; 573 $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']); 574 $Export = $DbResult->fetch_assoc(); 575 if($Export['OutputType'] == '') $Output .= ShowMessage('Nevybrán typ exportu', MESSAGE_CRITICAL); 576 else if($Export['ClientVersion'] == '') $Output .= ShowMessage('Export nemá vybránu verzi klienta', MESSAGE_CRITICAL); 577 else { 578 $DbResult = $this->System->Database->query('SELECT * FROM `ExportOutputType` WHERE `Id`='.$Export['OutputType']); 579 if($DbResult->num_rows > 0) 580 { 581 $DbResult = $this->System->Database->query('SELECT * FROM `ExportVersion` WHERE (`ExportType`='.$Export['OutputType'].') AND (`ClientVersion`='.$Export['ClientVersion'].')'); 582 if($DbResult->num_rows > 0) 583 { 584 $this->System->Database->query('UPDATE `Export` SET `UsedCount` = `UsedCount` + 1 WHERE `Id`='.$Export['Id']); 585 $Output = ExportOutput($Export['Id'], $Export['OutputType']); 586 } else $Output = ShowMessage('Nebyla vybrána požadovaná verze klienta.', MESSAGE_CRITICAL); 587 } else $Output = ShowMessage('Nebyl vybrán formát výstupu.', MESSAGE_CRITICAL); 588 } 589 return($Output); 590 } 591 592 function ExportViewStat() 593 { 594 global $Config; 595 596 $Export = new Export($this->System); 597 $Export->Id = $_GET['ExportId']; 598 $Export->Init(); 599 $Export->LoadFilters(); 600 601 if(($Export->Export['ClientVersion'] == '') or ($Export->ClientVersion['BuildNumber'] == '')) 602 $Output = ShowMessage('Nebyla vybrána verze klienta', MESSAGE_CRITICAL); 603 else { 604 $GroupListQuery = 'SELECT `Group`.* FROM `Group` '. 605 ' JOIN `ExportGroup` ON (`ExportGroup`.`Export`='.$Export->Id.') AND (`ExportGroup`.`Group`=`Group`.`Id`)'; 606 $Query = ''; 607 $UnionItems = array(); 608 $DbResult = $this->System->Database->query($GroupListQuery); 609 while($DbRow = $DbResult->fetch_assoc()) 610 { 611 $UnionItems[] = 'SELECT (SELECT COUNT(DISTINCT(`Entry`)) FROM ('. 612 ' SELECT `T`.* FROM `'.$DbRow['TablePrefix'].'` AS `T`'. 613 ' JOIN `ExportUser` ON (`ExportUser`.`User`=`T`.`User`) AND (`ExportUser`.`Export`='.$Export->Id.') '. 614 ' JOIN `ExportLanguage` ON (`ExportLanguage`.`Export`='.$Export->Id.')'. 615 ' WHERE (`Complete` = 1) AND (`VersionStart` <= '.$Export->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$Export->ClientVersion['BuildNumber'].')'. 616 ') AS `C1`) AS `Translated`, '. 617 '(SELECT COUNT(DISTINCT(`Entry`)) FROM ('. 618 ' SELECT `T`.* FROM `'.$DbRow['TablePrefix'].'` AS `T`'. 619 ' WHERE (`Language` = '.$Config['OriginalLanguage'].') AND (`VersionStart` <= '.$Export->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$Export->ClientVersion['BuildNumber'].')'. 620 ') AS `C2`) AS `Total`, "'.$DbRow['Name'].'" AS `Name`'; 621 } 622 $Query = substr($Query, 0, - 6); 623 624 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM ('.$GroupListQuery.') AS `T`'); 625 $DbRow = $DbResult->fetch_row(); 626 $PageList = GetPageList($DbRow[0]); 627 $Output = '<h3>Statistika dokončení vybraných skupin</h3>'. 628 $PageList['Output']; 629 630 $Output .= '<table class="BaseTable">'; 631 $TableColumns = array( 632 array('Name' => 'Name', 'Title' => 'Jméno'), 633 array('Name' => 'Translated', 'Title' => 'Přeložených'), 634 array('Name' => 'Total', 'Title' => 'Anglických'), 635 array('Name' => 'Percent', 'Title' => 'Procenta'), 636 ); 637 638 $Order = GetOrderTableHeader($TableColumns, 'Name', 0); 639 $Output .= $Order['Output']; 640 641 $Translated = 0; 642 $Total = 0; 643 if(count($UnionItems) > 0) 644 { 645 $ID = $this->System->Database->query('SELECT *, ROUND(`Translated` / `Total` * 100, 2) AS `Percent` FROM ('.implode(' UNION ALL ', $UnionItems).') AS `C3` '.$Order['SQL'].$PageList['SQLLimit']); 646 while($Group = $ID->fetch_assoc()) 647 { 648 $Output .= '<tr><td>'.$Group['Name'].'</td><td>'.$Group['Translated'].'</td><td>'.$Group['Total'].'</td><td>'.ProgressBar(150, $Group['Percent']).'</td></tr>'; 649 $Translated += $Group['Translated']; 650 $Total += $Group['Total']; 651 } 652 } 653 if($Total > 0) $Percent = $Translated / $Total * 100; 654 else $Percent = 100; 655 656 $Output .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$Translated.'</strong></td><td><strong>'.$Total.'</strong></td><td><strong>'.ProgressBar(150, round($Percent, 2)).'</strong></td></tr>'; 657 $Output .= '</table>'; 658 } 659 return($Output); 660 } 661 662 function ExportView() 663 { 664 $Output = ''; 665 if(array_key_exists('ExportId', $_GET) and is_numeric($_GET['ExportId'])) 666 { 667 $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']); 668 if($DbResult->num_rows > 0) 669 { 670 $Export = $DbResult->fetch_assoc(); 671 672 $DbResult = $this->System->Database->query('SELECT * FROM `User` WHERE `ID`='.$Export['User']); 673 $UserLine = $DbResult->fetch_assoc(); 674 $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>'; 675 $Output .= ShowTabs(array('Obecné', 'Překladatelé', 'Překlady', 'Jazyky', 'Formát', 'Verze', 'Statistika', 'Výstup')); 676 $Output .= '<div id="content">'; 677 if($_SESSION['Tab'] == 0) $Output .= $this->ExportViewGeneral(); 678 else if($_SESSION['Tab'] == 1) $Output .= $this->ExportViewTranslators(); 679 else if($_SESSION['Tab'] == 2) $Output .= $this->ExportViewGroups(); 680 else if($_SESSION['Tab'] == 3) $Output .= $this->ExportViewLanguages(); 681 else if($_SESSION['Tab'] == 4) $Output .= $this->ExportViewOutputFormat(); 682 else if($_SESSION['Tab'] == 5) $Output .= $this->ExportViewVersion(); 683 else if($_SESSION['Tab'] == 6) $Output .= $this->ExportViewStat(); 684 else if($_SESSION['Tab'] == 7) $Output .= $this->ExportViewOutput(); 685 else $Output .= $this->ExportViewGeneral(); 686 687 $Output .= '</div>'; 688 } else $Output .= ShowMessage('Export nenalezen.', MESSAGE_CRITICAL); 689 } else $Output .= ShowMessage('Nebylo zadáno Id.', MESSAGE_CRITICAL); 690 return($Output); 691 } 692 693 693 function Show() 694 694 {
Note:
See TracChangeset
for help on using the changeset viewer.