| 1 | <?php
|
|---|
| 2 |
|
|---|
| 3 | class PageLoadNames extends Page
|
|---|
| 4 | {
|
|---|
| 5 | function ReplaceTranslated($orig, $tran, $Text, $ID, $Group)
|
|---|
| 6 | {
|
|---|
| 7 | $tran_replace = str_replace(' ',' ',htmlspecialchars($tran));
|
|---|
| 8 | $orig_replace = str_replace(' ',' ',htmlspecialchars($orig));
|
|---|
| 9 |
|
|---|
| 10 | // if (strlen($orig) < strlen($Text)-1) {
|
|---|
| 11 | if ($Group <> '')
|
|---|
| 12 | {
|
|---|
| 13 | $Text = str_replace(' '.$orig,' <span Title="Přelož jako: '.$tran_replace.
|
|---|
| 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 {
|
|---|
| 16 | $Text = str_replace(' '.$orig,' <span Title="Přelož jako: '.$tran_replace.
|
|---|
| 17 | '" class="edit"><a class="edit" target="_NEW2" href="'.$this->System->Link('/'.T('dictionary', 'URL').'/?search='.$tran).'">'.$orig_replace.'</a></span>',$Text);
|
|---|
| 18 | }
|
|---|
| 19 | // }
|
|---|
| 20 | return $Text;
|
|---|
| 21 | }
|
|---|
| 22 |
|
|---|
| 23 | function ReplaceNotTranslated($orig, $tran, $Text, $ID, $Group)
|
|---|
| 24 | {
|
|---|
| 25 | $orig_replace = str_replace(' ',' ',htmlspecialchars($orig));
|
|---|
| 26 |
|
|---|
| 27 | $Text = str_replace(' '.$orig,' <span title="Kliknutím přeložíš" class="needtran"><a class="needtran" target="_NEW2" href="'.
|
|---|
| 28 | $this->System->Link('/form.php?group='.$Group.'&ID='.$ID).'">'.$orig_replace.'</a></span>',$Text);
|
|---|
| 29 | return $Text;
|
|---|
| 30 | }
|
|---|
| 31 |
|
|---|
| 32 | function ColorNames($Text, $names)
|
|---|
| 33 | {
|
|---|
| 34 | $Text = ' '.$Text;
|
|---|
| 35 | $Text = str_replace('$B$B','$B$B ',$Text);
|
|---|
| 36 |
|
|---|
| 37 | $Text = str_replace('$B','<span Title="Znamená odřádkování, překladu zachovej na stejné pozici." class="edit">$B</span>',$Text);
|
|---|
| 38 | $Text = str_replace('$N','<span Title="Znamená jméno hráče, překladu zachovej na stejné pozici." class="edit">$N</span>',$Text);
|
|---|
| 39 | $Text = str_replace('$R','<span Title="Znamená rasu hráče, překladu zachovej na stejné pozici." class="edit">$R</span>',$Text);
|
|---|
| 40 | $Text = str_replace('$C','<span Title="Znamená povolání hráče, překladu zachovej na stejné pozici." class="edit">$C</span>',$Text);
|
|---|
| 41 | $Text = str_replace('$G','<span Title="Vybere oslovení podle pohlaví hráče, překladu zachovej na stejné pozici." class="edit">$G</span>',$Text);
|
|---|
| 42 | $Text = str_replace('$b','<span Title="Znamená odřádkování, překladu zachovej na stejné pozici." class="edit">$B</span>',$Text);
|
|---|
| 43 | $Text = str_replace('$n','<span Title="Znamená jméno hráče, překladu zachovej na stejné pozici." class="edit">$N</span>',$Text);
|
|---|
| 44 | $Text = str_replace('$c','<span Title="Znamená povolání hráče, překladu zachovej na stejné pozici." class="edit">$c</span>',$Text);
|
|---|
| 45 | $Text = str_replace('$r','<span Title="Znamená rasu hráče, překladu zachovej na stejné pozici." class="edit">$R</span>',$Text);
|
|---|
| 46 | $Text = str_replace('$g','<span Title="Vybere oslovení podle pohlaví hráče, překladu zachovej na stejné pozici." class="edit">$G</span>',$Text);
|
|---|
| 47 | foreach ($names as $Line)
|
|---|
| 48 | {
|
|---|
| 49 | if (($_GET['ID'] <> $Line[0]) or ($Line[1] <> $_GET['GroupId']))
|
|---|
| 50 | {
|
|---|
| 51 | if ($Line[3] <> '')
|
|---|
| 52 | {
|
|---|
| 53 | $Text = $this->ReplaceTranslated($Line[2],$Line[3],$Text,$Line[0],$Line[1]);
|
|---|
| 54 | } else
|
|---|
| 55 | {
|
|---|
| 56 | $Text = $this->ReplaceNotTranslated($Line[2],$Line[3],$Text,$Line[0],$Line[1]);
|
|---|
| 57 | }
|
|---|
| 58 | }
|
|---|
| 59 | }
|
|---|
| 60 | return $Text;
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | function LoadNames()
|
|---|
| 64 | {
|
|---|
| 65 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
|---|
| 66 | $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
|
|---|
| 67 |
|
|---|
| 68 | $Output = '';
|
|---|
| 69 | if (array_key_exists('GroupId', $_GET)) $GroupId = $_GET['GroupId'];
|
|---|
| 70 | else return ShowMessage(T('GroupId not specified'), MESSAGE_CRITICAL);
|
|---|
| 71 | if (!array_key_exists('ID', $_GET)) return ShowMessage(T('ID not specified'), MESSAGE_CRITICAL);
|
|---|
| 72 | if (!array_key_exists('Column', $_GET)) return ShowMessage(T('Column not specified'), MESSAGE_CRITICAL);
|
|---|
| 73 | $Table = $TranslationTree[$GroupId]['TablePrefix'];
|
|---|
| 74 | $DbResult = $this->System->Database->query('SELECT * FROM `'.$Table.'` WHERE `ID` = '.$_GET['ID'].' LIMIT 1');
|
|---|
| 75 | $LineAJ = $DbResult->fetch_assoc();
|
|---|
| 76 | $Column = $_GET['Column'];
|
|---|
| 77 | //$Text = $LineAJ[$TranslationTree[$GroupId]['Items'][$_GET['Item']]];
|
|---|
| 78 | $Text = $LineAJ[$Column];
|
|---|
| 79 | $names = array();
|
|---|
| 80 | if ($User->Licence(LICENCE_USER))
|
|---|
| 81 | if (($GroupId < 4) or ($GroupId == 10) or ($GroupId == 11))
|
|---|
| 82 | {
|
|---|
| 83 | //<span class="edit">barvou.</span>
|
|---|
| 84 | $names = GetTranslatNames($Text, 0, GetTranslatNamesArray());
|
|---|
| 85 | } else
|
|---|
| 86 | {
|
|---|
| 87 | if (($GroupId == 13))
|
|---|
| 88 | {
|
|---|
| 89 | $names = GetTranslatNames($Text, 0, array('Dictionary' => 'Text',
|
|---|
| 90 | 'TextGlobalString' => 'Text', 'TextArea' => 'Name',
|
|---|
| 91 | 'TextItemSubClass' => 'Name', 'TextCharacterRace' => 'Name1',), false);
|
|---|
| 92 | } else
|
|---|
| 93 | {
|
|---|
| 94 | $names = GetTranslatNames($Text, 0, GetTranslatNamesArray());
|
|---|
| 95 | }
|
|---|
| 96 | }
|
|---|
| 97 | //$LineAJ[$Column]
|
|---|
| 98 | return $this->ColorNames(htmlspecialchars($Text), $names);
|
|---|
| 99 | }
|
|---|
| 100 |
|
|---|
| 101 | function Show(): string
|
|---|
| 102 | {
|
|---|
| 103 | $this->RawPage = true;
|
|---|
| 104 | return str_replace("\n", '<br/>', $this->LoadNames());
|
|---|
| 105 | }
|
|---|
| 106 | }
|
|---|