Changeset 548 for trunk/Modules/Dictionary/Dictionary.php
- Timestamp:
- Jun 18, 2013, 7:23:39 PM (11 years ago)
- Location:
- trunk/Modules/Dictionary
- Files:
-
- 1 added
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Dictionary/Dictionary.php
r546 r548 1 1 <?php 2 2 3 include('includes/global.php'); 3 class ModuleDictionary extends AppModule 4 { 5 function __construct($System) 6 { 7 parent::__construct($System); 8 $this->Name = 'Dictionary'; 9 $this->Version = '1.0'; 10 $this->Creator = 'Chronos'; 11 $this->License = 'GNU/GPL'; 12 $this->Description = 'Custom dictionary for better translation coordination'; 13 $this->Dependencies = array(); 14 } 15 16 function Start() 17 { 18 $this->System->RegisterPage('dictionary.php', 'PageDictionary'); 19 $this->System->RegisterMenuItem(array( 20 'Title' => 'Slovníček', 21 'Hint' => 'Slovník WoW výrazů', 22 'Link' => $this->System->Link('/dictionary.php'), 23 'Permission' => LICENCE_ANONYMOUS, 24 'Icon' => '', 25 )); 26 } 27 } 28 29 class PageDictionary extends Page 30 { 4 31 5 32 function WriteTranslatNames($Text,$mode) … … 46 73 } 47 74 48 $LanguageList = GetLanguageList();49 50 if(!isset($_SESSION['language']))51 {52 if($User->Licence(LICENCE_USER))53 {54 $_SESSION['language'] = $User->Language;55 } else $_SESSION['language'] = '';56 }57 if(array_key_exists('language', $_GET)) {58 if($_GET['language'] == '') $_SESSION['language'] = '';59 else $_SESSION['language'] = $_GET['language'] * 1;60 }61 62 $Output = '<h3>Slovníček</h3>';63 64 75 function DictionaryInsert() 65 76 { 66 global $ System, $User;77 global $User; 67 78 68 79 $Output = ''; … … 86 97 function DictionarySave() 87 98 { 88 global $ System, $User, $Config;99 global $User, $Config; 89 100 90 101 if($User->Licence(LICENCE_USER)) … … 93 104 { 94 105 // Check if original text exists and determine entry id 95 $DbResult = $ System->Database->query('SELECT * FROM `Dictionary` WHERE '.106 $DbResult = $this->Database->query('SELECT * FROM `Dictionary` WHERE '. 96 107 '`Text` = "'.$_POST['Original'].'" AND `Language`= '.$Config['OriginalLanguage']); 97 108 if($DbResult->num_rows > 0) … … 101 112 } else 102 113 { 103 $DbResult = $ System->Database->query('SELECT MAX(`Entry`) FROM `Dictionary`');114 $DbResult = $this->Database->query('SELECT MAX(`Entry`) FROM `Dictionary`'); 104 115 $DbRow = $DbResult->fetch_row(); 105 116 $Entry = $DbRow[0] + 1; 106 $ System->Database->query('INSERT INTO `Dictionary` ( `Text` , `Entry` , `Description` , '.117 $this->Database->query('INSERT INTO `Dictionary` ( `Text` , `Entry` , `Description` , '. 107 118 '`User`, `Language` ) VALUES ("'.$_POST['Original'].'", "'.$Entry.'", "", NULL, '.$Config['OriginalLanguage'].');'); 108 119 } 109 120 110 $DbResult = $ System->Database->query('SELECT `Id` FROM `Dictionary` WHERE '.121 $DbResult = $this->Database->query('SELECT `Id` FROM `Dictionary` WHERE '. 111 122 '`Entry` = '.$Entry.' AND `Language`='.$_POST['Language'].' AND `User`='.$User->Id); 112 123 if($DbResult->num_rows > 0) 113 124 { 114 125 $DbRow = $DbResult->fetch_assoc(); 115 $ System->Database->query('UPDATE `Dictionary` SET `Text`="'.$_POST['Translated'].'", '.126 $this->Database->query('UPDATE `Dictionary` SET `Text`="'.$_POST['Translated'].'", '. 116 127 '`Description` = "'.$_POST['Description'].'" WHERE Id='.$DbRow['Id']); 117 128 } else 118 $ System->Database->query('INSERT INTO `Dictionary` ( `Text` , `Entry` , `Description` , '.129 $this->Database->query('INSERT INTO `Dictionary` ( `Text` , `Entry` , `Description` , '. 119 130 '`User`, `Language` ) VALUES ("'.$_POST['Translated'].'", "'.$Entry.'", "'.$_POST['Description'].'", '.$User->Id.', '.$_POST['Language'].')'); 120 131 $Output = ShowMessage('Záznam byl uložen!'); … … 126 137 function DictionaryRemove() 127 138 { 128 global $ System, $User;139 global $User; 129 140 130 141 if($User->Licence(LICENCE_USER)) 131 142 { 132 $ System->Database->query('DELETE FROM `Dictionary` WHERE (`User`='.$User->Id.') AND (`Id`='.($_GET['id'] * 1).')');143 $this->Database->query('DELETE FROM `Dictionary` WHERE (`User`='.$User->Id.') AND (`Id`='.($_GET['id'] * 1).')'); 133 144 $Output = ShowMessage('Záznam odstraněn.'); 134 145 } else $Output = ShowMessage('Nemáte oprávnění', MESSAGE_CRITICAL); … … 138 149 function DictionaryModify() 139 150 { 140 global $ System, $User, $Config;151 global $User, $Config; 141 152 142 153 if($User->Licence(LICENCE_USER)) 143 154 { 144 $DbResult = $ System->Database->query('SELECT * FROM `Dictionary` WHERE `Id`='.($_GET['id'] * 1));155 $DbResult = $this->Database->query('SELECT * FROM `Dictionary` WHERE `Id`='.($_GET['id'] * 1)); 145 156 if($DbResult->num_rows > 0) 146 157 { 147 158 $DbRow = $DbResult->fetch_assoc(); 148 $DbResult = $ System->Database->query('SELECT * FROM `Dictionary` WHERE (`User` IS NULL) '.159 $DbResult = $this->Database->query('SELECT * FROM `Dictionary` WHERE (`User` IS NULL) '. 149 160 'AND (`Entry`='.$DbRow['Entry'].') AND (`Language`= '.$Config['OriginalLanguage'].')'); 150 161 $DbRow2 = $DbResult->fetch_assoc(); … … 168 179 function DictionaryGroup() 169 180 { 170 global $ System, $User, $TranslationTree;181 global $User, $TranslationTree; 171 182 172 183 $Output = ''; … … 183 194 '<a href="?action=group&mode=0&group='.$GroupId.'&ID='.$TextID.'" title="Zobrazit pouze přesné výsledky">Přesné</a> '. 184 195 '<a href="?action=group&mode=2&group='.$GroupId.'&ID='.$TextID.'" title="Zobrazit všechny nepřeložené">Nepřeložené</a> '; 185 $DbResult = $ System->Database->query('SELECT * FROM '.$Table.' WHERE ID = '.$TextID);196 $DbResult = $this->Database->query('SELECT * FROM '.$Table.' WHERE ID = '.$TextID); 186 197 $Line = $DbResult->fetch_assoc(); 187 198 if(!$Line) $Output .= ShowMessage('Překlad nenalezen.', MESSAGE_CRITICAL); … … 199 210 function DictionaryShow() 200 211 { 201 global $ System, $User, $LanguageList, $Config;212 global $User, $LanguageList, $Config; 202 213 203 214 $Output = '<form action="dictionary.php" method="get" style="margin: 0px; padding: 0px;">'. … … 246 257 $LanguageFilter.$Condition; 247 258 248 $DbResult = $ System->Database->query('SELECT COUNT(*) FROM ('.$sql.') AS `T1`');259 $DbResult = $this->Database->query('SELECT COUNT(*) FROM ('.$sql.') AS `T1`'); 249 260 $DbRow = $DbResult->fetch_row(); 250 261 $PageList = GetPageList($DbRow[0]); … … 266 277 267 278 $sql_page = $sql.$Order['SQL'].$PageList['SQLLimit']; 268 $DbResult = $ System->Database->query($sql_page);279 $DbResult = $this->Database->query($sql_page); 269 280 while($Line = $DbResult->fetch_assoc()) 270 281 { … … 291 302 } 292 303 293 $Output = ''; 304 function Show() 305 { 306 global $LanguageList; 307 308 $LanguageList = GetLanguageList(); 309 310 if(!isset($_SESSION['language'])) 311 { 312 if($User->Licence(LICENCE_USER)) 313 { 314 $_SESSION['language'] = $User->Language; 315 } else $_SESSION['language'] = ''; 316 } 317 if(array_key_exists('language', $_GET)) { 318 if($_GET['language'] == '') $_SESSION['language'] = ''; 319 else $_SESSION['language'] = $_GET['language'] * 1; 320 } 321 322 $Output = '<h3>Slovníček</h3>'; 323 294 324 $ShowList = true; 295 325 if(array_key_exists('action', $_GET)) 296 326 { 297 327 if($_GET['action'] == 'group') { 298 $Output .= DictionaryGroup();328 $Output .= $this->DictionaryGroup(); 299 329 $ShowList = false; 300 330 } 301 else if($_GET['action'] == 'insert') $Output .= DictionaryInsert();302 else if($_GET['action'] == 'save') $Output .= DictionarySave();303 else if($_GET['action'] == 'remove') $Output .= DictionaryRemove();304 else if($_GET['action'] == 'modify') $Output .= DictionaryModify();331 else if($_GET['action'] == 'insert') $Output .= $this->DictionaryInsert(); 332 else if($_GET['action'] == 'save') $Output .= $this->DictionarySave(); 333 else if($_GET['action'] == 'remove') $Output .= $this->DictionaryRemove(); 334 else if($_GET['action'] == 'modify') $Output .= $this->DictionaryModify(); 305 335 else $Output .= ShowMessage('Neznámá akce', MESSAGE_CRITICAL); 306 336 } 307 if($ShowList == true) $Output .= DictionaryShow(); 308 309 ShowPage($Output); 310 311 ?> 337 if($ShowList == true) $Output .= $this->DictionaryShow(); 338 return($Output); 339 } 340 }
Note:
See TracChangeset
for help on using the changeset viewer.