Changeset 561 for trunk/Modules/Translation
- Timestamp:
- Aug 13, 2013, 11:31:34 PM (11 years ago)
- Location:
- trunk/Modules/Translation
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Translation/Form.php
r552 r561 16 16 } 17 17 return $Text; 18 } 18 } 19 19 20 20 function Show() 21 21 { 22 $Action = ''; 23 if(array_key_exists('action', $_GET)) $Action = $_GET['action']; 24 25 if($Action == 'delete') $Output = $this->Delete(); 26 else $Output = $this->ShowForm(); 27 return($Output); 28 } 29 30 function ShowForm() 31 { 22 32 global $System, $Config, $User, $TranslationTree; 33 23 34 $Output = ''; 24 35 … … 197 208 } else $Output = ShowMessage('Nebylo zadáno ID.', MESSAGE_CRITICAL); 198 209 return($Output); 210 } 211 212 function Delete() 213 { 214 global $System, $User, $Config; 215 216 if($User->Licence(LICENCE_MODERATOR)) 217 { 218 $TextID = $_GET['ID']; 219 $System->Database->query('DELETE FROM `'.$Table.'` WHERE `ID` = '.$TextID.' AND `Language` <> '.$Config['OriginalLanguage']); 220 $Output = ShowMessage('Překlad byl smazán.'); 221 WriteLog('Překlad byl smazán! <a href="form.php?group='.$GroupID.'&ID='.$TextID.'">'.$TextID.'</a>', LOG_TYPE_MODERATOR); 222 } else $Output = ShowMessage('Nemáte oprávnění', MESSAGE_CRITICAL); 223 return($Output); 199 224 } 200 225 } -
trunk/Modules/Translation/Save.php
r554 r561 6 6 { 7 7 global $System, $User, $Config, $TranslationTree; 8 $Output = ''; 9 $CompleteText = array('nedokončený', 'dokončený'); 10 11 unset($Message); 12 $System->ModuleManager->Modules['FrontPage']->HandleLoginForm(); 13 if(isset($Message)) $Output .= ShowMessage($Message, $MessageType); 14 15 $GroupId = LoadGroupIdParameter(); 16 $Group = $TranslationTree[$GroupId]; 17 $Table = $Group['TablePrefix']; 18 if($User->Licence(LICENCE_USER)) 19 { 20 if(array_key_exists('ID', $_POST) and is_numeric($_POST['ID'])) 21 { 22 $Entry = $_POST['entry'] * 1; 23 $TextID = $_POST['ID'] * 1; 24 $Language = $_POST['Language'] * 1; 25 if(array_key_exists('End', $_POST)) $Complete = 1; 26 else $Complete = 0; 27 28 // Get source text record from database by ID 29 $DbResult = $System->Database->query('SELECT * FROM `'.$Table.'` WHERE `ID`='.$TextID); 30 if($DbResult->num_rows > 0) 31 { 32 $SourceText = $DbResult->fetch_assoc(); 33 34 // Get data for english original 35 $DbResult = $System->Database->query('SELECT * FROM `'.$Table.'` WHERE (`Entry`='.$SourceText['Entry']. 36 ') AND (`Language` = '.$Config['OriginalLanguage'].') AND (`VersionStart` = '.$SourceText['VersionStart']. 37 ') AND (`VersionEnd` = '.$SourceText['VersionEnd'].')'); 38 if($DbResult->num_rows > 0) 39 { 40 $EnglishText = $DbResult->fetch_assoc(); 41 42 // Get all similar english texts 43 $Filter = ''; 44 foreach($Group['Items'] as $GroupItem) 45 if(($GroupItem['Visible'] == 1) and ($EnglishText[$GroupItem['Column']] != '')) 46 $Filter .= ' OR (`'.$GroupItem['Column'].'` = "'.addslashes($EnglishText[$GroupItem['Column']]).'")'; 47 if(substr($Filter, 0, 3) == ' OR') $Filter = ' AND ('.substr($Filter, 3).')'; 48 49 $DbResult = $System->Database->query('SELECT * FROM `'.$Table.'` WHERE (`Language` = '.$Config['OriginalLanguage'].')'.$Filter); 50 while($EnglishFound = $DbResult->fetch_assoc()) 51 { 52 // Get user translation paired to found english item entry 53 $DbResult2 = $System->Database->query('SELECT * FROM `'.$Table.'` WHERE (`User` = '.$User->Id. 54 ') AND (`Entry` = '.$EnglishFound['Entry'].') AND (`VersionStart` = '.$EnglishFound['VersionStart']. 55 ') AND (`VersionEnd` = '.$EnglishFound['VersionEnd'].')'); 56 if($DbResult2->num_rows > 0) 57 { 58 // Update existed user translation 59 $ExistedText = $DbResult2->fetch_assoc(); 60 $Values = '`Language` = '.$Language; 61 62 $UpdateModifyTime = false; 63 $Completable = true; 64 $CompleteParts = $ExistedText['CompleteParts']; 65 foreach($Group['Items'] as $GroupItem) 66 { 67 if($GroupItem['Visible'] == 1) 68 { 69 if($SourceText[$GroupItem['Column']] != $ExistedText[$GroupItem['Column']]) 70 $UpdateModifyTime = true; 71 72 if($EnglishFound[$GroupItem['Column']] == $EnglishText[$GroupItem['Column']]) 73 { 74 if(array_key_exists($GroupItem['Column'], $_POST)) 75 { 76 $Values .= ', `'.$GroupItem['Column'].'` = "'.$_POST[$GroupItem['Column']].'"'; 77 $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1)); 78 } 79 } 80 if((($CompleteParts & (1 << ($GroupItem['Sequence'] - 1))) == 0) and ($EnglishFound[$GroupItem['Column']] != '')) $Completable = false; 81 } 82 } 83 if($Completable) $NewComplete = 1; // All parts of text are completed. Make entire text as completed 84 else $NewComplete = 0; 85 if($SourceText['ID'] == $ExistedText['ID']) 86 { 87 $NewComplete = $Complete; // Our original user text, set complete according user choice 88 if($Complete == 1) 89 { 90 foreach($Group['Items'] as $GroupItem) 91 if($GroupItem['Visible'] == 1) $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1)); 92 } 93 } 94 $Values .= ', `Complete`='.$NewComplete.', `CompleteParts` = '.$CompleteParts; 95 96 if($UpdateModifyTime) $Values .= ', `ModifyTime` = NOW()'; 97 98 // Update user translation 99 $System->Database->query('UPDATE `'.$Table.'` SET '.$Values.' WHERE `ID` = '.$ExistedText['ID']); 100 101 $Output .= 'Změny v překladu <a href="form.php?group='.$GroupId.'&ID='.$ExistedText['ID'].'">'.$ExistedText['ID'].'</a> ('.$ExistedText['Entry'].') uloženy jako '.$CompleteText[$NewComplete].'.<br />'; 102 WriteLog('Změny v překladu <a href="form.php?group='.$GroupId.'&ID='.$ExistedText['ID'].'">'.$ExistedText['ID'].'</a> ('.$ExistedText['Entry'].') uloženy jako '.$CompleteText[$NewComplete].'.', LOG_TYPE_TRANSLATION); 103 } else 104 { 105 // Insert new user translation 106 $Columns = '`Entry`, `VersionStart`, `VersionEnd`, `Language`, `User`, `Take`, `ModifyTime`'; 107 $Values = $EnglishFound['Entry'].', '.$EnglishFound['VersionStart'].', '.$EnglishFound['VersionEnd'].', '.$Language.', '.$User->Id.', '.$SourceText['ID'].', NOW()'; 108 109 $CompleteParts = 0; 110 $Completable = true; 111 foreach($Group['Items'] as $GroupItem) 112 { 113 $Columns .= ', `'.$GroupItem['Column'].'`'; 114 if($GroupItem['Visible'] == 1) 115 { 116 if($EnglishFound[$GroupItem['Column']] == $EnglishText[$GroupItem['Column']]) 117 { 118 // Read form user data 119 if(array_key_exists($GroupItem['Column'], $_POST)) 120 { 121 $Values .= ', "'.$_POST[$GroupItem['Column']].'"'; 122 $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1)); 123 } else $Values .= ', "'.addslashes($EnglishFound[$GroupItem['Column']]).'"'; 124 } else $Values .= ', "'.addslashes($EnglishFound[$GroupItem['Column']]).'"'; 125 if((($CompleteParts & (1 << ($GroupItem['Sequence'] - 1))) == 0) and ($EnglishFound[$GroupItem['Column']] != '')) $Completable = false; 126 } else 127 { 128 // Read from english text 129 $Values .= ', "'.$EnglishFound[$GroupItem['Column']].'"'; 130 } 131 } 132 if($Completable) $NewComplete = 1; // All parts of text are completed. Make entire text as completed 133 else $NewComplete = 0; 134 if($SourceText['ID'] == $EnglishFound['ID']) 135 { 136 $NewComplete = $Complete; // Our original user text, set complete according user choice 137 if($Complete == 1) 138 { 139 foreach($Group['Items'] as $GroupItem) 140 if($GroupItem['Visible'] == 1) $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1)); 141 } 142 } 143 $Columns .= ', `Complete`, `CompleteParts`'; 144 $Values .= ', '.$NewComplete.', '.$CompleteParts; 145 146 $System->Database->query('INSERT INTO `'.$Table.'` ('.$Columns.') VALUES ('.$Values.')'); 147 $LastID = $System->Database->insert_id; 148 149 $Output .= 'Text <a href="form.php?group='.$GroupId.'&ID='.$LastID.'">'.$LastID.'</a> ze skupiny <a href="TranslationList.php?group='.$GroupId.'&user=0&action=filter">'.$TranslationTree[$GroupId]['Name'].'</a> uložen jako '.$CompleteText[$NewComplete].'. Převzat z <a href="form.php?group='.$GroupId.'&ID='.$TextID.'">'.$TextID.'</a>.<br/>'; 150 WriteLog('Text <a href="form.php?group='.$GroupId.'&ID='.$LastID.'">'.$LastID.'</a> ze skupiny <a href="TranslationList.php?group='.$GroupId.'&user=0&text=&entry=&action=filter">'.$TranslationTree[$GroupId]['Name'].'</a> uložen jako '.$CompleteText[$NewComplete].'. Převzat z <a href="form.php?group='.$GroupId.'&ID='.$TextID.'">'.$TextID.'</a>.', LOG_TYPE_TRANSLATION); 151 } 152 } 153 } else $Output .= ShowMessage('Anglický originál k překladu nenalezen.', MESSAGE_CRITICAL); 154 } else $Output .= ShowMessage('Zadaná položka nenalezena.', MESSAGE_CRITICAL); 155 156 157 // Address and redirecting 158 $Output .= '<br />Překládat: <a href="TranslationList.php?group='.$GroupId.'&state=1&user=0&entry=">Nepřeložené</a> '; 159 160 $prev = FollowingTran($TextID, $Table, $GroupId, True); 161 $next = FollowingTran($TextID, $Table, $GroupId); 162 $Output .= '<br /><br />'; 163 $DbResult = $System->Database->query('SELECT `Redirecting` FROM `User` WHERE `ID`='.$User->Id); 164 $redirecting = $DbResult->fetch_assoc(); 165 166 switch($redirecting['Redirecting']) 167 { 168 case 1: 169 $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'. 170 'setTimeout("parent.location.href=\''.htmlspecialchars_decode('TranslationList.php?group='.$GroupId.'&state=1&user=0').'\'", 1500)'. 171 '</script>'; 172 break; 173 case 2: 174 if($next <> '') 175 $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'. 176 'setTimeout("parent.location.href=\''.htmlspecialchars_decode($next).'\'", 1500)'. 177 '</script>'; 178 break; 179 case 3: 180 if($prev <> '') 181 $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'. 182 'setTimeout("parent.location.href=\''.htmlspecialchars_decode($prev).'\'", 1500)'. 183 '</script>'; 184 break; 185 } 186 187 $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="'.$System->Link('/Options.php').'" title="Nastavení uživatele">Nastavení</a>'; 188 189 // Update flag for experience info load 190 $System->Database->query('UPDATE `User` SET `NeedUpdate` = 1 WHERE `ID` = '.$User->Id); 191 } else $Output .= ShowMessage('Položka nenalezena', MESSAGE_CRITICAL); 192 } else 193 { 194 if(array_key_exists('ID', $_POST) and array_key_exists('entry', $_POST) and array_key_exists('Language', $_POST) and array_key_exists('user', $_POST)) 195 { 196 $Output .= 'Byli jste automaticky odhlášeni. Pro <strong>Uložení překladu</strong> se musíte přihlásit zde:<br /><br />'. 197 '<form action="save.php?action=login&group='.$GroupId.'" method="post"><div>'. 198 '<input type="hidden" name="entry" value="'.$_POST['entry'].'" />'. 199 '<input type="hidden" name="user" value="'.$_POST['user'].'" />'. 200 '<input type="hidden" name="ID" value="'.$_POST['ID'].'" />'. 201 '<input type="hidden" name="Language" value="'.$_POST['Language'].'" />'; 202 203 foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) 204 { 205 if(array_key_exists($TextItem['Column'], $_POST)) $Value = $_POST[$TextItem['Column']]; else $Value = ''; 206 $Output .= '<input id="'.$TextItem['Column'].'" name="'.$TextItem['Column'].'" type="hidden" value="'.htmlspecialchars($Value).'" />'; 207 } 208 $Output .= '<table>'. 209 '<tr>'. 210 '<td>Jméno: <input type="text" name="LoginUser" size="13" /></td>'. 211 '</tr><tr>'. 212 '<td>Heslo: <input type="password" name="LoginPass" size="13" /></td>'. 213 '</tr><tr>'. 214 '<th><input type="submit" value="Přihlásit a uložit překlad" /></th>'. 215 '</tr>'. 216 '</table>'; 217 } else $Output = ShowMessage('Nezadány požadované údaje.', MESSAGE_CRITICAL); 218 } 8 9 $Output = ''; 10 $CompleteText = array('nedokončený', 'dokončený'); 11 12 unset($Message); 13 $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($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 = $System->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 = $System->Database->query('SELECT * FROM `'.$Table.'` WHERE (`Entry`='.$SourceText['Entry']. 37 ') AND (`Language` = '.$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 = $System->Database->query('SELECT * FROM `'.$Table.'` WHERE (`Language` = '.$Config['OriginalLanguage'].')'.$Filter); 51 while($EnglishFound = $DbResult->fetch_assoc()) 52 { 53 // Get user translation paired to found english item entry 54 $DbResult2 = $System->Database->query('SELECT * FROM `'.$Table.'` WHERE (`User` = '.$User->Id. 55 ') AND (`Entry` = '.$EnglishFound['Entry'].') AND (`VersionStart` = '.$EnglishFound['VersionStart']. 56 ') AND (`VersionEnd` = '.$EnglishFound['VersionEnd'].')'); 57 if($DbResult2->num_rows > 0) 58 { 59 // Update existed user translation 60 $ExistedText = $DbResult2->fetch_assoc(); 61 $Values = '`Language` = '.$Language; 62 63 $UpdateModifyTime = false; 64 $Completable = true; 65 $CompleteParts = $ExistedText['CompleteParts']; 66 foreach($Group['Items'] as $GroupItem) 67 { 68 if($GroupItem['Visible'] == 1) 69 { 70 if($SourceText[$GroupItem['Column']] != $ExistedText[$GroupItem['Column']]) 71 $UpdateModifyTime = true; 72 73 if($EnglishFound[$GroupItem['Column']] == $EnglishText[$GroupItem['Column']]) 74 { 75 if(array_key_exists($GroupItem['Column'], $_POST)) 76 { 77 $Values .= ', `'.$GroupItem['Column'].'` = "'.$_POST[$GroupItem['Column']].'"'; 78 $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1)); 79 } 80 } 81 if((($CompleteParts & (1 << ($GroupItem['Sequence'] - 1))) == 0) and ($EnglishFound[$GroupItem['Column']] != '')) $Completable = false; 82 } 83 } 84 if($Completable) $NewComplete = 1; // All parts of text are completed. Make entire text as completed 85 else $NewComplete = 0; 86 if($SourceText['ID'] == $ExistedText['ID']) 87 { 88 $NewComplete = $Complete; // Our original user text, set complete according user choice 89 if($Complete == 1) 90 { 91 foreach($Group['Items'] as $GroupItem) 92 if($GroupItem['Visible'] == 1) $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1)); 93 } 94 } 95 $Values .= ', `Complete`='.$NewComplete.', `CompleteParts` = '.$CompleteParts; 96 97 if($UpdateModifyTime) $Values .= ', `ModifyTime` = NOW()'; 98 99 // Update user translation 100 $System->Database->query('UPDATE `'.$Table.'` SET '.$Values.' WHERE `ID` = '.$ExistedText['ID']); 101 102 $Output .= 'Změny v překladu <a href="form.php?group='.$GroupId.'&ID='.$ExistedText['ID'].'">'.$ExistedText['ID'].'</a> ('.$ExistedText['Entry'].') uloženy jako '.$CompleteText[$NewComplete].'.<br />'; 103 WriteLog('Změny v překladu <a href="form.php?group='.$GroupId.'&ID='.$ExistedText['ID'].'">'.$ExistedText['ID'].'</a> ('.$ExistedText['Entry'].') uloženy jako '.$CompleteText[$NewComplete].'.', LOG_TYPE_TRANSLATION); 104 } else 105 { 106 // Insert new user translation 107 $Columns = '`Entry`, `VersionStart`, `VersionEnd`, `Language`, `User`, `Take`, `ModifyTime`'; 108 $Values = $EnglishFound['Entry'].', '.$EnglishFound['VersionStart'].', '.$EnglishFound['VersionEnd'].', '.$Language.', '.$User->Id.', '.$SourceText['ID'].', NOW()'; 109 110 $CompleteParts = 0; 111 $Completable = true; 112 foreach($Group['Items'] as $GroupItem) 113 { 114 $Columns .= ', `'.$GroupItem['Column'].'`'; 115 if($GroupItem['Visible'] == 1) 116 { 117 if($EnglishFound[$GroupItem['Column']] == $EnglishText[$GroupItem['Column']]) 118 { 119 // Read form user data 120 if(array_key_exists($GroupItem['Column'], $_POST)) 121 { 122 $Values .= ', "'.$_POST[$GroupItem['Column']].'"'; 123 $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1)); 124 } else $Values .= ', "'.addslashes($EnglishFound[$GroupItem['Column']]).'"'; 125 } else $Values .= ', "'.addslashes($EnglishFound[$GroupItem['Column']]).'"'; 126 if((($CompleteParts & (1 << ($GroupItem['Sequence'] - 1))) == 0) and ($EnglishFound[$GroupItem['Column']] != '')) $Completable = false; 127 } else 128 { 129 // Read from english text 130 $Values .= ', "'.$EnglishFound[$GroupItem['Column']].'"'; 131 } 132 } 133 if($Completable) $NewComplete = 1; // All parts of text are completed. Make entire text as completed 134 else $NewComplete = 0; 135 if($SourceText['ID'] == $EnglishFound['ID']) 136 { 137 $NewComplete = $Complete; // Our original user text, set complete according user choice 138 if($Complete == 1) 139 { 140 foreach($Group['Items'] as $GroupItem) 141 if($GroupItem['Visible'] == 1) $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1)); 142 } 143 } 144 $Columns .= ', `Complete`, `CompleteParts`'; 145 $Values .= ', '.$NewComplete.', '.$CompleteParts; 146 147 $System->Database->query('INSERT INTO `'.$Table.'` ('.$Columns.') VALUES ('.$Values.')'); 148 $LastID = $System->Database->insert_id; 149 150 $Output .= 'Text <a href="form.php?group='.$GroupId.'&ID='.$LastID.'">'.$LastID.'</a> ze skupiny <a href="TranslationList.php?group='.$GroupId.'&user=0&action=filter">'.$TranslationTree[$GroupId]['Name'].'</a> uložen jako '.$CompleteText[$NewComplete].'. Převzat z <a href="form.php?group='.$GroupId.'&ID='.$TextID.'">'.$TextID.'</a>.<br/>'; 151 WriteLog('Text <a href="form.php?group='.$GroupId.'&ID='.$LastID.'">'.$LastID.'</a> ze skupiny <a href="TranslationList.php?group='.$GroupId.'&user=0&text=&entry=&action=filter">'.$TranslationTree[$GroupId]['Name'].'</a> uložen jako '.$CompleteText[$NewComplete].'. Převzat z <a href="form.php?group='.$GroupId.'&ID='.$TextID.'">'.$TextID.'</a>.', LOG_TYPE_TRANSLATION); 152 } 153 } 154 } else $Output .= ShowMessage('Anglický originál k překladu nenalezen.', MESSAGE_CRITICAL); 155 } else $Output .= ShowMessage('Zadaná položka nenalezena.', MESSAGE_CRITICAL); 156 157 158 // Address and redirecting 159 $Output .= '<br />Překládat: <a href="TranslationList.php?group='.$GroupId.'&state=1&user=0&entry=">Nepřeložené</a> '; 160 161 $prev = FollowingTran($TextID, $Table, $GroupId, True); 162 $next = FollowingTran($TextID, $Table, $GroupId); 163 $Output .= '<br /><br />'; 164 $DbResult = $System->Database->query('SELECT `Redirecting` FROM `User` WHERE `ID`='.$User->Id); 165 $redirecting = $DbResult->fetch_assoc(); 166 167 switch($redirecting['Redirecting']) 168 { 169 case 1: 170 $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'. 171 'setTimeout("parent.location.href=\''.htmlspecialchars_decode('TranslationList.php?group='.$GroupId.'&state=1&user=0').'\'", 1500)'. 172 '</script>'; 173 break; 174 case 2: 175 if($next <> '') 176 $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'. 177 'setTimeout("parent.location.href=\''.htmlspecialchars_decode($next).'\'", 1500)'. 178 '</script>'; 179 break; 180 case 3: 181 if($prev <> '') 182 $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'. 183 'setTimeout("parent.location.href=\''.htmlspecialchars_decode($prev).'\'", 1500)'. 184 '</script>'; 185 break; 186 } 187 188 $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="'.$System->Link('/Options.php').'" title="Nastavení uživatele">Nastavení</a>'; 189 190 // Update flag for experience info load 191 $System->Database->query('UPDATE `User` SET `NeedUpdate` = 1 WHERE `ID` = '.$User->Id); 192 } else $Output .= ShowMessage('Položka nenalezena', MESSAGE_CRITICAL); 193 } else 194 { 195 if(array_key_exists('ID', $_POST) and array_key_exists('entry', $_POST) and array_key_exists('Language', $_POST) and array_key_exists('user', $_POST)) 196 { 197 $Output .= 'Byli jste automaticky odhlášeni. Pro <strong>Uložení překladu</strong> se musíte přihlásit zde:<br /><br />'. 198 '<form action="save.php?action=login&group='.$GroupId.'" method="post"><div>'. 199 '<input type="hidden" name="entry" value="'.$_POST['entry'].'" />'. 200 '<input type="hidden" name="user" value="'.$_POST['user'].'" />'. 201 '<input type="hidden" name="ID" value="'.$_POST['ID'].'" />'. 202 '<input type="hidden" name="Language" value="'.$_POST['Language'].'" />'; 203 204 foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) 205 { 206 if(array_key_exists($TextItem['Column'], $_POST)) $Value = $_POST[$TextItem['Column']]; else $Value = ''; 207 $Output .= '<input id="'.$TextItem['Column'].'" name="'.$TextItem['Column'].'" type="hidden" value="'.htmlspecialchars($Value).'" />'; 208 } 209 $Output .= '<table>'. 210 '<tr>'. 211 '<td>Jméno: <input type="text" name="LoginUser" size="13" /></td>'. 212 '</tr><tr>'. 213 '<td>Heslo: <input type="password" name="LoginPass" size="13" /></td>'. 214 '</tr><tr>'. 215 '<th><input type="submit" value="Přihlásit a uložit překlad" /></th>'. 216 '</tr>'. 217 '</table>'; 218 } else $Output = ShowMessage('Nezadány požadované údaje.', MESSAGE_CRITICAL); 219 } 219 220 return($Output); 220 221 } -
trunk/Modules/Translation/Translation.php
r550 r561 25 25 $this->System->RegisterPage('save.php', 'PageTranslationSave'); 26 26 $this->System->RegisterPage('TranslationList.php', 'PageTranslationList'); 27 $this->System->RegisterRSS(array('Title' => 'Poslední překlady', 'Channel' => 'translation')); 27 28 } 28 29 } -
trunk/Modules/Translation/TranslationList.php
r550 r561 3 3 class PageTranslationList extends Page 4 4 { 5 function ShowFilter($GroupId = 0) 6 { 7 global $System, $TranslationTree, $Config; 8 9 $Filter = array('SQL' => ''); 10 11 $Output = '<form action="?" method="post">'. 12 '<table class="BaseTable"><tr>'. 13 '<th>Zpracování</th>'. 14 '<th>Skupina</th>'. 15 '<th>Verze</th>'. 16 '<th>Jazyk</th>'. 17 '<th>Překladatel</th>'. 18 '<th>Slova</th>'. 19 '<th>Položka</th>'. 20 '<th></th></tr><tr>'; 21 22 // State 23 $Filter['State'] = GetParameter('state', 0, true, true); 24 $Output .= '<td><select name="state">'; 25 if($Filter['State'] == 0) $Selected = ' selected="selected"'; 26 else $Selected = ''; 27 $Output .= '<option value="0"'.$Selected.'>Všechny</option>'; 28 if($Filter['State'] == 1) $Selected = ' selected="selected"'; 29 else $Selected = ''; 30 $Output .= '<option value="1"'.$Selected.'>Nepřeložené</option>'; 31 if($Filter['State'] == 2) $Selected = ' selected="selected"'; 32 else $Selected = ''; 33 $Output .= '<option value="2"'.$Selected.'>Přeložené</option>'; 34 if($Filter['State'] == 3) $Selected = ' selected="selected"'; 35 else $Selected = ''; 36 $Output .= '<option value="3"'.$Selected.'>Rozpracované</option>'; 37 if($Filter['State'] == 4) $Selected = ' selected="selected"'; 38 else $Selected = ''; 39 $Output .= '<option value="4"'.$Selected.'>Anglické</option>'; 40 $Output .= '</select></td>'; 41 42 // Translation group 43 if($GroupId == 0) 44 { 45 $Filter['Group'] = GetParameter('group', 0, true, true); 46 if($Filter['Group'] != 0) 47 { 48 if(isset($TranslationTree[$Filter['Group']]) == false) ErrorMessage('Překladová skupina dle zadaného Id neexistuje.'); 49 $Table = $TranslationTree[$Filter['Group']]['TablePrefix']; 50 } 51 } else 52 { 53 $Filter['Group'] = $GroupId; 54 $Table = $TranslationTree[$Filter['Group']]['TablePrefix']; 55 } 56 57 $Output .= '<td><select name="group" style="width: 80px">'; 58 if($Filter['Group'] == 0) $Selected = ' selected="selected"'; 59 else $Selected = ''; 60 $Output .= '<option value="0"'.$Selected.'>Všechny</option>'; 61 $DbResult = $System->Database->query('SELECT `Id`,`Name` FROM `Group` ORDER BY `Name`'); 62 while($Group = $DbResult->fetch_assoc()) 63 { 64 if($Group['Id'] == $Filter['Group']) $Selected = ' selected="selected"'; 65 else $Selected = ''; 66 $Output .= '<option value="'.$Group['Id'].'"'.$Selected.'>'.$Group['Name'].'</option>'; 67 } 68 $Output .= '</select></td>'; 69 70 // Version 71 $Filter['Version'] = GetParameter('version', 0, true, true); 72 if($Filter['Version'] != 0) 73 { 74 $DbResult = $System->Database->query('SELECT `Id`, `BuildNumber`,`Version` FROM `ClientVersion` WHERE (`Imported` = 1) AND (`Id` ='.$Filter['Version'].')'); 75 if($DbResult->num_rows > 0) 76 { 77 $DbRow = $DbResult->fetch_assoc(); 78 $Filter['BuildNumber'] = $DbRow['BuildNumber']; 79 } else ErrorMessage('Zadaná verze klienta nenalezena'); 80 } 81 $Output .= '<td><select name="version">'; 82 if($Filter['Version'] == 0) $Selected = ' selected="selected"'; 83 else $Selected = ''; 84 $Output .= '<option value="0"'.$Selected.'>Všechny</option>'; 85 $DbResult = $System->Database->query('SELECT `Id`, `BuildNumber`,`Version` FROM `ClientVersion` WHERE `Imported` = 1 ORDER BY `BuildNumber` DESC'); 86 while($Version = $DbResult->fetch_assoc()) 87 { 88 if($Version['Id'] == $Filter['Version']) $Selected = ' selected="selected"'; 89 else $Selected = ''; 90 $Output .= '<option value="'.$Version['Id'].'"'.$Selected.'>'.$Version['Version'].'</option>'; 91 } 92 $Output .= '</select></td>'; 93 if($Filter['Version'] != 0) $VersionFilter = ' AND (`VersionStart` <= '.$Filter['BuildNumber'].') AND (`VersionEnd` >= '.$Filter['BuildNumber'].')'; 94 else $VersionFilter = ''; 95 //else $Filter['SQL'] .= ' AND '; DISTINCT(Entry) 96 97 // Language 98 $Filter['Language'] = GetParameter('lang', 0, true, true); 99 $Output .= '<td><select name="lang">'; 100 if($Filter['Language'] == 0) $Selected = ' selected="selected"'; 101 else $Selected = ''; 102 $Output .= '<option value="0"'.$Selected.'>Všechny</option>'; 103 $DbResult = $System->Database->query('SELECT `Id`, `Name` FROM `Language` WHERE `Enabled` = 1 ORDER BY `Name`'); 104 while($Language = $DbResult->fetch_assoc()) 105 { 106 if($Language['Id'] == $Filter['Language']) $Selected = ' selected="selected"'; 107 else $Selected = ''; 108 $Output .= '<option value="'.$Language['Id'].'"'.$Selected.'>'.$Language['Name'].'</option>'; 109 } 110 $Output .= '</select></td>'; 111 if($Filter['Language'] != 0) $LanguageFilter = ' AND (`T`.`Language` = '.$Filter['Language'].')'; 112 else $LanguageFilter = ''; 113 114 // User 115 $Filter['User'] = GetParameter('user', 0, true, true); 116 $Output .= '<td><select name="user" style="width: 80px">'; 117 if($Filter['User'] == 0) $Selected = ' selected="selected"'; 118 else $Selected = ''; 119 $Output .= '<option value="0"'.$Selected.'>Všichni</option>'; 120 $DbResult = $System->Database->query('SELECT `Id`, `Name` FROM `User` ORDER BY `Name`'); 121 while($User = $DbResult->fetch_assoc()) 122 { 123 if($User['Id'] == $Filter['User']) $Selected = ' selected="selected"'; 124 else $Selected = ''; 125 $Output .= '<option value="'.$User['Id'].'"'.$Selected.'>'.$User['Name'].'</option>'; 126 } 127 $Output .= '</select></td>'; 128 if($Filter['User'] != 0) $UserFilter = ' AND (`User` = '.$Filter['User'].')'; 129 else $UserFilter = ''; 130 131 // Words 132 $Filter['Text'] = GetParameter('text', '', false, true); 133 $Output .= '<td><input name="text" type="text" style="width: 60px;" value="'.$Filter['Text'].'"></td>'; 134 if($Filter['Text'] != '') 135 { 136 $Items = array('(`T`.`ID` LIKE "%'.$Filter['Text'].'%")', '(`T`.`Entry` LIKE "%'.$Filter['Text'].'%")'); 137 if($Filter['Group'] != 0) 138 foreach($TranslationTree[$Filter['Group']]['Items'] as $GroupItem) 139 if($GroupItem['Visible'] == 1) 140 $Items[] = '(`T`.`'.$GroupItem['Column'].'` LIKE "%'.$Filter['Text'].'%")'; 141 $Filter['SQL'] .= ' AND ('.implode(' OR ', $Items).')'; 142 } 143 144 // Entry 145 $Filter['Entry'] = GetParameter('entry', '', false, true); 146 $Output .= '<td><input name="entry" type="text" style="width: 60px;" value="'.$Filter['Entry'].'"></td>'; 147 if($Filter['Entry'] != '') 148 { 149 $Filter['SQL'] .= ' AND (`Entry` = "'.$Filter['Entry'].'")'; 150 } 151 152 if($Filter['Group'] != 0) 153 { 154 if($Filter['State'] == 0) $Filter['SQL'] .= $UserFilter.$VersionFilter.''; 155 else if($Filter['State'] == 1) $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.$Config['OriginalLanguage'].') '. 156 'AND NOT EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE '. 157 '(`Sub`.`Language` <> '.$Config['OriginalLanguage'].')'.$LanguageFilter.$UserFilter. 158 ' AND (`Sub`.`Entry` = `T`.`Entry`) AND (`Sub`.`Complete` = 1) AND '. 159 '(`Sub`.`VersionStart` = `T`.`VersionStart`) AND (`Sub`.`VersionEnd` = `T`.`VersionEnd`))'; 160 else if($Filter['State'] == 2) $Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Complete` = 1)'; 161 else if($Filter['State'] == 3) $Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Language` != '.$Config['OriginalLanguage']. 162 ') AND (`T`.`Complete` = 0)'; 163 else if($Filter['State'] == 4) $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.$Config['OriginalLanguage'].')'; 164 } 165 166 /* 167 // Ownership 168 if(array_key_exists('owner', $_GET) and is_numeric($_GET['owner'])) $Filter['Owner'] = $_GET['owner']; 169 else $Filter['Owner'] = 0; 170 $Output .= ' <td><select name="owner">'; 171 if($Filter['Owner'] == 0) $Selected = ' selected="selected"'; 172 else $Selected = ''; 173 $Output .= '<option value="0"'.$Selected.'>Všech</option>'; 174 if($Filter['Owner'] == 1) $Selected = ' selected="selected"'; 175 else $Selected = ''; 176 $Output .= '<option value="1"'.$Selected.'>Překladatelův tým</option>'; 177 if($Filter['Owner'] == 2) $Selected = ' selected="selected"'; 178 else $Selected = ''; 179 $Output .= '<option value="2"'.$Selected.'>Překladatele</option>'; 180 $Output .= '</select></td>'; 181 if(($Filter['Owner'] == 2) AND ($Filter['User'] != 0)) $Filter['SQL'] .= ' AND (`User` = '.$Filter['User'].')'; 182 */ 183 184 $Output .= '<td><input type="submit" value="Filtrovat"/></td>'; 185 $Output .= '</tr></table>'; 186 $Output .= '</form><br/>'; 187 $Filter['Output'] = $Output; 188 return($Filter); 5 function ShowFilter($GroupId = 0) 6 { 7 global $System, $TranslationTree, $Config; 8 9 $Filter = array('SQL' => ''); 10 11 $Output = '<form action="?" method="post">'. 12 '<table class="BaseTable"><tr>'. 13 '<th>Zpracování</th>'. 14 '<th>Skupina</th>'. 15 '<th>Verze</th>'. 16 '<th>Jazyk</th>'. 17 '<th>Překladatel</th>'. 18 '<th>Slova</th>'. 19 '<th>Položka</th>'. 20 '<th></th></tr><tr>'; 21 22 // State 23 $Filter['State'] = GetParameter('state', 0, true, true); 24 $Output .= '<td><select name="state">'; 25 if($Filter['State'] == 0) $Selected = ' selected="selected"'; 26 else $Selected = ''; 27 $Output .= '<option value="0"'.$Selected.'>Všechny</option>'; 28 if($Filter['State'] == 1) $Selected = ' selected="selected"'; 29 else $Selected = ''; 30 $Output .= '<option value="1"'.$Selected.'>Nepřeložené</option>'; 31 if($Filter['State'] == 2) $Selected = ' selected="selected"'; 32 else $Selected = ''; 33 $Output .= '<option value="2"'.$Selected.'>Přeložené</option>'; 34 if($Filter['State'] == 3) $Selected = ' selected="selected"'; 35 else $Selected = ''; 36 $Output .= '<option value="3"'.$Selected.'>Rozpracované</option>'; 37 if($Filter['State'] == 4) $Selected = ' selected="selected"'; 38 else $Selected = ''; 39 $Output .= '<option value="4"'.$Selected.'>Anglické</option>'; 40 $Output .= '</select></td>'; 41 42 // Translation group 43 if($GroupId == 0) 44 { 45 $Filter['Group'] = GetParameter('group', 0, true, true); 46 if($Filter['Group'] != 0) 47 { 48 if(isset($TranslationTree[$Filter['Group']]) == false) ErrorMessage('Překladová skupina dle zadaného Id neexistuje.'); 49 $Table = $TranslationTree[$Filter['Group']]['TablePrefix']; 50 } 51 } else 52 { 53 $Filter['Group'] = $GroupId; 54 $Table = $TranslationTree[$Filter['Group']]['TablePrefix']; 55 } 56 57 $Output .= '<td><select name="group" style="width: 80px">'; 58 if($Filter['Group'] == 0) $Selected = ' selected="selected"'; 59 else $Selected = ''; 60 $Output .= '<option value="0"'.$Selected.'>Všechny</option>'; 61 $DbResult = $System->Database->query('SELECT `Id`,`Name` FROM `Group` ORDER BY `Name`'); 62 while($Group = $DbResult->fetch_assoc()) 63 { 64 if($Group['Id'] == $Filter['Group']) $Selected = ' selected="selected"'; 65 else $Selected = ''; 66 $Output .= '<option value="'.$Group['Id'].'"'.$Selected.'>'.$Group['Name'].'</option>'; 67 } 68 $Output .= '</select></td>'; 69 70 // Version 71 $Filter['Version'] = GetParameter('version', 0, true, true); 72 if($Filter['Version'] != 0) 73 { 74 $DbResult = $System->Database->query('SELECT `Id`, `BuildNumber`,`Version` FROM `ClientVersion` WHERE (`Imported` = 1) AND (`Id` ='.$Filter['Version'].')'); 75 if($DbResult->num_rows > 0) 76 { 77 $DbRow = $DbResult->fetch_assoc(); 78 $Filter['BuildNumber'] = $DbRow['BuildNumber']; 79 } else ErrorMessage('Zadaná verze klienta nenalezena'); 80 } 81 $Output .= '<td><select name="version">'; 82 if($Filter['Version'] == 0) $Selected = ' selected="selected"'; 83 else $Selected = ''; 84 $Output .= '<option value="0"'.$Selected.'>Všechny</option>'; 85 $DbResult = $System->Database->query('SELECT `Id`, `BuildNumber`,`Version` FROM `ClientVersion` WHERE `Imported` = 1 ORDER BY `BuildNumber` DESC'); 86 while($Version = $DbResult->fetch_assoc()) 87 { 88 if($Version['Id'] == $Filter['Version']) $Selected = ' selected="selected"'; 89 else $Selected = ''; 90 $Output .= '<option value="'.$Version['Id'].'"'.$Selected.'>'.$Version['Version'].'</option>'; 91 } 92 $Output .= '</select></td>'; 93 if($Filter['Version'] != 0) $VersionFilter = ' AND (`VersionStart` <= '.$Filter['BuildNumber'].') AND (`VersionEnd` >= '.$Filter['BuildNumber'].')'; 94 else $VersionFilter = ''; 95 //else $Filter['SQL'] .= ' AND '; DISTINCT(Entry) 96 97 // Language 98 $Filter['Language'] = GetParameter('lang', 0, true, true); 99 $Output .= '<td><select name="lang">'; 100 if($Filter['Language'] == 0) $Selected = ' selected="selected"'; 101 else $Selected = ''; 102 $Output .= '<option value="0"'.$Selected.'>Všechny</option>'; 103 $DbResult = $System->Database->query('SELECT `Id`, `Name` FROM `Language` WHERE `Enabled` = 1 ORDER BY `Name`'); 104 while($Language = $DbResult->fetch_assoc()) 105 { 106 if($Language['Id'] == $Filter['Language']) $Selected = ' selected="selected"'; 107 else $Selected = ''; 108 $Output .= '<option value="'.$Language['Id'].'"'.$Selected.'>'.$Language['Name'].'</option>'; 109 } 110 $Output .= '</select></td>'; 111 if($Filter['Language'] != 0) $LanguageFilter = ' AND (`T`.`Language` = '.$Filter['Language'].')'; 112 else $LanguageFilter = ''; 113 114 // User 115 $Filter['User'] = GetParameter('user', 0, true, true); 116 $Output .= '<td><select name="user" style="width: 80px">'; 117 if($Filter['User'] == 0) $Selected = ' selected="selected"'; 118 else $Selected = ''; 119 $Output .= '<option value="0"'.$Selected.'>Všichni</option>'; 120 $DbResult = $System->Database->query('SELECT `Id`, `Name` FROM `User` ORDER BY `Name`'); 121 while($User = $DbResult->fetch_assoc()) 122 { 123 if($User['Id'] == $Filter['User']) $Selected = ' selected="selected"'; 124 else $Selected = ''; 125 $Output .= '<option value="'.$User['Id'].'"'.$Selected.'>'.$User['Name'].'</option>'; 126 } 127 $Output .= '</select></td>'; 128 if($Filter['User'] != 0) $UserFilter = ' AND (`User` = '.$Filter['User'].')'; 129 else $UserFilter = ''; 130 131 // Words 132 $Filter['Text'] = GetParameter('text', '', false, true); 133 $Output .= '<td><input name="text" type="text" style="width: 60px;" value="'.$Filter['Text'].'"></td>'; 134 if($Filter['Text'] != '') 135 { 136 $Items = array('(`T`.`ID` LIKE "%'.$Filter['Text'].'%")', '(`T`.`Entry` LIKE "%'.$Filter['Text'].'%")'); 137 if($Filter['Group'] != 0) 138 foreach($TranslationTree[$Filter['Group']]['Items'] as $GroupItem) 139 if($GroupItem['Visible'] == 1) 140 $Items[] = '(`T`.`'.$GroupItem['Column'].'` LIKE "%'.$Filter['Text'].'%")'; 141 $Filter['SQL'] .= ' AND ('.implode(' OR ', $Items).')'; 142 } 143 144 // Entry 145 $Filter['Entry'] = GetParameter('entry', '', false, true); 146 $Output .= '<td><input name="entry" type="text" style="width: 60px;" value="'.$Filter['Entry'].'"></td>'; 147 if($Filter['Entry'] != '') 148 { 149 $Filter['SQL'] .= ' AND (`Entry` = "'.$Filter['Entry'].'")'; 150 } 151 152 if($Filter['Group'] != 0) 153 { 154 if($Filter['State'] == 0) $Filter['SQL'] .= $UserFilter.$VersionFilter.''; 155 else if($Filter['State'] == 1) $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.$Config['OriginalLanguage'].') '. 156 'AND NOT EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE '. 157 '(`Sub`.`Language` <> '.$Config['OriginalLanguage'].')'.$LanguageFilter.$UserFilter. 158 ' AND (`Sub`.`Entry` = `T`.`Entry`) AND (`Sub`.`Complete` = 1) AND '. 159 '(`Sub`.`VersionStart` = `T`.`VersionStart`) AND (`Sub`.`VersionEnd` = `T`.`VersionEnd`))'; 160 else if($Filter['State'] == 2) $Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Complete` = 1)'; 161 else if($Filter['State'] == 3) $Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Language` != '.$Config['OriginalLanguage']. 162 ') AND (`T`.`Complete` = 0)'; 163 else if($Filter['State'] == 4) $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.$Config['OriginalLanguage'].')'; 164 } 165 166 /* 167 // Ownership 168 if(array_key_exists('owner', $_GET) and is_numeric($_GET['owner'])) $Filter['Owner'] = $_GET['owner']; 169 else $Filter['Owner'] = 0; 170 $Output .= ' <td><select name="owner">'; 171 if($Filter['Owner'] == 0) $Selected = ' selected="selected"'; 172 else $Selected = ''; 173 $Output .= '<option value="0"'.$Selected.'>Všech</option>'; 174 if($Filter['Owner'] == 1) $Selected = ' selected="selected"'; 175 else $Selected = ''; 176 $Output .= '<option value="1"'.$Selected.'>Překladatelův tým</option>'; 177 if($Filter['Owner'] == 2) $Selected = ' selected="selected"'; 178 else $Selected = ''; 179 $Output .= '<option value="2"'.$Selected.'>Překladatele</option>'; 180 $Output .= '</select></td>'; 181 if(($Filter['Owner'] == 2) AND ($Filter['User'] != 0)) $Filter['SQL'] .= ' AND (`User` = '.$Filter['User'].')'; 182 */ 183 184 $Output .= '<td><input type="submit" value="Filtrovat"/></td>'; 185 $Output .= '</tr></table>'; 186 $Output .= '</form><br/>'; 187 $Filter['Output'] = $Output; 188 return($Filter); 189 } 190 191 function ShowTranslationList($Filter) 192 { 193 global $System, $TranslationTree; 194 195 $Output = $Filter['Output']; 196 $Table = $TranslationTree[$Filter['Group']]['TablePrefix']; 197 198 $Query = 'SELECT `T`.`ID`, `T`.`Entry`, `T`.`VersionStart`, `T`.`VersionEnd`, '. 199 '`T`.`'.$TranslationTree[$Filter['Group']]['Items'][0]['Column'].'`, '. 200 '`User`.`Name` AS `UserName`, `User`.`ID` AS `UserId`, '. 201 '`Language`.`Name` AS `LanguageName`, `TS`.`Version` AS `VersionStartText`, `TE`.`Version` AS `VersionEndText` '. 202 'FROM `'.$Table.'` AS `T` '. 203 'LEFT JOIN `User` ON `User`.`ID` = `T`.`User` '. 204 'LEFT JOIN `Language` ON `Language`.`ID` = `T`.`Language` '. 205 'LEFT JOIN `ClientVersion` AS `TS` ON `TS`.`BuildNumber` = `T`.`VersionStart` '. 206 'LEFT JOIN `ClientVersion` AS `TE` ON `TE`.`BuildNumber` = `T`.`VersionEnd` '. 207 'WHERE 1 '.$Filter['SQL']; 208 209 // Get total item count 210 $DbResult = $System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS `TT`'); 211 $DbRow = $DbResult->fetch_row(); 212 $PageList = GetPageList($DbRow[0]); 213 214 $Output .= $PageList['Output']; 215 $TableColumns = array( 216 array('Name' => 'ID', 'Title' => 'Číslo'), 217 array('Name' => 'Entry', 'Title' => 'Položka'), 218 array('Name' => $TranslationTree[$Filter['Group']]['Items'][0]['Column'], 'Title' => 'Název'), 219 array('Name' => 'VersionStart', 'Title' => 'Verze'), 220 array('Name' => 'LanguageName', 'Title' => 'Jazyk'), 221 array('Name' => 'UserName', 'Title' => 'Překladatel'), 222 ); 223 224 $Order = GetOrderTableHeader($TableColumns, 'VersionStart', 1); 225 $Output .= '<table class="BaseTable">'. 226 $Order['Output']; 227 228 $DbResult = $System->Database->query($Query.' '.$Order['SQL'].' '.$PageList['SQLLimit']); 229 while($Line = $DbResult->fetch_assoc()) 230 { 231 $Output .= '<tr><td><a href="form.php?group='.$Filter['Group'].'&ID='.$Line['ID'].'">'.$Line['ID'].'</a></td><td>'.$Line['Entry'].'</td>'. 232 '<td>'.htmlspecialchars($Line[$TranslationTree[$Filter['Group']]['Items'][0]['Column']]).'</td>'. 233 '<td>'.$Line['VersionStartText'].'-'.$Line['VersionEndText'].'</td>'. 234 '<td>'.$Line['LanguageName'].'</td>'. 235 '<td><a href="user.php?user='.$Line['UserId'].'">'.$Line['UserName'].'</a></td>'; 236 '</tr>'; 237 } 238 $Output .= '</table>'. 239 $PageList['Output']; 240 return($Output); 241 } 242 243 function ShowGroupList($Filter) 244 { 245 global $System, $TranslationTree; 246 247 $Output = $Filter['Output']; 248 249 $Output .= '<table class="BaseTable"><tr><th>Skupina</th><th>Počet</th></tr>'; 250 $Total = 0; 251 foreach($TranslationTree as $Group) 252 if($Group['TablePrefix'] != '') 253 { 254 $Filter = $this->ShowFilter($Group['Id']); 255 $ID = $System->Database->query('SELECT COUNT(*) FROM `'.$Group['TablePrefix'].'` AS `T` WHERE 1 '.$Filter['SQL']); 256 $Line = $ID->fetch_row(); 257 $Output .= '<tr><td><a href="?group='.$Group['Id'].'">'.$Group['Name'].'</td><td>'.$Line[0].'</a></tr>'; 258 $Total += $Line[0]; 259 } 260 $Output .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$Total.'</strong></td></tr>'. 261 '</table>'; 262 return($Output); 263 } 264 265 function ShowGroupTypeList() 266 { 267 global $System, $User; 268 269 $DbResult = $System->Database->query('SELECT COUNT(*) FROM `Group`'); 270 $DbRow = $DbResult->fetch_row(); 271 $PageList = GetPageList($DbRow[0]); 272 $Output = '<h3>Seznam překladových skupin</h3>'. 273 $PageList['Output']; 274 275 $Output .= '<table class="BaseTable">'; 276 $TableColumns = array( 277 array('Name' => 'Name', 'Title' => 'Jméno'), 278 array('Name' => 'SourceType', 'Title' => 'Typ zdroje'), 279 array('Name' => '', 'Title' => 'Zdroje'), 280 array('Name' => 'LastImport', 'Title' => 'Datum posledního importu'), 281 array('Name' => 'LastVersion', 'Title' => 'Verze posledního importu'), 282 ); 283 284 $Order = GetOrderTableHeader($TableColumns, 'Name', 0); 285 $Output .= $Order['Output']; 286 287 $DbResult = $System->Database->query('SELECT * FROM `Group`'.$Order['SQL'].$PageList['SQLLimit']); 288 while($Group = $DbResult->fetch_assoc()) 289 { 290 $Output .= '<tr><td><a href="?group='.$Group['Id'].'&action=filter">'.$Group['Name'].'</a></td><td>'.$Group['SourceType'].'</td><td>'; 291 if($Group['MangosTable'] != '') $Output .= $Group['MangosTable'].'.sql '; 292 if($Group['DBCFileName'] != '') $Output .= $Group['DBCFileName'].'.dbc '; 293 if($Group['LuaFileName'] != '') $Output .= $Group['LuaFileName'].'.lua '; 294 $Output .= '</td><td><a title="Změny po posledním importu u vybrané překladové skupiny" href="log.php?group='. 295 $Group['Id'].'&type=11">'.HumanDate($Group['LastImport']).'</a></td><td>'.GetVersionWOW($Group['LastVersion']).'</td></tr>'; 296 } 297 $Output .= '</table>'. 298 '<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/>'; 299 if($User->Licence(LICENCE_ADMIN)) $Output .= '<a href="?action=groupadd">Přidat překladovou skupinu</a>'; 300 return($Output); 301 } 302 303 function ShowMenu() 304 { 305 global $User, $TranslationTree; 306 307 $GroupId = GetParameter('group', 0, true); 308 if($GroupId == 0) $Output = ShowMessage('Skupina nenalezena', MESSAGE_CRITICAL); 309 else { 310 $Table = $TranslationTree[$GroupId]['TablePrefix']; 311 312 $Output = '<h3>Základní filtrování textů</h3><br/>'. 313 '<table class="BaseTable"><tr><th>Odkaz</th><th>Popis</th></tr>'. 314 '<tr><td><a title="Všechny dostupné texty ve skupině" href="?group='.$GroupId.'&state=4">Všechny</a></td>'. 315 '<td>Zobrazit všechny dostupné anglické texty ve skupině.</td></tr>'. 316 '<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>'. 317 '<td>Zobrazit pouze již přeložené texty.</td></tr>'. 318 '<tr><td><a title="Nepřeložené texty" href="?group='.$GroupId.'&state=1">Nepřeložené</a></td>'. 319 '<td>Dosud nepřeložené texty, které je potřeba přeložit.</td></tr>'. 320 '<tr><td><a title="Nedokončené texty" href="?group='.$GroupId.'&state=3">Nedokončené</a></td>'. 321 '<td>Texty označené jako rozpracované.</td></tr>'; 322 323 if($User->Licence(LICENCE_USER)) 324 { 325 $Output .= '<tr><td><a title="Nedokončené texty" href="?group='.$GroupId.'&state=3&user='.$User->Id.'">Moje nedokončené</a></td> 326 <td>Nedokončené texty přihlášeného uživatele</td></tr> 327 <tr><td><a title="Přeložené texty přihlášeného uživatele" href="?group='.$GroupId.'&state=2&user='.$User->Id.'">Moje přeložené</a></td> 328 <td>Přeložené texty přihlášeného uživatele</td></tr>'; 329 } 330 331 $Output .= '<tr><td><form action="?group='.$GroupId.'&entry=" method="post"><div>'. 332 '<input type="text" name="text" size="8" />'. 333 '<input type="submit" value="Hledat" />'. 334 '</div></form>'. 335 '</td><td>Vyhledat pomocí textu</td></tr>'; 336 337 $Output .= '<tr><td><form action="?group='.$GroupId.'&text=" method="post"><div>'. 338 '<input type="text" name="entry" size="8" />'. 339 '<input type="submit" value="Hledat" />'. 340 '</div></form>'. 341 '</td><td>Zobrazit podle ID textu v databázi MaNGOSu</td></tr>'; 342 343 $Output .= '</table>'; 344 } 345 return($Output); 346 } 347 348 function ShowGroupAdd() 349 { 350 global $User; 351 352 if($User->Licence(LICENCE_ADMIN)) 353 { 354 $Output = '<h3>Vložení nové překladové skupiny</h3>'. 355 '<form action="?action=groupaddfinish" method="post">'. 356 '<table>'. 357 '<tr><td>Název:</td><td><input type="text" name="Name"/></td></tr>'. 358 '<tr><td>Název tabulky v databázi:</td><td><input type="text" name="TablePrefix"/></td></tr>'. 359 '<tr><td>Typ zdroje:</td><td><input type="text" name="SourceType"/></td></tr>'. 360 '<tr><td>Mangos databáze:</td><td><input type="text" name="MangosDatabase"/></td></tr>'. 361 '<tr><td>Mangos tabulka:</td><td><input type="text" name="MangosTable"/></td></tr>'. 362 '<tr><td colspan="2"><input type="submit" name="add" value="Přidat"/></td></tr>'. 363 '</table></form>'; 364 } else $Output = ShowMessage('Nemáte oprávnění.', MESSAGE_CRITICAL); 365 return($Output); 366 } 367 368 function ShowGroupAddFinish() 369 { 370 global $User; 371 372 if($User->Licence(LICENCE_ADMIN)) 373 { 374 // TODO: Add group items manipulation oprations 375 } 376 } 377 378 function Show() 379 { 380 $Action = GetParameter('action', ''); 381 if($Action == 'filter') $Output = $this->ShowMenu(); 382 else if($Action == 'grouplist') $Output = $this->ShowGroupTypeList(); 383 else if($Action == 'groupadd') $Output = $this->ShowGroupAdd(); 384 else if($Action == 'groupaddfinish') $Output = $this->ShowGroupAddFinish(); 385 else 386 { 387 $Filter = $this->ShowFilter(); 388 if($Filter['Group'] > 0) $Output = $this->ShowTranslationList($Filter); 389 else $Output = $this->ShowGroupList($Filter); 390 } 391 return($Output); 392 } 189 393 } 190 191 function ShowTranslationList($Filter)192 {193 global $System, $TranslationTree;194 195 $Output = $Filter['Output'];196 $Table = $TranslationTree[$Filter['Group']]['TablePrefix'];197 198 $Query = 'SELECT `T`.`ID`, `T`.`Entry`, `T`.`VersionStart`, `T`.`VersionEnd`, '.199 '`T`.`'.$TranslationTree[$Filter['Group']]['Items'][0]['Column'].'`, '.200 '`User`.`Name` AS `UserName`, `User`.`ID` AS `UserId`, '.201 '`Language`.`Name` AS `LanguageName`, `TS`.`Version` AS `VersionStartText`, `TE`.`Version` AS `VersionEndText` '.202 'FROM `'.$Table.'` AS `T` '.203 'LEFT JOIN `User` ON `User`.`ID` = `T`.`User` '.204 'LEFT JOIN `Language` ON `Language`.`ID` = `T`.`Language` '.205 'LEFT JOIN `ClientVersion` AS `TS` ON `TS`.`BuildNumber` = `T`.`VersionStart` '.206 'LEFT JOIN `ClientVersion` AS `TE` ON `TE`.`BuildNumber` = `T`.`VersionEnd` '.207 'WHERE 1 '.$Filter['SQL'];208 209 // Get total item count210 $DbResult = $System->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS `TT`');211 $DbRow = $DbResult->fetch_row();212 $PageList = GetPageList($DbRow[0]);213 214 $Output .= $PageList['Output'];215 $TableColumns = array(216 array('Name' => 'ID', 'Title' => 'Číslo'),217 array('Name' => 'Entry', 'Title' => 'Položka'),218 array('Name' => $TranslationTree[$Filter['Group']]['Items'][0]['Column'], 'Title' => 'Název'),219 array('Name' => 'VersionStart', 'Title' => 'Verze'),220 array('Name' => 'LanguageName', 'Title' => 'Jazyk'),221 array('Name' => 'UserName', 'Title' => 'Překladatel'),222 );223 224 $Order = GetOrderTableHeader($TableColumns, 'VersionStart', 1);225 $Output .= '<table class="BaseTable">'.226 $Order['Output'];227 228 $DbResult = $System->Database->query($Query.' '.$Order['SQL'].' '.$PageList['SQLLimit']);229 while($Line = $DbResult->fetch_assoc())230 {231 $Output .= '<tr><td><a href="form.php?group='.$Filter['Group'].'&ID='.$Line['ID'].'">'.$Line['ID'].'</a></td><td>'.$Line['Entry'].'</td>'.232 '<td>'.htmlspecialchars($Line[$TranslationTree[$Filter['Group']]['Items'][0]['Column']]).'</td>'.233 '<td>'.$Line['VersionStartText'].'-'.$Line['VersionEndText'].'</td>'.234 '<td>'.$Line['LanguageName'].'</td>'.235 '<td><a href="user.php?user='.$Line['UserId'].'">'.$Line['UserName'].'</a></td>';236 '</tr>';237 }238 $Output .= '</table>'.239 $PageList['Output'];240 return($Output);241 }242 243 function ShowGroupList($Filter)244 {245 global $System, $TranslationTree;246 247 $Output = $Filter['Output'];248 249 $Output .= '<table class="BaseTable"><tr><th>Skupina</th><th>Počet</th></tr>';250 $Total = 0;251 foreach($TranslationTree as $Group)252 if($Group['TablePrefix'] != '')253 {254 $Filter = $this->ShowFilter($Group['Id']);255 $ID = $System->Database->query('SELECT COUNT(*) FROM `'.$Group['TablePrefix'].'` AS `T` WHERE 1 '.$Filter['SQL']);256 $Line = $ID->fetch_row();257 $Output .= '<tr><td><a href="?group='.$Group['Id'].'">'.$Group['Name'].'</td><td>'.$Line[0].'</a></tr>';258 $Total += $Line[0];259 }260 $Output .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$Total.'</strong></td></tr>'.261 '</table>';262 return($Output);263 }264 265 function ShowGroupTypeList()266 {267 global $System, $User;268 269 $DbResult = $System->Database->query('SELECT COUNT(*) FROM `Group`');270 $DbRow = $DbResult->fetch_row();271 $PageList = GetPageList($DbRow[0]);272 $Output = '<h3>Seznam překladových skupin</h3>'.273 $PageList['Output'];274 275 $Output .= '<table class="BaseTable">';276 $TableColumns = array(277 array('Name' => 'Name', 'Title' => 'Jméno'),278 array('Name' => 'SourceType', 'Title' => 'Typ zdroje'),279 array('Name' => '', 'Title' => 'Zdroje'),280 array('Name' => 'LastImport', 'Title' => 'Datum posledního importu'),281 array('Name' => 'LastVersion', 'Title' => 'Verze posledního importu'),282 );283 284 $Order = GetOrderTableHeader($TableColumns, 'Name', 0);285 $Output .= $Order['Output'];286 287 $DbResult = $System->Database->query('SELECT * FROM `Group`'.$Order['SQL'].$PageList['SQLLimit']);288 while($Group = $DbResult->fetch_assoc())289 {290 $Output .= '<tr><td><a href="?group='.$Group['Id'].'&action=filter">'.$Group['Name'].'</a></td><td>'.$Group['SourceType'].'</td><td>';291 if($Group['MangosTable'] != '') $Output .= $Group['MangosTable'].'.sql ';292 if($Group['DBCFileName'] != '') $Output .= $Group['DBCFileName'].'.dbc ';293 if($Group['LuaFileName'] != '') $Output .= $Group['LuaFileName'].'.lua ';294 $Output .= '</td><td><a title="Změny po posledním importu u vybrané překladové skupiny" href="log.php?group='.295 $Group['Id'].'&type=11">'.HumanDate($Group['LastImport']).'</a></td><td>'.GetVersionWOW($Group['LastVersion']).'</td></tr>';296 }297 $Output .= '</table>'.298 '<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/>';299 if($User->Licence(LICENCE_ADMIN)) $Output .= '<a href="?action=groupadd">Přidat překladovou skupinu</a>';300 return($Output);301 }302 303 function ShowMenu()304 {305 global $User, $TranslationTree;306 307 $GroupId = GetParameter('group', 0, true);308 if($GroupId == 0) $Output = ShowMessage('Skupina nenalezena', MESSAGE_CRITICAL);309 else {310 $Table = $TranslationTree[$GroupId]['TablePrefix'];311 312 $Output = '<h3>Základní filtrování textů</h3><br/>'.313 '<table class="BaseTable"><tr><th>Odkaz</th><th>Popis</th></tr>'.314 '<tr><td><a title="Všechny dostupné texty ve skupině" href="?group='.$GroupId.'&state=4">Všechny</a></td>'.315 '<td>Zobrazit všechny dostupné anglické texty ve skupině.</td></tr>'.316 '<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>'.317 '<td>Zobrazit pouze již přeložené texty.</td></tr>'.318 '<tr><td><a title="Nepřeložené texty" href="?group='.$GroupId.'&state=1">Nepřeložené</a></td>'.319 '<td>Dosud nepřeložené texty, které je potřeba přeložit.</td></tr>'.320 '<tr><td><a title="Nedokončené texty" href="?group='.$GroupId.'&state=3">Nedokončené</a></td>'.321 '<td>Texty označené jako rozpracované.</td></tr>';322 323 if($User->Licence(LICENCE_USER))324 {325 $Output .= '<tr><td><a title="Nedokončené texty" href="?group='.$GroupId.'&state=3&user='.$User->Id.'">Moje nedokončené</a></td>326 <td>Nedokončené texty přihlášeného uživatele</td></tr>327 <tr><td><a title="Přeložené texty přihlášeného uživatele" href="?group='.$GroupId.'&state=2&user='.$User->Id.'">Moje přeložené</a></td>328 <td>Přeložené texty přihlášeného uživatele</td></tr>';329 }330 331 $Output .= '<tr><td><form action="?group='.$GroupId.'&entry=" method="post"><div>'.332 '<input type="text" name="text" size="8" />'.333 '<input type="submit" value="Hledat" />'.334 '</div></form>'.335 '</td><td>Vyhledat pomocí textu</td></tr>';336 337 $Output .= '<tr><td><form action="?group='.$GroupId.'&text=" method="post"><div>'.338 '<input type="text" name="entry" size="8" />'.339 '<input type="submit" value="Hledat" />'.340 '</div></form>'.341 '</td><td>Zobrazit podle ID textu v databázi MaNGOSu</td></tr>';342 343 $Output .= '</table>';344 }345 return($Output);346 }347 348 function ShowGroupAdd()349 {350 global $User;351 352 if($User->Licence(LICENCE_ADMIN))353 {354 $Output = '<h3>Vložení nové překladové skupiny</h3>'.355 '<form action="?action=groupaddfinish" method="post">'.356 '<table>'.357 '<tr><td>Název:</td><td><input type="text" name="Name"/></td></tr>'.358 '<tr><td>Název tabulky v databázi:</td><td><input type="text" name="TablePrefix"/></td></tr>'.359 '<tr><td>Typ zdroje:</td><td><input type="text" name="SourceType"/></td></tr>'.360 '<tr><td>Mangos databáze:</td><td><input type="text" name="MangosDatabase"/></td></tr>'.361 '<tr><td>Mangos tabulka:</td><td><input type="text" name="MangosTable"/></td></tr>'.362 '<tr><td colspan="2"><input type="submit" name="add" value="Přidat"/></td></tr>'.363 '</table></form>';364 } else $Output = ShowMessage('Nemáte oprávnění.', MESSAGE_CRITICAL);365 return($Output);366 }367 368 function ShowGroupAddFinish()369 {370 global $User;371 372 if($User->Licence(LICENCE_ADMIN))373 {374 // TODO: Add group items manipulation oprations375 }376 }377 378 function Show()379 {380 $Action = GetParameter('action', '');381 if($Action == 'filter') $Output = $this->ShowMenu();382 else if($Action == 'grouplist') $Output = $this->ShowGroupTypeList();383 else if($Action == 'groupadd') $Output = $this->ShowGroupAdd();384 else if($Action == 'groupaddfinish') $Output = $this->ShowGroupAddFinish();385 else386 {387 $Filter = $this->ShowFilter();388 if($Filter['Group'] > 0) $Output = $this->ShowTranslationList($Filter);389 else $Output = $this->ShowGroupList($Filter);390 }391 return($Output);392 }393 }
Note:
See TracChangeset
for help on using the changeset viewer.