Changeset 816 for trunk/Modules/Dictionary/Dictionary.php
- Timestamp:
- Feb 22, 2015, 11:20:50 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Dictionary/Dictionary.php
r809 r816 13 13 $this->Dependencies = array(); 14 14 } 15 15 16 16 function Start() 17 17 { 18 19 20 21 22 23 24 25 18 $this->System->RegisterPage('dictionary', 'PageDictionary'); 19 $this->System->RegisterMenuItem(array( 20 'Name' => 'Dictionary', 21 'Title' => T('Dictionary'), 22 'Hint' => T('Dictionary words from WoW'), 23 'Link' => $this->System->Link('/dictionary/'), 24 'Permission' => LICENCE_ANONYMOUS, 25 'Icon' => '', 26 26 ), 1); 27 27 if(array_key_exists('Search', $this->System->ModuleManager->Modules)) 28 28 $this->System->ModuleManager->Modules['Search']->RegisterSearch('dictionary', 29 T('Dictionary'), array('Text', 'Description'), 29 T('Dictionary'), array('Text', 'Description'), 30 30 '(SELECT * FROM `Dictionary` WHERE `Language` = '.$this->System->Config['OriginalLanguage'].') AS `T`', $this->System->Link('/dictionary/?search=')); 31 31 } … … 35 35 { 36 36 37 function WriteTranslatNames($Text, $mode) 37 function WriteTranslatNames($Text, $mode) 38 38 { 39 39 $Output = ''; … … 62 62 63 63 $buff = GetTranslatNames($Text,$mode,GetTranslatNamesArray()); 64 64 65 65 // $buff[] = array($Line['ID'],GetIDbyName($Table),$Line[$Column],$Line['Tran']); 66 66 foreach($buff as $Line) { 67 if ($mode == 0) 68 { 69 if (strpos(strtolower($Text), strtolower($Line[2])) > 0) 67 if ($mode == 0) 68 { 69 if (strpos(strtolower($Text), strtolower($Line[2])) > 0) 70 70 { 71 71 $Output .= '<tr><td>'.$Line[2].'</td>'; … … 73 73 else $Output .= '<td><a target="_NEW2" href="'.$this->System->Link('/form.php?group='.$Line[1].'&ID='.$Line[0]).'">Překládat</a></td></tr>'; 74 74 } 75 } else 75 } else 76 76 { 77 77 $Output .= '<tr><td>'.$Line[2].'</td>'; … … 101 101 '</form>'; 102 102 } else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 103 return($Output); 103 return($Output); 104 104 } 105 105 … … 125 125 '`User`, `Language` ) VALUES ("'.$_POST['Original'].'", "'.$Entry.'", "", NULL, '.$this->System->Config['OriginalLanguage'].');'); 126 126 } 127 127 128 128 $DbResult = $this->Database->query('SELECT `Id` FROM `Dictionary` WHERE '. 129 129 '`Entry` = '.$Entry.' AND `Language`='.$_POST['Language'].' AND `User`='.$this->System->User->Id); … … 136 136 $this->Database->query('INSERT INTO `Dictionary` ( `Text` , `Entry` , `Description` , '. 137 137 '`User`, `Language` ) VALUES ("'.$_POST['Translated'].'", "'.$Entry.'", "'. 138 138 $_POST['Description'].'", '.$this->System->User->Id.', '.$_POST['Language'].')'); 139 139 $Output = ShowMessage('Záznam byl uložen!'); 140 140 } else $Output = ShowMessage(T('You have to fill all column of form.'), MESSAGE_CRITICAL); 141 141 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 142 return($Output); 142 return($Output); 143 143 } 144 144 … … 176 176 '</fieldset>'. 177 177 '</form>'; 178 } else $Output = ShowMessage(T('Item not found'), MESSAGE_CRITICAL); 178 } else $Output = ShowMessage(T('Item not found'), MESSAGE_CRITICAL); 179 179 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 180 180 return($Output); … … 184 184 { 185 185 global $TranslationTree; 186 186 187 187 $Output = ''; 188 188 $GroupId = LoadGroupIdParameter(); … … 190 190 else $mode = 0; //0 = exact names, 1=all names, 2=nontranslated 191 191 $Table = $TranslationTree[$GroupId]['TablePrefix']; 192 192 193 193 if(array_key_exists('ID', $_GET)) 194 194 { … … 208 208 $Output .= $this->WriteTranslatNames($Text, $mode); 209 209 } 210 } 210 } 211 211 return($Output); 212 212 } … … 215 215 { 216 216 global $LanguageList; 217 217 218 218 $Output = '<form action="?" method="get" style="margin: 0px; padding: 0px;">'. 219 219 '<table style="width: 100%; height: 100%;">'; … … 221 221 if(array_key_exists('search', $_GET)) $Search = $_GET['search']; 222 222 else $Search = ''; 223 223 224 224 $Output .= '<tr><td> 225 225 <input type="text" value="'.$Search.'" name="search" size="30" /> 226 226 <input type="submit" value="'.T('Search').'" />'; 227 if($this->System->User->Licence(LICENCE_USER)) 228 229 230 $Output .= '</td></tr>'. 227 if($this->System->User->Licence(LICENCE_USER)) 228 $Output .= ' <a href="?action=insert">'.T('Add word').'</a>'; 229 230 $Output .= '</td></tr>'. 231 231 '<tr><td>'.T('Language').': '; 232 232 $Lang = '<a href="?language=">'.T('All').'</a>'; … … 236 236 if($Language['Enabled'] == 1) 237 237 { 238 238 $Lang = ' <a href="?language='.$Language['Id'].'">'.$Language['Name'].'</a>'; 239 239 if($Language['Id'] == $_SESSION['language']) $Output .= '<strong>'.$Lang.'</strong> '; 240 240 else $Output .= $Lang; … … 247 247 else $LanguageFilter = ' AND (`T1`.`Language` = '.$_SESSION['language'].')'; 248 248 249 if($Search <> '') 249 if($Search <> '') 250 250 { 251 251 $Condition = ' AND (LOWER(`T1`.`Text`) LIKE LOWER("%'.$Search.'%")) OR '. 252 252 ' (LOWER(`T2`.`Text`) LIKE LOWER("%'.$Search.'%")) OR '. 253 253 '(LOWER(`T1`.`Description`) LIKE LOWER("%'.$Search.'%"))'; 254 } else $Condition = ''; 254 } else $Condition = ''; 255 255 $sql = 'SELECT `User`.`Name` AS `UserName`, `User`.`Id` AS `UserId`, '. 256 256 '`Language`.`Name` AS `LangName`, `T1`.`Id` AS `Id`, '. 257 '`T1`.`Entry`, `T2`.`Text` AS `Original`, `T1`.`Text` AS `Translated`, `T1`.`Description` '. 257 '`T1`.`Entry`, `T2`.`Text` AS `Original`, `T1`.`Text` AS `Translated`, `T1`.`Description` '. 258 258 'FROM `Dictionary` AS `T1` JOIN `Dictionary` AS `T2` '. 259 259 'ON (`T2`.`Entry` = `T1`.`Entry`) AND (`T2`.`Language` = '.$this->System->Config['OriginalLanguage'].') '. … … 262 262 'WHERE 1'. 263 263 $LanguageFilter.$Condition; 264 264 265 265 $DbResult = $this->Database->query('SELECT COUNT(*) FROM ('.$sql.') AS `T1`'); 266 266 $DbRow = $DbResult->fetch_row(); 267 $PageList = GetPageList($DbRow[0]); 267 $PageList = GetPageList($DbRow[0]); 268 268 269 269 $Output .= $PageList['Output']; 270 270 271 271 if(is_numeric($_SESSION['language'])) $LanguageName = $LanguageList[$_SESSION['language']]['Name']; 272 272 else $LanguageName = 'Překlad'; 273 $TableColumns = array( 274 array('Name' => 'Original', 'Title' => T('English')), 273 $TableColumns = array( 274 array('Name' => 'Original', 'Title' => T('English')), 275 275 array('Name' => 'Translated', 'Title' => $LanguageName), 276 ); 276 ); 277 277 if(!is_numeric($_SESSION['language'])) $TableColumns[] = array('Name' => 'LangName', 'Title' => T('Language')); 278 278 $TableColumns[] = array('Name' => 'Description', 'Title' => T('Description')); 279 $TableColumns[] = array('Name' => 'UserName', 'Title' => T('Translator')); 279 $TableColumns[] = array('Name' => 'UserName', 'Title' => T('Translator')); 280 280 if($this->System->User->Licence(LICENCE_USER)) $TableColumns[] = array('Name' => '', 'Title' => T('Action')); 281 281 $Order = GetOrderTableHeader($TableColumns, 'Original'); … … 284 284 $sql_page = $sql.$Order['SQL'].$PageList['SQLLimit']; 285 285 $DbResult = $this->Database->query($sql_page); 286 while($Line = $DbResult->fetch_assoc()) 286 while($Line = $DbResult->fetch_assoc()) 287 287 { 288 288 $Output .= '<tr>'. … … 294 294 if($this->System->User->Licence(LICENCE_USER)) 295 295 { 296 if($Line['UserId'] == $this->System->User->Id) 296 if($Line['UserId'] == $this->System->User->Id) 297 297 $Output .= '<td><a href="?action=remove&id='.$Line['Id'].'" onclick="return confirmAction(\''.T('Do you really want to delete item?').'\');">'.T('Delete').'</a>'. 298 298 ' <a href="?action=modify&id='.$Line['Id'].'">'.T('Modify').'</a></td>'; … … 301 301 $Output .= '</tr>'; 302 302 } 303 $Output .= '</table>'. 303 $Output .= '</table>'. 304 304 $PageList['Output']. 305 '</td></tr>'. 305 '</td></tr>'. 306 306 '</table></form>'; 307 307 return($Output); … … 310 310 function Show() 311 311 { 312 313 314 315 312 global $LanguageList; 313 314 $this->Title = T('Dictionary'); 315 316 316 $LanguageList = GetLanguageList(); 317 317 318 318 if(!isset($_SESSION['language'])) 319 319 { 320 321 322 320 if($this->System->User->Licence(LICENCE_USER)) 321 { 322 $_SESSION['language'] = $this->System->User->Language; 323 323 } else $_SESSION['language'] = ''; 324 324 } 325 325 if(array_key_exists('language', $_GET)) { 326 326 if($_GET['language'] == '') $_SESSION['language'] = ''; 327 327 else $_SESSION['language'] = $_GET['language'] * 1; 328 328 } 329 329 … … 331 331 332 332 $ShowList = true; 333 if(array_key_exists('action', $_GET)) 333 if(array_key_exists('action', $_GET)) 334 334 { 335 335 if($_GET['action'] == 'group') { … … 337 337 $ShowList = false; 338 338 } 339 else if($_GET['action'] == 'insert') $Output .= $this->DictionaryInsert(); 340 else if($_GET['action'] == 'save') $Output .= $this->DictionarySave(); 339 else if($_GET['action'] == 'insert') $Output .= $this->DictionaryInsert(); 340 else if($_GET['action'] == 'save') $Output .= $this->DictionarySave(); 341 341 else if($_GET['action'] == 'remove') $Output .= $this->DictionaryRemove(); 342 342 else if($_GET['action'] == 'modify') $Output .= $this->DictionaryModify(); 343 else $Output .= ShowMessage(T('Unknown action'), MESSAGE_CRITICAL); 344 } 343 else $Output .= ShowMessage(T('Unknown action'), MESSAGE_CRITICAL); 344 } 345 345 if($ShowList == true) $Output .= $this->DictionaryShow(); 346 346 return($Output);
Note:
See TracChangeset
for help on using the changeset viewer.