Changeset 524 for trunk/dictionary.php
- Timestamp:
- Feb 20, 2013, 9:40:53 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dictionary.php
r507 r524 53 53 { 54 54 $_SESSION['language'] = $User->Language; 55 } else $_SESSION['language'] = 2; 55 } else { 56 $LanguageId = reset($LanguageList); 57 $_SESSION['language'] = $LanguageId['Id']; 58 } 56 59 } 57 60 if(array_key_exists('language', $_GET)) $_SESSION['language'] = LoadLanguageIdParameter(); … … 95 98 'Původní anglické slovo:</td><td><input type="text" name="Original" /></td></tr>'. 96 99 '<tr><td>Přeložené:</td><td><input type="text" name="Translated" /></td></tr>'. 97 '<tr><td> Popis:</td><td><input type="text" name="Description" /></td></tr>'.100 '<tr><td>Volitelný popis:</td><td><input type="text" name="Description" /></td></tr>'. 98 101 '<tr><td colspan="2"><input type="submit" value="Uložit" /></td></tr>'. 99 102 '</td></tr></table>'. … … 105 108 if(array_key_exists('Original', $_POST) and array_key_exists('Translated', $_POST) and array_key_exists('Description', $_POST)) 106 109 { 107 $DbResult = $System->Database->query('SELECT * FROM `Dictionary` WHERE `Text` = "'.$_POST['Original'].'" AND `Language`= 0');110 $DbResult = $System->Database->query('SELECT * FROM `Dictionary` WHERE `Text` = "'.$_POST['Original'].'" AND `Language`= '.$Config['OriginalLanguage']); 108 111 if($DbResult->num_rows > 0) 109 112 { … … 115 118 $DbRow = $DbResult->fetch_row(); 116 119 $Entry = $DbRow[0] + 1; 117 $System->Database->query('INSERT INTO `Dictionary` ( `Text` , `Entry` , `Description` , `User`, `Language` ) VALUES ("'.$_POST['Original'].'", "'.$Entry.'", "", NULL, 0);');120 $System->Database->query('INSERT INTO `Dictionary` ( `Text` , `Entry` , `Description` , `User`, `Language` ) VALUES ("'.$_POST['Original'].'", "'.$Entry.'", "", NULL, '.$Config['OriginalLanguage'].');'); 118 121 } 119 122 … … 137 140 $DbResult = $System->Database->query('SELECT * FROM `Dictionary` WHERE `User`='.$User->Id.' AND `Entry`='.$_GET['entry'].' AND `Language`='.$_SESSION['language']); 138 141 $DbRow = $DbResult->fetch_assoc(); 139 $DbResult = $System->Database->query('SELECT * FROM `Dictionary` WHERE (`User` IS NULL) AND (`Entry`='.$_GET['entry'].') AND (`Language`= 0)');142 $DbResult = $System->Database->query('SELECT * FROM `Dictionary` WHERE (`User` IS NULL) AND (`Entry`='.$_GET['entry'].') AND (`Language`= '.$Config['OriginalLanguage'].')'); 140 143 $DbRow2 = $DbResult->fetch_assoc(); 141 144 $Output .= '<form action="dictionary.php?action=save" method="post">'. … … 169 172 if($Language['Enabled'] == 1) 170 173 { 171 if($Language['Id'] == $_SESSION['language']) $Output .= '<strong>';172 $Output .= ' <a href="?language='.$Language['Id'].'">'.$Language['Name'].'</a>';173 if($Language['Id'] == $_SESSION['language']) $Output .= '</strong>';174 $Lang = ' <a href="?language='.$Language['Id'].'">'.$Language['Name'].'</a>'; 175 if($Language['Id'] == $_SESSION['language']) $Output .= '<strong>'.$Lang.'</strong> '; 176 else $Output .= $Lang; 174 177 } 175 178 $Output .= '</td></tr>'. … … 179 182 if($Search <> '') 180 183 { 181 $sql = 'SELECT `User`.`Name` AS `UserName`, `User`. `ID` AS `UserID`, `T3`.`Entry`, `T3`.`Original`, `T3`.`Translated`, `T3`.`Description` FROM (SELECT `T2`.`User`, `T1`.`Language`, `T1`.`Text` AS `Original`, `T2`.`Text` AS `Translated`, `T2`.`Description`, `T1`.`Entry` AS `Entry` FROM `Dictionary` AS `T1` JOIN `Dictionary` AS `T2` ON `T2`.`Entry` = `T1`.`Entry` AND `T2`.`Language` = '.$_SESSION['language'].' WHERE LOWER(`T1`.`Text`) LIKE LOWER("%'.$Search.'%") OR LOWER(`T1`.`Description`) LIKE LOWER("%'.$Search.'%") ) AS `T3` JOIN `User` ON `User`.`ID` = `T3`.`User` WHERE `T3`.`Language` = 0';182 } else $sql = 'SELECT `User`.`Name` AS `UserName`, `ID` AS `UserID`, `T3`.`Entry`, `T3`.`Original`, `T3`.`Translated`, `T3`.`Description` FROM (SELECT `T2`.`User`, `T1`.Language, `T1`.`Text` AS `Original`, `T2`.`Text` AS `Translated`, `T2`.`Description`, `T1`.`Entry` AS `Entry` FROM `Dictionary` AS `T1` JOIN `Dictionary` AS `T2` ON `T2`.`Entry` = `T1`.`Entry` AND `T2`.`Language` = '.$_SESSION['language'].') AS `T3` JOIN `User` ON `User`.`ID` = `T3`.`User` WHERE `T3`.`Language` = 0';184 $sql = 'SELECT `User`.`Name` AS `UserName`, `User`. `ID` AS `UserID`, `T3`.`Entry`, `T3`.`Original`, `T3`.`Translated`, `T3`.`Description` FROM (SELECT `T2`.`User`, `T1`.`Language`, `T1`.`Text` AS `Original`, `T2`.`Text` AS `Translated`, `T2`.`Description`, `T1`.`Entry` AS `Entry` FROM `Dictionary` AS `T1` JOIN `Dictionary` AS `T2` ON `T2`.`Entry` = `T1`.`Entry` AND `T2`.`Language` = '.$_SESSION['language'].' WHERE LOWER(`T1`.`Text`) LIKE LOWER("%'.$Search.'%") OR LOWER(`T1`.`Description`) LIKE LOWER("%'.$Search.'%") ) AS `T3` JOIN `User` ON `User`.`ID` = `T3`.`User` WHERE `T3`.`Language` = '.$Config['OriginalLanguage']; 185 } else $sql = 'SELECT `User`.`Name` AS `UserName`, `ID` AS `UserID`, `T3`.`Entry`, `T3`.`Original`, `T3`.`Translated`, `T3`.`Description` FROM (SELECT `T2`.`User`, `T1`.Language, `T1`.`Text` AS `Original`, `T2`.`Text` AS `Translated`, `T2`.`Description`, `T1`.`Entry` AS `Entry` FROM `Dictionary` AS `T1` JOIN `Dictionary` AS `T2` ON `T2`.`Entry` = `T1`.`Entry` AND `T2`.`Language` = '.$_SESSION['language'].') AS `T3` JOIN `User` ON `User`.`ID` = `T3`.`User` WHERE `T3`.`Language` = '.$Config['OriginalLanguage']; 183 186 184 187 $DbResult = $System->Database->query('SELECT COUNT(*) FROM ('.$sql.') AS `T1`');
Note:
See TracChangeset
for help on using the changeset viewer.