Changeset 880 for trunk/Modules/Dictionary
- Timestamp:
- Apr 7, 2020, 10:15:48 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Dictionary/Dictionary.php
r861 r880 25 25 'Icon' => '', 26 26 ), 1); 27 if (array_key_exists('Search', $this->System->ModuleManager->Modules))27 if (array_key_exists('Search', $this->System->ModuleManager->Modules)) 28 28 $this->System->ModuleManager->Modules['Search']->RegisterSearch('dictionary', 29 29 T('Dictionary'), array('Text', 'Description'), … … 65 65 66 66 // $buff[] = array($Line['ID'],GetIDbyName($Table),$Line[$Column],$Line['Tran']); 67 foreach ($buff as $Line)67 foreach ($buff as $Line) 68 68 { 69 69 if ($mode == 0) … … 83 83 } 84 84 $Output .= '</table>'; 85 return ($Output);85 return $Output; 86 86 } 87 87 … … 89 89 { 90 90 $Output = ''; 91 if ($this->System->User->Licence(LICENCE_USER))91 if ($this->System->User->Licence(LICENCE_USER)) 92 92 { 93 93 $Output .= '<form action="?action=save" method="post">'. … … 103 103 '</form>'; 104 104 } else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 105 return ($Output);105 return $Output; 106 106 } 107 107 108 108 function DictionarySave() 109 109 { 110 if ($this->System->User->Licence(LICENCE_USER))111 { 112 if (array_key_exists('Original', $_POST) and array_key_exists('Translated', $_POST) and array_key_exists('Description', $_POST))110 if ($this->System->User->Licence(LICENCE_USER)) 111 { 112 if (array_key_exists('Original', $_POST) and array_key_exists('Translated', $_POST) and array_key_exists('Description', $_POST)) 113 113 { 114 114 // Check if original text exists and determine entry id 115 115 $DbResult = $this->Database->query('SELECT * FROM `Dictionary` WHERE '. 116 116 '`Text` = "'.$_POST['Original'].'" AND `Language`= '.$this->System->Config['OriginalLanguage']); 117 if ($DbResult->num_rows > 0)117 if ($DbResult->num_rows > 0) 118 118 { 119 119 $DbRow = $DbResult->fetch_assoc(); … … 130 130 $DbResult = $this->Database->query('SELECT `Id` FROM `Dictionary` WHERE '. 131 131 '`Entry` = '.$Entry.' AND `Language`='.$_POST['Language'].' AND `User`='.$this->System->User->Id); 132 if ($DbResult->num_rows > 0)132 if ($DbResult->num_rows > 0) 133 133 { 134 134 $DbRow = $DbResult->fetch_assoc(); … … 142 142 } else $Output = ShowMessage(T('You have to fill all column of form.'), MESSAGE_CRITICAL); 143 143 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 144 return ($Output);144 return $Output; 145 145 } 146 146 147 147 function DictionaryRemove() 148 148 { 149 if ($this->System->User->Licence(LICENCE_USER))149 if ($this->System->User->Licence(LICENCE_USER)) 150 150 { 151 151 $this->Database->query('DELETE FROM `Dictionary` WHERE (`User`='.$this->System->User->Id.') AND (`Id`='.($_GET['id'] * 1).')'); 152 152 $Output = ShowMessage(T('Record removed')); 153 153 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 154 return ($Output);154 return $Output; 155 155 } 156 156 157 157 function DictionaryModify() 158 158 { 159 if ($this->System->User->Licence(LICENCE_USER))159 if ($this->System->User->Licence(LICENCE_USER)) 160 160 { 161 161 $DbResult = $this->Database->query('SELECT * FROM `Dictionary` WHERE `Id`='.($_GET['id'] * 1)); 162 if ($DbResult->num_rows > 0)162 if ($DbResult->num_rows > 0) 163 163 { 164 164 $DbRow = $DbResult->fetch_assoc(); … … 180 180 } else $Output = ShowMessage(T('Item not found'), MESSAGE_CRITICAL); 181 181 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 182 return ($Output);182 return $Output; 183 183 } 184 184 … … 189 189 $Output = ''; 190 190 $GroupId = LoadGroupIdParameter(); 191 if (array_key_exists('mode', $_GET)) $mode = $_GET['mode'];191 if (array_key_exists('mode', $_GET)) $mode = $_GET['mode']; 192 192 else $mode = 0; //0 = exact names, 1=all names, 2=nontranslated 193 193 $Table = $TranslationTree[$GroupId]['TablePrefix']; 194 194 195 if (array_key_exists('ID', $_GET))195 if (array_key_exists('ID', $_GET)) 196 196 { 197 197 $TextID = $_GET['ID']; … … 202 202 $DbResult = $this->Database->query('SELECT * FROM '.$Table.' WHERE ID = '.$TextID); 203 203 $Line = $DbResult->fetch_assoc(); 204 if (!$Line) $Output .= ShowMessage(T('Translation not found'), MESSAGE_CRITICAL);204 if (!$Line) $Output .= ShowMessage(T('Translation not found'), MESSAGE_CRITICAL); 205 205 else 206 206 { 207 207 $Text = ''; 208 foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)208 foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) 209 209 $Text .= ' '.$Line[$TextItem['Column']]; 210 210 $Output .= $this->WriteTranslatNames($Text, $mode); 211 211 } 212 212 } 213 return ($Output);213 return $Output; 214 214 } 215 215 … … 221 221 '<table style="width: 100%; height: 100%;">'; 222 222 223 if (array_key_exists('search', $_GET)) $Search = $_GET['search'];223 if (array_key_exists('search', $_GET)) $Search = $_GET['search']; 224 224 else $Search = ''; 225 225 … … 227 227 <input type="text" value="'.$Search.'" name="search" size="30" /> 228 228 <input type="submit" value="'.T('Search').'" />'; 229 if ($this->System->User->Licence(LICENCE_USER))229 if ($this->System->User->Licence(LICENCE_USER)) 230 230 $Output .= ' <a href="?action=insert">'.T('Add word').'</a>'; 231 231 … … 233 233 '<tr><td>'.T('Language').': '; 234 234 $Lang = '<a href="?language=">'.T('All').'</a>'; 235 if ($_SESSION['language'] == '') $Output .= '<strong>'.$Lang.'</strong> ';235 if ($_SESSION['language'] == '') $Output .= '<strong>'.$Lang.'</strong> '; 236 236 else $Output .= $Lang; 237 foreach ($LanguageList as $Language)238 if ($Language['Enabled'] == 1)237 foreach ($LanguageList as $Language) 238 if ($Language['Enabled'] == 1) 239 239 { 240 240 $Lang = ' <a href="?language='.$Language['Id'].'">'.T($Language['Name']).'</a>'; 241 if ($Language['Id'] == $_SESSION['language']) $Output .= '<strong>'.$Lang.'</strong> ';241 if ($Language['Id'] == $_SESSION['language']) $Output .= '<strong>'.$Lang.'</strong> '; 242 242 else $Output .= $Lang; 243 243 } … … 245 245 '<tr><td>'; 246 246 247 if (!is_numeric($_SESSION['language'])) $LanguageFilter = '';247 if (!is_numeric($_SESSION['language'])) $LanguageFilter = ''; 248 248 else $LanguageFilter = ' AND (`T1`.`Language` = '.$_SESSION['language'].')'; 249 249 250 if ($Search <> '')250 if ($Search <> '') 251 251 { 252 252 $Condition = ' AND (LOWER(`T1`.`Text`) LIKE LOWER("%'.$Search.'%")) OR '. … … 270 270 $Output .= $PageList['Output']; 271 271 272 if (is_numeric($_SESSION['language'])) $LanguageName = $LanguageList[$_SESSION['language']]['Name'];272 if (is_numeric($_SESSION['language'])) $LanguageName = $LanguageList[$_SESSION['language']]['Name']; 273 273 else $LanguageName = T('Translation'); 274 274 $TableColumns = array( … … 276 276 array('Name' => 'Translated', 'Title' => T($LanguageName)), 277 277 ); 278 if (!is_numeric($_SESSION['language'])) $TableColumns[] = array('Name' => 'LangName', 'Title' => T('Language'));278 if (!is_numeric($_SESSION['language'])) $TableColumns[] = array('Name' => 'LangName', 'Title' => T('Language')); 279 279 $TableColumns[] = array('Name' => 'Description', 'Title' => T('Description')); 280 280 $TableColumns[] = array('Name' => 'UserName', 'Title' => T('Translator')); 281 if ($this->System->User->Licence(LICENCE_USER)) $TableColumns[] = array('Name' => '', 'Title' => T('Action'));281 if ($this->System->User->Licence(LICENCE_USER)) $TableColumns[] = array('Name' => '', 'Title' => T('Action')); 282 282 $Order = GetOrderTableHeader($TableColumns, 'Original'); 283 283 $Output .= '<table class="BaseTable">'.$Order['Output']; … … 285 285 $sql_page = $sql.$Order['SQL'].$PageList['SQLLimit']; 286 286 $DbResult = $this->Database->query($sql_page); 287 while ($Line = $DbResult->fetch_assoc())287 while ($Line = $DbResult->fetch_assoc()) 288 288 { 289 289 $Output .= '<tr>'. 290 290 '<td>'.htmlspecialchars($Line['Original']).'</td>'. 291 291 '<td><strong>'.htmlspecialchars($Line['Translated']).'</strong></td>'; 292 if (!is_numeric($_SESSION['language'])) $Output .= '<td>'.T($Line['LangName']).'</td>';292 if (!is_numeric($_SESSION['language'])) $Output .= '<td>'.T($Line['LangName']).'</td>'; 293 293 $Output .= '<td>'.htmlspecialchars($Line['Description']).'</td>'. 294 294 '<td><a href="'.$this->System->Link('/user/?user='.$Line['UserId']).'">'. 295 295 $Line['UserName'].'</a></td>'; 296 if ($this->System->User->Licence(LICENCE_USER))297 { 298 if ($Line['UserId'] == $this->System->User->Id)296 if ($this->System->User->Licence(LICENCE_USER)) 297 { 298 if ($Line['UserId'] == $this->System->User->Id) 299 299 $Output .= '<td><a href="?action=remove&id='.$Line['Id']. 300 300 '" onclick="return confirmAction(\''.T('Do you really want to delete item?').'\');">'.T('Delete').'</a>'. … … 308 308 '</td></tr>'. 309 309 '</table></form>'; 310 return ($Output);310 return $Output; 311 311 } 312 312 … … 319 319 $LanguageList = GetLanguageList(); 320 320 321 if (!isset($_SESSION['language']))322 { 323 if ($this->System->User->Licence(LICENCE_USER))321 if (!isset($_SESSION['language'])) 322 { 323 if ($this->System->User->Licence(LICENCE_USER)) 324 324 { 325 325 $_SESSION['language'] = $this->System->User->Language; 326 326 } else $_SESSION['language'] = ''; 327 327 } 328 if (array_key_exists('language', $_GET))329 { 330 if ($_GET['language'] == '') $_SESSION['language'] = '';328 if (array_key_exists('language', $_GET)) 329 { 330 if ($_GET['language'] == '') $_SESSION['language'] = ''; 331 331 else $_SESSION['language'] = $_GET['language'] * 1; 332 332 } … … 335 335 336 336 $ShowList = true; 337 if (array_key_exists('action', $_GET))338 { 339 if ($_GET['action'] == 'group')337 if (array_key_exists('action', $_GET)) 338 { 339 if ($_GET['action'] == 'group') 340 340 { 341 341 $Output .= $this->DictionaryGroup(); 342 342 $ShowList = false; 343 343 } 344 else if ($_GET['action'] == 'insert') $Output .= $this->DictionaryInsert();345 else if ($_GET['action'] == 'save') $Output .= $this->DictionarySave();346 else if ($_GET['action'] == 'remove') $Output .= $this->DictionaryRemove();347 else if ($_GET['action'] == 'modify') $Output .= $this->DictionaryModify();344 else if ($_GET['action'] == 'insert') $Output .= $this->DictionaryInsert(); 345 else if ($_GET['action'] == 'save') $Output .= $this->DictionarySave(); 346 else if ($_GET['action'] == 'remove') $Output .= $this->DictionaryRemove(); 347 else if ($_GET['action'] == 'modify') $Output .= $this->DictionaryModify(); 348 348 else $Output .= ShowMessage(T('Unknown action'), MESSAGE_CRITICAL); 349 349 } 350 if ($ShowList == true) $Output .= $this->DictionaryShow();351 return ($Output);350 if ($ShowList == true) $Output .= $this->DictionaryShow(); 351 return $Output; 352 352 } 353 353 }
Note:
See TracChangeset
for help on using the changeset viewer.