Changeset 816 for trunk/Modules/Export/CreateAddon.php
- Timestamp:
- Feb 22, 2015, 11:20:50 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Export/CreateAddon.php
r788 r816 5 5 class ExportAddon extends Export 6 6 { 7 7 8 8 // Replace special codes by lua functions 9 9 function ReplaceVarInText($string, $strlower = 'strlower') 10 10 { 11 11 12 12 $string = str_replace('$N', '"..'.$strlower.'(UnitName("player")).."', $string); 13 13 $string = str_replace('$n', '"..'.$strlower.'(UnitName("player")).."', $string); … … 17 17 $string = str_replace('$r', '"..'.$strlower.'(UnitRace("player")).."', $string); 18 18 $Gender = '$G'; 19 while(strpos($string, $Gender) !== false) 19 while(strpos($string, $Gender) !== false) 20 20 { 21 21 $Before = substr($string, 0, strpos($string, $Gender)); … … 28 28 $Woman = str_replace(' ', '', $Woman); 29 29 $string = $Before.'"..gsub(gsub(UnitSex("player"), "^2$", "'.$Man.'"), "^3$", "'.$Woman.'").."'.$After; 30 } 30 } 31 31 $Gender = '$g'; 32 while(strpos($string, $Gender) !== false) 32 while(strpos($string, $Gender) !== false) 33 33 { 34 34 $Before = substr($string, 0, strpos($string, $Gender)); … … 41 41 $Woman = str_replace(' ', '', $Woman); 42 42 $string = $Before.'"..gsub(gsub(UnitSex("player"), "^2$", "'.$Man.'"),"^3$", "'.$Woman.'").."'.$After; 43 } 43 } 44 44 45 45 $string = str_replace('$', '', $string); 46 46 $string = str_replace("\r", '', $string); 47 47 $string = str_replace("\n", '\r\n', $string); 48 return($string); 48 return($string); 49 49 } 50 50 … … 53 53 // $string = mysql_escape_string($string); 54 54 $string = strtolower($string); 55 55 56 56 $string = str_replace('"', '\"', $string); 57 $string = str_replace('$b$b', ' ', $string); 58 $string = str_replace('$b $b', ' ', $string); 59 $string = str_replace('$b', ' ', $string); 60 $string = $this->ReplaceVarInText($string); 57 $string = str_replace('$b$b', ' ', $string); 58 $string = str_replace('$b $b', ' ', $string); 59 $string = str_replace('$b', ' ', $string); 60 $string = $this->ReplaceVarInText($string); 61 61 $string = str_replace("\r", ' ', $string); 62 62 $string = str_replace("\n", ' ', $string); … … 64 64 $string = str_replace('\\n', ' ', $string); 65 65 $string = str_replace(' ', '', $string); 66 // while(strpos($string, ' ')) 66 // while(strpos($string, ' ')) 67 67 // $string = str_replace(' ', ' ', $string); 68 68 return($string); … … 73 73 $string = $this->Database->real_escape_string($string); 74 74 $string = str_replace('$B', '\r\n', $string); 75 $string = str_replace('$b', '\r\n', $string); 75 $string = str_replace('$b', '\r\n', $string); 76 76 $string = $this->ReplaceVarInText($string,''); 77 77 return($string); … … 104 104 { 105 105 global $TranslationTree, $CreatedFileList; 106 106 107 107 $Output = ''; 108 108 $this->LoadFilters(); 109 109 110 110 $CreatedFileList = array(); 111 111 $CreatedFileListCount = array(); 112 112 113 113 if(!file_exists($this->TempDir.'CzWoW/')) mkdir($this->TempDir.'CzWoW/', 0777, true); 114 114 115 115 $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id.' AND `Group`.`TablePrefix` != ""'); 116 116 while($Group = $DbResult->fetch_assoc()) 117 117 { 118 118 //získání čísla verze pro export 119 $ID = $this->Database->query('SELECT LastVersion FROM `Group` WHERE Id = '.$Group['Id']); 119 $ID = $this->Database->query('SELECT LastVersion FROM `Group` WHERE Id = '.$Group['Id']); 120 120 $LastVersion = $ID->fetch_assoc(); 121 121 122 122 if ($LastVersion['LastVersion'] < $this->ClientVersion['BuildNumber']) 123 123 $ExportVersion = $LastVersion['LastVersion']; … … 125 125 126 126 foreach($TranslationTree[$Group['Id']]['Items'] as $Column) 127 if($Column['AddonFileName'] != '') 127 if($Column['AddonFileName'] != '') 128 128 { 129 129 $this->AddProgress(1); 130 if(!isset($CreatedFileListCount[$Column['AddonFileName']])) 130 if(!isset($CreatedFileListCount[$Column['AddonFileName']])) 131 131 $CreatedFileListCount[$Column['AddonFileName']] = 0; 132 132 $CreatedFileListCount[$Column['AddonFileName']]++; 133 133 $FileIndex = $CreatedFileListCount[$Column['AddonFileName']]; 134 134 135 135 $CreatedFileList[] = $Column['AddonFileName'].'_'.$FileIndex; 136 $FileName = $this->TempDir.'CzWoW/'.$Column['AddonFileName'].'_'.$FileIndex.'.lua'; 136 $FileName = $this->TempDir.'CzWoW/'.$Column['AddonFileName'].'_'.$FileIndex.'.lua'; 137 137 $Output .= $Column['AddonFileName'].': '; 138 138 $i = 0; … … 140 140 $Buffer = 'CZWOW_'.$Column['AddonFileName'].'_count='.$FileIndex.';CZWOW_'.$Column['AddonFileName'].'_'.$FileIndex.'={'; 141 141 $TableTexts = array(); 142 142 143 143 //old version 144 144 //get version before … … 146 146 if ($ExportVersion == '') $BuildNumber = $this->ClientVersion['BuildNumber']; 147 147 $ID = $this->Database->query('SELECT `BuildNumber` FROM `ClientVersion` WHERE '. 148 ' `Imported` = 1 AND `BuildNumber` < '.$BuildNumber.' ORDER BY `BuildNumber` DESC LIMIT 1'); 149 if($ID->num_rows > 0) { 148 ' `Imported` = 1 AND `BuildNumber` < '.$BuildNumber.' ORDER BY `BuildNumber` DESC LIMIT 1'); 149 if($ID->num_rows > 0) { 150 150 $ExportVersionOld = $ID->fetch_assoc(); 151 151 $ExportVersionOld = $ExportVersionOld['BuildNumber']; 152 153 $DbResult2 = $this->Database->query($this->BuildQuery($Group,$ExportVersionOld)); 154 while($Line = $DbResult2->fetch_assoc()) 152 153 $DbResult2 = $this->Database->query($this->BuildQuery($Group,$ExportVersionOld)); 154 while($Line = $DbResult2->fetch_assoc()) 155 155 { 156 $en = trim($this->ReplaceEnText($Line['En'.$Column['Column']])); 156 $en = trim($this->ReplaceEnText($Line['En'.$Column['Column']])); 157 157 $cz = $this->ReplaceCzText($Line[$Column['Column']]); 158 if(($en <> '') and ($cz <> '') and ($this->NotCancel($en))) 158 if(($en <> '') and ($cz <> '') and ($this->NotCancel($en))) 159 159 { 160 $TableTexts[$en] = $cz; 160 $TableTexts[$en] = $cz; 161 161 } 162 162 } 163 163 } 164 164 //last version 165 166 $DbResult2 = $this->Database->query($this->BuildQuery($Group,$ExportVersion)); 167 while($Line = $DbResult2->fetch_assoc()) 165 166 $DbResult2 = $this->Database->query($this->BuildQuery($Group,$ExportVersion)); 167 while($Line = $DbResult2->fetch_assoc()) 168 168 { 169 $en = trim($this->ReplaceEnText($Line['En'.$Column['Column']])); 169 $en = trim($this->ReplaceEnText($Line['En'.$Column['Column']])); 170 170 $cz = $this->ReplaceCzText($Line[$Column['Column']]); 171 if(($en <> '') and ($cz <> '') and ($this->NotCancel($en))) 171 if(($en <> '') and ($cz <> '') and ($this->NotCancel($en))) 172 172 { 173 $TableTexts[$en] = $cz; 173 $TableTexts[$en] = $cz; 174 174 } 175 175 } 176 176 177 177 foreach($TableTexts as $key => $value) { 178 178 $Buffer .= "\n".'["'.$key.'"]="'.$value.'",'; 179 179 $i++; 180 180 } 181 182 181 182 183 183 $Buffer = $Buffer."\n};if not CZWOW_".$Column['AddonFileName']." then CZWOW_".$Column['AddonFileName']."=0; end; CZWOW_".$Column['AddonFileName']."=CZWOW_".$Column['AddonFileName']."+".$i.";\n"; 184 184 … … 193 193 $Buffer = ''; 194 194 foreach($CreatedFileList as $CreatedFile) 195 $Buffer .= 'CZWOW_'.str_replace('_','_count=',$CreatedFile).';'."\n"; 195 $Buffer .= 'CZWOW_'.str_replace('_','_count=',$CreatedFile).';'."\n"; 196 196 foreach($TranslationTree as $Group) 197 197 foreach($TranslationTree[$Group['Id']]['Items'] as $Column) 198 if (($Column['AddonFileName'] != '') and (!in_array($Column['AddonFileName'].'_1', $CreatedFileList))) 198 if (($Column['AddonFileName'] != '') and (!in_array($Column['AddonFileName'].'_1', $CreatedFileList))) 199 199 { 200 $Buffer .= 'CZWOW_'.$Column['AddonFileName'].'_count=0;'."\n"; 201 } 202 200 $Buffer .= 'CZWOW_'.$Column['AddonFileName'].'_count=0;'."\n"; 201 } 202 203 203 file_put_contents($this->TempDir.'CzWoW/'.$CountFiles, $Buffer); 204 205 204 205 206 206 // Generate file Translates.xml 207 207 $Buffer = '<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/.\FrameXML\UI.xsd">'."\n"; … … 218 218 { 219 219 global $TranslationTree; 220 220 221 221 $this->LoadFilters(); 222 222 223 223 $Buffer = "local f=function(name, en, cz) CzWoW_interface[name]=cz;CzWoW_interface_entoname[en]=name; end; CzWoW_interface={};CzWoW_interface_entoname={ };\n"; 224 224 $Group = $TranslationTree[14]; // client table 225 225 $Column['Column'] = 'Text'; 226 226 227 227 $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id.' AND `Group`.`TablePrefix` != "" AND `Group`.`Id` = 14'); 228 228 //$Group = $DbResult->fetch_assoc(); … … 231 231 else 232 232 $CanGenerated = ''; 233 233 234 234 $DbResult = $this->Database->query($this->BuildQuery($Group,$CanGenerated)); 235 while($Line = $DbResult->fetch_array()) 235 while($Line = $DbResult->fetch_array()) 236 236 { 237 237 $Original = $this->my_trim($Line['En'.$Column['Column']]); 238 238 $Translated = $this->my_trim($Line[$Column['Column']]); 239 if($this->ClientVersion['Version'] == '2.4.3') 239 if($this->ClientVersion['Version'] == '2.4.3') 240 240 { 241 241 $Original = str_replace("|Hchannel:%d|h[%s]|h", '[%s]', $Original); … … 265 265 $Buffer = ' 266 266 Čeština pro klienty: 267 Vytvořeno v projektu http://wowpreklad.zdechov.net/ 267 Vytvořeno v projektu http://wowpreklad.zdechov.net/ 268 268 Obsahuje Fonty pro správné zobrazování českých znaků, WoW addon překládající 269 269 texty 270 270 271 271 Instalace: 272 272 Soubory rozbalte/zkopírujte do kořenové složky s hrou. Obvikle bývá 273 273 "C:/Program Files/World of Warcraft/". 274 274 275 275 Verze: 276 Verze Addonu: '.$Line['Version'].' 276 Verze Addonu: '.$Line['Version'].' 277 277 Tato verze je pro verzi hry '.$this->ClientVersion['Version'].' 278 278 279 279 Změny ve verzích: 280 280 281 281 '; 282 282 $DbResult = $System->Database->query('SELECT * FROM `CzWoWPackageVersion` ORDER BY `Date` DESC'); 283 while($Line = $DbResult->fetch_assoc()) 283 while($Line = $DbResult->fetch_assoc()) 284 284 { 285 285 $Buffer .=' 286 Verze: '.$Line['Version'].' 286 Verze: '.$Line['Version'].' 287 287 ============= 288 288 '.$Line['text'].' 289 289 290 290 '; 291 291 }
Note:
See TracChangeset
for help on using the changeset viewer.