Changeset 816 for trunk/Modules/Translation/Form.php
- Timestamp:
- Feb 22, 2015, 11:20:50 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Translation/Form.php
r813 r816 6 6 var $ID; 7 7 8 9 10 11 8 function Show() 9 { 10 $this->Title = T('Translation'); 11 $Action = ''; 12 12 if(array_key_exists('action', $_GET)) $Action = $_GET['action']; 13 13 14 14 if($Action == 'delete') $Output = $this->Delete(); 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 15 else $Output = $this->ShowForm(); 16 return($Output); 17 } 18 19 function ShowForm() 20 { 21 global $TranslationTree; 22 23 $Output = ''; 24 25 $GroupId = LoadGroupIdParameter(); 26 $this->GroupId = $GroupId; 27 $Table = $TranslationTree[$GroupId]['TablePrefix']; 28 if(array_key_exists('action', $_GET)) $Action = $_GET['action']; 29 else $Action = ''; 30 31 if(array_key_exists('ID', $_GET)) 32 { 33 $TextID = $_GET['ID'] * 1; 34 $this->ID = $TextID; 35 36 $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE `ID` = '.$TextID); 37 $Line = $DbResult->fetch_assoc(); 38 if(!$Line) 39 { 40 $Output .= ShowMessage('Překlad nenalezen.', MESSAGE_CRITICAL); 41 } else 42 { 43 if ($this->System->Config['OriginalLanguage'] == $Line['Language']){ 44 44 $LineAJ = $Line; 45 45 … … 51 51 52 52 53 53 $sql = 'SELECT '.$Columns.' Tran.`Entry` FROM `'.$Table.'` as Tran'; 54 54 $join = ' JOIN `'.$Table.'` as `Orig` ON `Orig`.`Language` = 0 AND `Tran`.`Entry` = `Orig`.`Entry` AND `Tran`.`VersionEnd` = `Orig`.`VersionEnd` '; 55 55 $where = ' WHERE '.'( `Tran`.'.$Language.' ) AND '.'(`Tran`.`Entry` = '.$Line['Entry'].') ORDER BY `Tran`.`ModifyTime` DESC'; 56 56 $DbResult = $this->Database->query($sql.$join.$where); 57 57 while ($LineSearch = $DbResult->fetch_assoc()) { 58 59 60 58 foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) 59 if($TextItem['Visible'] == 1) 60 if (($LineAJ[$TextItem['Column']] <> '') and 61 61 ($LineSearch[$TextItem['Column']] <> '') and 62 62 ($LineSearch['Orig_'.$TextItem['Column']] <> $LineSearch[$TextItem['Column']]) and … … 65 65 { 66 66 $Line[$TextItem['Column']] = $LineSearch[$TextItem['Column']]; 67 67 // echo $Line[$TextItem['Column']].'<br />'; 68 68 } 69 69 } 70 70 71 71 } else { 72 73 74 75 72 $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE '. 73 '(`Language` = '.$this->System->Config['OriginalLanguage'].') AND '. 74 '(`Entry` = '.$Line['Entry'].') AND (`VersionEnd` = '.$Line['VersionEnd'].') LIMIT 1'); 75 $LineAJ = $DbResult->fetch_assoc(); 76 76 } 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 77 if(!$LineAJ) 78 { 79 $Output .= ShowMessage('Anglický originál k překladu nenalezen.', MESSAGE_CRITICAL); 80 } else 81 { 82 83 if($Line['User'] != '') 84 { 85 $IDUser = $this->Database->query('SELECT * FROM `User` WHERE `ID` = '.$Line['User']); 86 $LineUser = $IDUser->fetch_array(); 87 } else 88 $LineUser = array('Name' => ''); 89 90 $Output .= 'Skupina: <strong>'.$TranslationTree[$GroupId]['Name'].'</strong><br />'; 91 92 if(($Line['Language'] <> 0) and ($LineUser['Name'] <> '')) 93 $Output .= 'Přeložil: <strong>'.$LineUser['Name'].'</strong> dne '.HumanDate($Line['ModifyTime']).'<br />'; 94 if(($Line['Take'] <> 0) and ($Line['Take'] <> $Line['ID'])) 95 { 96 $DbResult = $this->Database->query('SELECT `Language`,`VersionStart`,`VersionEnd` FROM `'.$Table.'` WHERE `ID` = '.$Line['Take']); 97 $Language = $DbResult->fetch_assoc(); 98 // echo $Language['Language'].' '.$Line['Take']; 99 100 $DbResult = $this->Database->query('SELECT `Name` FROM `Language` WHERE `Id` ='.$Language['Language']); 101 $Lang = $DbResult->fetch_assoc(); 102 103 $Output .= 'Původní text: <strong>'. 104 ' ID <a href="form.php?group='.$GroupId.'&ID='.$Line['Take'].'">'.$Line['Take'].'</a></strong>'. 105 ' ('.$Lang['Name'].')'. 106 ' <br />'; 107 } 108 $Output .= 'Text: '; 109 if($Line['Language'] <> 0) 110 { 111 if($Line['Complete'] == 1) $Output .= ' <b>Hotov</b>'; 112 else $Output .= ' <b> Uložen v rozepsaných</b> '; 113 } else $Output .= ' <b>Anglická, původní verze</b> '; 114 115 $Output .= '<br />'. 116 'Verze: <b><a href="'.$this->System->Link('/client-version/?action=item&id='.GetVersionWOWId($Line['VersionStart'])).'">'.GetVersionWOW($Line['VersionStart']). 117 117 '</a> - <a href="'.$this->System->Link('/client-version/?action=item&id='.GetVersionWOWId($Line['VersionEnd'])).'">'.GetVersionWOW($Line['VersionEnd']).'</a></b>'. 118 119 120 121 122 123 124 125 126 127 128 129 130 118 '<br />'; 119 120 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `'.$Table.'` WHERE '. 121 '(`Entry` = '.$Line['Entry'].')'); 122 $Version = $DbResult->fetch_row(); 123 $Version = $Version[0]; 124 if($Version > 0) 125 { 126 $Output .= '<form action="comparison.php" method="get"><a href="TranslationList.php?group='. 127 $GroupId.'&user=0&state=2&entry='.$Line['Entry'].'&text=">Počet verzí: <strong>'.$Version.'</strong></a> 128 <input type="hidden" name="group" value="'.$GroupId.'" /> 129 <input type="hidden" name="entry" value="'.$Line['Entry'].'" /> 130 <input type="hidden" name="ID2" value="'.$TextID.'" />'; 131 131 132 132 if($this->System->User->Licence(LICENCE_USER)) { //allow to compare only to user 133 133 $Output .= '<select onchange="this.form.submit();" name="ID1"> 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 134 <option value="-1">Vyberte text k porovnání</option> 135 <option value="-1">Zobrazit/porovnat všechny</option>'; 136 $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'].')'); 137 while($Version = $DataID->fetch_array()) 138 { 139 if($Version['ID'] == $Line['Take']) $Output .= '<option value="'. 140 $Version['ID'].'">'.$Version['ID'].' - '.$Version['User'].' (převzato)</option>'; 141 else 142 { 143 if($Version['Language'] == 0) $Version['UserName'] = 'Předloha'; 144 $Output .= '<option value="'.$Version['ID'].'">'.$Version['ID'].' - '. 145 $Version['UserName'].' ('.GetVersionWOW($Version['VersionStart']).' - '. 146 GetVersionWOW($Version['VersionEnd']).')</option>'; 147 } 148 } 149 $Output .= '</select>'; 150 150 } 151 151 $Output .= '</form>'; 152 153 154 155 156 157 158 159 160 161 162 163 //if(($GroupId < 4) or ($GroupId == 10) or ($GroupId == 11))164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 152 } else 153 { 154 $Output .= '<a href="TranslationList.php?group='.$GroupId.'&user=0&state=2&entry='. 155 $Line['Entry'].'&text=">Počet verzí: <strong>'.$Version.'</strong></a>'; 156 } 157 158 // Special characters: $B - New line, $N - Name, $C - profession 159 if($this->System->User->Licence(LICENCE_USER)) 160 { 161 $Output .= '<form action="save.php?group='.$GroupId.'" method="post"><div>'; 162 // TODO: Remove fixed group id condition 163 // if(($GroupId < 4) or ($GroupId == 10) or ($GroupId == 11)) 164 $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>'; 165 $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" />'. 166 '<input type="submit" value="Dokončeno" name="End" title="Klikněte na Dokončeno jesli jsou všechny texty hotové a chcete již publikovat" /> '; 167 FollowingTran($TextID, $Table, $GroupId, true); 168 FollowingTran($TextID, $Table, $GroupId); 169 } 170 171 if($TranslationTree[$GroupId]['WowheadName'] != '') 172 $WowheadLink = '<a href="http://www.wowhead.com/?'.$TranslationTree[$GroupId]['WowheadName'].'='.$LineAJ['Entry'].'">'.$LineAJ['Entry'].'</a>'; 173 else $WowheadLink = $LineAJ['Entry']; 174 175 $Output .= '<input type="hidden" name="entry" value="'.$LineAJ['Entry'].'" /> 176 <input type="hidden" name="user" value="'.$this->System->User->Id.'" /> 177 <input type="hidden" name="ID" value="'.$TextID.'" /> 178 <table class="BaseTable"> 179 <tr> 180 <th>Číslo textu: '.$WowheadLink.'</th> 181 <th>Nepřeložené</th> 182 <th>Přeložené</th> 183 </tr> 184 <tr> 185 <th>Jazyk</th> 186 <td>Anglický</td> 187 <td>'; 188 if($Line['Language'] <> 0) $Language = $Line['Language']; 189 else if($this->System->User->Id != 0) 190 { 191 $Language = $this->System->User->Language; 192 } else $Language = 0; 193 if($this->System->User->Licence(LICENCE_USER)) $Output .= WriteLanguages($Language); 194 else { 195 $DbResult3 = $this->Database->select('Language', '`Id`, `Name`', '(`Enabled` = 1) AND (`Id`='.$Language.')'); 196 if($DbResult3->num_rows > 0) 197 { 198 $Language = $DbResult3->fetch_assoc(); 199 $Output .= $Language['Name']; 200 } 201 } 202 203 $Output .= '</td></tr>'; 204 204 205 205 //todo javascript 206 206 207 207 $Output .= '<script src="http://code.jquery.com/jquery-latest.js"></script>'. 208 208 '<script>'; 209 209 $Output .= '$(document).ready(function() {'; 210 210 foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) 211 211 $Output .= '$("#'.$TextItem['Column'].'").load("'.$this->System->Link('/LoadNames.php?ID='.$LineAJ['ID'].'&Column='.$TextItem['Column'].'&GroupId='.$GroupId).'");'; 212 212 … … 214 214 '</script>'; 215 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 216 foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) 217 if($TextItem['Visible'] == 1) 218 { 219 if(($LineAJ[$TextItem['Column']] <> '') or ($Line[$TextItem['Column']] <> '')) 220 { 221 if(($TextItem['Name'] == 'Text') and (($Table == 'global_strings') or ($Table == 'glue_strings'))) 222 $Output .= '<tr><th>'.$LineAJ['ShortCut'].'</th>'; 223 else $Output .= '<tr><th>'.$TextItem['Name'].'</th>'; 224 $Output .= '<td id="'.$TextItem['Column'].'">'.str_replace("\n", '<br/>', htmlspecialchars($LineAJ[$TextItem['Column']])).'</td> 225 <td>'; 226 if($this->System->User->Licence(LICENCE_USER)) 227 $Output .= '<textarea rows="8" cols="40" onkeydown="ResizeTextArea(this)" class="textedit" id="'.$TextItem['Column'].'" name="'.$TextItem['Column'].'">'; 228 $Output .= htmlspecialchars($Line[$TextItem['Column']]); 229 if($this->System->User->Licence(LICENCE_USER)) $Output .= '</textarea></td></tr>'; 230 } 231 } else 232 { 233 $Output .= '<input id="'.$TextItem['Column'].'" name="'.$TextItem['Column'].'" type="hidden" value="'.htmlspecialchars($Line[$TextItem['Column']]).'" />'; 234 } 235 $Output .= '</table></div>'; 236 if($this->System->User->Licence(LICENCE_USER)) { 237 237 $Output .= '</form>'; 238 238 239 239 $Output .= '<table class="BaseTable">'. 240 241 242 243 240 '<tr><th>Překladač:</th><th>Nepřeložené</th><th>Přeložené</th>'; 241 foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) 242 if($TextItem['Visible'] == 1) 243 if ($LineAJ[$TextItem['Column']] <> '') 244 244 $Output .= '<tr><td>'.$TextItem['Column'].'</td><td>'.$LineAJ[$TextItem['Column']].'</td><td>'.GetTranslateGoogle($LineAJ[$TextItem['Column']]).'</td></tr>'; 245 245 … … 247 247 $Output .= '</table>'; 248 248 } 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 249 } 250 } 251 } else $Output = ShowMessage('Nebylo zadáno ID.', MESSAGE_CRITICAL); 252 return($Output); 253 } 254 255 function Delete() 256 { 257 global $TranslationTree; 258 259 if($this->System->User->Licence(LICENCE_MODERATOR)) 260 { 261 $GroupId = LoadGroupIdParameter(); 262 $this->GroupId = $GroupId; 263 $Table = $TranslationTree[$GroupId]['TablePrefix']; 264 $TextID = $_GET['ID']; 265 $this->Database->query('DELETE FROM `'.$Table.'` WHERE `ID` = '.$TextID.' AND `Language` <> '.$this->System->Config['OriginalLanguage']); 266 $Output = ShowMessage('Překlad byl smazán.'); 267 $this->System->ModuleManager->Modules['Log']->WriteLog('Překlad byl smazán! <a href="'.$this->System->Link('/form.php?group='.$this->GroupId.'&ID='.$TextID).'">'.$TextID.'</a>', LOG_TYPE_MODERATOR); 268 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 269 return($Output); 270 } 271 271 }
Note:
See TracChangeset
for help on using the changeset viewer.