1 | <?php
|
---|
2 |
|
---|
3 | include('includes/global.php');
|
---|
4 |
|
---|
5 | function GetIDbyName($Table)
|
---|
6 | {
|
---|
7 | global $TranslationTree;
|
---|
8 |
|
---|
9 | foreach($TranslationTree as $TableID => $Value)
|
---|
10 | {
|
---|
11 | //echo $Value['TablePrefix'].'='.$Table.'<br>';
|
---|
12 | if ($Value['TablePrefix'] == $Table) return $TableID;
|
---|
13 | }
|
---|
14 | }
|
---|
15 |
|
---|
16 | function GetTranslatNames($Text)
|
---|
17 | {
|
---|
18 | global $Database, $mode;
|
---|
19 |
|
---|
20 | if ($mode == 0) echo ('..Přesné');
|
---|
21 | if ($mode == 1) echo ('..Všechny přeložené');
|
---|
22 | if ($mode == 2) echo ('..Nepřeložené');
|
---|
23 | echo('<div style="overflow: auto; width: 100%; height: 345px;"><table width="98%" class="BaseTable">');
|
---|
24 | echo('<tr><th>Originál</th>'.'<th>Překlad</th>');
|
---|
25 | $TablesColumn = array
|
---|
26 | (
|
---|
27 | 'gameobject' => 'Name',
|
---|
28 | 'creature' => 'name',
|
---|
29 | 'item' => 'Name',
|
---|
30 | 'transports' => 'Name',
|
---|
31 | 'areatrigger_teleport' => 'Name',
|
---|
32 | 'areatrigger_tavern' => 'Name',
|
---|
33 | );
|
---|
34 | /* $TablesID = array('gameobject' => 5,
|
---|
35 | 'creature' => 6,
|
---|
36 | 'item' => 4,
|
---|
37 | 'transports' => 'Name',
|
---|
38 | 'areatrigger_teleport' => 'Name',
|
---|
39 | 'areatrigger_tavern' => 'Name',); */
|
---|
40 |
|
---|
41 | foreach($TablesColumn as $Table => $Column)
|
---|
42 | {
|
---|
43 | $sql = 'SELECT `ID`,'.$Column.',(SELECT `Name` FROM '.$Table.' AS `T` WHERE `O`.`entry` = `T`.`entry` AND `Language` <> 0 LIMIT 1) AS `tran` FROM `'.$Table.'` AS `O` WHERE ';
|
---|
44 | $groupby = ' GROUP BY `'.$Column.'`';
|
---|
45 |
|
---|
46 | $ArrStr = explode(' ', $Text);
|
---|
47 | $where = 'Language = 0 ';
|
---|
48 | if ($mode == 1) $where .= ' AND EXISTS(SELECT 1 FROM '.$Table.' AS sub WHERE (sub.Language <> 0) AND (sub.entry = O.entry))';
|
---|
49 | if ($mode == 2) $where .= ' AND NOT EXISTS(SELECT 1 FROM '.$Table.' AS sub WHERE (sub.Language <> 0) AND (sub.entry = O.entry))';
|
---|
50 | $where .= ' AND (';
|
---|
51 |
|
---|
52 | for($i = 0; $i < count($ArrStr); $i++)
|
---|
53 | {
|
---|
54 | if (strpos($ArrStr[$i],'\'s') > 0) $ArrStr[$i] = substr($ArrStr[$i],0,strlen($ArrStr[$i])-4);
|
---|
55 | if (strpos($ArrStr[$i],',') > 0) $ArrStr[$i] = substr($ArrStr[$i],0,strlen($ArrStr[$i])-1);
|
---|
56 | if (strpos($ArrStr[$i],'.') > 0) $ArrStr[$i] = substr($ArrStr[$i],0,strlen($ArrStr[$i])-1);
|
---|
57 | if (strpos($ArrStr[$i],'!') > 0) $ArrStr[$i] = substr($ArrStr[$i],0,strlen($ArrStr[$i])-1);
|
---|
58 | if (strpos($ArrStr[$i],'?') > 0) $ArrStr[$i] = substr($ArrStr[$i],0,strlen($ArrStr[$i])-1);
|
---|
59 |
|
---|
60 | if (strlen($ArrStr[$i]) > 4)
|
---|
61 | $where .= 'O.'.$Column.' LIKE "%'.addslashes($ArrStr[$i]).'%" OR ';
|
---|
62 | }
|
---|
63 | $where = substr($where,0,strlen($where)-4);
|
---|
64 | $where .= ')';
|
---|
65 | echo ('</tr>');
|
---|
66 |
|
---|
67 | $ID = $Database->SQLCommand($sql.$where.$groupby);
|
---|
68 | while($Line = mysql_fetch_assoc($ID))
|
---|
69 | {
|
---|
70 | if ($mode == 0)
|
---|
71 | {
|
---|
72 | if (strpos(strtolower($Text),strtolower($Line[$Column])) > 0)
|
---|
73 | {
|
---|
74 | echo('<tr><td>'.$Line[$Column].'</td>');
|
---|
75 | if ($Line['tran'] <> '') echo('<td>'.$Line['tran'].'</td></tr>');
|
---|
76 | else echo('<td><a target="_NEW2" href="form.php?group='.GetIDbyName($Table).'&ID='.$Line['ID'].'">Překládat</a></td></tr>');
|
---|
77 | }
|
---|
78 | } else
|
---|
79 | {
|
---|
80 | echo('<tr><td>'.$Line[$Column].'</td>');
|
---|
81 | if ($Line['tran'] <> '') echo('<td>'.$Line['tran'].'</td></tr>');
|
---|
82 | else echo('<td><a target="_NEW2" href="form.php?group='.GetIDbyName($Table).'&ID='.$Line['ID'].'">Překládat</a></td></tr>');
|
---|
83 | }
|
---|
84 | }
|
---|
85 | }
|
---|
86 | echo('</table></div>');
|
---|
87 | }
|
---|
88 |
|
---|
89 | ShowPage();
|
---|
90 |
|
---|
91 | if(!isset($_SESSION['language']))
|
---|
92 | {
|
---|
93 | if(Licence(LICENCE_USER))
|
---|
94 | {
|
---|
95 | $DbResult = $Database->SQLCommand('SELECT `Language` FROM `user` WHERE `ID`='.$_SESSION['UserID']);
|
---|
96 | $User = mysql_fetch_assoc($DbResult);
|
---|
97 | $_SESSION['language'] = $User['Language'];
|
---|
98 | } else $_SESSION['language'] = 1;
|
---|
99 | }
|
---|
100 | if(array_key_exists('language', $_GET)) $_SESSION['language'] = LoadLanguageIdParameter();
|
---|
101 |
|
---|
102 | echo('<h3>Slovníček</h3>');
|
---|
103 |
|
---|
104 | if(array_key_exists('group', $_GET))
|
---|
105 | {
|
---|
106 | $GroupId = LoadGroupIdParameter();
|
---|
107 | if(array_key_exists('mode', $_GET)) $mode = $_GET['mode']; else $mode = 0; //0 = přesné názvy, 1=všechny názvy, 2=nepřeložené
|
---|
108 | $Table = $TranslationTree[$GroupId]['TablePrefix'];
|
---|
109 |
|
---|
110 | if(array_key_exists('ID', $_GET))
|
---|
111 | {
|
---|
112 | $TextID = $_GET['ID'];
|
---|
113 | echo ('Přeložené názvy vztahující se k překladu: <a target="_NEW" href="form.php?group='.$GroupId.'&ID='.$TextID.'">'.$TextID.'</a><br />'.
|
---|
114 | '<a href="?mode=1&group='.$GroupId.'&ID='.$TextID.'" title="Zobrazit všechny podobné výsledky">Všechny</a> '.
|
---|
115 | '<a href="?mode=0&group='.$GroupId.'&ID='.$TextID.'" title="Zobrazit pouze přesné výsledky">Přesné</a> '.
|
---|
116 | '<a href="?mode=2&group='.$GroupId.'&ID='.$TextID.'" title="Zobrazit všechny nepřeložené">Nepřeložené</a> ');
|
---|
117 | $Line = mysql_fetch_assoc($Database->SQLCommand('SELECT * FROM '.$Table.' Where ID = '.$TextID));
|
---|
118 | if(!$Line) die('Překlad nenalezen.');
|
---|
119 |
|
---|
120 | $Text = '';
|
---|
121 | foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)
|
---|
122 | $Text .= ' '.$Line[$TextItem['Column']];
|
---|
123 | GetTranslatNames($Text);
|
---|
124 | }
|
---|
125 | } else
|
---|
126 | {
|
---|
127 | if(array_key_exists('action', $_GET))
|
---|
128 | {
|
---|
129 | if(($_GET['action'] == 'insert') and Licence(LICENCE_USER))
|
---|
130 | {
|
---|
131 | echo('<form action="dictionary.php?action=save" method="post">'.
|
---|
132 | '<fieldset><legend>Vložení nového slova</legend>'.
|
---|
133 | '<table><tr><td>'.
|
---|
134 | 'Původní anglické slovo:</td><td><input type="text" name="Original" /></td></tr>'.
|
---|
135 | '<tr><td>Přeložené:</td><td><input type="text" name="Translated" /></td></tr>'.
|
---|
136 | '<tr><td>Popis:</td><td><input type="text" name="Description" /></td></tr>'.
|
---|
137 | '<tr><td colspan="2"><input type="submit" value="Uložit" /></td></tr>'.
|
---|
138 | '</td></tr></table>'.
|
---|
139 | '</fieldset>'.
|
---|
140 | '</form>');
|
---|
141 | } else
|
---|
142 | if(($_GET['action'] == 'save') and Licence(LICENCE_USER))
|
---|
143 | {
|
---|
144 | if(array_key_exists('Original', $_POST) and array_key_exists('Translated', $_POST) and array_key_exists('Description', $_POST))
|
---|
145 | {
|
---|
146 | $DbResult = $Database->SQLCommand('SELECT * FROM `dictionary` WHERE `Text` = "'.$_POST['Original'].'" AND Language=0');
|
---|
147 | if(mysql_num_rows($DbResult) > 0)
|
---|
148 | {
|
---|
149 | $DbRow = mysql_fetch_assoc($DbResult);
|
---|
150 | $Entry = $DbRow['Entry'];
|
---|
151 | } else
|
---|
152 | {
|
---|
153 | $DbResult = $Database->SQLCommand('SELECT MAX(Entry) FROM dictionary');
|
---|
154 | $DbRow = mysql_fetch_row($DbResult);
|
---|
155 | $Entry = $DbRow[0] + 1;
|
---|
156 | $Database->SQLCommand('INSERT INTO `dictionary` ( `Text` , `Entry` , `Description` , `User`, `Language` ) VALUES ("'.$_POST['Original'].'", "'.$Entry.'", "", 0, 0);');
|
---|
157 | }
|
---|
158 |
|
---|
159 | $DbResult = $Database->SQLCommand('SELECT Id FROM `dictionary` WHERE `Entry` = '.$Entry.' AND Language='.$_SESSION['language'].' AND User='.$_SESSION['UserID']);
|
---|
160 | if(mysql_num_rows($DbResult) > 0)
|
---|
161 | {
|
---|
162 | $DbRow = mysql_fetch_assoc($DbResult);
|
---|
163 | $Database->SQLCommand('UPDATE `dictionary` SET `Text`="'.$_POST['Translated'].'", `Description` = "'.$_POST['Description'].'" WHERE Id='.$DbRow['Id']);
|
---|
164 | } else
|
---|
165 | $Database->SQLCommand('INSERT INTO `dictionary` ( `Text` , `Entry` , `Description` , `User`, `Language` ) VALUES ("'.$_POST['Translated'].'", "'.$Entry.'", "'.$_POST['Description'].'", '.$_SESSION['UserID'].', '.$_SESSION['language'].')');
|
---|
166 | echo('Záznam byl uložen!');
|
---|
167 | } else echo('Nebyly zaslány všechny položky formuláře.');
|
---|
168 | } else
|
---|
169 | if(($_GET['action'] == 'remove') and Licence(LICENCE_USER))
|
---|
170 | {
|
---|
171 | $Database->SQLCommand('DELETE FROM dictionary WHERE User='.$_SESSION['UserID'].' AND Language='.$_SESSION['language'].' AND Entry='.$_GET['entry']);
|
---|
172 | } else
|
---|
173 | if(($_GET['action'] == 'modify') and Licence(LICENCE_USER))
|
---|
174 | {
|
---|
175 | $DbResult = $Database->SQLCommand('SELECT * FROM dictionary WHERE User='.$_SESSION['UserID'].' AND Entry='.$_GET['entry'].' AND Language='.$_SESSION['language']);
|
---|
176 | $DbRow = mysql_fetch_assoc($DbResult);
|
---|
177 | $DbResult = $Database->SQLCommand('SELECT * FROM dictionary WHERE User=0 AND Entry='.$_GET['entry'].' AND Language=0');
|
---|
178 | $DbRow2 = mysql_fetch_assoc($DbResult);
|
---|
179 | echo('<form action="dictionary.php?action=save" method="post">'.
|
---|
180 | '<fieldset><legend>Upravení slova</legend>'.
|
---|
181 | '<table><tr><td>'.
|
---|
182 | 'Původní anglické slovo:</td><td><input type="text" name="Original" value="'.$DbRow2['Text'].'" /></td></tr>'.
|
---|
183 | '<tr><td>Přeložené:</td><td><input type="text" name="Translated" value="'.$DbRow['Text'].'" /></td></tr>'.
|
---|
184 | '<tr><td>Popis:</td><td><input type="text" name="Description" value="'.$DbRow['Description'].'" /></td></tr>'.
|
---|
185 | '<tr><td colspan="2"><input type="submit" value="Uložit" /></td></tr>'.
|
---|
186 | '</td></tr></table>'.
|
---|
187 | '</fieldset>'.
|
---|
188 | '</form>');
|
---|
189 | }
|
---|
190 | }
|
---|
191 |
|
---|
192 | echo('<form action="dictionary.php" method="get" style="margin: 0px; padding: 0px;">'.
|
---|
193 | '<table style="width: 100%; height: 100%;">');
|
---|
194 |
|
---|
195 | if(array_key_exists('search', $_GET)) $Search = $_GET['search'];
|
---|
196 | else $Search = '';
|
---|
197 |
|
---|
198 | echo('<tr><td>
|
---|
199 | <input type="text" value="'.$Search.'" name="search" size="30" />
|
---|
200 | <input type="submit" value="Vyhledat" />');
|
---|
201 | if(Licence(LICENCE_USER)) echo(' <a href="dictionary.php?action=insert">Vložit slovo</a>');
|
---|
202 |
|
---|
203 | echo('</td></tr>');
|
---|
204 | echo('<tr><td>Jazyk: ');
|
---|
205 | foreach($LanguageList as $Language)
|
---|
206 | if($Language['Enabled'] == 1)
|
---|
207 | {
|
---|
208 | if($Language['Id'] == $_SESSION['language']) echo('<strong>');
|
---|
209 | echo(' <a href="?language='.$Language['Id'].'">'.$Language['Name'].'</a>');
|
---|
210 | if($Language['Id'] == $_SESSION['language']) echo('</strong>');
|
---|
211 | }
|
---|
212 | echo('</td></tr>');
|
---|
213 | echo('<tr><td>');
|
---|
214 | //<div style="overflow: auto; width: 100%; height: 100%;">');
|
---|
215 |
|
---|
216 | if($Search <> '')
|
---|
217 | {
|
---|
218 | $sql = 'SELECT `user`.`user` 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';
|
---|
219 | } else $sql = 'SELECT `user`.`user` 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';
|
---|
220 |
|
---|
221 | $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM ('.$sql.') AS T1');
|
---|
222 | $DbRow = mysql_fetch_row($DbResult);
|
---|
223 | $PageList = GetPageList($DbRow[0]);
|
---|
224 |
|
---|
225 | $sql_page = $sql.' '.$PageList['SQLLimit'];
|
---|
226 |
|
---|
227 | echo($PageList['Output']);
|
---|
228 | echo('<table width="98%" class="BaseTable">
|
---|
229 | <tr><th>Angličtina</th>
|
---|
230 | <th>'.$LanguageList[$_SESSION['language']]['Name'].'</th>
|
---|
231 | <th>Popis</th><th>Překladatel</th>');
|
---|
232 | if(Licence(LICENCE_USER)) echo('<th>Akce</th>');
|
---|
233 | echo('</tr>');
|
---|
234 | $ID = $Database->SQLCommand($sql_page);
|
---|
235 | while($Line = mysql_fetch_assoc($ID))
|
---|
236 | {
|
---|
237 | echo('<tr>
|
---|
238 | <td>'.$Line['Original'].'</td>
|
---|
239 | <td><strong>'.$Line['Translated'].'</strong></td>
|
---|
240 | <td>'.$Line['Description'].'</td>
|
---|
241 | <td>'.$Line['UserName'].'</td>');
|
---|
242 | if(Licence(LICENCE_USER))
|
---|
243 | {
|
---|
244 | if($Line['UserID'] == $_SESSION['UserID'])
|
---|
245 | echo('<td><a href="?action=remove&entry='.$Line['Entry'].'">Smazat</a> <a href="?action=modify&entry='.$Line['Entry'].'">Upravit</a></td>');
|
---|
246 | else echo('<td></td>');
|
---|
247 | }
|
---|
248 | echo('</tr>');
|
---|
249 | }
|
---|
250 | echo('</table>');
|
---|
251 | echo($PageList['Output']);
|
---|
252 | echo('</td></tr>');
|
---|
253 | echo('</table></form>');
|
---|
254 | }
|
---|
255 |
|
---|
256 | ShowFooter();
|
---|
257 |
|
---|
258 | ?>
|
---|