Title = T('Translation'); $Action = ''; if (array_key_exists('action', $_GET)) $Action = $_GET['action']; if ($Action == 'delete') $Output = $this->Delete(); else $Output = $this->ShowForm(); return $Output; } function ShowForm(): string { $User = ModuleUser::Cast($this->System->GetModule('User'))->User; $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree(); $Output = ''; $GroupId = LoadGroupIdParameter(); $this->GroupId = $GroupId; $Table = $TranslationTree[$GroupId]['TablePrefix']; if (array_key_exists('action', $_GET)) $Action = $_GET['action']; else $Action = ''; $TextID = 0; if (TryGetUrlParameterInt('ID', $TextID)) { $this->ID = $TextID; $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE `ID` = '.$TextID); $Line = $DbResult->fetch_assoc(); if (!$Line) { $Output .= ShowMessage('Překlad nenalezen.', MESSAGE_CRITICAL); } else { if (Core::Cast($this->System)->Config['OriginalLanguage'] == $Line['Language']){ $LineAJ = $Line; if ($User->Language <> '') $Language = '`Language` = '.$User->Language; else $Language = '`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage']; $Columns = ''; foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) $Columns .= ' `Orig`.`'.$TextItem['Column'].'` as `Orig_'.$TextItem['Column'].'`, `Tran`.`'.$TextItem['Column'].'` as `'.$TextItem['Column'].'`,'; $sql = 'SELECT '.$Columns.' Tran.`Entry` FROM `'.$Table.'` as Tran'; $join = ' JOIN `'.$Table.'` as `Orig` ON `Orig`.`Language` = 0 AND `Tran`.`Entry` = `Orig`.`Entry` AND `Tran`.`VersionEnd` = `Orig`.`VersionEnd` '; $where = ' WHERE '.'( `Tran`.'.$Language.' ) AND '.'(`Tran`.`Entry` = '.$Line['Entry'].') ORDER BY `Tran`.`ModifyTime` DESC'; $DbResult = $this->Database->query($sql.$join.$where); while ($LineSearch = $DbResult->fetch_assoc()) { foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) { if ($TextItem['Visible'] == 1) { if (($LineAJ[$TextItem['Column']] <> '') and ($LineSearch[$TextItem['Column']] <> '') and ($LineSearch['Orig_'.$TextItem['Column']] <> $LineSearch[$TextItem['Column']]) and ($LineAJ[$TextItem['Column']] == $Line[$TextItem['Column']]) ) { $Line[$TextItem['Column']] = $LineSearch[$TextItem['Column']]; } } } } } else { $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE '. '(`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') AND '. '(`Entry` = '.$Line['Entry'].') AND (`VersionEnd` = '.$Line['VersionEnd'].') LIMIT 1'); $LineAJ = $DbResult->fetch_assoc(); } if (!$LineAJ) { $Output .= ShowMessage('Anglický originál k překladu nenalezen.', MESSAGE_CRITICAL); } else { if ($Line['User'] != '') { $IDUser = $this->Database->query('SELECT * FROM `User` WHERE `ID` = '.$Line['User']); $LineUser = $IDUser->fetch_array(); } else $LineUser = array('Name' => ''); $Output .= T('Group').': '.$TranslationTree[$GroupId]['Name'].'
'; if (($Line['Language'] <> 0) and ($LineUser['Name'] <> '')) $Output .= T('Translated by').': '.$LineUser['Name'].' dne '.HumanDate($Line['ModifyTime']).'
'; if (($Line['Take'] <> 0) and ($Line['Take'] <> $Line['ID'])) { $DbResult = $this->Database->query('SELECT `Language`,`VersionStart`,`VersionEnd` FROM `'.$Table.'` WHERE `ID` = '.$Line['Take']); $Language = $DbResult->fetch_assoc(); $DbResult = $this->Database->query('SELECT `Name` FROM `Language` WHERE `Id` ='.$Language['Language']); $Lang = $DbResult->fetch_assoc(); $Output .= T('Original text').': '. ' ID '.$Line['Take'].''. ' ('.T($Lang['Name']).')'. '
'; } $Output .= 'Text: '; if ($Line['Language'] <> 0) { if ($Line['Complete'] == 1) $Output .= ' '.T('Completed').''; else $Output .= ' '.T('Stored in unfinished').' '; } else $Output .= ' '.T('Original version').' '; $Output .= '
'. T('Version').': '.GetVersionWOW($Line['VersionStart']). ' - '.GetVersionWOW($Line['VersionEnd']).''. '
'; $DbResult = $this->Database->query('SELECT COUNT(*) FROM `'.$Table.'` WHERE '. '(`Entry` = '.$Line['Entry'].')'); $Version = $DbResult->fetch_row(); $Version = $Version[0]; if ($Version > 0) { $Output .= '
'.T('Number of versions').': '.$Version.' '; if ($User->Licence(LICENCE_USER)) { // allow to compare only to user $Output .= ''; } $Output .= '
'; } else { $Output .= ''.T('Number of versions').': '.$Version.''; } // Special characters: $B - New line, $N - Name, $C - profession if ($User->Licence(LICENCE_USER)) { $Output .= '
'; // TODO: Remove fixed group id condition // if (($GroupId < 4) or ($GroupId == 10) or ($GroupId == 11)) $Output .= ''.T('Search in names').''; $Output .= ' '. ' '; FollowingTran($TextID, $Table, $GroupId, true); FollowingTran($TextID, $Table, $GroupId); } if ($TranslationTree[$GroupId]['WowheadName'] != '') $WowheadLink = ''.$LineAJ['Entry'].''; else $WowheadLink = $LineAJ['Entry']; $Output .= ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''; // TODO: javascript $Output .= ''. ''; foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) { if ($TextItem['Visible'] == 1) { if (($LineAJ[$TextItem['Column']] <> '') or ($Line[$TextItem['Column']] <> '')) { if (($TextItem['Name'] == 'Text') and (($Table == 'global_strings') or ($Table == 'glue_strings'))) $Output .= ''; else $Output .= ''; $Output .= ''; } } else { $Output .= ''; } } $Output .= '
'.T('Text number').': '.$WowheadLink.''.T('Not translated').''.T('Translated').'
'.T('Language').''.T('Original').''; if ($Line['Language'] <> 0) $Language = $Line['Language']; else if ($User->Id != 0) { $Language = $User->Language; } else $Language = 0; if ($User->Licence(LICENCE_USER)) { $Output .= WriteLanguages($Language); } else { $DbResult3 = $this->Database->select('Language', '`Id`, `Name`', '(`Enabled` = 1) AND (`Id`='.$Language.')'); if ($DbResult3->num_rows > 0) { $Language = $DbResult3->fetch_assoc(); $Output .= T($Language['Name']); } } $Output .= '
'.$LineAJ['ShortCut'].'
'.T($TextItem['Name']).''.str_replace("\n", '
', htmlspecialchars($LineAJ[$TextItem['Column']])).'
'; if ($User->Licence(LICENCE_USER)) $Output .= '
'; if ($User->Licence(LICENCE_USER)) { $Output .= '
'; if (isset(Core::Cast($this->System)->Config['Web']['EnableGoogleTranslate']) and Core::Cast($this->System)->Config['Web']['EnableGoogleTranslate']) { $Output .= '
'. ''; foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) { if ($TextItem['Visible'] == 1) { if ($LineAJ[$TextItem['Column']] <> '') { $Output .= ''. ''. ''; } } } $Output .= '
'.T('Google translator').':'.T('Not translated').''.T('Translated').'
'.$TextItem['Column'].''.$LineAJ[$TextItem['Column']].''.GetTranslateGoogle($this->System, $LineAJ[$TextItem['Column']]).'
'; } } } } } else $Output = ShowMessage('Nebylo zadáno ID.', MESSAGE_CRITICAL); return $Output; } function Delete() { $User = ModuleUser::Cast($this->System->GetModule('User'))->User; $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree(); if ($User->Licence(LICENCE_MODERATOR)) { $GroupId = LoadGroupIdParameter(); $this->GroupId = $GroupId; $Table = $TranslationTree[$GroupId]['TablePrefix']; $TextID = $_GET['ID']; $this->Database->query('DELETE FROM `'.$Table.'` WHERE `ID` = '.$TextID.' AND `Language` <> '.Core::Cast($this->System)->Config['OriginalLanguage']); $Output = ShowMessage('Překlad byl smazán.'); $this->System->ModuleManager->Modules['Log']->WriteLog('Překlad byl smazán! '.$TextID.'', LOG_TYPE_MODERATOR); } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); return $Output; } }