Changeset 401 for trunk/export
- Timestamp:
- Mar 24, 2010, 7:47:23 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/export/export.php
r395 r401 24 24 $DbResult = $this->Database->query('SELECT * FROM `Export` WHERE `Id`='.$this->Id); 25 25 if($DbResult->num_rows == 0) throw new Exception('Export '.$this->Id.' neexistuje'); 26 $this->Export = $DbResult->fetch_assoc(); 27 28 // Filter selected languages 29 $this->WhereLang = ''; 30 $DbResult = $this->Database->query('SELECT * FROM `ExportLanguage` WHERE `Export`='.$this->Id.' ORDER BY `Sequence`'); 31 echo($this->Database->error); 32 while($Language = $DbResult->fetch_assoc()) 33 $this->WhereLang .= ' OR (`Language` = '.$Language['Language'].')'; 34 if($this->WhereLang == '') $this->WhereLang = 1; 35 else $this->WhereLang = '('.substr($this->WhereLang, 4).')'; 26 $this->Export = $DbResult->fetch_assoc(); 36 27 37 28 // Filter selected users 38 $this->SelectedUsers = '';39 29 $this->UserNames = ''; 40 30 $DbResult = $this->Database->query('SELECT `ExportUser`.*, `User`.`Name`, `User`.`ID` FROM `ExportUser` LEFT JOIN `User` ON `User`.`ID`=`ExportUser`.`User` WHERE `ExportUser`.`Export`='.$this->Id.' ORDER BY `ExportUser`.`Sequence`'); 41 31 while($UserLine = $DbResult->fetch_assoc()) 42 32 { 43 $this->SelectedUsers .= ','.$UserLine['ID']; 44 $this->UserNames .= ','.$UserLine['Name']; 45 } 46 $this->SelectedUsers = substr($this->SelectedUsers, 1); 47 $this->UserNames = substr($this->UserNames, 1); 33 $this->UserNames .= ', '.$UserLine['Name']; 34 } 35 $this->UserNames = substr($this->UserNames, 2); 48 36 49 if($this->SelectedUsers == '')50 {51 $this->WhereUsers = 0;52 $this->OrderByUserList = '';53 } else54 {55 $this->WhereUsers = '(`User` IN ('.$this->SelectedUsers.'))';56 $this->OrderByUserList = ' ORDER BY FIELD(`User`, '.$this->SelectedUsers.')';57 }58 59 37 $DbResult = $this->Database->query('SELECT * FROM `ClientVersion` WHERE `Id`='.$this->Export['ClientVersion']); 60 38 $this->ClientVersion = $DbResult->fetch_assoc(); 39 } 40 41 function BuildQuery($Group, $Columns = '`T`.*') 42 { 43 $Query = 'SELECT * FROM (SELECT '.$Columns.', `User`.`Name` AS `UserName` FROM `'.$Group['TablePrefix'].'` AS `T`'. 44 ' JOIN `ExportUser` ON (`ExportUser`.`User`=`T`.`User`) AND (`ExportUser`.`Export`='.$this->Id.') '. 45 ' JOIN `User` ON `User`.`ID`=`T`.`User`'. 46 ' JOIN `ExportLanguage` ON (`ExportLanguage`.`Export`='.$this->Id.')'. 47 ' WHERE (`Complete` = 1) AND (`VersionStart` <= '.$this->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$this->ClientVersion['BuildNumber'].')'. 48 ' ORDER BY `ExportLanguage`.`Sequence`, `ExportUser`.`Sequence`) AS `TT` GROUP BY `TT`.`Entry`'; 49 return($Query); 61 50 } 62 51 … … 91 80 if($Group['MangosTable'] != '') 92 81 { 93 $Query = 'SELECT * FROM (SELECT * FROM '.$Group['TablePrefix'].' WHERE (`Complete` = 1) AND `VersionStart` <= '.$this->ClientVersion['BuildNumber'].' AND `VersionEnd` >= '.$this->ClientVersion['BuildNumber'].' AND '.$this->WhereLang.' AND '.$this->WhereUsers.$this->OrderByUserList.') AS `T` GROUP BY `T`.`Entry`';94 //echo($Query);95 82 $Buffer .= "\n\n-- ".$Group['Name']."\n\n"; 96 $DbResult2 = $this->Database->query($ Query);83 $DbResult2 = $this->Database->query($this->BuildQuery($Group)); 97 84 while($Line = $DbResult2->fetch_array()) 98 85 { … … 134 121 $Buffer = $this->ExportToMangosSQL(); 135 122 123 /* 136 124 // Data to aowow 137 138 125 $Database2 = new mysqli($this->Config['Database']['Host'], $this->Config['Database']['User'], $this->Config['Database']['Password'], $this->Config['Database']['Database']); 139 126 $Database2->query('SET NAMES '.$this->Config['Database']['Charset']); … … 176 163 $Buffer .= "\n\n"; 177 164 } 165 */ 178 166 if($this->Export['WithDiacritic'] != 1) $Buffer = utf2ascii($Buffer); 179 167 return($Buffer); … … 210 198 $Group['MangosTableIndex'] = 'entry'; 211 199 } 212 $Query = 'SELECT *,(SELECT `Name` FROM `User` WHERE `User`.`ID`=`T`.`User`) AS `UserName` FROM (SELECT * FROM `'.$Group['TablePrefix'].'` WHERE (`Complete` = 1) AND (`VersionStart` <= '.$this->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$this->ClientVersion['BuildNumber'].') AND '.$this->WhereLang.' AND '.$this->WhereUsers.$this->OrderByUserList.') AS `T` GROUP BY `T`.`entry`';213 //echo($Query);214 200 $Buffer .= ' <group id="'.$Group['Id'].'" name="'.$Group['TablePrefix'].'">'."\n"; 215 $DbResult2 = $this->Database->query($ Query);201 $DbResult2 = $this->Database->query($this->BuildQuery($Group)); 216 202 while($Line = $DbResult2->fetch_assoc()) 217 203 { … … 247 233 if(file_exists('../source/'.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc')) 248 234 { 249 $ i= 1;250 $ columns = '';235 $I = 1; 236 $Columns = ''; 251 237 foreach($TranslationTree[$Group['Id']]['Items'] as $Column) 252 238 { 253 $ columns .= ' `T`.`'.$Column['Column'].'` AS `Text'.$i.'`,';254 $ i = $i+ 1;239 $Columns .= '`T`.`'.$Column['Column'].'` AS `Text'.$I.'`, '; 240 $I = $I + 1; 255 241 } 256 $Query = 'SELECT '.$columns.' `T`.`Entry` AS `Entry` FROM (SELECT * FROM `'.$Group['TablePrefix'].'` WHERE (`Complete` = 1) AND '.$this->WhereLang.' AND '.$this->WhereUsers.' AND (`VersionStart` <= '.$this->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$this->ClientVersion['BuildNumber'].')) AS `T` GROUP BY `T`.`Entry`'; 242 $Columns = substr($Columns, 0, -2); 243 244 $Query = $this->BuildQuery($Group, $Columns); 257 245 $Query = str_replace('`', '\`', $Query); 258 246 $Query = '"'.str_replace(' ', '\ ', $Query).'"'; 259 247 260 $ params = '-u '.$Config['Database']['User'].' -p '.$Config['Database']['Password'].' -f ../source/'.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc -n '.$this->TempDir.'dbc/'.$Group['DBCFileName'].'.dbc -c '.GetDBCColumns($this->ClientVersion['Version'], $Group['DBCFileName']).' -q '.$Query;248 $Params = '-u '.$Config['Database']['User'].' -p '.$Config['Database']['Password'].' -f ../source/'.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc -n '.$this->TempDir.'dbc/'.$Group['DBCFileName'].'.dbc -c '.GetDBCColumns($this->ClientVersion['Version'], $Group['DBCFileName']).' -q '.$Query; 261 249 262 //echo('./DBCExport '.$params); 263 exec('./DBCExport '.$params); 250 exec('./DBCExport '.$Params); 264 251 265 252 } else echo('Zdrojový soubor '.'../source/'.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc'.' nenalezen.'."\n"); … … 295 282 $Value['Comment'] = substr(trim($LineParts[1]), 3); 296 283 297 $Query = 'SELECT * FROM (SELECT * FROM `'.$Group['TablePrefix'].'` WHERE (`Complete` = 1) AND '.$this->WhereLang.' AND '.$this->WhereUsers.' AND (`ShortCut`="'.$Value['ShortCut'].'") AND (`VersionStart` <= '.$this->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$this->ClientVersion['BuildNumber'].')'.$this->OrderByUserList.') AS `T` GROUP BY `T`.`Entry`'; 298 //echo($Query); 299 $DbResult2 = $this->Database->query($Query); 284 $DbResult2 = $this->Database->query($this->BuildQuery($Group)); 300 285 if($DbResult2->num_rows > 0) 301 286 {
Note:
See TracChangeset
for help on using the changeset viewer.