Changeset 880 for trunk/Modules/Translation/Save.php
- Timestamp:
- Apr 7, 2020, 10:15:48 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Translation/Save.php
r859 r880 11 11 // Get source text record from database by ID 12 12 $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE `ID`='.$TextID); 13 if ($DbResult->num_rows > 0)13 if ($DbResult->num_rows > 0) 14 14 { 15 15 $SourceText = $DbResult->fetch_assoc(); … … 19 19 'AND (`Language` = '.$this->System->Config['OriginalLanguage'].') AND (`VersionStart` = '.$SourceText['VersionStart'].') '. 20 20 'AND (`VersionEnd` = '.$SourceText['VersionEnd'].')'); 21 if ($DbResult->num_rows > 0)21 if ($DbResult->num_rows > 0) 22 22 { 23 23 $EnglishText = $DbResult->fetch_assoc(); … … 25 25 // Get all similar english texts 26 26 $Filter = array(); 27 foreach ($Group['Items'] as $GroupItem)27 foreach ($Group['Items'] as $GroupItem) 28 28 { 29 if (($GroupItem['Visible'] == 1) and ($EnglishText[$GroupItem['Column']] != ''))29 if (($GroupItem['Visible'] == 1) and ($EnglishText[$GroupItem['Column']] != '')) 30 30 $Filter[] = '(`'.$GroupItem['Column'].'` = "'.addslashes($EnglishText[$GroupItem['Column']]).'")'; 31 31 } 32 if (count($Filter) > 0) $Filter = ' AND ('.implode(' OR ', $Filter).')';32 if (count($Filter) > 0) $Filter = ' AND ('.implode(' OR ', $Filter).')'; 33 33 else $Filter = ' AND 0'; 34 34 35 35 $Query = 'SELECT * FROM `'.$Table.'` WHERE (`Language` = '.$this->System->Config['OriginalLanguage'].')'.$Filter; 36 36 $DbResult = $this->Database->query($Query); 37 while ($EnglishFound = $DbResult->fetch_assoc())37 while ($EnglishFound = $DbResult->fetch_assoc()) 38 38 { 39 39 // Get user translation paired to found english item entry … … 41 41 ') AND (`Entry` = '.$EnglishFound['Entry'].') AND (`VersionStart` = '.$EnglishFound['VersionStart']. 42 42 ') AND (`VersionEnd` = '.$EnglishFound['VersionEnd'].')'); 43 if ($DbResult2->num_rows > 0)43 if ($DbResult2->num_rows > 0) 44 44 { 45 45 // Update existed user translation … … 47 47 $Modified = false; 48 48 $Values = '`Language` = '.$Language; 49 if ($Language != $ExistedText['Language']) $Modified = true;49 if ($Language != $ExistedText['Language']) $Modified = true; 50 50 51 51 $Completable = true; 52 52 $CompleteParts = $ExistedText['CompleteParts']; 53 foreach ($Group['Items'] as $GroupItem)54 { 55 if ($GroupItem['Visible'] == 1)56 { 57 if ($EnglishFound[$GroupItem['Column']] == $EnglishText[$GroupItem['Column']])53 foreach ($Group['Items'] as $GroupItem) 54 { 55 if ($GroupItem['Visible'] == 1) 56 { 57 if ($EnglishFound[$GroupItem['Column']] == $EnglishText[$GroupItem['Column']]) 58 58 { 59 if (array_key_exists($GroupItem['Column'], $_POST))59 if (array_key_exists($GroupItem['Column'], $_POST)) 60 60 { 61 if ($_POST[$GroupItem['Column']] != $ExistedText[$GroupItem['Column']])61 if ($_POST[$GroupItem['Column']] != $ExistedText[$GroupItem['Column']]) 62 62 $Modified = true; 63 63 … … 66 66 } 67 67 } 68 if ((($CompleteParts & (1 << ($GroupItem['Sequence'] - 1))) == 0) and68 if ((($CompleteParts & (1 << ($GroupItem['Sequence'] - 1))) == 0) and 69 69 ($EnglishFound[$GroupItem['Column']] != '')) $Completable = false; 70 70 } 71 71 } 72 if ($Completable) $NewComplete = 1; // All parts of text are completed. Make entire text as completed72 if ($Completable) $NewComplete = 1; // All parts of text are completed. Make entire text as completed 73 73 else $NewComplete = 0; 74 74 75 75 // Update completion status for edited translation item 76 if ($SourceText['ID'] == $ExistedText['ID'])76 if ($SourceText['ID'] == $ExistedText['ID']) 77 77 { 78 78 $NewComplete = $Complete; // Our original user text, set complete according user choice 79 if ($Complete == 1)80 { 81 foreach ($Group['Items'] as $GroupItem)82 if ($GroupItem['Visible'] == 1) $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1));79 if ($Complete == 1) 80 { 81 foreach ($Group['Items'] as $GroupItem) 82 if ($GroupItem['Visible'] == 1) $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1)); 83 83 } 84 84 } 85 85 $Values .= ', `Complete`='.$NewComplete.', `CompleteParts` = '.$CompleteParts; 86 if (($NewComplete != $ExistedText['Complete']) or ($CompleteParts != $ExistedText['CompleteParts']))86 if (($NewComplete != $ExistedText['Complete']) or ($CompleteParts != $ExistedText['CompleteParts'])) 87 87 $Modified = true; 88 88 89 89 $Values .= ', `ModifyTime` = NOW()'; 90 if ($Modified)90 if ($Modified) 91 91 { 92 92 // Update user translation … … 114 114 $CompleteParts = 0; 115 115 $Completable = true; 116 foreach ($Group['Items'] as $GroupItem)116 foreach ($Group['Items'] as $GroupItem) 117 117 { 118 118 $Columns .= ', `'.$GroupItem['Column'].'`'; 119 if ($GroupItem['Visible'] == 1)120 { 121 if ($EnglishFound[$GroupItem['Column']] == $EnglishText[$GroupItem['Column']])119 if ($GroupItem['Visible'] == 1) 120 { 121 if ($EnglishFound[$GroupItem['Column']] == $EnglishText[$GroupItem['Column']]) 122 122 { 123 123 // Read form user data 124 if (array_key_exists($GroupItem['Column'], $_POST))124 if (array_key_exists($GroupItem['Column'], $_POST)) 125 125 { 126 126 $Values .= ', "'.$_POST[$GroupItem['Column']].'"'; … … 128 128 } else $Values .= ', "'.addslashes($EnglishFound[$GroupItem['Column']]).'"'; 129 129 } else $Values .= ', "'.addslashes($EnglishFound[$GroupItem['Column']]).'"'; 130 if ((($CompleteParts & (1 << ($GroupItem['Sequence'] - 1))) == 0) and ($EnglishFound[$GroupItem['Column']] != '')) $Completable = false;130 if ((($CompleteParts & (1 << ($GroupItem['Sequence'] - 1))) == 0) and ($EnglishFound[$GroupItem['Column']] != '')) $Completable = false; 131 131 } else 132 132 { … … 135 135 } 136 136 } 137 if ($Completable) $NewComplete = 1; // All parts of text are completed. Make entire text as completed137 if ($Completable) $NewComplete = 1; // All parts of text are completed. Make entire text as completed 138 138 else $NewComplete = 0; 139 139 // Update completion status for edited translation item 140 if ($SourceText['ID'] == $EnglishFound['ID'])140 if ($SourceText['ID'] == $EnglishFound['ID']) 141 141 { 142 142 $TakeID = $TextID; 143 143 $NewComplete = $Complete; // Our original user text, set complete according user choice 144 if ($Complete == 1)145 { 146 foreach ($Group['Items'] as $GroupItem)147 if ($GroupItem['Visible'] == 1) $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1));144 if ($Complete == 1) 145 { 146 foreach ($Group['Items'] as $GroupItem) 147 if ($GroupItem['Visible'] == 1) $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1)); 148 148 } 149 149 } … … 171 171 } else $Output .= ShowMessage('Anglický originál k překladu nenalezen.', MESSAGE_CRITICAL); 172 172 } else $Output .= ShowMessage('Zadaná položka nenalezena.', MESSAGE_CRITICAL); 173 return ($Output);173 return $Output; 174 174 } 175 175 … … 183 183 unset($Message); 184 184 $this->System->ModuleManager->Modules['FrontPage']->HandleLoginForm(); 185 if (isset($Message)) $Output .= ShowMessage($Message, $MessageType);185 if (isset($Message)) $Output .= ShowMessage($Message, $MessageType); 186 186 187 187 $GroupId = LoadGroupIdParameter(); 188 188 $Group = $TranslationTree[$GroupId]; 189 189 $Table = $Group['TablePrefix']; 190 if ($this->System->User->Licence(LICENCE_USER))191 { 192 if (array_key_exists('ID', $_POST) and is_numeric($_POST['ID']))190 if ($this->System->User->Licence(LICENCE_USER)) 191 { 192 if (array_key_exists('ID', $_POST) and is_numeric($_POST['ID'])) 193 193 { 194 194 $Entry = $_POST['entry'] * 1; 195 195 $TextID = $_POST['ID'] * 1; 196 196 $Language = $_POST['Language'] * 1; 197 if (array_key_exists('End', $_POST)) $Complete = 1;197 if (array_key_exists('End', $_POST)) $Complete = 1; 198 198 else $Complete = 0; 199 199 … … 207 207 { 208 208 // User automatically logged out. Show login dialog and allow to save retry. 209 if (array_key_exists('ID', $_POST) and array_key_exists('entry', $_POST) and array_key_exists('Language', $_POST) and array_key_exists('user', $_POST))209 if (array_key_exists('ID', $_POST) and array_key_exists('entry', $_POST) and array_key_exists('Language', $_POST) and array_key_exists('user', $_POST)) 210 210 { 211 211 $Output .= 'Byli jste automaticky odhlášeni. Pro <strong>Uložení překladu</strong> se musíte přihlásit zde:<br /><br />'. … … 216 216 '<input type="hidden" name="Language" value="'.$_POST['Language'].'" />'; 217 217 218 foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)218 foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) 219 219 { 220 if (array_key_exists($TextItem['Column'], $_POST)) $Value = $_POST[$TextItem['Column']]; else $Value = '';220 if (array_key_exists($TextItem['Column'], $_POST)) $Value = $_POST[$TextItem['Column']]; else $Value = ''; 221 221 $Output .= '<input id="'.$TextItem['Column'].'" name="'.$TextItem['Column'].'" type="hidden" value="'.htmlspecialchars($Value).'" />'; 222 222 } … … 232 232 } else $Output = ShowMessage('Nezadány požadované údaje.', MESSAGE_CRITICAL); 233 233 } 234 return ($Output);234 return $Output; 235 235 } 236 236 … … 246 246 $redirecting = $DbResult->fetch_assoc(); 247 247 248 switch ($redirecting['Redirecting'])248 switch ($redirecting['Redirecting']) 249 249 { 250 250 case 1: … … 254 254 break; 255 255 case 2: 256 if ($next <> '')256 if ($next <> '') 257 257 $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'. 258 258 'setTimeout("parent.location.href=\''.htmlspecialchars_decode($next).'\'", 1500)'. … … 260 260 break; 261 261 case 3: 262 if ($prev <> '')262 if ($prev <> '') 263 263 $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'. 264 264 'setTimeout("parent.location.href=\''.htmlspecialchars_decode($prev).'\'", 1500)'. … … 269 269 $Output .= sprintf(T('You can be redirected automatically from this page. You can set where you want to be transfered here: %s'), '<a href="'. 270 270 $this->System->Link('/options/').'" title="'.T('User settings').'">'.T('Options').'</a>'); 271 return ($Output);271 return $Output; 272 272 } 273 273 }
Note:
See TracChangeset
for help on using the changeset viewer.