Changeset 893 for trunk/Modules/Translation/Form.php
- Timestamp:
- Mar 6, 2023, 1:48:45 AM (22 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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);
Note:
See TracChangeset
for help on using the changeset viewer.