Changeset 816 for trunk/Modules/Translation
- Timestamp:
- Feb 22, 2015, 11:20:50 PM (10 years ago)
- Location:
- trunk/Modules/Translation
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Translation/Comparison.php
r752 r816 3 3 class PageTranslationComparison extends Page 4 4 { 5 6 7 8 9 10 11 12 13 14 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 5 function CompareString($String1, $String2) 6 { 7 $Result = ''; 8 //TODO: Implement colored comparison 9 //strcasecmp($String1, $String2) == 0 je totožné 10 // echo $String1.'<br /><br />'; 11 $ArrStr1 = explode(' ', $String1); 12 $ArrStr2 = explode(' ', $String2); 13 14 for($i = 0; $i < count($ArrStr1); $i++) 15 { 16 if(isset($ArrStr2[$i])) 17 { 18 if($ArrStr1[$i] == $ArrStr2[$i]) 19 { 20 $Result .= $ArrStr1[$i].' '; 21 } else 22 { 23 $find = false; 24 for($j = 0; $j < count($ArrStr2); $j++) 25 { 26 if(($ArrStr1[$i] == $ArrStr2[$j]) and ($find == false)) 27 { 28 $Result .= $ArrStr1[$i].' '; 29 $find = true; 30 } 31 } 32 if($find == false) 33 $Result .= '<span class="edit">'.$ArrStr1[$i].' </span>'; 34 } 35 } else $Result .= '<span class="edit">'.$ArrStr1[$i].' </span>'; 36 } 37 return($Result); 38 } 39 40 function Show() 41 { 42 global $TranslationTree; 43 44 44 $Output = ''; 45 45 46 47 46 if($this->System->User->Licence(LICENCE_USER)) 47 { 48 48 $Output = 'Text je porovnáván vždy ku předešlému (vlevo). Změny jsou zvýrazněny <span class="edit">barvou.</span><br /><br />'; 49 50 $GroupId = LoadGroupIdParameter();51 $Table = $TranslationTree[$GroupId]['TablePrefix'];52 53 if(array_key_exists('entry', $_GET))54 {55 $Textentry = $_GET['entry'];56 if((array_key_exists('ID1', $_GET)) and ($_GET['ID1'] <> -1)) //porovnání pouze 2 textů57 {58 $TextID1 = $_GET['ID1'];59 $TextID2 = $_GET['ID2'];60 $WhereID = ' AND ((`'.$Table.'`.`ID` = '.$TextID1.') OR (`'.$Table.'`.`ID` = '.$TextID2.'))';61 } else $WhereID = '';62 63 $DataID = $this->Database->query('SELECT `'.$Table.'`.*, `User`.`Name` AS `UserName`, '.64 '`Language`.`Name` AS `LanguageName` '.65 'FROM '.$Table.' LEFT JOIN `User` ON `User`.`Id` = `'.$Table.'`.`User` '.66 ' LEFT JOIN `Language` ON `Language`.`Id` = `'.$Table.'`.`Language` '.67 'WHERE `Entry` = '.$Textentry.' '.$WhereID.' ORDER BY `Language`');68 while($Line[] = $DataID->fetch_assoc());69 array_pop($Line);70 71 $Output .= 'Počet porovnávaných textů: <strong>'.count($Line).'</strong><br /> ';72 73 $Output .= '<strong>Číslo textu: <a href="http://www.wowhead.com/?quest='.$Textentry.'">'.$Textentry.'</a></strong>'.74 '<table class="BaseTable">'.75 '<tr><th>Přeložil</th>';76 foreach($Line as $Index => $LineItem)77 $Output .= '<th>'.$LineItem['UserName'].'</th>';78 $Output .= '</tr>'.79 '<tr>'.80 '<th>ID textu</th>';81 foreach($Line as $Index => $LineItem)82 $Output .= '<td><a href="form.php?group='.$GroupId.'&ID='.$LineItem['ID'].'">'.$LineItem['ID'].'</a></td>';83 $Output .= '</tr>'.84 '<tr><th>Převzato</th>';85 foreach($Line as $Index => $LineItem)86 $Output .= '<td><a href="form.php?group='.$GroupId.'&ID='.$LineItem['Take'].'">'.$LineItem['Take'].'</a></td>';87 $Output .= '</tr>'.88 '<tr><th>Jazyk</th>';89 foreach($Line as $Index => $LineItem)90 $Output .= '<td>'.$LineItem['LanguageName'].'</td>';91 $Output .= '</tr>'.92 '<tr><th>Verze</th>';93 foreach($Line as $Index => $LineItem)94 $Output .= '<td>'.GetVersionWOW($LineItem['VersionStart']).' - '.GetVersionWOW($LineItem['VersionEnd']).'</td>';95 $Output .= '</tr>';96 foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)97 {98 $writethis = false;99 for($i = 0; $i < count($Line); $i++)100 {101 if($Line[$i][$TextItem['Column']] <> '') $writethis = true;102 }103 if($writethis)104 {105 $Output .= '<tr><th>'.$TextItem['Name'].'</th>';106 for($i = 0; $i < count($Line); $i++)107 {108 if($i > 0)109 {110 $Output .= '<td>';111 $Output .= str_replace("\n", '<br/>', $this->CompareString(htmlspecialchars($Line[$i][$TextItem['Column']]),htmlspecialchars($Line[$i - 1][$TextItem['Column']])));112 $Output .= '</td>';113 } else $Output .= '<td>'.htmlspecialchars($Line[$i][$TextItem['Column']]).'</td>';114 }115 $Output .= '</tr>';116 }117 }118 $Output .= '</table>';119 } else $Output .= ShowMessage('Nebylo zadáno ID.', MESSAGE_CRITICAL);120 } else $Output .= ShowMessage('Porovnávat můžou pouze překladatelé!', MESSAGE_CRITICAL);121 49 122 return($Output); 123 } 50 $GroupId = LoadGroupIdParameter(); 51 $Table = $TranslationTree[$GroupId]['TablePrefix']; 52 53 if(array_key_exists('entry', $_GET)) 54 { 55 $Textentry = $_GET['entry']; 56 if((array_key_exists('ID1', $_GET)) and ($_GET['ID1'] <> -1)) //porovnání pouze 2 textů 57 { 58 $TextID1 = $_GET['ID1']; 59 $TextID2 = $_GET['ID2']; 60 $WhereID = ' AND ((`'.$Table.'`.`ID` = '.$TextID1.') OR (`'.$Table.'`.`ID` = '.$TextID2.'))'; 61 } else $WhereID = ''; 62 63 $DataID = $this->Database->query('SELECT `'.$Table.'`.*, `User`.`Name` AS `UserName`, '. 64 '`Language`.`Name` AS `LanguageName` '. 65 'FROM '.$Table.' LEFT JOIN `User` ON `User`.`Id` = `'.$Table.'`.`User` '. 66 ' LEFT JOIN `Language` ON `Language`.`Id` = `'.$Table.'`.`Language` '. 67 'WHERE `Entry` = '.$Textentry.' '.$WhereID.' ORDER BY `Language`'); 68 while($Line[] = $DataID->fetch_assoc()); 69 array_pop($Line); 70 71 $Output .= 'Počet porovnávaných textů: <strong>'.count($Line).'</strong><br /> '; 72 73 $Output .= '<strong>Číslo textu: <a href="http://www.wowhead.com/?quest='.$Textentry.'">'.$Textentry.'</a></strong>'. 74 '<table class="BaseTable">'. 75 '<tr><th>Přeložil</th>'; 76 foreach($Line as $Index => $LineItem) 77 $Output .= '<th>'.$LineItem['UserName'].'</th>'; 78 $Output .= '</tr>'. 79 '<tr>'. 80 '<th>ID textu</th>'; 81 foreach($Line as $Index => $LineItem) 82 $Output .= '<td><a href="form.php?group='.$GroupId.'&ID='.$LineItem['ID'].'">'.$LineItem['ID'].'</a></td>'; 83 $Output .= '</tr>'. 84 '<tr><th>Převzato</th>'; 85 foreach($Line as $Index => $LineItem) 86 $Output .= '<td><a href="form.php?group='.$GroupId.'&ID='.$LineItem['Take'].'">'.$LineItem['Take'].'</a></td>'; 87 $Output .= '</tr>'. 88 '<tr><th>Jazyk</th>'; 89 foreach($Line as $Index => $LineItem) 90 $Output .= '<td>'.$LineItem['LanguageName'].'</td>'; 91 $Output .= '</tr>'. 92 '<tr><th>Verze</th>'; 93 foreach($Line as $Index => $LineItem) 94 $Output .= '<td>'.GetVersionWOW($LineItem['VersionStart']).' - '.GetVersionWOW($LineItem['VersionEnd']).'</td>'; 95 $Output .= '</tr>'; 96 foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) 97 { 98 $writethis = false; 99 for($i = 0; $i < count($Line); $i++) 100 { 101 if($Line[$i][$TextItem['Column']] <> '') $writethis = true; 102 } 103 if($writethis) 104 { 105 $Output .= '<tr><th>'.$TextItem['Name'].'</th>'; 106 for($i = 0; $i < count($Line); $i++) 107 { 108 if($i > 0) 109 { 110 $Output .= '<td>'; 111 $Output .= str_replace("\n", '<br/>', $this->CompareString(htmlspecialchars($Line[$i][$TextItem['Column']]),htmlspecialchars($Line[$i - 1][$TextItem['Column']]))); 112 $Output .= '</td>'; 113 } else $Output .= '<td>'.htmlspecialchars($Line[$i][$TextItem['Column']]).'</td>'; 114 } 115 $Output .= '</tr>'; 116 } 117 } 118 $Output .= '</table>'; 119 } else $Output .= ShowMessage('Nebylo zadáno ID.', MESSAGE_CRITICAL); 120 } else $Output .= ShowMessage('Porovnávat můžou pouze překladatelé!', MESSAGE_CRITICAL); 121 122 return($Output); 123 } 124 124 } -
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 } -
trunk/Modules/Translation/LoadNames.php
r806 r816 3 3 class PageLoadNames extends Page 4 4 { 5 function ReplaceTranslated($orig,$tran,$Text,$ID,$Group) 5 function ReplaceTranslated($orig,$tran,$Text,$ID,$Group) 6 6 { 7 7 $tran_replace = str_replace(' ',' ',htmlspecialchars($tran)); … … 9 9 10 10 // if (strlen($orig) < strlen($Text)-1) { 11 if ($Group <> '') 11 if ($Group <> '') 12 12 { 13 13 $Text = str_replace(' '.$orig,' <span Title="Přelož jako: '.$tran_replace. 14 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 { 15 } else { 16 16 $Text = str_replace(' '.$orig,' <span Title="Přelož jako: '.$tran_replace. 17 17 '" class="edit"><a class="edit" target="_NEW2" href="'.$this->System->Link('/dictionary/?search='.$tran).'">'.$orig_replace.'</a></span>',$Text); 18 18 } 19 //}19 // } 20 20 return ($Text); 21 21 } 22 function ReplaceNotTranslated($orig,$tran,$Text,$ID,$Group) 22 function ReplaceNotTranslated($orig,$tran,$Text,$ID,$Group) 23 23 { 24 24 $orig_replace = str_replace(' ',' ',htmlspecialchars($orig)); 25 25 26 26 $Text = str_replace(' '.$orig,' <span title="Kliknutím přeložíš" class="needtran"><a class="needtran" target="_NEW2" href="'. 27 27 $this->System->Link('/form.php?group='.$Group.'&ID='.$ID).'">'.$orig_replace.'</a></span>',$Text); 28 28 return ($Text); 29 29 } 30 31 32 30 31 function ColorNames($Text, $names) 32 { 33 33 $Text = ' '.$Text; 34 34 $Text = str_replace('$B$B','$B$B ',$Text); 35 36 37 38 39 40 41 42 43 44 45 46 47 if (($_GET['ID'] <> $Line[0]) or ($Line[1] <> $_GET['GroupId'])) 35 36 $Text = str_replace('$B','<span Title="Znamená odřádkování, překladu zachovej na stejné pozici." class="edit">$B</span>',$Text); 37 $Text = str_replace('$N','<span Title="Znamená jméno hráče, překladu zachovej na stejné pozici." class="edit">$N</span>',$Text); 38 $Text = str_replace('$R','<span Title="Znamená rasu hráče, překladu zachovej na stejné pozici." class="edit">$R</span>',$Text); 39 $Text = str_replace('$C','<span Title="Znamená povolání hráče, překladu zachovej na stejné pozici." class="edit">$C</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 $Text = str_replace('$b','<span Title="Znamená odřádkování, překladu zachovej na stejné pozici." class="edit">$B</span>',$Text); 42 $Text = str_replace('$n','<span Title="Znamená jméno hráče, překladu zachovej na stejné pozici." class="edit">$N</span>',$Text); 43 $Text = str_replace('$c','<span Title="Znamená povolání hráče, překladu zachovej na stejné pozici." class="edit">$c</span>',$Text); 44 $Text = str_replace('$r','<span Title="Znamená rasu hráče, překladu zachovej na stejné pozici." class="edit">$R</span>',$Text); 45 $Text = str_replace('$g','<span Title="Vybere oslovení podle pohlaví hráče, překladu zachovej na stejné pozici." class="edit">$G</span>',$Text); 46 foreach($names as $Line) { 47 if (($_GET['ID'] <> $Line[0]) or ($Line[1] <> $_GET['GroupId'])) 48 48 if ($Line[3] <> '') { 49 49 $Text = $this->ReplaceTranslated($Line[2],$Line[3],$Text,$Line[0],$Line[1]); 50 51 50 51 } else { 52 52 $Text = $this->ReplaceNotTranslated($Line[2],$Line[3],$Text,$Line[0],$Line[1]); 53 54 55 56 } 53 } 54 } 55 return $Text; 56 } 57 57 58 function LoadNames() 58 function LoadNames() 59 59 { 60 60 global $TranslationTree; 61 61 62 62 $Output = ''; 63 63 if(array_key_exists('GroupId', $_GET)) $GroupId = $_GET['GroupId']; … … 71 71 //$Text = $LineAJ[$TranslationTree[$GroupId]['Items'][$_GET['Item']]]; 72 72 $Text = $LineAJ[$Column]; 73 74 75 if(($GroupId < 4) or ($GroupId == 10) or ($GroupId == 11)) 73 $names = array(); 74 if ($this->System->User->Licence(LICENCE_USER)) 75 if(($GroupId < 4) or ($GroupId == 10) or ($GroupId == 11)) 76 76 { 77 78 79 80 81 77 //<span class="edit">barvou.</span> 78 $names = GetTranslatNames($Text, 0, GetTranslatNamesArray()); 79 } else { 80 if(($GroupId == 13)) { 81 $names = GetTranslatNames($Text, 0, array('Dictionary' => 'Text', 'TextGlobalString' => 'Text', 'TextArea' => 'Name', 'TextItemSubClass' => 'Name', 'TextCharacterRace' => 'Name1',),false); 82 82 } else { 83 84 85 86 87 83 $names = GetTranslatNames($Text, 0, GetTranslatNamesArray()); 84 } 85 } 86 //$LineAJ[$Column] 87 return ($this->ColorNames(htmlspecialchars($Text),$names)); 88 88 } 89 89 90 90 function Show() 91 91 { 92 92 $this->RawPage = true; 93 93 return(str_replace("\n", '<br/>', $this->LoadNames())); 94 94 } -
trunk/Modules/Translation/Progress.php
r793 r816 6 6 { 7 7 $Output = ''; 8 8 9 9 $BuildNumber = GetBuildNumber($_SESSION['StatVersion']); 10 10 if(is_numeric($_SESSION['language'])) $LanguageFilter = 'AND (`Language`='.$_SESSION['language'].')'; 11 11 else $LanguageFilter = ' AND (`Language`!='.$this->System->Config['OriginalLanguage'].')'; 12 12 13 13 $GroupListQuery = 'SELECT `Id`, `TablePrefix`, `Name` FROM `Group`'; 14 14 $Query = ''; … … 30 30 } 31 31 $Query = substr($Query, 0, - 6); 32 32 33 33 $DbResult = $this->Database->query('SELECT COUNT(*) FROM ('.$GroupListQuery.') AS `T`'); 34 34 $DbRow = $DbResult->fetch_row(); 35 35 $PageList = GetPageList($DbRow[0]); 36 36 $Output .= $PageList['Output']; 37 37 38 38 $Output .= '<table class="BaseTable">'; 39 39 $TableColumns = array( … … 43 43 array('Name' => 'Percent', 'Title' => 'Procenta'), 44 44 ); 45 45 46 46 $Order = GetOrderTableHeader($TableColumns, 'Name', 0); 47 47 $Output .= $Order['Output']; 48 48 49 49 $Translated = 0; 50 50 $Total = 0; … … 62 62 } 63 63 return($Output); 64 } 64 } 65 65 66 66 function Show() 67 67 { 68 68 $this->Title = T('Progress'); 69 69 $LanguageList = GetLanguageList(); 70 70 71 71 if(array_key_exists('Version', $_GET)) $_SESSION['StatVersion'] = $_GET['Version']; 72 if(!array_key_exists('StatVersion', $_SESSION)) 73 { 72 if(!array_key_exists('StatVersion', $_SESSION)) 73 { 74 74 if($this->System->User->Licence(LICENCE_USER) and ($this->System->User->PreferredVersionGame != '')) 75 75 { 76 76 $_SESSION['StatVersion'] = $this->System->User->PreferredVersionGame; 77 77 } else 78 78 $_SESSION['StatVersion'] = $this->System->Config['Web']['GameVersion']; 79 } 79 } 80 80 81 81 if(!isset($_SESSION['language'])) 82 82 { 83 84 85 83 if($this->System->User->Licence(LICENCE_USER)) 84 { 85 $_SESSION['language'] = $this->System->User->Language; 86 86 } else $_SESSION['language'] = ''; 87 87 } 88 88 if(array_key_exists('language', $_GET)) { 89 89 if($_GET['language'] == '') $_SESSION['language'] = ''; 90 91 92 90 else { 91 $_SESSION['language'] = $_GET['language'] * 1; 92 } 93 93 } 94 94 if(!array_key_exists($_SESSION['language'], $LanguageList)) $_SESSION['language'] = ''; … … 109 109 if($Language['Enabled'] == 1) 110 110 { 111 111 $Lang = ' <a href="?language='.$Language['Id'].'">'.$Language['Name'].'</a>'; 112 112 if($Language['Id'] == $_SESSION['language']) $Output .= '<strong>'.$Lang.'</strong> '; 113 113 else $Output .= $Lang; -
trunk/Modules/Translation/Save.php
r800 r816 5 5 function Show() 6 6 { 7 8 9 10 11 12 13 14 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 44 45 46 47 48 49 50 51 52 53 54 55 56 //JOIN `TextSpell` as sub1 ON sub1.Language = 0 AND T.`Entry` = sub1.`Entry` AND T.`VersionStart` = sub1.`VersionStart` 7 global $TranslationTree, $Message, $MessageType; 8 9 $Output = ''; 10 $CompleteText = array('nedokončený', 'dokončený'); 11 12 unset($Message); 13 $this->System->ModuleManager->Modules['FrontPage']->HandleLoginForm(); 14 if(isset($Message)) $Output .= ShowMessage($Message, $MessageType); 15 16 $GroupId = LoadGroupIdParameter(); 17 $Group = $TranslationTree[$GroupId]; 18 $Table = $Group['TablePrefix']; 19 if($this->System->User->Licence(LICENCE_USER)) 20 { 21 if(array_key_exists('ID', $_POST) and is_numeric($_POST['ID'])) 22 { 23 $Entry = $_POST['entry'] * 1; 24 $TextID = $_POST['ID'] * 1; 25 $Language = $_POST['Language'] * 1; 26 if(array_key_exists('End', $_POST)) $Complete = 1; 27 else $Complete = 0; 28 29 // Get source text record from database by ID 30 $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE `ID`='.$TextID); 31 if($DbResult->num_rows > 0) 32 { 33 $SourceText = $DbResult->fetch_assoc(); 34 35 // Get data for english original 36 $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE (`Entry`='.$SourceText['Entry'].') '. 37 'AND (`Language` = '.$this->System->Config['OriginalLanguage'].') AND (`VersionStart` = '.$SourceText['VersionStart'].') '. 38 'AND (`VersionEnd` = '.$SourceText['VersionEnd'].')'); 39 if($DbResult->num_rows > 0) 40 { 41 $EnglishText = $DbResult->fetch_assoc(); 42 43 // Get all similar english texts 44 $Filter = ''; 45 foreach($Group['Items'] as $GroupItem) 46 if(($GroupItem['Visible'] == 1) and ($EnglishText[$GroupItem['Column']] != '')) 47 $Filter .= ' OR (`'.$GroupItem['Column'].'` = "'.addslashes($EnglishText[$GroupItem['Column']]).'")'; 48 if(substr($Filter, 0, 3) == ' OR') $Filter = ' AND ('.substr($Filter, 3).')'; 49 50 $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE (`Language` = '.$this->System->Config['OriginalLanguage'].')'.$Filter); 51 while($EnglishFound = $DbResult->fetch_assoc()) 52 { 53 // Get user translation paired to found english item entry 54 //TODO: and need update sql 55 //SELECT T.ID,T.Take,sub1.ID,T.`VersionStart`,T.`VersionEnd`,sub1.`VersionStart` as OrigStart,sub1.`VersionEnd` as OrigEnd FROM `TextSpell` as T 56 //JOIN `TextSpell` as sub1 ON sub1.Language = 0 AND T.`Entry` = sub1.`Entry` AND T.`VersionStart` = sub1.`VersionStart` 57 57 //WHERE T.Language != 0 AND T.`VersionEnd` != sub1.`VersionEnd` 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 if((($CompleteParts & (1 << ($GroupItem['Sequence'] - 1))) == 0) and86 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 117 118 119 120 121 58 $DbResult2 = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE (`User` = '.$this->System->User->Id. 59 ') AND (`Entry` = '.$EnglishFound['Entry'].') AND (`VersionStart` = '.$EnglishFound['VersionStart']. 60 ') AND (`VersionEnd` = '.$EnglishFound['VersionEnd'].')'); 61 if($DbResult2->num_rows > 0) 62 { 63 // Update existed user translation 64 $ExistedText = $DbResult2->fetch_assoc(); 65 $Values = '`Language` = '.$Language; 66 67 $UpdateModifyTime = false; 68 $Completable = true; 69 $CompleteParts = $ExistedText['CompleteParts']; 70 foreach($Group['Items'] as $GroupItem) 71 { 72 if($GroupItem['Visible'] == 1) 73 { 74 if($SourceText[$GroupItem['Column']] != $ExistedText[$GroupItem['Column']]) 75 $UpdateModifyTime = true; 76 77 if($EnglishFound[$GroupItem['Column']] == $EnglishText[$GroupItem['Column']]) 78 { 79 if(array_key_exists($GroupItem['Column'], $_POST)) 80 { 81 $Values .= ', `'.$GroupItem['Column'].'` = "'.$_POST[$GroupItem['Column']].'"'; 82 $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1)); 83 } 84 } 85 if((($CompleteParts & (1 << ($GroupItem['Sequence'] - 1))) == 0) and 86 ($EnglishFound[$GroupItem['Column']] != '')) $Completable = false; 87 } 88 } 89 if($Completable) $NewComplete = 1; // All parts of text are completed. Make entire text as completed 90 else $NewComplete = 0; 91 if($SourceText['ID'] == $ExistedText['ID']) 92 { 93 $NewComplete = $Complete; // Our original user text, set complete according user choice 94 if($Complete == 1) 95 { 96 foreach($Group['Items'] as $GroupItem) 97 if($GroupItem['Visible'] == 1) $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1)); 98 } 99 } 100 $Values .= ', `Complete`='.$NewComplete.', `CompleteParts` = '.$CompleteParts; 101 102 if($UpdateModifyTime) $Values .= ', `ModifyTime` = NOW()'; 103 104 // Update user translation 105 $this->Database->query('UPDATE `'.$Table.'` SET '.$Values.' WHERE `ID` = '.$ExistedText['ID']); 106 107 $Output .= 'Změny v překladu <a href="'.$this->System->Link('/form.php?group='. 108 $GroupId.'&ID='.$ExistedText['ID']).'">'.$ExistedText['ID'].'</a> ('. 109 $ExistedText['Entry'].') uloženy jako '.$CompleteText[$NewComplete].'.<br />'; 110 $this->System->ModuleManager->Modules['Log']->WriteLog('Změny v překladu <a href="'. 111 $this->System->Link('/form.php?group='.$GroupId.'&ID='.$ExistedText['ID']).'">'. 112 $ExistedText['ID'].'</a> ('.$ExistedText['Entry'].') uloženy jako '.$CompleteText[$NewComplete].'.', LOG_TYPE_TRANSLATION); 113 } else 114 { 115 // Insert new user translation 116 $Columns = '`Entry`, `VersionStart`, `VersionEnd`, `Language`, `User`, `Take`, `ModifyTime`'; 117 $Values = $EnglishFound['Entry'].', '.$EnglishFound['VersionStart'].', '. 118 $EnglishFound['VersionEnd'].', '.$Language.', '.$this->System->User->Id.', '.$EnglishFound['ID'].', NOW()'; 119 120 $CompleteParts = 0; 121 $Completable = true; 122 122 $OnlyRank = true; 123 124 125 126 127 128 129 130 131 132 133 if (44 <> $GroupItem['Id']) $OnlyRank = false; 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 if (!$OnlyRank) 160 { 161 162 163 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 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 }244 return($Output); 123 foreach($Group['Items'] as $GroupItem) 124 { 125 $Columns .= ', `'.$GroupItem['Column'].'`'; 126 if($GroupItem['Visible'] == 1) 127 { 128 if($EnglishFound[$GroupItem['Column']] == $EnglishText[$GroupItem['Column']]) 129 { 130 // Read form user data 131 if(array_key_exists($GroupItem['Column'], $_POST)) 132 { 133 if (44 <> $GroupItem['Id']) $OnlyRank = false; 134 $Values .= ', "'.$_POST[$GroupItem['Column']].'"'; 135 $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1)); 136 } else $Values .= ', "'.addslashes($EnglishFound[$GroupItem['Column']]).'"'; 137 } else $Values .= ', "'.addslashes($EnglishFound[$GroupItem['Column']]).'"'; 138 if((($CompleteParts & (1 << ($GroupItem['Sequence'] - 1))) == 0) and ($EnglishFound[$GroupItem['Column']] != '')) $Completable = false; 139 } else 140 { 141 // Read from english text 142 $Values .= ', "'.$EnglishFound[$GroupItem['Column']].'"'; 143 } 144 } 145 if($Completable) $NewComplete = 1; // All parts of text are completed. Make entire text as completed 146 else $NewComplete = 0; 147 if($SourceText['ID'] == $EnglishFound['ID']) 148 { 149 $NewComplete = $Complete; // Our original user text, set complete according user choice 150 if($Complete == 1) 151 { 152 foreach($Group['Items'] as $GroupItem) 153 if($GroupItem['Visible'] == 1) $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1)); 154 } 155 } 156 $Columns .= ', `Complete`, `CompleteParts`'; 157 $Values .= ', '.$NewComplete.', '.$CompleteParts; 158 159 if (!$OnlyRank) 160 { 161 $this->Database->query('INSERT INTO `'.$Table.'` ('.$Columns.') VALUES ('.$Values.')'); 162 $LastID = $this->Database->insert_id; 163 164 $Output .= 'Text <a href="'.$this->System->Link('/form.php?group='. 165 $GroupId.'&ID='.$LastID).'">'.$LastID.'</a> ze skupiny <a href="TranslationList.php?group='. 166 $GroupId.'&user=0&action=filter">'.$TranslationTree[$GroupId]['Name'].'</a> uložen jako '. 167 $CompleteText[$NewComplete].'. Převzat z <a href="form.php?group='.$GroupId.'&ID='.$TextID.'">'.$TextID.'</a>.<br/>'; 168 $this->System->ModuleManager->Modules['Log']->WriteLog('Text <a href="'. 169 $this->System->Link('/form.php?group='.$GroupId.'&ID='.$LastID).'">'. 170 $LastID.'</a> ze skupiny <a href="TranslationList.php?group='. 171 $GroupId.'&user=0&text=&entry=&action=filter">'. 172 $TranslationTree[$GroupId]['Name'].'</a> uložen jako '.$CompleteText[$NewComplete]. 173 '. Převzat z <a href="form.php?group='.$GroupId.'&ID='.$TextID.'">'.$TextID.'</a>.', LOG_TYPE_TRANSLATION); 174 } 175 } 176 } 177 } else $Output .= ShowMessage('Anglický originál k překladu nenalezen.', MESSAGE_CRITICAL); 178 } else $Output .= ShowMessage('Zadaná položka nenalezena.', MESSAGE_CRITICAL); 179 180 181 // Address and redirecting 182 $Output .= '<br />Překládat: <a href="TranslationList.php?group='.$GroupId.'&state=1&user=0&entry=">Nepřeložené</a> '; 183 184 $prev = FollowingTran($TextID, $Table, $GroupId, True); 185 $next = FollowingTran($TextID, $Table, $GroupId); 186 $Output .= '<br /><br />'; 187 $DbResult = $this->Database->query('SELECT `Redirecting` FROM `User` WHERE `ID`='.$this->System->User->Id); 188 $redirecting = $DbResult->fetch_assoc(); 189 190 switch($redirecting['Redirecting']) 191 { 192 case 1: 193 $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'. 194 'setTimeout("parent.location.href=\''.htmlspecialchars_decode('TranslationList.php?group='.$GroupId.'&state=1&user=0').'\'", 1500)'. 195 '</script>'; 196 break; 197 case 2: 198 if($next <> '') 199 $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'. 200 'setTimeout("parent.location.href=\''.htmlspecialchars_decode($next).'\'", 1500)'. 201 '</script>'; 202 break; 203 case 3: 204 if($prev <> '') 205 $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'. 206 'setTimeout("parent.location.href=\''.htmlspecialchars_decode($prev).'\'", 1500)'. 207 '</script>'; 208 break; 209 } 210 211 $Output .= 'Z této stránky můžete být automaticky přesměrování. Nastavit kam chcete být přesměrování si můžete v <a href="'. 212 $this->System->Link('/Options.php').'" title="Nastavení uživatele">Nastavení</a>'; 213 214 // Update flag for experience info load 215 $this->Database->query('UPDATE `User` SET `NeedUpdate` = 1 WHERE `ID` = '.$this->System->User->Id); 216 } else $Output .= ShowMessage('Položka nenalezena', MESSAGE_CRITICAL); 217 } else 218 { 219 if(array_key_exists('ID', $_POST) and array_key_exists('entry', $_POST) and array_key_exists('Language', $_POST) and array_key_exists('user', $_POST)) 220 { 221 $Output .= 'Byli jste automaticky odhlášeni. Pro <strong>Uložení překladu</strong> se musíte přihlásit zde:<br /><br />'. 222 '<form action="save.php?action=login&group='.$GroupId.'" method="post"><div>'. 223 '<input type="hidden" name="entry" value="'.$_POST['entry'].'" />'. 224 '<input type="hidden" name="user" value="'.$_POST['user'].'" />'. 225 '<input type="hidden" name="ID" value="'.$_POST['ID'].'" />'. 226 '<input type="hidden" name="Language" value="'.$_POST['Language'].'" />'; 227 228 foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) 229 { 230 if(array_key_exists($TextItem['Column'], $_POST)) $Value = $_POST[$TextItem['Column']]; else $Value = ''; 231 $Output .= '<input id="'.$TextItem['Column'].'" name="'.$TextItem['Column'].'" type="hidden" value="'.htmlspecialchars($Value).'" />'; 232 } 233 $Output .= '<table>'. 234 '<tr>'. 235 '<td>Jméno: <input type="text" name="LoginUser" size="13" /></td>'. 236 '</tr><tr>'. 237 '<td>Heslo: <input type="password" name="LoginPass" size="13" /></td>'. 238 '</tr><tr>'. 239 '<th><input type="submit" value="Přihlásit a uložit překlad" /></th>'. 240 '</tr>'. 241 '</table>'; 242 } else $Output = ShowMessage('Nezadány požadované údaje.', MESSAGE_CRITICAL); 243 } 244 return($Output); 245 245 } 246 246 } -
trunk/Modules/Translation/Translation.php
r815 r816 23 23 function Start() 24 24 { 25 25 global $TranslationTree; 26 26 27 28 29 30 27 $this->System->RegisterPage('comparison.php', 'PageTranslationComparison'); 28 $this->System->RegisterPage('form.php', 'PageTranslationForm'); 29 $this->System->RegisterPage('save.php', 'PageTranslationSave'); 30 $this->System->RegisterPage('progress', 'PageProgress'); 31 31 $this->System->RegisterPage('TranslationList.php', 'PageTranslationList'); 32 32 $this->System->RegisterPage('LoadNames.php', 'PageLoadNames'); … … 42 42 if(array_key_exists('Search', $this->System->ModuleManager->Modules)) 43 43 { 44 45 46 44 foreach($TranslationTree as $Group) 45 { 46 $Table = $Group['TablePrefix']; 47 47 48 49 50 51 52 48 $Columns = array('ID', 'Entry'); 49 foreach($Group['Items'] as $Item) 50 { 51 if($Item['Column'] != '') $Columns[] = $Item['Column']; 52 } 53 53 54 54 $this->System->ModuleManager->Modules['Search']->RegisterSearch('group'.$Group['Id'], 55 55 sprintf(T('Translation group "%s"'), $Group['Name']), $Columns, '`'.$Table.'`', $this->System->Link('/TranslationList.php?group='. 56 56 $Group['Id'].'&user=0&state=0&entry=&text=')); 57 57 } 58 58 } 59 59 } … … 61 61 function ShowRSS() 62 62 { 63 63 $Items = array(); 64 64 $DbResult = $this->Database->query('SELECT UNIX_TIMESTAMP(`Date`) AS `Date`, `User`.`Name` AS `UserName`, `Text` FROM `Log` '. 65 65 'JOIN `User` ON `User`.`ID` = `Log`.`User` WHERE `Type` = 1 ORDER BY `Date` DESC LIMIT 100'); … … 81 81 'WebmasterEmail' => $this->System->Config['Web']['AdminEmail'], 82 82 'Items' => $Items, 83 83 )); 84 84 return($Output); 85 85 } -
trunk/Modules/Translation/TranslationList.php
r791 r816 3 3 class CompletionState 4 4 { 5 6 7 8 9 10 11 12 5 const All = 0; 6 const NotTranslated = 1; 7 const Translated = 2; 8 const NotFinished = 3; 9 const Original = 4; 10 const NotFinishedNotTranslated = 5; 11 const Missing1 = 6; 12 const Missing2 = 7; 13 13 } 14 14 … … 16 16 class PageTranslationList extends Page 17 17 { 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 18 function ShowFilter($GroupId = 0) 19 { 20 global $TranslationTree; 21 22 $Filter = array('SQL' => ''); 23 24 $Output = '<form action="?" method="post">'. 25 '<table class="BaseTable"><tr>'. 26 '<th>Zpracování</th>'. 27 '<th>Skupina</th>'. 28 '<th>Verze</th>'. 29 '<th>Jazyk</th>'. 30 '<th>Překladatel</th>'. 31 '<th>Slova</th>'. 32 '<th>Položka</th>'. 33 '<th></th></tr><tr>'; 34 35 // State 36 $Filter['State'] = GetParameter('state', 0, true, true); 37 $Output .= '<td><select name="state">'; 38 $StateTypes = array( 39 CompletionState::All => 'Všechny', 40 40 CompletionState::NotTranslated => 'Nepřeložené', 41 41 CompletionState::Translated => 'Přeložené', … … 46 46 CompletionState::Missing2 => 'Chybějící $-Neopravený' 47 47 ); 48 49 50 51 52 } 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 48 foreach ($StateTypes as $index=>$StateType) { 49 if($Filter['State'] == $index) $Selected = ' selected="selected"'; 50 else $Selected = ''; 51 $Output .= '<option value="'.$index.'"'.$Selected.'>'.$StateType.'</option>'; 52 } 53 $Output .= '</select></td>'; 54 55 // Translation group 56 if($GroupId == 0) 57 { 58 $Filter['Group'] = GetParameter('group', 0, true, true); 59 if($Filter['Group'] != 0) 60 { 61 if(isset($TranslationTree[$Filter['Group']]) == false) ErrorMessage('Překladová skupina dle zadaného Id neexistuje.'); 62 $Table = $TranslationTree[$Filter['Group']]['TablePrefix']; 63 } 64 } else 65 { 66 $Filter['Group'] = $GroupId; 67 $Table = $TranslationTree[$Filter['Group']]['TablePrefix']; 68 } 69 70 $Output .= '<td><select name="group" style="width: 80px">'; 71 if($Filter['Group'] == 0) $Selected = ' selected="selected"'; 72 else $Selected = ''; 73 $Output .= '<option value="0"'.$Selected.'>Všechny</option>'; 74 $DbResult = $this->Database->query('SELECT `Id`,`Name` FROM `Group` ORDER BY `Name`'); 75 while($Group = $DbResult->fetch_assoc()) 76 { 77 if($Group['Id'] == $Filter['Group']) $Selected = ' selected="selected"'; 78 else $Selected = ''; 79 $Output .= '<option value="'.$Group['Id'].'"'.$Selected.'>'.$Group['Name'].'</option>'; 80 } 81 $Output .= '</select></td>'; 82 82 83 83 if ($this->System->User->Licence(LICENCE_USER)) 84 85 else 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 117 118 119 120 121 122 123 124 125 126 127 128 84 $Filter['Version'] = GetParameter('version', $this->System->User->PreferredVersion, true, true); 85 else 86 $Filter['Version'] = GetParameter('version', 0, true, true); 87 if($Filter['Version'] != 0) 88 { 89 $DbResult = $this->Database->query('SELECT `Id`, `BuildNumber`,`Version` FROM `ClientVersion` WHERE (`Imported` = 1) AND (`Id` ='.$Filter['Version'].')'); 90 if($DbResult->num_rows > 0) 91 { 92 $DbRow = $DbResult->fetch_assoc(); 93 $Filter['BuildNumber'] = $DbRow['BuildNumber']; 94 } else ErrorMessage('Zadaná verze klienta nenalezena'); 95 } 96 $Output .= '<td><select name="version">'; 97 if($Filter['Version'] == 0) $Selected = ' selected="selected"'; 98 else $Selected = ''; 99 $Output .= '<option value="0"'.$Selected.'>Všechny</option>'; 100 $DbResult = $this->Database->query('SELECT `Id`, `BuildNumber`,`Version` FROM `ClientVersion` WHERE `Imported` = 1 ORDER BY `BuildNumber` DESC'); 101 while($Version = $DbResult->fetch_assoc()) 102 { 103 if($Version['Id'] == $Filter['Version']) $Selected = ' selected="selected"'; 104 else $Selected = ''; 105 $Output .= '<option value="'.$Version['Id'].'"'.$Selected.'>'.$Version['Version'].'</option>'; 106 } 107 $Output .= '</select></td>'; 108 if($Filter['Version'] != 0) $VersionFilter = ' AND (`VersionStart` <= '.$Filter['BuildNumber'].') AND (`VersionEnd` >= '.$Filter['BuildNumber'].')'; 109 else $VersionFilter = ''; 110 //else $Filter['SQL'] .= ' AND '; DISTINCT(Entry) 111 112 // Language 113 $Filter['Language'] = GetParameter('lang', 0, true, true); 114 $Output .= '<td><select name="lang">'; 115 if($Filter['Language'] == 0) $Selected = ' selected="selected"'; 116 else $Selected = ''; 117 $Output .= '<option value="0"'.$Selected.'>Všechny</option>'; 118 $DbResult = $this->Database->query('SELECT `Id`, `Name` FROM `Language` WHERE `Enabled` = 1 ORDER BY `Name`'); 119 while($Language = $DbResult->fetch_assoc()) 120 { 121 if($Language['Id'] == $Filter['Language']) $Selected = ' selected="selected"'; 122 else $Selected = ''; 123 $Output .= '<option value="'.$Language['Id'].'"'.$Selected.'>'.$Language['Name'].'</option>'; 124 } 125 $Output .= '</select></td>'; 126 $LanguageFilter = ''; 127 $LanguageFilterSub = ''; 128 if($Filter['Language'] != 0) { 129 129 $LanguageFilter = ' AND (`T`.`Language` = '.$Filter['Language'].')'; 130 130 $LanguageFilterSub = ' AND (`Sub`.`Language` = '.$Filter['Language'].')'; 131 131 } 132 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 133 // User 134 $Filter['User'] = GetParameter('user', 0, true, true); 135 $Output .= '<td><select name="user" style="width: 80px">'; 136 if($Filter['User'] == 0) $Selected = ' selected="selected"'; 137 else $Selected = ''; 138 $Output .= '<option value="0"'.$Selected.'>Všichni</option>'; 139 $DbResult = $this->Database->query('SELECT `Id`, `Name` FROM `User` ORDER BY `Name`'); 140 while($User = $DbResult->fetch_assoc()) 141 { 142 if($User['Id'] == $Filter['User']) $Selected = ' selected="selected"'; 143 else $Selected = ''; 144 $Output .= '<option value="'.$User['Id'].'"'.$Selected.'>'.$User['Name'].'</option>'; 145 } 146 $Output .= '</select></td>'; 147 if($Filter['User'] != 0) $UserFilter = ' AND (`User` = '.$Filter['User'].')'; 148 else $UserFilter = ''; 149 150 // Words 151 $Filter['Text'] = GetParameter('text', '', false, true); 152 $Output .= '<td><input name="text" type="text" style="width: 60px;" value="'.htmlentities($Filter['Text']).'"></td>'; 153 if($Filter['Text'] != '') 154 { 155 $Items = array('(`T`.`ID` LIKE "%'.$Filter['Text'].'%")', '(`T`.`Entry` LIKE "%'.$Filter['Text'].'%")'); 156 if($Filter['Group'] != 0) 157 foreach($TranslationTree[$Filter['Group']]['Items'] as $GroupItem) 158 if($GroupItem['Visible'] == 1) 159 $Items[] = '(`T`.`'.$GroupItem['Column'].'` LIKE "%'.$Filter['Text'].'%")'; 160 $Filter['SQL'] .= ' AND ('.implode(' OR ', $Items).')'; 161 } 162 163 // Entry 164 $Filter['Entry'] = GetParameter('entry', '', false, true); 165 $Output .= '<td><input name="entry" type="text" style="width: 60px;" value="'.htmlentities($Filter['Entry']).'"></td>'; 166 if($Filter['Entry'] != '') 167 { 168 $Filter['SQL'] .= ' AND (`Entry` = "'.$Filter['Entry'].'")'; 169 } 170 171 if($Filter['Group'] != 0) 172 { 173 $WithoutAlter = ' AND NOT EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE '. 174 '(`Sub`.`Language` <> '.$this->System->Config['OriginalLanguage'].')'.$LanguageFilterSub. 175 ' AND (`Sub`.`Entry` = `T`.`Entry`) AND (`Sub`.`ID` != `T`.`ID`) AND (`Sub`.`Complete` = 1) AND '. 176 '(`Sub`.`VersionStart` = `T`.`VersionStart`) AND (`Sub`.`VersionEnd` = `T`.`VersionEnd`) LIMIT 1 ) '; 177 foreach($TranslationTree[$Filter['Group']]['Items'] as $GroupItem) 178 if($GroupItem['Visible'] == 1) { 179 $ItemsVar[] = 'LENGTH(`T`.`'.$GroupItem['Column'].'`) - LENGTH( REPLACE( `T`.`'.$GroupItem['Column'].'`, \'$\', \'\' ) ) '. 180 180 ' < ('. 181 181 'SELECT LENGTH(`Sub`.`'.$GroupItem['Column'].'`) - LENGTH( REPLACE( `Sub`.`'.$GroupItem['Column'].'`, \'$\', \'\' ) ) FROM `'.$Table.'` AS `Sub` WHERE '. 182 183 182 ' `Sub`.`Entry` = `T`.`Entry` AND `Sub`.`Language` = '.$this->System->Config['OriginalLanguage'].' AND '. 183 '`Sub`.`VersionStart` = `T`.`VersionStart` AND `Sub`.`VersionEnd` = `T`.`VersionEnd` LIMIT 1 '. 184 184 ')'; 185 186 187 188 189 190 191 192 193 194 195 196 185 } 186 if($Filter['State'] == CompletionState::All) $Filter['SQL'] .= $UserFilter.$VersionFilter.''; 187 else if($Filter['State'] == CompletionState::NotTranslated) $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.$this->System->Config['OriginalLanguage'].') '. 188 'AND NOT EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE '. 189 '(`Sub`.`Language` <> '.$this->System->Config['OriginalLanguage'].') '.$LanguageFilterSub.$UserFilter. 190 ' AND (`Sub`.`Entry` = `T`.`Entry`) AND (`Sub`.`Complete` = 1) AND '. 191 '(`Sub`.`VersionStart` = `T`.`VersionStart`) AND (`Sub`.`VersionEnd` = `T`.`VersionEnd`))'; 192 else if($Filter['State'] == CompletionState::Translated) $Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Complete` = 1)'; 193 else if($Filter['State'] == CompletionState::NotFinished) $Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Language` != '.$this->System->Config['OriginalLanguage']. 194 ') AND (`T`.`Complete` = 0)'; 195 else if($Filter['State'] == CompletionState::Original) $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.$this->System->Config['OriginalLanguage'].')'; 196 else if($Filter['State'] == CompletionState::NotFinishedNotTranslated) $Filter['SQL'] .= $UserFilter.$VersionFilter.$WithoutAlter. 197 197 ' AND (`T`.`Language` != '.$this->System->Config['OriginalLanguage']. 198 198 ') AND (`T`.`Complete` = 0)'. 199 199 ''; 200 200 else if($Filter['State'] == CompletionState::Missing1) { 201 201 $Filter['SQL'] .= $UserFilter.$VersionFilter.' AND (`T`.`Complete` = 1) AND `T`.`Language` != '.$this->System->Config['OriginalLanguage']; 202 202 $Filter['SQL'] .= ' AND ('.implode(' OR ', $ItemsVar).') '; 203 204 203 } 204 else if($Filter['State'] == CompletionState::Missing2) { 205 205 $Filter['SQL'] .= $UserFilter.$VersionFilter.' AND (`T`.`Complete` = 1) AND `T`.`Language` != '.$this->System->Config['OriginalLanguage']; 206 206 $Filter['SQL'] .= ' '. $WithoutAlter; 207 207 $Filter['SQL'] .= ' AND ('.implode(' OR ', $ItemsVar).') '; 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 208 } 209 } 210 211 /* 212 // Ownership 213 if(array_key_exists('owner', $_GET) and is_numeric($_GET['owner'])) $Filter['Owner'] = $_GET['owner']; 214 else $Filter['Owner'] = 0; 215 $Output .= ' <td><select name="owner">'; 216 if($Filter['Owner'] == 0) $Selected = ' selected="selected"'; 217 else $Selected = ''; 218 $Output .= '<option value="0"'.$Selected.'>Všech</option>'; 219 if($Filter['Owner'] == 1) $Selected = ' selected="selected"'; 220 else $Selected = ''; 221 $Output .= '<option value="1"'.$Selected.'>Překladatelův tým</option>'; 222 if($Filter['Owner'] == 2) $Selected = ' selected="selected"'; 223 else $Selected = ''; 224 $Output .= '<option value="2"'.$Selected.'>Překladatele</option>'; 225 $Output .= '</select></td>'; 226 if(($Filter['Owner'] == 2) AND ($Filter['User'] != 0)) $Filter['SQL'] .= ' AND (`User` = '.$Filter['User'].')'; 227 */ 228 229 $Output .= '<td><input type="submit" value="Filtrovat"/></td>'; 230 $Output .= '</tr></table>'; 231 $Output .= '</form><br/>'; 232 $Filter['Output'] = $Output; 233 return($Filter); 234 } 235 236 function ShowTranslationList($Filter) 237 { 238 global $TranslationTree; 239 240 $Output = $Filter['Output']; 241 $Table = $TranslationTree[$Filter['Group']]['TablePrefix']; 242 243 $Query = 'SELECT `T`.`ModifyTime`, `T`.`ID`, `T`.`Entry`, `T`.`VersionStart`, `T`.`VersionEnd`, '. 244 '`T`.`'.$TranslationTree[$Filter['Group']]['Items'][0]['Column'].'`, '. 245 '`User`.`Name` AS `UserName`, `User`.`ID` AS `UserId`, '. 246 '`Language`.`Name` AS `LanguageName`, `TS`.`Version` AS `VersionStartText`, `TE`.`Version` AS `VersionEndText` '. 247 'FROM `'.$Table.'` AS `T` '. 248 'LEFT JOIN `User` ON `User`.`ID` = `T`.`User` '. 249 'LEFT JOIN `Language` ON `Language`.`ID` = `T`.`Language` '. 250 'LEFT JOIN `ClientVersion` AS `TS` ON `TS`.`BuildNumber` = `T`.`VersionStart` '. 251 'LEFT JOIN `ClientVersion` AS `TE` ON `TE`.`BuildNumber` = `T`.`VersionEnd` '. 252 'WHERE 1 '.$Filter['SQL']; 253 254 // Get total item count 255 $DbResult = $this->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS `TT`'); 256 $DbRow = $DbResult->fetch_row(); 257 $PageList = GetPageList($DbRow[0]); 258 259 $Output .= $PageList['Output']; 260 $TableColumns = array( 261 array('Name' => 'ID', 'Title' => 'Číslo'), 262 array('Name' => 'Entry', 'Title' => 'Položka'), 263 array('Name' => $TranslationTree[$Filter['Group']]['Items'][0]['Column'], 'Title' => 'Název'), 264 array('Name' => 'VersionStart', 'Title' => 'Verze'), 265 array('Name' => 'LanguageName', 'Title' => 'Jazyk'), 266 array('Name' => 'UserName', 'Title' => 'Překladatel'), 267 array('Name' => 'ModifyTime', 'Title' => 'Datum'), 268 ); 269 270 $Order = GetOrderTableHeader($TableColumns, 'VersionStart', 1); 271 $Output .= '<table class="BaseTable">'. 272 $Order['Output']; 273 274 $DbResult = $this->Database->query($Query.' '.$Order['SQL'].' '.$PageList['SQLLimit']); 275 while($Line = $DbResult->fetch_assoc()) 276 { 277 $Output .= '<tr><td><a href="form.php?group='.$Filter['Group'].'&ID='.$Line['ID'].'">'.$Line['ID'].'</a></td><td>'.$Line['Entry'].'</td>'. 278 '<td>'.htmlspecialchars($Line[$TranslationTree[$Filter['Group']]['Items'][0]['Column']]).'</td>'. 279 '<td>'.$Line['VersionStartText'].'-'.$Line['VersionEndText'].'</td>'. 280 '<td>'.$Line['LanguageName'].'</td>'. 281 '<td><a href="user.php?user='.$Line['UserId'].'">'.$Line['UserName'].'</a></td>'. 282 '<td>'.HumanDate($Line['ModifyTime']).'</td>' 283 283 ; 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 284 '</tr>'; 285 } 286 $Output .= '</table>'. 287 $PageList['Output']; 288 return($Output); 289 } 290 291 function ShowGroupList($Filter) 292 { 293 global $TranslationTree; 294 295 $Output = $Filter['Output']; 296 297 $Output .= '<table class="BaseTable"><tr><th>Skupina</th><th>Počet</th></tr>'; 298 $Total = 0; 299 foreach($TranslationTree as $Group) 300 if($Group['TablePrefix'] != '') 301 { 302 $Filter = $this->ShowFilter($Group['Id']); 303 $ID = $this->Database->query('SELECT COUNT(*) FROM `'.$Group['TablePrefix'].'` AS `T` WHERE 1 '.$Filter['SQL']); 304 $Line = $ID->fetch_row(); 305 if ($Line[0] <> '0') 306 $Output .= '<tr><td><a href="?group='.$Group['Id'].'">'.$Group['Name'].'</td><td>'.$Line[0].'</a></tr>'; 307 $Total += $Line[0]; 308 } 309 $Output .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$Total.'</strong></td></tr>'. 310 '</table>'; 311 return($Output); 312 } 313 314 function ShowGroupTypeList() 315 { 316 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Group`'); 317 $DbRow = $DbResult->fetch_row(); 318 $PageList = GetPageList($DbRow[0]); 319 $Output = '<h3>Seznam překladových skupin</h3>'. 320 $PageList['Output']; 321 322 $Output .= '<table class="BaseTable">'; 323 $TableColumns = array( 324 array('Name' => 'Name', 'Title' => 'Jméno'), 325 array('Name' => 'SourceType', 'Title' => 'Typ zdroje'), 326 array('Name' => '', 'Title' => 'Zdroje'), 327 array('Name' => 'LastImport', 'Title' => 'Datum posledního importu'), 328 array('Name' => 'LastVersion', 'Title' => 'Verze posledního importu'), 329 ); 330 if($this->System->User->Licence(LICENCE_ADMIN)) 331 $TableColumns[] = array('Name' => '', 'Title' => 'Akce'); 332 333 $Order = GetOrderTableHeader($TableColumns, 'Name', 0); 334 $Output .= $Order['Output']; 335 336 $DbResult = $this->Database->query('SELECT * FROM `Group`'.$Order['SQL'].$PageList['SQLLimit']); 337 while($Group = $DbResult->fetch_assoc()) 338 { 339 $Output .= '<tr><td><a href="?group='.$Group['Id'].'&action=filter">'.$Group['Name'].'</a></td><td>'.$Group['SourceType'].'</td><td>'; 340 if($Group['MangosTable'] != '') $Output .= $Group['MangosTable'].'.sql '; 341 if($Group['DBCFileName'] != '') $Output .= $Group['DBCFileName'].'.dbc '; 342 if($Group['LuaFileName'] != '') $Output .= $Group['LuaFileName'].'.lua '; 343 $Output .= '</td>'; 344 344 if($this->System->User->Licence(LICENCE_ADMIN)) 345 345 $Output .= '<td><a title="Změny po posledním importu u vybrané překladové skupiny" href="log.php?group='. 346 346 $Group['Id'].'&type=11">'.HumanDate($Group['LastImport']).'</a></td>'; 347 347 else $Output .= '<td>'.HumanDate($Group['LastImport']).'</td>'; 348 348 $Output .= '<td><a href="'.$this->System->Link('/client-version/?action=item&id='. 349 349 GetVersionWOWId($Group['LastVersion'])).'">'.GetVersionWOW($Group['LastVersion']).'</a></td>'; 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 350 if($this->System->User->Licence(LICENCE_ADMIN)) 351 $Output .= '<td><a href="?action=groupdelete&id='.$Group['Id'].'">Smazat</a></td>'; 352 $Output .= '</tr>'; 353 354 } 355 $Output .= '</table>'. 356 '<br /><a title="Záznam změn po importu" href="log.php?type=11">Záznam změn v textech při importu</a><br/>'; 357 if($this->System->User->Licence(LICENCE_ADMIN)) $Output .= '<a href="?action=groupadd">Přidat překladovou skupinu</a>'; 358 return($Output); 359 } 360 361 function ShowMenu() 362 { 363 global $TranslationTree; 364 365 $GroupId = GetParameter('group', 0, true); 366 if($GroupId == 0) $Output = ShowMessage('Skupina nenalezena', MESSAGE_CRITICAL); 367 else { 368 $Table = $TranslationTree[$GroupId]['TablePrefix']; 369 370 $Output = '<h3>Základní filtrování textů</h3><br/>'. 371 '<table class="BaseTable"><tr><th>Odkaz</th><th>Popis</th></tr>'. 372 '<tr><td><a title="Všechny dostupné texty ve skupině" href="?group='.$GroupId.'&state=4">Všechny</a></td>'. 373 '<td>Zobrazit všechny dostupné anglické texty ve skupině.</td></tr>'. 374 '<tr><td><a title="Přeložené texty, můžete zde hlasovat, nebo text opravovat" href="?group='.$GroupId.'&state=2">Přeložené</a></td>'. 375 '<td>Zobrazit pouze již přeložené texty.</td></tr>'. 376 '<tr><td><a title="Nepřeložené texty" href="?group='.$GroupId.'&state=1">Nepřeložené</a></td>'. 377 '<td>Dosud nepřeložené texty, které je potřeba přeložit.</td></tr>'. 378 '<tr><td><a title="Nedokončené texty" href="?group='.$GroupId.'&state=3">Nedokončené</a></td>'. 379 '<td>Texty označené jako rozpracované.</td></tr>'; 380 381 if($this->System->User->Licence(LICENCE_USER)) 382 { 383 $Output .= '<tr><td><a title="Nedokončené texty" href="?group='.$GroupId.'&state=3&user='.$this->System->User->Id.'">Moje nedokončené</a></td> 384 <td>Nedokončené texty přihlášeného uživatele</td></tr> 385 <tr><td><a title="Přeložené texty přihlášeného uživatele" href="?group='.$GroupId.'&state=2&user='.$this->System->User->Id.'">Moje přeložené</a></td> 386 <td>Přeložené texty přihlášeného uživatele</td></tr>'; 387 } 388 389 $Output .= '<tr><td><form action="?group='.$GroupId.'&entry=" method="post"><div>'. 390 '<input type="text" name="text" size="8" />'. 391 '<input type="submit" value="Hledat" />'. 392 '</div></form>'. 393 '</td><td>Vyhledat pomocí textu</td></tr>'; 394 395 $Output .= '<tr><td><form action="?group='.$GroupId.'&text=" method="post"><div>'. 396 '<input type="text" name="entry" size="8" />'. 397 '<input type="submit" value="Hledat" />'. 398 '</div></form>'. 399 '</td><td>Zobrazit podle ID textu v databázi MaNGOSu</td></tr>'; 400 401 $Output .= '</table>'; 402 } 403 return($Output); 404 } 405 406 function ShowGroupAdd() 407 { 408 if($this->System->User->Licence(LICENCE_ADMIN)) 409 { 410 $Output = '<h3>Vložení nové překladové skupiny</h3>'. 411 '<form action="?action=groupaddfinish" method="post">'. 412 '<table>'. 413 '<tr><td>Název:</td><td><input type="text" name="Name"/></td></tr>'. 414 '<tr><td>Název tabulky v databázi:</td><td>Text<input type="text" name="TablePrefix"/></td></tr>'. 415 '<tr><td colspan="2"><input type="submit" name="add" value="Přidat"/></td></tr>'. 416 '</table></form>'; 417 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 418 return($Output); 419 } 420 421 function ShowGroupAddFinish() 422 { 423 if($this->System->User->Licence(LICENCE_ADMIN)) 424 { 425 $TableName = 'Text'.$_POST['TablePrefix']; 426 $DbResult = $this->System->Database->select('Group', 'Id', 'TablePrefix="'.$TableName.'"'); 427 if($DbResult->num_rows == 0) 428 { 429 430 $this->System->Database->query('CREATE TABLE IF NOT EXISTS `'.$TableName.'` ( 431 431 `ID` int(11) NOT NULL AUTO_INCREMENT, 432 432 `Entry` int(11) NOT NULL, … … 455 455 ADD CONSTRAINT `'.$TableName.'_ibfk_2` FOREIGN KEY (`User`) REFERENCES `User` (`ID`), 456 456 ADD CONSTRAINT `'.$TableName.'_ibfk_3` FOREIGN KEY (`Take`) REFERENCES `'.$TableName.'` (`ID`);'); 457 458 459 460 457 $DbResult = $this->System->Database->insert('Group', array('Name' => $_POST['Name'], 458 'TablePrefix' => $TableName, 'PrimaryKeyItem' => 'Entry')); 459 $Group = $this->System->Database->insert_id; 460 $this->System->Database->insert('GroupItem', array('Group' => $Group, 461 461 'Name' => 'Jméno', 'Column' => 'Name', 'Visible' => 1)); 462 462 $Output = ShowMessage('Překladová skupina vytvořena', MESSAGE_INFORMATION); 463 463 } else $Output = ShowMessage('Překladová skupina '.$TableName.' již existuje', MESSAGE_CRITICAL); 464 464 $Output .= $this->ShowGroupTypeList(); 465 466 return($Output); 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 465 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 466 return($Output); 467 } 468 469 function ShowGroupDelete() 470 { 471 if($this->System->User->Licence(LICENCE_ADMIN)) 472 { 473 $DbResult = $this->System->Database->select('Group', '*', 'Id='.$_GET['id']); 474 if($DbResult->num_rows == 1) 475 { 476 $Group = $DbResult->fetch_assoc(); 477 $this->Database->query('DROP TABLE `'.$Group['TablePrefix'].'`'); 478 $this->Database->query('DELETE FROM `GroupItem` WHERE `Group`='.$Group['Id']); 479 $this->Database->query('DELETE FROM `Group` WHERE `Id`='.$Group['Id']); 480 $Output = ShowMessage('Překladová skupina '.$Group['Name'].' smazána', MESSAGE_INFORMATION); 481 } else $Output = ShowMessage('Překladová skupina nenalezena', MESSAGE_CRITICAL); 482 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 483 $Output .= $this->ShowGroupTypeList(); 484 return($Output); 485 } 486 487 function Show() 488 { 489 $this->Title = T('Translation groups'); 490 $Action = GetParameter('action', ''); 491 if($Action == 'filter') $Output = $this->ShowMenu(); 492 else if($Action == 'grouplist') $Output = $this->ShowGroupTypeList(); 493 else if($Action == 'groupadd') $Output = $this->ShowGroupAdd(); 494 else if($Action == 'groupdelete') $Output = $this->ShowGroupDelete(); 495 else if($Action == 'groupaddfinish') $Output = $this->ShowGroupAddFinish(); 496 else 497 { 498 $Filter = $this->ShowFilter(); 499 if($Filter['Group'] > 0) $Output = $this->ShowTranslationList($Filter); 500 else $Output = $this->ShowGroupList($Filter); 501 } 502 return($Output); 503 } 504 504 }
Note:
See TracChangeset
for help on using the changeset viewer.