1 | <?php
|
---|
2 |
|
---|
3 | class PageTranslationForm extends Page
|
---|
4 | {
|
---|
5 | var $GroupId;
|
---|
6 | var $ID;
|
---|
7 | function ReplaceTranslated($orig,$tran,$Text,$ID,$Group) {
|
---|
8 | $tran_replace = str_replace(' ',' ',htmlspecialchars($tran));
|
---|
9 | $orig_replace = str_replace(' ',' ',htmlspecialchars($orig));
|
---|
10 |
|
---|
11 | // if (strlen($orig) < strlen($Text)-1) {
|
---|
12 | if ($Group <> '') {
|
---|
13 | $Text = str_replace(' '.$orig,' <span Title="Přelož jako: '.$tran_replace.'" class="edit"><a class="edit" target="_NEW2" href="'.$this->System->Link('/form.php?group='.$Group.'&ID='.$ID).'">'.$orig_replace.'</a></span>',$Text);
|
---|
14 | } else {
|
---|
15 | $Text = str_replace(' '.$orig,' <span Title="Přelož jako: '.$tran_replace.'" class="edit"><a class="edit" target="_NEW2" href="'.$this->System->Link('/dictionary/?search='.$tran).'">'.$orig_replace.'</a></span>',$Text);
|
---|
16 | }
|
---|
17 | // }
|
---|
18 | return ($Text);
|
---|
19 | }
|
---|
20 | function ReplaceNotTranslated($orig,$tran,$Text,$ID,$Group) {
|
---|
21 | // echo $orig.'-'.$Text.'<br>';
|
---|
22 | $orig_replace = str_replace(' ',' ',htmlspecialchars($orig));
|
---|
23 |
|
---|
24 | $Text = str_replace(' '.$orig,' <span title="Kliknutím přeložíš" class="needtran"><a class="needtran" target="_NEW2" href="'.$this->System->Link('/form.php?group='.$Group.'&ID='.$ID).'">'.$orig_replace.'</a></span>',$Text);
|
---|
25 | return ($Text);
|
---|
26 | }
|
---|
27 |
|
---|
28 | function ColorNames($Text, $names)
|
---|
29 | {
|
---|
30 | $Text = ' '.$Text;
|
---|
31 | $Text = str_replace('$B$B','$B$B ',$Text);
|
---|
32 |
|
---|
33 | $Text = str_replace('$B','<span Title="Znamená odřádkování, překladu zachovej na stejné pozici." class="edit">$B</span>',$Text);
|
---|
34 | $Text = str_replace('$N','<span Title="Znamená jméno hráče, překladu zachovej na stejné pozici." class="edit">$N</span>',$Text);
|
---|
35 | $Text = str_replace('$R','<span Title="Znamená rasu hráče, překladu zachovej na stejné pozici." class="edit">$R</span>',$Text);
|
---|
36 | $Text = str_replace('$G','<span Title="Vybere oslovení podle pohlaví hráče, překladu zachovej na stejné pozici." class="edit">$G</span>',$Text);
|
---|
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('$g','<span Title="Vybere oslovení podle pohlaví hráče, překladu zachovej na stejné pozici." class="edit">$G</span>',$Text);
|
---|
41 | foreach($names as $Line) {
|
---|
42 | if (($this->ID <> $Line[0]) or ($Line[1] <> $this->GroupId))
|
---|
43 | if ($Line[3] <> '') {
|
---|
44 | $Text = $this->ReplaceTranslated($Line[2],$Line[3],$Text,$Line[0],$Line[1]);
|
---|
45 |
|
---|
46 | } else {
|
---|
47 | $Text = $this->ReplaceNotTranslated($Line[2],$Line[3],$Text,$Line[0],$Line[1]);
|
---|
48 | }
|
---|
49 | }
|
---|
50 | return $Text;
|
---|
51 | }
|
---|
52 |
|
---|
53 | function Show()
|
---|
54 | {
|
---|
55 | $this->Title = T('Translation');
|
---|
56 | $Action = '';
|
---|
57 | if(array_key_exists('action', $_GET)) $Action = $_GET['action'];
|
---|
58 |
|
---|
59 | if($Action == 'delete') $Output = $this->Delete();
|
---|
60 | else $Output = $this->ShowForm();
|
---|
61 | return($Output);
|
---|
62 | }
|
---|
63 |
|
---|
64 | function ShowForm()
|
---|
65 | {
|
---|
66 | global $TranslationTree;
|
---|
67 |
|
---|
68 | $Output = '';
|
---|
69 |
|
---|
70 | $GroupId = LoadGroupIdParameter();
|
---|
71 | $this->GroupId = $GroupId;
|
---|
72 | $Table = $TranslationTree[$GroupId]['TablePrefix'];
|
---|
73 | if(array_key_exists('action', $_GET)) $Action = $_GET['action'];
|
---|
74 | else $Action = '';
|
---|
75 |
|
---|
76 | if(array_key_exists('ID', $_GET))
|
---|
77 | {
|
---|
78 | $TextID = $_GET['ID'] * 1;
|
---|
79 | $this->ID = $TextID;
|
---|
80 |
|
---|
81 | $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE `ID` = '.$TextID);
|
---|
82 | $Line = $DbResult->fetch_assoc();
|
---|
83 | if(!$Line)
|
---|
84 | {
|
---|
85 | $Output .= ShowMessage('Překlad nenalezen.', MESSAGE_CRITICAL);
|
---|
86 | } else
|
---|
87 | {
|
---|
88 | if ($this->System->Config['OriginalLanguage'] == $Line['Language']){
|
---|
89 | $LineAJ = $Line;
|
---|
90 | $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE '.
|
---|
91 | '(`Language` != '.$this->System->Config['OriginalLanguage'].') AND '.
|
---|
92 | '(`Entry` = '.$Line['Entry'].') ORDER BY `ModifyTime` DESC LIMIT 1');
|
---|
93 | $LineSearch = $DbResult->fetch_assoc();
|
---|
94 | foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)
|
---|
95 | if($TextItem['Visible'] == 1)
|
---|
96 | if (($LineAJ[$TextItem['Column']] <> '') and ($LineSearch[$TextItem['Column']] <> '')) $Line[$TextItem['Column']] = $LineSearch[$TextItem['Column']];
|
---|
97 |
|
---|
98 | } else {
|
---|
99 | $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE '.
|
---|
100 | '(`Language` = '.$this->System->Config['OriginalLanguage'].') AND '.
|
---|
101 | '(`Entry` = '.$Line['Entry'].') AND (`VersionEnd` = '.$Line['VersionEnd'].') LIMIT 1');
|
---|
102 | $LineAJ = $DbResult->fetch_assoc();
|
---|
103 | }
|
---|
104 | if(!$LineAJ)
|
---|
105 | {
|
---|
106 | $Output .= ShowMessage('Anglický originál k překladu nenalezen.', MESSAGE_CRITICAL);
|
---|
107 | } else
|
---|
108 | {
|
---|
109 |
|
---|
110 | if($Line['User'] != '')
|
---|
111 | {
|
---|
112 | $IDUser = $this->Database->query('SELECT * FROM `User` WHERE `ID` = '.$Line['User']);
|
---|
113 | $LineUser = $IDUser->fetch_array();
|
---|
114 | } else
|
---|
115 | $LineUser = array('Name' => '');
|
---|
116 |
|
---|
117 | $Output .= 'Skupina: <strong>'.$TranslationTree[$GroupId]['Name'].'</strong><br />';
|
---|
118 |
|
---|
119 | if(($Line['Language'] <> 0) and ($LineUser['Name'] <> ''))
|
---|
120 | $Output .= 'Přeložil: <strong>'.$LineUser['Name'].'</strong> dne '.HumanDate($Line['ModifyTime']).'<br />';
|
---|
121 | if(($Line['Take'] <> 0) and ($Line['Take'] <> $Line['ID']))
|
---|
122 | {
|
---|
123 | $DbResult = $this->Database->query('SELECT `Language`,`VersionStart`,`VersionEnd` FROM `'.$Table.'` WHERE `ID` = '.$Line['Take']);
|
---|
124 | $Language = $DbResult->fetch_assoc();
|
---|
125 | // echo $Language['Language'].' '.$Line['Take'];
|
---|
126 |
|
---|
127 | $DbResult = $this->Database->query('SELECT `Name` FROM `Language` WHERE `Id` ='.$Language['Language']);
|
---|
128 | $Lang = $DbResult->fetch_assoc();
|
---|
129 |
|
---|
130 | $Output .= 'Původní text: <strong>'.
|
---|
131 | ' ID <a href="form.php?group='.$GroupId.'&ID='.$Line['Take'].'">'.$Line['Take'].'</a></strong>'.
|
---|
132 | ' ('.$Lang['Name'].')'.
|
---|
133 | ' <br />';
|
---|
134 | }
|
---|
135 | $Output .= 'Text: ';
|
---|
136 | if($Line['Language'] <> 0)
|
---|
137 | {
|
---|
138 | if($Line['Complete'] == 1) $Output .= ' <b>Hotov</b>';
|
---|
139 | else $Output .= ' <b> Uložen v rozepsaných</b> ';
|
---|
140 | } else $Output .= ' <b>Anglická, původní verze</b> ';
|
---|
141 |
|
---|
142 | $Output .= '<br />'.
|
---|
143 | 'Verze: <b>'.GetVersionWOW($Line['VersionStart']).' - '.GetVersionWOW($Line['VersionEnd']).'</b>'.
|
---|
144 | '<br />';
|
---|
145 |
|
---|
146 | $DbResult = $this->Database->query('SELECT COUNT(*) FROM `'.$Table.'` WHERE '.
|
---|
147 | '(`Entry` = '.$Line['Entry'].')');
|
---|
148 | $Version = $DbResult->fetch_row();
|
---|
149 | $Version = $Version[0];
|
---|
150 | if($Version > 0)
|
---|
151 | {
|
---|
152 | $Output .= '<form action="comparison.php" method="get"><a href="TranslationList.php?group='.
|
---|
153 | $GroupId.'&user=0&state=2&entry='.$Line['Entry'].'&text=">Počet verzí: <strong>'.$Version.'</strong></a>
|
---|
154 | <input type="hidden" name="group" value="'.$GroupId.'" />
|
---|
155 | <input type="hidden" name="entry" value="'.$Line['Entry'].'" />
|
---|
156 | <input type="hidden" name="ID2" value="'.$TextID.'" />
|
---|
157 | <select onchange="this.form.submit();" name="ID1">
|
---|
158 | <option value="-1">Vyberte text k porovnání</option>
|
---|
159 | <option value="-1">Zobrazit/porovnat všechny</option>';
|
---|
160 | $DataID = $this->Database->query('SELECT *, (SELECT `User`.`Name` AS `UserName` FROM `User` WHERE `User`.`ID` = `'.$Table.'`.`User`) AS `UserName` FROM `'.$Table.'` WHERE (`Entry` = '.$Line['Entry'].') AND (`ID` <> '.$Line['ID'].')');
|
---|
161 | while($Version = $DataID->fetch_array())
|
---|
162 | {
|
---|
163 | if($Version['ID'] == $Line['Take']) $Output .= '<option value="'.
|
---|
164 | $Version['ID'].'">'.$Version['ID'].' - '.$Version['User'].' (převzato)</option>';
|
---|
165 | else
|
---|
166 | {
|
---|
167 | if($Version['Language'] == 0) $Version['UserName'] = 'Předloha';
|
---|
168 | $Output .= '<option value="'.$Version['ID'].'">'.$Version['ID'].' - '.
|
---|
169 | $Version['UserName'].' ('.GetVersionWOW($Version['VersionStart']).' - '.
|
---|
170 | GetVersionWOW($Version['VersionEnd']).')</option>';
|
---|
171 | }
|
---|
172 | }
|
---|
173 | $Output .= '</select></form>';
|
---|
174 | } else
|
---|
175 | {
|
---|
176 | $Output .= '<a href="TranslationList.php?group='.$GroupId.'&user=0&state=2&entry='.
|
---|
177 | $Line['Entry'].'&text=">Počet verzí: <strong>'.$Version.'</strong></a>';
|
---|
178 | }
|
---|
179 |
|
---|
180 | // Special characters: $B - New line, $N - Name, $C - profession
|
---|
181 | if($this->System->User->Licence(LICENCE_USER))
|
---|
182 | {
|
---|
183 | $Output .= '<form action="save.php?group='.$GroupId.'" method="post"><div>';
|
---|
184 | // TODO: Remove fixed group id condition
|
---|
185 | // if(($GroupId < 4) or ($GroupId == 10) or ($GroupId == 11))
|
---|
186 | $Output .= '<a href="'.$this->System->Link('/dictionary/?action=group&group='.$GroupId.'&ID='.$LineAJ['ID']).'" target="_blank" title="Zobrazit přeložené názvy věci, postav, a herních objektů k tomuto překladu">Vyhledat v názvech</a>';
|
---|
187 | $Output .= ' <input type="submit" value="Uložit do rozepsaných" name="save" title="Klikněte na uložit pro pozdější dokončení překladu" />'.
|
---|
188 | '<input type="submit" value="Dokončeno" name="End" title="Klikněte na Dokončeno jesli jsou všechny texty hotové a chcete již publikovat" /> ';
|
---|
189 | FollowingTran($TextID, $Table, $GroupId, true);
|
---|
190 | FollowingTran($TextID, $Table, $GroupId);
|
---|
191 | }
|
---|
192 |
|
---|
193 | if($TranslationTree[$GroupId]['WowheadName'] != '')
|
---|
194 | $WowheadLink = '<a href="http://www.wowhead.com/?'.$TranslationTree[$GroupId]['WowheadName'].'='.$LineAJ['Entry'].'">'.$LineAJ['Entry'].'</a>';
|
---|
195 | else $WowheadLink = $LineAJ['Entry'];
|
---|
196 |
|
---|
197 | $Output .= '<input type="hidden" name="entry" value="'.$LineAJ['Entry'].'" />
|
---|
198 | <input type="hidden" name="user" value="'.$this->System->User->Id.'" />
|
---|
199 | <input type="hidden" name="ID" value="'.$TextID.'" />
|
---|
200 | <table class="BaseTable">
|
---|
201 | <tr>
|
---|
202 | <th>Číslo textu: '.$WowheadLink.'</th>
|
---|
203 | <th>Nepřeložené</th>
|
---|
204 | <th>Přeložené</th>
|
---|
205 | </tr>
|
---|
206 | <tr>
|
---|
207 | <th>Jazyk</th>
|
---|
208 | <td>Anglický</td>
|
---|
209 | <td>';
|
---|
210 | if($Line['Language'] <> 0) $Language = $Line['Language'];
|
---|
211 | else if($this->System->User->Id != 0)
|
---|
212 | {
|
---|
213 | $Language = $this->System->User->Language;
|
---|
214 | } else $Language = 0;
|
---|
215 | if($this->System->User->Licence(LICENCE_USER)) $Output .= WriteLanguages($Language);
|
---|
216 | else {
|
---|
217 | $DbResult3 = $this->Database->select('Language', '`Id`, `Name`', '`Enabled` = 1');
|
---|
218 | if($DbResult3->num_rows > 0)
|
---|
219 | {
|
---|
220 | $Language = $DbResult3->fetch_assoc();
|
---|
221 | $Output .= $Language['Name'];
|
---|
222 | }
|
---|
223 | }
|
---|
224 |
|
---|
225 | $Output .= '</td></tr>';
|
---|
226 |
|
---|
227 | // Difference highlighting
|
---|
228 | $Text = '';
|
---|
229 | foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)
|
---|
230 | if($TextItem['Visible'] == 1)
|
---|
231 | $Text = $Text.' '.$LineAJ[$TextItem['Column']];
|
---|
232 |
|
---|
233 | if(($GroupId < 4) or ($GroupId == 10) or ($GroupId == 11)) {
|
---|
234 | //<span class="edit">barvou.</span>
|
---|
235 | $names = GetTranslatNames($Text, 0, GetTranslatNamesArray());
|
---|
236 | } else {
|
---|
237 | $names = GetTranslatNames($Text, 0, array('Dictionary' => 'Text'));
|
---|
238 | }
|
---|
239 |
|
---|
240 | foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)
|
---|
241 | if($TextItem['Visible'] == 1)
|
---|
242 | {
|
---|
243 | if(($LineAJ[$TextItem['Column']] <> '') or ($Line[$TextItem['Column']] <> ''))
|
---|
244 | {
|
---|
245 | if(($TextItem['Name'] == 'Text') and (($Table == 'global_strings') or ($Table == 'glue_strings')))
|
---|
246 | $Output .= '<tr><th>'.$LineAJ['ShortCut'].'</th>';
|
---|
247 | else $Output .= '<tr><th>'.$TextItem['Name'].'</th>';
|
---|
248 | $Output .= '<td>'.str_replace("\n", '<br/>', $this->ColorNames(htmlspecialchars($LineAJ[$TextItem['Column']]),$names)).'</td>
|
---|
249 | <td>';
|
---|
250 | if($this->System->User->Licence(LICENCE_USER))
|
---|
251 | $Output .= '<textarea rows="8" cols="40" onkeydown="ResizeTextArea(this)" class="textedit" id="'.$TextItem['Column'].'" name="'.$TextItem['Column'].'">';
|
---|
252 | $Output .= htmlspecialchars($Line[$TextItem['Column']]);
|
---|
253 | if($this->System->User->Licence(LICENCE_USER)) $Output .= '</textarea></td></tr>';
|
---|
254 | }
|
---|
255 | } else
|
---|
256 | {
|
---|
257 | $Output .= '<input id="'.$TextItem['Column'].'" name="'.$TextItem['Column'].'" type="hidden" value="'.htmlspecialchars($Line[$TextItem['Column']]).'" />';
|
---|
258 | }
|
---|
259 | $Output .= '</table></div>';
|
---|
260 | if($this->System->User->Licence(LICENCE_USER)) $Output .= '</form>';
|
---|
261 | }
|
---|
262 | }
|
---|
263 | } else $Output = ShowMessage('Nebylo zadáno ID.', MESSAGE_CRITICAL);
|
---|
264 | return($Output);
|
---|
265 | }
|
---|
266 |
|
---|
267 | function Delete()
|
---|
268 | {
|
---|
269 | if($this->System->User->Licence(LICENCE_MODERATOR))
|
---|
270 | {
|
---|
271 | $TextID = $_GET['ID'];
|
---|
272 | $this->Database->query('DELETE FROM `'.$Table.'` WHERE `ID` = '.$TextID.' AND `Language` <> '.$this->System->Config['OriginalLanguage']);
|
---|
273 | $Output = ShowMessage('Překlad byl smazán.');
|
---|
274 | $this->System->ModuleManager->Modules['Log']->WriteLog('Překlad byl smazán! <a href="'.$this->System->Link('/form.php?group='.$GroupID.'&ID='.$TextID).'">'.$TextID.'</a>', LOG_TYPE_MODERATOR);
|
---|
275 | } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
|
---|
276 | return($Output);
|
---|
277 | }
|
---|
278 | }
|
---|