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('Google translator').': | '.T('Not translated').' | '.T('Translated').' | '; foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) { if ($TextItem['Visible'] == 1) { if ($LineAJ[$TextItem['Column']] <> '') { $Output .= '
---|---|---|
'.$TextItem['Column'].' | '. ''.$LineAJ[$TextItem['Column']].' | '. ''.GetTranslateGoogle($this->System, $LineAJ[$TextItem['Column']]).' |