source: trunk/download.php@ 84

Last change on this file since 84 was 84, checked in by george, 16 years ago
  • Doplněno: Pokyny pro zprovoznění systému.
  • Upraveno: Pokyny při pro volbu formy výstupu ve Stahování.
  • Opraveno: Doplněno správné zobrazování jmen autorů překladů v některých výpisech překladů.
File size: 14.5 KB
Line 
1<?php
2
3session_start();
4
5if(!array_key_exists('ExportSetting', $_SESSION))
6 $_SESSION['ExportSetting'] = $_COOKIE['ExportSetting'];
7
8setcookie('ExportSetting', $_SESSION['ExportSetting']);
9include('includes/global.php');
10include('includes/zip.lib.php');
11include('export.php');
12include('addon/make.php');
13
14ShowPage();
15
16function CheckBox($Name, $Checked = false)
17{
18 if($Checked) $Checked = ' checked="1"'; else $Checked = '';
19 return('<input type="checkbox" value="1" name="'.$Name.'"'.$Checked.' />');
20}
21
22function RadioButton($Name, $Value, $Checked = false)
23{
24 if($Checked) $Checked = ' checked="1"'; else $Checked = '';
25 return('<input type="radio" name="'.$Name.'" value="'.$Value.'"'.$Checked.' />');
26}
27
28function SelectOption($Name, $Text, $Selected = false)
29{
30 if($Selected) $Selected = ' selected="1"'; else $Selected = '';
31 return('<option type="checkbox" value="'.$Name.'"'.$Selected.'/>'.$Text.'</option>');
32}
33
34if(array_key_exists('UserID', $_SESSION) and ($_SESSION['UserID'] != ''))
35{
36 $DbResult = $Database->SQLCommand('SELECT ExportSetting FROM user WHERE ID='.$_SESSION['UserID']);
37 $DbRow = mysql_fetch_assoc($DbResult);
38 $ExportSetting = unserialize($DbRow['ExportSetting']);
39
40 //print_r($_POST);
41} else
42{
43 $ExportSetting = unserialize($_SESSION['ExportSetting']);
44}
45if(!isset($ExportSetting['users-selection'])) $ExportSetting['users-selection'] = array();
46if(!isset($ExportSetting['Diacritics'])) $ExportSetting['Diacritics'] = 1;
47if(!isset($ExportSetting['language-cz'])) $ExportSetting['language-cz'] = 1;
48if(!isset($ExportSetting['language-sk'])) $ExportSetting['language-sk'] = 1;
49if(!isset($ExportSetting['language-other'])) $ExportSetting['language-other'] = 1;
50if(!isset($ExportSetting['users-order'])) $ExportSetting['users-order'] = '';
51if(!isset($ExportSetting['Export'])) $ExportSetting['Export'] = 'Addon';
52if(!isset($ExportSetting['groups'])) $ExportSetting['groups'] = array();
53
54function CreateZipFromDir(&$Zip, $Path, $ZipPath)
55{
56 //echo($Path.'<br />');
57 $FileList = scandir($Path);
58 foreach($FileList as $FileName)
59 {
60 if(file_exists($Path.$FileName) and ($FileName != '.') and ($FileName != '..'))
61 {
62 //echo($Path.$FileName.'<br />');
63 if(is_dir($Path.$FileName)) CreateZipFromDir($Zip, $Path.$FileName.'/', $ZipPath.$FileName.'/');
64 else $Zip->addFile(file_get_contents($Path.$FileName), $ZipPath.$FileName);
65 }
66 }
67}
68
69if(!array_key_exists('action', $_GET)) $_GET['action'] = '';
70switch($_GET['action'])
71{
72 case 'result':
73 $ExportSetting['Export'] = @$_POST['Export'];
74 switch($ExportSetting['Export'])
75 {
76 case 'MangosSQLCompressed':
77 if(function_exists('gzcompress'))
78 {
79 $TempDir = 'tmp/'.$_SESSION['User'].'/';
80 if(!file_exists($TempDir)) mkdir($TempDir, 0777, true);
81 $SaveFilename = $TempDir.'CzWoW_SQL.zip';
82 $SQLFilename = 'CzWoW_SQL.sql';
83 $BufferZip = ExportToMangosSQL($ExportSetting);
84 $ZipFile = new zipfile();
85 $ZipFile->addFile($BufferZip, $SQLFilename);
86 $Buffer = $ZipFile->file();
87 file_put_contents($SaveFilename, $Buffer);
88 } else echo('Funkce pro tvorbu Zip souboru není podporována!');
89 echo('<script type="text/javascript" language="JavaScript" charset="utf-8">'.
90 'setTimeout("parent.location.href=\''.$SaveFilename.'\'", 1000)'.
91 '</script>');
92
93 echo('Pokud nezačalo stahování, soubor by mělo jít stáhnout pomocí tohoto odkazu: '.
94 '<a href="'.$SaveFilename.'">CzWoW_SQL.zip</a><br />'.
95 'Pokud se vám zdá, že filtr na export nefunguje, vymažte si vyrovnávací paměť prohlížeče a zkuste stáhnout soubor znovu.');
96 break;
97 case 'MangosSQLDirect':
98 echo('Vygenerovaný SQL kód: <br /><pre class="SQLCode">');
99 echo(htmlspecialchars(ExportToMangosSQL($ExportSetting)));
100 echo('</pre>');
101 break;
102 case 'XMLCompressed':
103 if(function_exists('gzcompress'))
104 {
105 $TempDir = 'tmp/'.$_SESSION['User'].'/';
106 if(!file_exists($TempDir)) mkdir($TempDir, 0777, true);
107 $SaveFilename = $TempDir.'CzWoW_XML.zip';
108 $SQLFilename = 'CzWoW_XML.sql';
109 $BufferZip = ExportToXML($ExportSetting);
110 $ZipFile = new zipfile();
111 $ZipFile->addFile($BufferZip, $SQLFilename);
112 $Buffer = $ZipFile->file();
113 file_put_contents($SaveFilename, $Buffer);
114 } else echo('Funkce pro tvorbu Zip souboru není podporována!');
115 echo('<script type="text/javascript" language="JavaScript" charset="utf-8">'.
116 'setTimeout("parent.location.href=\''.$SaveFilename.'\'", 1000)'.
117 '</script>');
118
119 echo('Pokud nezačalo stahování, soubor by mělo jít stáhnout pomocí tohoto odkazu: '.
120 '<a href="'.$SaveFilename.'">CzWoW_SQL.zip</a><br />'.
121 'Pokud se vám zdá, že filtr na export nefunguje, vymažte si vyrovnávací paměť prohlížeče a zkuste stáhnout soubor znovu.');
122 break;
123 case 'XMLDirect':
124 echo('Vygenerované XML: <br /><pre class="SQLCode">');
125 echo(htmlspecialchars(ExportToXML($ExportSetting)));
126 echo('</pre>');
127 break;
128 case 'Server':
129 if(Licence(LICENCE_ADMIN))
130 {
131 $Buffer = ExportToMangosSQL($ExportSetting);
132 $Database->SelectDatabase($Config['Database']['DatabaseMangos']);
133 $BufferArray = explode("\n", $Buffer);
134 echo('Přenášení dat do serveru...<br />');
135 foreach($BufferArray as $Line)
136 {
137 $Database->SQLCommand($Line);
138 echo('.');
139 }
140 echo("<br />Hotovo<br />");
141 } else echo('Nemáte oprávnění.');
142 break;
143 case 'Addon':
144 if(function_exists('gzcompress'))
145 {
146 $TempDir = 'tmp/'.$_SESSION['User'].'/CzWoW/';
147 echo('Generování addonu...<br />');
148 MakeAddon($ExportSetting);
149 $SaveFilename = 'tmp/'.$_SESSION['User'].'/CzWoW_Addon.zip';
150 $Zip = new zipfile();
151 CreateZipFromDir($Zip, $TempDir, 'CzWoW/');
152 $Zip->addFile(file_get_contents('addon/CzWoW/OptionsFrame.xml'), 'CzWoW/OptionsFrame.xml');
153 $Zip->addFile(file_get_contents('addon/CzWoW/CzWoW.xml'), 'CzWoW/CzWoW.xml');
154 $Zip->addFile(file_get_contents('addon/CzWoW/CzWoW.toc'), 'CzWoW/CzWoW.toc');
155 //$Zip->addFile(file_get_contents('addon/CzWoW/CzWoW.lua'), 'CzWoW/CzWoW.lua');
156 $Zip->addFile(file_get_contents('addon/CzWoW/GameMenuFrame.xml'), 'CzWoW/GameMenuFrame.xml');
157 $Zip->addFile(file_get_contents('addon/CzWoW/Localization.lua'), 'CzWoW/Localization.lua');
158 $Zip->addFile(file_get_contents('addon/ProffBot/ProffBot.toc'), 'ProffBot/ProffBot.toc');
159 $Zip->addFile(file_get_contents('addon/ProffBot/ProffBot.xml'), 'ProffBot/ProffBot.xml');
160 $Zip->addFile(file_get_contents('addon/ProffBot/ProffBot.lua'), 'ProffBot/ProffBot.lua');
161 $Buffer = $Zip->file();
162 file_put_contents($SaveFilename, $Buffer);
163 echo('Hotovo<br /><br />');
164 } else echo('Funkce pro tvorbu Zip souboru není podporována!');
165 echo('<script type="text/javascript" language="JavaScript" charset="utf-8">'.
166 'setTimeout("parent.location.href=\''.$SaveFilename.'\'", 1000)'.
167 '</script>');
168
169 echo('Pokud nezačalo stahování, soubor by mělo jít stáhnout pomocí tohoto odkazu: '.
170 '<a href="'.$SaveFilename.'">CzWoW_Addon.zip</a><br />'.
171 'Pokud se vám zdá, že filtr na export nefunguje, vymažte si vyrovnávací paměť prohlížeče a zkuste stáhnout soubor znovu.');
172 echo('<br /><strong>Použití ve hře</strong><br />Menu addonu ve hře vyvoléte povelem /czwow.');
173 break;
174 }
175 WriteLog('Generování SQL výstupu: Typ exportu: <b>'.$ExportSetting['Export'].'</b>, Diakritika: <b>'.$ExportSetting['Diacritics'].'</b>', 2);
176 break;
177 case 'output':
178 if(array_key_exists('groups', $_POST)) $ExportSetting['groups'] = $_POST['groups'];
179 $ExportSetting['Diacritics'] = array_key_exists('Diacritics', $_POST);
180 $ExportSetting['language-cz'] = array_key_exists('language-cz', $_POST);
181 $ExportSetting['language-sk'] = array_key_exists('language-sk', $_POST);
182 $ExportSetting['language-other'] = array_key_exists('language-other', $_POST);
183 echo('<strong>Krok 3. - Typ výstupu</strong><br /><br />');
184 echo('<form action="?action=result" method="post">'.
185 '<table width="100%"><tr><td width="50%">'.
186 '<fieldset><legend>Forma výstupu</legend>'.
187 RadioButton('Export', 'MangosSQLDirect', $ExportSetting['Export'] == 'MangosSQLDirect').'MaNGOS SQL - přímo zobrazit<br />'.
188 RadioButton('Export', 'MangosSQLCompressed', $ExportSetting['Export'] == 'MangosSQLCompressed').'MaNGOS SQL - komprimovaný soubor<br />'.
189 RadioButton('Export', 'XMLDirect', $ExportSetting['Export'] == 'XMLDirect').'XML - přímo zobrazit<br />'.
190 RadioButton('Export', 'XMLCompressed', $ExportSetting['Export'] == 'XMLCompressed').'XML - komprimovaný soubor<br />'.
191 RadioButton('Export', 'Addon', $ExportSetting['Export'] == 'Addon').'Addon - komprimovaný soubor<br />');
192 if(Licence(LICENCE_ADMIN))
193 echo(RadioButton('Export', 'Server', $ExportSetting['Export'] == 'Server').'Poslat přímo na server (pouze admin)<br />');
194 //echo('
195 echo('</fieldset><br /></td><td>Zvolte způsob, jakým mají být získána výstupní data. V případě přímého zobrazení může být do vašeho prohlížeče přenášeno vysoké množství dat, což může vést k jeho přetížení.<br />Addon je potřeba nakopírovat do složky klienta Interface/AddOns a ve hře lze zpřístupnit jeho možnosti pomocí příkazu /czwow.</td></tr></table>');
196 echo('<br /><input type="submit" value="Dokončit" />');
197 echo('</form>');
198 break;
199 case 'parameters':
200 $ExportSetting['users-order'] = $_POST['users-order'];
201 $ExportSetting['users-selection'] = array();
202 $UsersList = explode(',', $_POST['users-order']);
203 foreach($UsersList as $Index => $Item)
204 {
205 if(array_key_exists('user_'.$Item, $_POST)) $ExportSetting['users-selection'][] = $Item;
206 }
207 //if(array_key_exists('users', $_POST)) $ExportSetting['users'] = $_POST['users'];
208 echo('<strong>Krok 2. - Volba parametrů</strong><br /><br />');
209 echo('<form action="?action=output" method="post">');
210 echo('<table width="100%"><tr><td>');
211 echo('<fieldset><legend>Jazyk</legend>'.
212 CheckBox('Diacritics', $ExportSetting['Diacritics'] == 1).'Včetně diakritiky<br /><br />');
213 //echo('<input type="checkbox" name="Use" checked="true">Přidat výchovýběr databáze.<br />');
214
215 echo(CheckBox('language-cz', $ExportSetting['language-cz'] == 1).'Český překlad<br />'.
216 CheckBox('language-sk', $ExportSetting['language-sk'] == 1).'Slovenský překlad<br />'.
217 CheckBox('language-other', $ExportSetting['language-other'] == 1).'Jiné jazyky<br />');
218 echo('</fieldset><br /></td><td>Pro správné zobrazení českých znaků ve hře je nutné používat upravené <a href="download/ceske_fonty_do_wow.zip">počeštěné fonty</a>.<br />Vyberte jaké jazyky se mají uvažovat při exportu.</td></tr><tr><td><fieldset><legend>Skupiny textů</legend>');
219 echo('<select name="groups[]" size="15" style="width: 400px;" multiple="1">');
220 foreach($TranslationTree as $Group)
221 if($Group['TablePrefix'] != '')
222 echo(SelectOption($Group['Id'], $Group['Name'].' ('.$Group['TablePrefix'].')', in_array($Group['Id'], $ExportSetting['groups'])));
223
224 echo('</select></fieldset><br /></td><td>Vyberte skupiny textů, z kterých bude sestaven export. Přidržením CTRL nebo SHIFT můžete provádět výběr více položek.</td></tr></table><input type="submit" value="Pokračovat" />');
225 echo('</form>');
226 break;
227 default:
228 echo('<strong>Krok 1. - Výběr překladatelů</strong><br /><br />');
229 echo('<script type="text/javascript" src="style/jquery.js"></script>
230<script type="text/javascript" src="style/jquery-ui.js"></script>
231<script type="text/javascript">
232$(document).ready(function()
233{
234 $("#users-table").sortable({ items: "tr", sort: SortComplete });
235 $("#users-order").val($("#users-table").sortable(\'toArray\'));
236});
237
238function SortComplete()
239{
240 $("#users-order").val($("#users-table").sortable(\'toArray\'));
241}
242</script>');
243 echo('<form action="?action=parameters" method="post">');
244 echo('<table><tr><td>'.
245 '<table class="BaseTable" id="users-table" width="100%"><tr><th>Jméno</th><th>Překladů</th><th></th></tr>');
246 $Query = 'SELECT T.user, T.ID, T.TranslatedCount FROM (SELECT user, ID, (';
247 foreach($TranslationTree as $Group)
248 if($Group['TablePrefix'] != '')
249 $Query .= '(SELECT COUNT(*) FROM '.$Group['TablePrefix'].' WHERE (user = user.ID) AND (Complete = 1) AND (Language <> 0)) + ';
250 $Query .= ' 0) AS TranslatedCount FROM `user` ORDER BY user) AS T WHERE T.TranslatedCount > 0 ORDER BY T.TranslatedCount DESC';
251 //echo($Query);
252 $ID = $Database->SQLCommand($Query);
253
254 // Rebuild user order list
255 $Users = array();
256 while($Line = mysql_fetch_array($ID)) $Users[$Line['ID']] = $Line;
257 $UsersOrder = explode(',', $ExportSetting['users-order']);
258 foreach($Users as $User)
259 if(!in_array($User['ID'], $UsersOrder)) $UsersOrder[] = $User['ID'];
260 foreach($UsersOrder as $Index => $UserId)
261 if(!array_key_exists($UserId, $Users)) unset($UsersOrder[$Index]);
262 $ExportSetting['users-order'] = implode(',', $UsersOrder);
263
264 //print_r($UsersOrder);
265 // Show ordered user list
266 foreach($UsersOrder as $UserId)
267 echo('<tr id="'.$UserId.'"><td>'.$Users[$UserId]['user'].'</td><td>'.$Users[$UserId]['TranslatedCount'].
268 '</td><td>'.CheckBox('user_'.$UserId, in_array($UserId, $ExportSetting['users-selection'])).'</td></tr>');
269 echo('</table></td><td valign="top">Zvolte ze seznamu uživatele, od kterých chcete načítat překlady a upravte jejich pořadí, takže od uživatelů výše budou brány překlady přednostně.<br />'.
270 'Řádky v tabulce můžete přesouvat metodou uchop a táhni.'.
271 '</td></tr></table>'.
272 '<div><input name="users-order" id="users-order" size="100" type="hidden" /><br />');
273 echo('<input type="submit" value="Pokračovat" /></div>');
274 echo('</form>');
275 break;
276}
277
278if(array_key_exists('UserID', $_SESSION) and ($_SESSION['UserID'] != ''))
279 $Database->SQLCommand('UPDATE user SET ExportSetting = "'.addslashes(serialize($ExportSetting)).'" WHERE ID='.$_SESSION['UserID']);
280 else $_SESSION['ExportSetting'] = serialize($ExportSetting);
281
282//print_r($ExportSetting);
283
284ShowFooter();
285?>
Note: See TracBrowser for help on using the repository browser.