System->GetModule('User'))->User; $TranslationTree = ModuleTranslation::Cast($this->System->GetModule('Translation'))->GetTranslationTree(); $Filter = array('SQL' => ''); $Output = '
'. ''. ''. ''. ''. ''. ''. ''. ''. ''; // State $Filter['State'] = GetParameter('state', 0, true, true); $Output .= ''; // Translation group if ($GroupId == 0) { $Filter['Group'] = GetParameter('group', 0, true, true); if ($Filter['Group'] != 0) { if (isset($TranslationTree[$Filter['Group']]) == false) ErrorMessage('Překladová skupina dle zadaného Id neexistuje.'); $Table = $TranslationTree[$Filter['Group']]['TablePrefix']; } } else { $Filter['Group'] = $GroupId; $Table = $TranslationTree[$Filter['Group']]['TablePrefix']; } $Output .= ''; if ($User->Licence(LICENCE_USER)) $Filter['Version'] = GetParameter('version', $User->PreferredVersion, true, true); else $Filter['Version'] = GetParameter('version', 0, true, true); if ($Filter['Version'] != 0) { $DbResult = $this->Database->query('SELECT `Id`, `BuildNumber`,`Version` FROM `ClientVersion` WHERE (`Imported` = 1) AND (`Id` ='.$Filter['Version'].')'); if ($DbResult->num_rows > 0) { $DbRow = $DbResult->fetch_assoc(); $Filter['BuildNumber'] = $DbRow['BuildNumber']; } else ErrorMessage('Zadaná verze klienta nenalezena'); } $Output .= ''; if ($Filter['Version'] != 0) $VersionFilter = ' AND (`VersionStart` <= '.$Filter['BuildNumber'].') AND (`VersionEnd` >= '.$Filter['BuildNumber'].')'; else $VersionFilter = ''; //else $Filter['SQL'] .= ' AND '; DISTINCT(Entry) // Language $Filter['Language'] = GetParameter('lang', 0, true, true); $Output .= ''; $LanguageFilter = ''; $LanguageFilterSub = ''; if ($Filter['Language'] != 0) { $LanguageFilter = ' AND (`T`.`Language` = '.$Filter['Language'].')'; $LanguageFilterSub = ' AND (`Sub`.`Language` = '.$Filter['Language'].')'; } // User $Filter['User'] = GetParameter('user', 0, true, true); $Output .= ''; if ($Filter['User'] != 0) $UserFilter = ' AND (`User` = '.$Filter['User'].')'; else $UserFilter = ''; // Words $Filter['Text'] = GetParameter('text', '', false, true); $Output .= ''; if ($Filter['Text'] != '') { $Items = array('(`T`.`ID` LIKE "%'.$Filter['Text'].'%")', '(`T`.`Entry` LIKE "%'.$Filter['Text'].'%")'); if ($Filter['Group'] != 0) foreach ($TranslationTree[$Filter['Group']]['Items'] as $GroupItem) if ($GroupItem['Visible'] == 1) $Items[] = '(`T`.`'.$GroupItem['Column'].'` LIKE "%'.$Filter['Text'].'%")'; $Filter['SQL'] .= ' AND ('.implode(' OR ', $Items).')'; } // Entry $Filter['Entry'] = GetParameter('entry', '', false, true); $Output .= ''; if ($Filter['Entry'] != '') { $Filter['SQL'] .= ' AND (`Entry` = "'.$Filter['Entry'].'")'; } if ($Filter['Group'] != 0) { $WithoutAlter = ' AND NOT EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE '. '(`Sub`.`Language` <> '.Core::Cast($this->System)->Config['OriginalLanguage'].')'.$LanguageFilterSub. ' AND (`Sub`.`Entry` = `T`.`Entry`) AND (`Sub`.`ID` != `T`.`ID`) AND (`Sub`.`Complete` = 1) AND '. '(`Sub`.`VersionStart` = `T`.`VersionStart`) AND (`Sub`.`VersionEnd` = `T`.`VersionEnd`) LIMIT 1 ) '; foreach ($TranslationTree[$Filter['Group']]['Items'] as $GroupItem) if ($GroupItem['Visible'] == 1) { $ItemsVar[] = 'LENGTH(`T`.`'.$GroupItem['Column'].'`) - LENGTH( REPLACE( `T`.`'.$GroupItem['Column'].'`, \'$\', \'\' ) ) '. ' < ('. 'SELECT LENGTH(`Sub`.`'.$GroupItem['Column'].'`) - LENGTH( REPLACE( `Sub`.`'.$GroupItem['Column'].'`, \'$\', \'\' ) ) FROM `'.$Table.'` AS `Sub` WHERE '. ' `Sub`.`Entry` = `T`.`Entry` AND `Sub`.`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].' AND '. '`Sub`.`VersionStart` = `T`.`VersionStart` AND `Sub`.`VersionEnd` = `T`.`VersionEnd` LIMIT 1 '. ')'; } if ($Filter['State'] == CompletionState::All) { $Filter['SQL'] .= $UserFilter.$VersionFilter; } else if ($Filter['State'] == CompletionState::NotTranslated) { $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') '. 'AND NOT EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE '. '(`Sub`.`Language` <> '.Core::Cast($this->System)->Config['OriginalLanguage'].') '.$LanguageFilterSub.$UserFilter. ' AND (`Sub`.`Entry` = `T`.`Entry`) AND (`Sub`.`Complete` = 1) AND '. '(`Sub`.`VersionStart` = `T`.`VersionStart`) AND (`Sub`.`VersionEnd` = `T`.`VersionEnd`))'; } else if ($Filter['State'] == CompletionState::Translated) { $Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Complete` = 1)'; } else if ($Filter['State'] == CompletionState::NotFinished) { $Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage']. ') AND (`T`.`Complete` = 0)'; } else if ($Filter['State'] == CompletionState::Original) { $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].')'; } else if ($Filter['State'] == CompletionState::NotFinishedNotTranslated) { $Filter['SQL'] .= $UserFilter.$VersionFilter.$WithoutAlter. ' AND (`T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage']. ') AND (`T`.`Complete` = 0)'; } else if ($Filter['State'] == CompletionState::Missing1) { $Filter['SQL'] .= $UserFilter.$VersionFilter.' AND (`T`.`Complete` = 1) AND `T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage']; $Filter['SQL'] .= ' AND ('.implode(' OR ', $ItemsVar).') '; } else if ($Filter['State'] == CompletionState::Missing2) { $Filter['SQL'] .= $UserFilter.$VersionFilter.' AND (`T`.`Complete` = 1) AND `T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage']; $Filter['SQL'] .= ' '. $WithoutAlter; $Filter['SQL'] .= ' AND ('.implode(' OR ', $ItemsVar).') '; } } /* // Ownership if (array_key_exists('owner', $_GET) and is_numeric($_GET['owner'])) $Filter['Owner'] = $_GET['owner']; else $Filter['Owner'] = 0; $Output .= ' '; if (($Filter['Owner'] == 2) AND ($Filter['User'] != 0)) $Filter['SQL'] .= ' AND (`User` = '.$Filter['User'].')'; */ $Output .= ''; $Output .= '
'.T('Processing').''.T('Group').''.T('Version').''.T('Language').''.T('Translator').''.T('Words').''.T('Item').'
'; $Output .= '

'; $Filter['Output'] = $Output; return $Filter; } function ShowTranslationList($Filter) { $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree(); $Output = $Filter['Output']; $Table = $TranslationTree[$Filter['Group']]['TablePrefix']; $Query = 'SELECT `T`.`ModifyTime`, `T`.`ID`, `T`.`Entry`, `T`.`VersionStart`, `T`.`VersionEnd`, '. '`T`.`'.$TranslationTree[$Filter['Group']]['Items'][0]['Column'].'`, '. '`User`.`Name` AS `UserName`, `User`.`ID` AS `UserId`, '. '`Language`.`Name` AS `LanguageName`, `TS`.`Version` AS `VersionStartText`, `TE`.`Version` AS `VersionEndText` '. 'FROM `'.$Table.'` AS `T` '. 'LEFT JOIN `User` ON `User`.`ID` = `T`.`User` '. 'LEFT JOIN `Language` ON `Language`.`ID` = `T`.`Language` '. 'LEFT JOIN `ClientVersion` AS `TS` ON `TS`.`BuildNumber` = `T`.`VersionStart` '. 'LEFT JOIN `ClientVersion` AS `TE` ON `TE`.`BuildNumber` = `T`.`VersionEnd` '. 'WHERE 1 '.$Filter['SQL']; // Get total item count $DbResult = $this->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS `TT`'); $DbRow = $DbResult->fetch_row(); $PageList = GetPageList($DbRow[0]); $Output .= $PageList['Output']; $TableColumns = array( array('Name' => 'ID', 'Title' => T('Number')), array('Name' => 'Entry', 'Title' => T('Item')), array('Name' => $TranslationTree[$Filter['Group']]['Items'][0]['Column'], 'Title' => T('Name')), array('Name' => 'VersionStart', 'Title' => T('From version')), array('Name' => 'VersionEnd', 'Title' => T('To version')), array('Name' => 'LanguageName', 'Title' => T('Language')), array('Name' => 'UserName', 'Title' => T('Translator')), array('Name' => 'ModifyTime', 'Title' => T('Date')), ); $Order = GetOrderTableHeader($TableColumns, 'VersionStart', 1); $Output .= ''. $Order['Output']; $DbResult = $this->Database->query($Query.' '.$Order['SQL'].' '.$PageList['SQLLimit']); while ($Line = $DbResult->fetch_assoc()) { $Text = $Line[$TranslationTree[$Filter['Group']]['Items'][0]['Column']]; if ($Text != null) $Text = htmlspecialchars($Text); $Output .= ''. ''. ''. ''. ''. ''. ''. ''. ''; } $Output .= '
'.$Line['ID'].''.$Line['Entry'].''.$Text.''.GetVersionWOW($Line['VersionStart']).''.GetVersionWOW($Line['VersionEnd']).''.T($Line['LanguageName']).''.$Line['UserName'].''.HumanDate($Line['ModifyTime']).'
'. $PageList['Output']; return $Output; } function ShowGroupList($Filter) { $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree(); $Output = $Filter['Output']; $Output .= ''; $Total = 0; foreach ($TranslationTree as $Group) { if ($Group['TablePrefix'] != '') { $Filter = $this->ShowFilter($Group['Id']); $ID = $this->Database->query('SELECT COUNT(*) FROM `'.$Group['TablePrefix'].'` AS `T` WHERE 1 '.$Filter['SQL']); $Line = $ID->fetch_row(); if ($Line[0] <> '0') $Output .= ''; $Total += $Line[0]; } } $Output .= ''. '
'.T('Group').''.T('Count').'
'.$Group['Name'].''.$Line[0].'
'.T('Total').''.$Total.'
'; return $Output; } function ShowMenu() { $User = ModuleUser::Cast($this->System->GetModule('User'))->User; $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree(); $GroupId = GetParameter('group', 0, true); if ($GroupId == 0) $Output = ShowMessage('Skupina nenalezena', MESSAGE_CRITICAL); else { $Table = $TranslationTree[$GroupId]['TablePrefix']; $Output = '

'.T('Basic text filtering').'


'. ''. ''. ''. ''. ''. ''. ''. ''. ''; if ($User->Licence(LICENCE_USER)) { $Output .= ''; } $Output .= ''; $Output .= ''; $Output .= '
'.T('Link').''.T('Description').'
'.T('All').''.T('Show all available original texts in group').'
'.T('Translated').''.T('Show only translated texts').'
'.T('Untranslated').''.T('Not yet translated texts which need to be translated').'
'.T('Unfinished').''.T('Texts marked as unfinished').'
'.T('My unfinished').' '.T('Unfinished texts of logged-in user').'
'.T('My translated').' '.T('Translated texts of logged-in user').'
'. ''. ''. '
'. '
'.T('Search using text').'
'. ''. ''. '
'. '
'.T('Show by datbase text ID').'
'; } return $Output; } function Show(): string { $this->Title = T('Translation groups'); $Action = GetParameter('action', ''); if ($Action == 'filter') $Output = $this->ShowMenu(); else { $Filter = $this->ShowFilter(); if ($Filter['Group'] > 0) $Output = $this->ShowTranslationList($Filter); else $Output = $this->ShowGroupList($Filter); } return $Output; } } class PageTranslationGroups extends Page { function ShowList() { $User = ModuleUser::Cast($this->System->GetModule('User'))->User; $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Group`'); $DbRow = $DbResult->fetch_row(); $PageList = GetPageList($DbRow[0]); $Output = '

'.T('List of translation groups').'

'. $PageList['Output']; $Output .= ''; $TableColumns = array( array('Name' => 'Name', 'Title' => T('Name')), array('Name' => 'SourceType', 'Title' => T('Source type')), array('Name' => '', 'Title' => T('Sources')), array('Name' => 'LastImport', 'Title' => T('Date of last import')), array('Name' => 'LastVersion', 'Title' => T('Version of last import')), ); if ($User->Licence(LICENCE_ADMIN)) $TableColumns[] = array('Name' => '', 'Title' => T('Actions')); $Order = GetOrderTableHeader($TableColumns, 'Name', 0); $Output .= $Order['Output']; $DbResult = $this->Database->query('SELECT * FROM `Group`'.$Order['SQL'].$PageList['SQLLimit']); while ($Group = $DbResult->fetch_assoc()) { $Output .= ''. ''; if ($User->Licence(LICENCE_ADMIN)) $Output .= ''; else $Output .= ''; $Output .= ''; if ($User->Licence(LICENCE_ADMIN)) $Output .= ''; $Output .= ''; } $Output .= '
'.T($Group['Name']).''.$Group['SourceType'].''; if ($Group['MangosTable'] != '') $Output .= $Group['MangosTable'].'.sql '; if ($Group['DBCFileName'] != '') $Output .= $Group['DBCFileName'].'.dbc '; if ($Group['LuaFileName'] != '') $Output .= $Group['LuaFileName'].'.lua '; $Output .= ''.HumanDate($Group['LastImport']).''.HumanDate($Group['LastImport']).''.GetVersionWOW($Group['LastVersion']).''.T('Remove').'
'. '
'.T('Changelog of text modification during import').'
'; if ($User->Licence(LICENCE_ADMIN)) $Output .= ''.T('Add translation group').''; return $Output; } function ShowGroupAdd() { $User = ModuleUser::Cast($this->System->GetModule('User'))->User; if ($User->Licence(LICENCE_ADMIN)) { $Output = '

Vložení nové překladové skupiny

'. '
'. ''. ''. ''. ''. '
Název:
Název tabulky v databázi:Text
'; } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); return $Output; } function ShowGroupAddFinish() { $User = ModuleUser::Cast($this->System->GetModule('User'))->User; if ($User->Licence(LICENCE_ADMIN)) { $TableName = 'Text'.$_POST['TablePrefix']; $DbResult = $this->System->Database->select('Group', 'Id', 'TablePrefix="'.$TableName.'"'); if ($DbResult->num_rows == 0) { $this->System->Database->query('CREATE TABLE IF NOT EXISTS `'.$TableName.'` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `Entry` int(11) NOT NULL, `Name` varchar(255) NOT NULL, `Language` int(11) NOT NULL DEFAULT "0", `User` int(11) DEFAULT NULL, `Complete` int(11) NOT NULL, `CompleteParts` int(11) NOT NULL, `Take` int(11) DEFAULT NULL, `VersionStart` int(11) NOT NULL, `VersionEnd` int(11) NOT NULL, `ModifyTime` datetime NOT NULL, PRIMARY KEY (`ID`), KEY `Entry` (`Entry`), KEY `User` (`User`), KEY `Take` (`Take`), KEY `Language` (`Language`), KEY `Complete` (`Complete`), KEY `VersionStart` (`VersionStart`), KEY `VersionEnd` (`VersionEnd`), KEY `ModifyTime` (`ModifyTime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); $this->System->Database->query('ALTER TABLE `'.$TableName.'` ADD CONSTRAINT `'.$TableName.'_ibfk_1` FOREIGN KEY (`Language`) REFERENCES `Language` (`Id`), ADD CONSTRAINT `'.$TableName.'_ibfk_2` FOREIGN KEY (`User`) REFERENCES `User` (`ID`), ADD CONSTRAINT `'.$TableName.'_ibfk_3` FOREIGN KEY (`Take`) REFERENCES `'.$TableName.'` (`ID`);'); $DbResult = $this->System->Database->insert('Group', array('Name' => $_POST['Name'], 'TablePrefix' => $TableName, 'PrimaryKeyItem' => 'Entry')); $Group = $this->System->Database->insert_id; $this->System->Database->insert('GroupItem', array('Group' => $Group, 'Name' => 'Jméno', 'Column' => 'Name', 'Visible' => 1)); $Output = ShowMessage('Překladová skupina vytvořena', MESSAGE_INFORMATION); } else $Output = ShowMessage('Překladová skupina '.$TableName.' již existuje', MESSAGE_CRITICAL); $Output .= $this->ShowList(); } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); return $Output; } function ShowGroupDelete() { $User = ModuleUser::Cast($this->System->GetModule('User'))->User; if ($User->Licence(LICENCE_ADMIN)) { $DbResult = $this->System->Database->select('Group', '*', '`Id`='.$_GET['id']); if ($DbResult->num_rows == 1) { $Group = $DbResult->fetch_assoc(); $this->Database->query('DROP TABLE `'.$Group['TablePrefix'].'`'); $this->Database->query('DELETE FROM `GroupItem` WHERE `Group`='.$Group['Id']); $this->Database->query('DELETE FROM `Group` WHERE `Id`='.$Group['Id']); $Output = ShowMessage('Překladová skupina '.$Group['Name'].' smazána', MESSAGE_INFORMATION); } else $Output = ShowMessage('Překladová skupina nenalezena', MESSAGE_CRITICAL); } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); $Output .= $this->ShowList(); return $Output; } function Show(): string { $this->Title = T('Translation groups'); $Action = GetParameter('action', ''); if ($Action == 'groupadd') $Output = $this->ShowGroupAdd(); else if ($Action == 'groupdelete') $Output = $this->ShowGroupDelete(); else if ($Action == 'groupaddfinish') $Output = $this->ShowGroupAddFinish(); else $Output = $this->ShowList(); return $Output; } }