Changeset 893 for trunk/Modules/Translation
- Timestamp:
- Mar 6, 2023, 1:48:45 AM (22 months ago)
- Location:
- trunk/Modules/Translation
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Translation/Comparison.php
r888 r893 40 40 function Show(): string 41 41 { 42 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 42 43 $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree(); 43 44 44 45 $Output = ''; 45 46 46 if ($ this->System->User->Licence(LICENCE_USER))47 if ($User->Licence(LICENCE_USER)) 47 48 { 48 49 $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 />'; -
trunk/Modules/Translation/Form.php
r888 r893 19 19 function ShowForm(): string 20 20 { 21 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 21 22 $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree(); 22 23 … … 41 42 } else 42 43 { 43 if ( $this->System->Config['OriginalLanguage'] == $Line['Language']){44 if (Core::Cast($this->System)->Config['OriginalLanguage'] == $Line['Language']){ 44 45 $LineAJ = $Line; 45 46 46 if ($ this->System->User->Language <> '') $Language = '`Language` = '.$this->System->User->Language;47 else $Language = '`Language` != '. $this->System->Config['OriginalLanguage'];47 if ($User->Language <> '') $Language = '`Language` = '.$User->Language; 48 else $Language = '`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage']; 48 49 $Columns = ''; 49 50 foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) … … 55 56 $where = ' WHERE '.'( `Tran`.'.$Language.' ) AND '.'(`Tran`.`Entry` = '.$Line['Entry'].') ORDER BY `Tran`.`ModifyTime` DESC'; 56 57 $DbResult = $this->Database->query($sql.$join.$where); 57 while ($LineSearch = $DbResult->fetch_assoc()) { 58 while ($LineSearch = $DbResult->fetch_assoc()) 59 { 58 60 foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) 61 { 59 62 if ($TextItem['Visible'] == 1) 63 { 60 64 if (($LineAJ[$TextItem['Column']] <> '') and 61 65 ($LineSearch[$TextItem['Column']] <> '') and 62 66 ($LineSearch['Orig_'.$TextItem['Column']] <> $LineSearch[$TextItem['Column']]) and 63 67 ($LineAJ[$TextItem['Column']] == $Line[$TextItem['Column']]) 64 ) 65 { 66 $Line[$TextItem['Column']] = $LineSearch[$TextItem['Column']]; 67 } 68 } 69 70 } else { 68 ) 69 { 70 $Line[$TextItem['Column']] = $LineSearch[$TextItem['Column']]; 71 } 72 } 73 } 74 } 75 } else 76 { 71 77 $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE '. 72 '(`Language` = '. $this->System->Config['OriginalLanguage'].') AND '.78 '(`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') AND '. 73 79 '(`Entry` = '.$Line['Entry'].') AND (`VersionEnd` = '.$Line['VersionEnd'].') LIMIT 1'); 74 80 $LineAJ = $DbResult->fetch_assoc(); … … 79 85 } else 80 86 { 81 82 87 if ($Line['User'] != '') 83 88 { … … 128 133 <input type="hidden" name="ID2" value="'.$TextID.'" />'; 129 134 130 if ($ this->System->User->Licence(LICENCE_USER)) { // allow to compare only to user135 if ($User->Licence(LICENCE_USER)) { // allow to compare only to user 131 136 $Output .= '<select onchange="this.form.submit();" name="ID1"> 132 137 <option value="-1">'.T('Select text for comparison').'</option> … … 155 160 156 161 // Special characters: $B - New line, $N - Name, $C - profession 157 if ($ this->System->User->Licence(LICENCE_USER))162 if ($User->Licence(LICENCE_USER)) 158 163 { 159 164 $Output .= '<form action="'.$this->System->Link('/save.php?group='.$GroupId).'" method="post"><div>'; … … 175 180 176 181 $Output .= '<input type="hidden" name="entry" value="'.$LineAJ['Entry'].'" /> 177 <input type="hidden" name="user" value="'.$ this->System->User->Id.'" />182 <input type="hidden" name="user" value="'.$User->Id.'" /> 178 183 <input type="hidden" name="ID" value="'.$TextID.'" /> 179 184 <table class="BaseTable"> … … 188 193 <td>'; 189 194 if ($Line['Language'] <> 0) $Language = $Line['Language']; 190 else if ($ this->System->User->Id != 0)191 { 192 $Language = $ this->System->User->Language;195 else if ($User->Id != 0) 196 { 197 $Language = $User->Language; 193 198 } else $Language = 0; 194 if ($this->System->User->Licence(LICENCE_USER)) $Output .= WriteLanguages($Language); 195 else { 199 if ($User->Licence(LICENCE_USER)) 200 { 201 $Output .= WriteLanguages($Language); 202 } 203 else 204 { 196 205 $DbResult3 = $this->Database->select('Language', '`Id`, `Name`', '(`Enabled` = 1) AND (`Id`='.$Language.')'); 197 206 if ($DbResult3->num_rows > 0) … … 200 209 $Output .= T($Language['Name']); 201 210 } 202 211 } 203 212 204 213 $Output .= '</td></tr>'; … … 210 219 $Output .= '$(document).ready(function() {'; 211 220 foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) 221 { 212 222 $Output .= '$("#'.$TextItem['Column'].'").load("'.$this->System->Link('/LoadNames.php?ID='.$LineAJ['ID'].'&Column='.$TextItem['Column'].'&GroupId='.$GroupId).'");'; 223 } 213 224 214 225 $Output .= '});'. 215 226 '</script>'; 216 227 217 foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) 228 foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) 229 { 218 230 if ($TextItem['Visible'] == 1) 219 231 { … … 225 237 $Output .= '<td id="'.$TextItem['Column'].'">'.str_replace("\n", '<br/>', htmlspecialchars($LineAJ[$TextItem['Column']])).'</td> 226 238 <td>'; 227 if ($ this->System->User->Licence(LICENCE_USER))239 if ($User->Licence(LICENCE_USER)) 228 240 $Output .= '<textarea rows="8" cols="40" onkeydown="ResizeTextArea(this)" class="textedit" id="'.$TextItem['Column'].'" name="'.$TextItem['Column'].'">'; 229 241 $Output .= htmlspecialchars($Line[$TextItem['Column']]); 230 if ($ this->System->User->Licence(LICENCE_USER)) $Output .= '</textarea></td></tr>';242 if ($User->Licence(LICENCE_USER)) $Output .= '</textarea></td></tr>'; 231 243 } 232 244 } else … … 234 246 $Output .= '<input id="'.$TextItem['Column'].'" name="'.$TextItem['Column'].'" type="hidden" value="'.htmlspecialchars($Line[$TextItem['Column']]).'" />'; 235 247 } 236 $Output .= '</table></div>'; 237 if ($this->System->User->Licence(LICENCE_USER)) { 238 $Output .= '</form>'; 239 240 if (isset($this->System->Config['Web']['EnableGoogleTranslate']) and 241 $this->System->Config['Web']['EnableGoogleTranslate']) 242 { 248 } 249 250 $Output .= '</table></div>'; 251 if ($User->Licence(LICENCE_USER)) 252 { 253 $Output .= '</form>'; 254 255 if (isset(Core::Cast($this->System)->Config['Web']['EnableGoogleTranslate']) and 256 Core::Cast($this->System)->Config['Web']['EnableGoogleTranslate']) 257 { 243 258 $Output .= '<br/><table class="BaseTable">'. 244 259 '<tr><th>'.T('Google translator').':</th><th>'.T('Not translated').'</th><th>'.T('Translated').'</th>'; 245 260 foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) 261 { 246 262 if ($TextItem['Visible'] == 1) 263 { 247 264 if ($LineAJ[$TextItem['Column']] <> '') 265 { 248 266 $Output .= '<tr><td>'.$TextItem['Column'].'</td>'. 249 267 '<td>'.$LineAJ[$TextItem['Column']].'</td>'. 250 '<td>'.GetTranslateGoogle($LineAJ[$TextItem['Column']]).'</td></tr>'; 251 268 '<td>'.GetTranslateGoogle($this->System, $LineAJ[$TextItem['Column']]).'</td></tr>'; 269 } 270 } 271 } 252 272 $Output .= '</table>'; 253 254 273 } 274 } 255 275 } 256 276 } … … 261 281 function Delete() 262 282 { 283 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 263 284 $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree(); 264 285 265 if ($ this->System->User->Licence(LICENCE_MODERATOR))286 if ($User->Licence(LICENCE_MODERATOR)) 266 287 { 267 288 $GroupId = LoadGroupIdParameter(); … … 269 290 $Table = $TranslationTree[$GroupId]['TablePrefix']; 270 291 $TextID = $_GET['ID']; 271 $this->Database->query('DELETE FROM `'.$Table.'` WHERE `ID` = '.$TextID.' AND `Language` <> '. $this->System->Config['OriginalLanguage']);292 $this->Database->query('DELETE FROM `'.$Table.'` WHERE `ID` = '.$TextID.' AND `Language` <> '.Core::Cast($this->System)->Config['OriginalLanguage']); 272 293 $Output = ShowMessage('Překlad byl smazán.'); 273 294 $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); -
trunk/Modules/Translation/LoadNames.php
r888 r893 20 20 return $Text; 21 21 } 22 22 23 function ReplaceNotTranslated($orig,$tran,$Text,$ID,$Group) 23 24 { … … 44 45 $Text = str_replace('$r','<span Title="Znamená rasu hráče, překladu zachovej na stejné pozici." class="edit">$R</span>',$Text); 45 46 $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 if ($Line[3] <> '') { 49 $Text = $this->ReplaceTranslated($Line[2],$Line[3],$Text,$Line[0],$Line[1]); 50 51 } else { 52 $Text = $this->ReplaceNotTranslated($Line[2],$Line[3],$Text,$Line[0],$Line[1]); 47 foreach ($names as $Line) 48 { 49 if (($_GET['ID'] <> $Line[0]) or ($Line[1] <> $_GET['GroupId'])) 50 { 51 if ($Line[3] <> '') 52 { 53 $Text = $this->ReplaceTranslated($Line[2],$Line[3],$Text,$Line[0],$Line[1]); 54 } else 55 { 56 $Text = $this->ReplaceNotTranslated($Line[2],$Line[3],$Text,$Line[0],$Line[1]); 57 } 53 58 } 54 59 } … … 58 63 function LoadNames() 59 64 { 65 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 60 66 $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree(); 61 67 … … 72 78 $Text = $LineAJ[$Column]; 73 79 $names = array(); 74 if ($ this->System->User->Licence(LICENCE_USER))80 if ($User->Licence(LICENCE_USER)) 75 81 if (($GroupId < 4) or ($GroupId == 10) or ($GroupId == 11)) 76 82 { 77 83 //<span class="edit">barvou.</span> 78 84 $names = GetTranslatNames($Text, 0, GetTranslatNamesArray()); 79 } else { 80 if (($GroupId == 13)) { 85 } else 86 { 87 if (($GroupId == 13)) 88 { 81 89 $names = GetTranslatNames($Text, 0, array('Dictionary' => 'Text', 82 90 'TextGlobalString' => 'Text', 'TextArea' => 'Name', 83 91 'TextItemSubClass' => 'Name', 'TextCharacterRace' => 'Name1',), false); 84 } else { 92 } else 93 { 85 94 $names = GetTranslatNames($Text, 0, GetTranslatNamesArray()); 86 95 } 87 96 } 88 97 //$LineAJ[$Column] 89 98 return $this->ColorNames(htmlspecialchars($Text),$names); 90 99 } -
trunk/Modules/Translation/Progress.php
r888 r893 9 9 $BuildNumber = GetBuildNumber($_SESSION['StatVersion']); 10 10 if (is_numeric($_SESSION['language'])) $LanguageFilter = 'AND (`Language`='.$_SESSION['language'].')'; 11 else $LanguageFilter = ' AND (`Language`!='. $this->System->Config['OriginalLanguage'].')';11 else $LanguageFilter = ' AND (`Language`!='.Core::Cast($this->System)->Config['OriginalLanguage'].')'; 12 12 13 13 $GroupListQuery = 'SELECT `Id`, `TablePrefix`, `Name` FROM `Group`'; … … 25 25 '(SELECT COUNT(DISTINCT(`Entry`)) FROM ('. 26 26 'SELECT `T`.`Entry` FROM `'.$DbRow['TablePrefix'].'` AS `T` '. 27 'WHERE (`Language` = '. $this->System->Config['OriginalLanguage'].') '.27 'WHERE (`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') '. 28 28 'AND (`VersionStart` <= '.$BuildNumber.') AND (`VersionEnd` >= '.$BuildNumber.')'. 29 29 ') AS `C2`) AS `Total`, "'.$DbRow['Name'].'" AS `Name` UNION '; … … 59 59 else $TotalCount = 0; 60 60 $Output .= '<tr><td><strong>'.T('Total').'</strong></td><td><strong>'.$Translated.'</strong></td><td><strong>'.$Total.'</strong></td><td><strong>'.ProgressBar(150, $TotalCount).'</strong></td></tr>'. 61 61 '</table>'; 62 62 } 63 63 return $Output; … … 66 66 function Show(): string 67 67 { 68 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 68 69 $this->Title = T('Progress'); 69 70 $LanguageList = GetLanguageList(); … … 72 73 if (!array_key_exists('StatVersion', $_SESSION)) 73 74 { 74 if ($ this->System->User->Licence(LICENCE_USER) and ($this->System->User->PreferredVersionGame != ''))75 if ($User->Licence(LICENCE_USER) and ($User->PreferredVersionGame != '')) 75 76 { 76 $_SESSION['StatVersion'] = $this->System->User->PreferredVersionGame; 77 } else { 78 $_SESSION['StatVersion'] = $this->System->Config['Web']['GameVersion']; 77 $_SESSION['StatVersion'] = $User->PreferredVersionGame; 78 } else 79 { 80 $_SESSION['StatVersion'] = Core::Cast($this->System)->Config['Web']['GameVersion']; 79 81 } 80 82 } … … 82 84 if (!isset($_SESSION['language'])) 83 85 { 84 if ($ this->System->User->Licence(LICENCE_USER))86 if ($User->Licence(LICENCE_USER)) 85 87 { 86 $_SESSION['language'] = $this->System->User->Language; 87 } else { 88 $_SESSION['language'] = $User->Language; 89 } else 90 { 88 91 $_SESSION['language'] = ''; 89 92 } … … 93 96 if ($_GET['language'] == '') { 94 97 $_SESSION['language'] = ''; 95 } else { 98 } else 99 { 96 100 $_SESSION['language'] = $_GET['language'] * 1; 97 101 } … … 103 107 $DbResult = $this->Database->query('SELECT `Version`, `Title` FROM `ClientVersion` WHERE `Imported`=1 ORDER BY `Version`'); 104 108 while ($DbRow = $DbResult->fetch_assoc()) 109 { 105 110 $Output .= '<a href="?Version='.$DbRow['Version'].'" title="'.$DbRow['Title'].'">'.$DbRow['Version'].'</a> '; 111 } 106 112 $Output .= '<br/>'; 107 113 -
trunk/Modules/Translation/Save.php
r888 r893 5 5 function Translate($Group, $TextID, $Complete, $Language) 6 6 { 7 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 7 8 $Output = ''; 8 9 $Table = $Group['TablePrefix']; … … 17 18 // Get data for english original 18 19 $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE (`Entry`='.$SourceText['Entry'].') '. 19 'AND (`Language` = '. $this->System->Config['OriginalLanguage'].') AND (`VersionStart` = '.$SourceText['VersionStart'].') '.20 'AND (`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') AND (`VersionStart` = '.$SourceText['VersionStart'].') '. 20 21 'AND (`VersionEnd` = '.$SourceText['VersionEnd'].')'); 21 22 if ($DbResult->num_rows > 0) … … 33 34 else $Filter = ' AND 0'; 34 35 35 $Query = 'SELECT * FROM `'.$Table.'` WHERE (`Language` = '. $this->System->Config['OriginalLanguage'].')'.$Filter;36 $Query = 'SELECT * FROM `'.$Table.'` WHERE (`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].')'.$Filter; 36 37 $DbResult = $this->Database->query($Query); 37 38 while ($EnglishFound = $DbResult->fetch_assoc()) 38 39 { 39 40 // Get user translation paired to found english item entry 40 $DbResult2 = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE (`User` = '.$ this->System->User->Id.41 $DbResult2 = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE (`User` = '.$User->Id. 41 42 ') AND (`Entry` = '.$EnglishFound['Entry'].') AND (`VersionStart` = '.$EnglishFound['VersionStart']. 42 43 ') AND (`VersionEnd` = '.$EnglishFound['VersionEnd'].')'); … … 110 111 $Columns = '`Entry`, `VersionStart`, `VersionEnd`, `Language`, `User`, `Take`, `ModifyTime`'; 111 112 $Values = $EnglishFound['Entry'].', '.$EnglishFound['VersionStart'].', '. 112 $EnglishFound['VersionEnd'].', '.$Language.', '.$ this->System->User->Id.', '.$TakeID.', NOW()';113 $EnglishFound['VersionEnd'].', '.$Language.', '.$User->Id.', '.$TakeID.', NOW()'; 113 114 114 115 $CompleteParts = 0; … … 178 179 global $Message, $MessageType; 179 180 181 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 180 182 $Output = ''; 181 183 $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree(); … … 188 190 $Group = $TranslationTree[$GroupId]; 189 191 $Table = $Group['TablePrefix']; 190 if ($ this->System->User->Licence(LICENCE_USER))192 if ($User->Licence(LICENCE_USER)) 191 193 { 192 194 if (array_key_exists('ID', $_POST) and is_numeric($_POST['ID'])) … … 202 204 $Output .= $this->ShowRedirection($GroupId, $Table, $TextID); 203 205 204 UserLevelUpdate($ this->System->User->Id);206 UserLevelUpdate($User->Id); 205 207 } else $Output .= ShowMessage('Položka nenalezena', MESSAGE_CRITICAL); 206 208 } else … … 237 239 function ShowRedirection($GroupId, $Table, $TextID) 238 240 { 241 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 239 242 // Address and redirecting 240 243 $Output = '<br />'.T('Translate').': <a href="'.$this->System->Link('/TranslationList.php?group='.$GroupId.'&state=1&user=0&entry=').'">'.T('Not translated').'</a> '; … … 243 246 $next = FollowingTran($TextID, $Table, $GroupId); 244 247 $Output .= '<br /><br />'; 245 $DbResult = $this->Database->query('SELECT `Redirecting` FROM `User` WHERE `ID`='.$ this->System->User->Id);248 $DbResult = $this->Database->query('SELECT `Redirecting` FROM `User` WHERE `ID`='.$User->Id); 246 249 $redirecting = $DbResult->fetch_assoc(); 247 250 -
trunk/Modules/Translation/Translation.php
r888 r893 11 11 class ModuleTranslation extends Module 12 12 { 13 public array $TranslationTree; 14 13 15 function __construct(System $System) 14 16 { … … 79 81 ( 80 82 'Title' => strip_tags($DbRow['Text'].' ('.$DbRow['UserName'].')'), 81 'Link' => 'http://'. $this->System->Config['Web']['Host'].$this->System->Link('/'),83 'Link' => 'http://'.Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/'), 82 84 'Description' => $DbRow['Text'], 83 85 'Time' => $DbRow['Date'], … … 86 88 $Output = GenerateRSS(array 87 89 ( 88 'Title' => $this->System->Config['Web']['Title'].' - '.T('Last translations'),89 'Link' => 'http ://'.$this->System->Config['Web']['Host'].$this->System->Link('/'),90 'Description' => $this->System->Config['Web']['Description'],91 'WebmasterEmail' => $this->System->Config['Web']['AdminEmail'],90 'Title' => Core::Cast($this->System)->Config['Web']['Title'].' - '.T('Last translations'), 91 'Link' => 'https://'.Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/'), 92 'Description' => Core::Cast($this->System)->Config['Web']['Description'], 93 'WebmasterEmail' => Core::Cast($this->System)->Config['Web']['AdminEmail'], 92 94 'Items' => $Items, 93 95 )); … … 113 115 $DbRow['Id'].' AS `Group`, "'.addslashes($DbRow['Name']).'" AS `GroupName`, `T`.`Take` FROM `'. 114 116 $DbRow['TablePrefix'].'` AS `T`'. 115 ' WHERE (`T`.`Complete` = 1) AND (`T`.`Language` != '. $this->System->Config['OriginalLanguage'].') ORDER BY `T`.`ModifyTime` DESC LIMIT '.117 ' WHERE (`T`.`Complete` = 1) AND (`T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage'].') ORDER BY `T`.`ModifyTime` DESC LIMIT '. 116 118 $Count.') AS `T`'; 117 119 } … … 139 141 { 140 142 if (isset($this->TranslationTree)) return $this->TranslationTree; 141 else { 143 else 144 { 142 145 $Result = array(); 143 146 $Groups = array(); … … 164 167 function ShowTranslatedMenu() 165 168 { 169 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 166 170 $TranslationTree = $this->GetTranslationTree(); 167 171 … … 183 187 ' <a title="Přeložené texty, můžete zde hlasovat, nebo opravovat překlady" href="'. 184 188 $this->System->Link('/TranslationList.php?group='.$Group['Id'].'&state=2&user=0&entry=&text=').'">'.T('Translated').'</a><br />'; 185 if (isset($ this->System->User) and $this->System->User->Licence(LICENCE_USER))189 if (isset($User) and $User->Licence(LICENCE_USER)) 186 190 { 187 191 $Output .= ' <a title="'.T('Unfinished translations').'" href="'.$this->System->Link('/TranslationList.php?group='.$Group['Id'].'&state=3').'">'.T('Unfinished').'</a><br />'. 188 192 ' <a title="Všechny překlady, které jste přeložil" href="'. 189 193 $this->System->Link('/TranslationList.php?group='.$Group['Id'].'&state=1&user='. 190 $ this->System->User->Id).'&entry=&text=">'.T('Own').'</a><br />';194 $User->Id).'&entry=&text=">'.T('Own').'</a><br />'; 191 195 } 192 196 $Output .= ' <a title="'.T('Compose special filter').'" href="'. … … 198 202 return $Output; 199 203 } 204 205 static function Cast(Module $Module): ModuleTranslation 206 { 207 if ($Module instanceof ModuleTranslation) 208 { 209 return $Module; 210 } 211 throw new Exception('Expected '.ModuleTranslation::GetClassName().' type but got '.gettype($Module)); 212 } 200 213 } -
trunk/Modules/Translation/TranslationList.php
r888 r893 13 13 } 14 14 15 16 15 class PageTranslationList extends Page 17 16 { 18 17 function ShowFilter($GroupId = 0) 19 18 { 20 $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree(); 19 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 20 $TranslationTree = ModuleTranslation::Cast($this->System->GetModule('Translation'))->GetTranslationTree(); 21 21 22 22 $Filter = array('SQL' => ''); … … 85 85 $Output .= '</select></td>'; 86 86 87 if ($ this->System->User->Licence(LICENCE_USER))88 $Filter['Version'] = GetParameter('version', $ this->System->User->PreferredVersion, true, true);87 if ($User->Licence(LICENCE_USER)) 88 $Filter['Version'] = GetParameter('version', $User->PreferredVersion, true, true); 89 89 else 90 90 $Filter['Version'] = GetParameter('version', 0, true, true); … … 176 176 { 177 177 $WithoutAlter = ' AND NOT EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE '. 178 '(`Sub`.`Language` <> '. $this->System->Config['OriginalLanguage'].')'.$LanguageFilterSub.178 '(`Sub`.`Language` <> '.Core::Cast($this->System)->Config['OriginalLanguage'].')'.$LanguageFilterSub. 179 179 ' AND (`Sub`.`Entry` = `T`.`Entry`) AND (`Sub`.`ID` != `T`.`ID`) AND (`Sub`.`Complete` = 1) AND '. 180 180 '(`Sub`.`VersionStart` = `T`.`VersionStart`) AND (`Sub`.`VersionEnd` = `T`.`VersionEnd`) LIMIT 1 ) '; … … 184 184 ' < ('. 185 185 'SELECT LENGTH(`Sub`.`'.$GroupItem['Column'].'`) - LENGTH( REPLACE( `Sub`.`'.$GroupItem['Column'].'`, \'$\', \'\' ) ) FROM `'.$Table.'` AS `Sub` WHERE '. 186 ' `Sub`.`Entry` = `T`.`Entry` AND `Sub`.`Language` = '. $this->System->Config['OriginalLanguage'].' AND '.186 ' `Sub`.`Entry` = `T`.`Entry` AND `Sub`.`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].' AND '. 187 187 '`Sub`.`VersionStart` = `T`.`VersionStart` AND `Sub`.`VersionEnd` = `T`.`VersionEnd` LIMIT 1 '. 188 188 ')'; … … 192 192 } else 193 193 if ($Filter['State'] == CompletionState::NotTranslated) { 194 $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '. $this->System->Config['OriginalLanguage'].') '.194 $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') '. 195 195 'AND NOT EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE '. 196 '(`Sub`.`Language` <> '. $this->System->Config['OriginalLanguage'].') '.$LanguageFilterSub.$UserFilter.196 '(`Sub`.`Language` <> '.Core::Cast($this->System)->Config['OriginalLanguage'].') '.$LanguageFilterSub.$UserFilter. 197 197 ' AND (`Sub`.`Entry` = `T`.`Entry`) AND (`Sub`.`Complete` = 1) AND '. 198 198 '(`Sub`.`VersionStart` = `T`.`VersionStart`) AND (`Sub`.`VersionEnd` = `T`.`VersionEnd`))'; … … 202 202 } else 203 203 if ($Filter['State'] == CompletionState::NotFinished) { 204 $Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Language` != '. $this->System->Config['OriginalLanguage'].204 $Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage']. 205 205 ') AND (`T`.`Complete` = 0)'; 206 206 } else 207 207 if ($Filter['State'] == CompletionState::Original) { 208 $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '. $this->System->Config['OriginalLanguage'].')';208 $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].')'; 209 209 } else 210 210 if ($Filter['State'] == CompletionState::NotFinishedNotTranslated) { 211 211 $Filter['SQL'] .= $UserFilter.$VersionFilter.$WithoutAlter. 212 ' AND (`T`.`Language` != '. $this->System->Config['OriginalLanguage'].212 ' AND (`T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage']. 213 213 ') AND (`T`.`Complete` = 0)'; 214 214 } else 215 215 if ($Filter['State'] == CompletionState::Missing1) { 216 $Filter['SQL'] .= $UserFilter.$VersionFilter.' AND (`T`.`Complete` = 1) AND `T`.`Language` != '. $this->System->Config['OriginalLanguage'];216 $Filter['SQL'] .= $UserFilter.$VersionFilter.' AND (`T`.`Complete` = 1) AND `T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage']; 217 217 $Filter['SQL'] .= ' AND ('.implode(' OR ', $ItemsVar).') '; 218 218 } else 219 219 if ($Filter['State'] == CompletionState::Missing2) { 220 $Filter['SQL'] .= $UserFilter.$VersionFilter.' AND (`T`.`Complete` = 1) AND `T`.`Language` != '. $this->System->Config['OriginalLanguage'];220 $Filter['SQL'] .= $UserFilter.$VersionFilter.' AND (`T`.`Complete` = 1) AND `T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage']; 221 221 $Filter['SQL'] .= ' '. $WithoutAlter; 222 222 $Filter['SQL'] .= ' AND ('.implode(' OR ', $ItemsVar).') '; … … 333 333 function ShowMenu() 334 334 { 335 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 335 336 $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree(); 336 337 … … 351 352 '<td>'.T('Texts marked as unfinished').'</td></tr>'; 352 353 353 if ($ this->System->User->Licence(LICENCE_USER))354 if ($User->Licence(LICENCE_USER)) 354 355 { 355 $Output .= '<tr><td><a title="'.T('Unfinished texts').'" href="?group='.$GroupId.'&state=3&user='.$ this->System->User->Id.'">'.T('My unfinished').'</a></td>356 $Output .= '<tr><td><a title="'.T('Unfinished texts').'" href="?group='.$GroupId.'&state=3&user='.$User->Id.'">'.T('My unfinished').'</a></td> 356 357 <td>'.T('Unfinished texts of logged-in user').'</td></tr> 357 <tr><td><a title="'.T('Translated texts of logged-in user').'" href="?group='.$GroupId.'&state=2&user='.$ this->System->User->Id.'">'.T('My translated').'</a></td>358 <tr><td><a title="'.T('Translated texts of logged-in user').'" href="?group='.$GroupId.'&state=2&user='.$User->Id.'">'.T('My translated').'</a></td> 358 359 <td>'.T('Translated texts of logged-in user').'</td></tr>'; 359 360 } … … 395 396 function ShowList() 396 397 { 398 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 397 399 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Group`'); 398 400 $DbRow = $DbResult->fetch_row(); … … 408 410 array('Name' => 'LastImport', 'Title' => T('Date of last import')), 409 411 array('Name' => 'LastVersion', 'Title' => T('Version of last import')), 410 );411 if ($this->System->User->Licence(LICENCE_ADMIN))412 $TableColumns[] = array('Name' => '', 'Title' => T('Actions'));413 414 $Order = GetOrderTableHeader($TableColumns, 'Name', 0);415 $Output .= $Order['Output'];416 417 $DbResult = $this->Database->query('SELECT * FROM `Group`'.$Order['SQL'].$PageList['SQLLimit']);418 while ($Group = $DbResult->fetch_assoc())419 {420 $Output .= '<tr><td><a href="'.$this->System->Link('/TranslationList.php?group='.$Group['Id'].'&action=filter').'">'.T($Group['Name']).'</a></td>'.421 '<td>'.$Group['SourceType'].'</td><td>';422 if ($Group['MangosTable'] != '') $Output .= $Group['MangosTable'].'.sql ';423 if ($Group['DBCFileName'] != '') $Output .= $Group['DBCFileName'].'.dbc ';424 if ($Group['LuaFileName'] != '') $Output .= $Group['LuaFileName'].'.lua ';425 $Output .= '</td>';426 if ($this->System->User->Licence(LICENCE_ADMIN))427 $Output .= '<td><a title="Změny po posledním importu u vybrané překladové skupiny" href="'.$this->System->Link('/log/?group='.428 $Group['Id'].'&type=11').'">'.HumanDate($Group['LastImport']).'</a></td>';429 else $Output .= '<td>'.HumanDate($Group['LastImport']).'</td>';430 $Output .= '<td><a href="'.$this->System->Link('/client-version/?action=item&id='.431 GetVersionWOWId($Group['LastVersion'])).'">'.GetVersionWOW($Group['LastVersion']).'</a></td>';432 if ($this->System->User->Licence(LICENCE_ADMIN))433 $Output .= '<td><a href="?action=groupdelete&id='.$Group['Id'].'">'.T('Remove').'</a></td>';434 $Output .= '</tr>';412 ); 413 if ($User->Licence(LICENCE_ADMIN)) 414 $TableColumns[] = array('Name' => '', 'Title' => T('Actions')); 415 416 $Order = GetOrderTableHeader($TableColumns, 'Name', 0); 417 $Output .= $Order['Output']; 418 419 $DbResult = $this->Database->query('SELECT * FROM `Group`'.$Order['SQL'].$PageList['SQLLimit']); 420 while ($Group = $DbResult->fetch_assoc()) 421 { 422 $Output .= '<tr><td><a href="'.$this->System->Link('/TranslationList.php?group='.$Group['Id'].'&action=filter').'">'.T($Group['Name']).'</a></td>'. 423 '<td>'.$Group['SourceType'].'</td><td>'; 424 if ($Group['MangosTable'] != '') $Output .= $Group['MangosTable'].'.sql '; 425 if ($Group['DBCFileName'] != '') $Output .= $Group['DBCFileName'].'.dbc '; 426 if ($Group['LuaFileName'] != '') $Output .= $Group['LuaFileName'].'.lua '; 427 $Output .= '</td>'; 428 if ($User->Licence(LICENCE_ADMIN)) 429 $Output .= '<td><a title="Změny po posledním importu u vybrané překladové skupiny" href="'.$this->System->Link('/log/?group='. 430 $Group['Id'].'&type=11').'">'.HumanDate($Group['LastImport']).'</a></td>'; 431 else $Output .= '<td>'.HumanDate($Group['LastImport']).'</td>'; 432 $Output .= '<td><a href="'.$this->System->Link('/client-version/?action=item&id='. 433 GetVersionWOWId($Group['LastVersion'])).'">'.GetVersionWOW($Group['LastVersion']).'</a></td>'; 434 if ($User->Licence(LICENCE_ADMIN)) 435 $Output .= '<td><a href="?action=groupdelete&id='.$Group['Id'].'">'.T('Remove').'</a></td>'; 436 $Output .= '</tr>'; 435 437 } 436 438 $Output .= '</table>'. 437 439 '<br /><a title="'.T('Changelog of changes after import').'" href="'.$this->System->Link('/log/?type=11').'">'.T('Changelog of text modification during import').'</a><br/>'; 438 if ($ this->System->User->Licence(LICENCE_ADMIN)) $Output .= '<a href="?action=groupadd">'.T('Add translation group').'</a>';440 if ($User->Licence(LICENCE_ADMIN)) $Output .= '<a href="?action=groupadd">'.T('Add translation group').'</a>'; 439 441 return $Output; 440 442 } … … 442 444 function ShowGroupAdd() 443 445 { 444 if ($this->System->User->Licence(LICENCE_ADMIN)) 446 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 447 if ($User->Licence(LICENCE_ADMIN)) 445 448 { 446 449 $Output = '<h3>Vložení nové překladové skupiny</h3>'. … … 457 460 function ShowGroupAddFinish() 458 461 { 459 if ($this->System->User->Licence(LICENCE_ADMIN)) 462 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 463 if ($User->Licence(LICENCE_ADMIN)) 460 464 { 461 465 $TableName = 'Text'.$_POST['TablePrefix']; … … 505 509 function ShowGroupDelete() 506 510 { 507 if ($this->System->User->Licence(LICENCE_ADMIN)) 511 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 512 if ($User->Licence(LICENCE_ADMIN)) 508 513 { 509 514 $DbResult = $this->System->Database->select('Group', '*', '`Id`='.$_GET['id']);
Note:
See TracChangeset
for help on using the changeset viewer.