Changeset 826 for trunk/Modules/Translation
- Timestamp:
- Mar 1, 2015, 3:38:19 PM (10 years ago)
- Location:
- trunk/Modules/Translation
- Files:
-
- 4 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Translation/Form.php
r821 r826 203 203 $Output .= '</td></tr>'; 204 204 205 // todojavascript205 // TODO: javascript 206 206 207 207 $Output .= '<script src="'.$this->System->Link('/style/jquery.js').'"></script>'. … … 238 238 239 239 $Output .= '<br/><table class="BaseTable">'. 240 '<tr><th> Překladač:</th><th>Nepřeložené</th><th>Přeložené</th>';240 '<tr><th>Google překladač:</th><th>Nepřeložené</th><th>Přeložené</th>'; 241 241 foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) 242 242 if($TextItem['Visible'] == 1) … … 245 245 '<td>'.$LineAJ[$TextItem['Column']].'</td>'. 246 246 '<td>'.GetTranslateGoogle($LineAJ[$TextItem['Column']]).'</td></tr>'; 247 248 247 249 248 $Output .= '</table>'; -
trunk/Modules/Translation/Progress.php
r816 r826 19 19 { 20 20 $Query .= 'SELECT (SELECT COUNT(DISTINCT(`Entry`)) FROM ('. 21 22 23 24 25 26 27 28 29 21 'SELECT `T`.`Entry` FROM `'.$DbRow['TablePrefix'].'` AS `T` '. 22 'WHERE (`Complete` = 1) '.$LanguageFilter.' '. 23 'AND (`VersionStart` <= '.$BuildNumber.') AND (`VersionEnd` >= '.$BuildNumber.')'. 24 ') AS `C1`) AS `Translated`, '. 25 '(SELECT COUNT(DISTINCT(`Entry`)) FROM ('. 26 'SELECT `T`.`Entry` FROM `'.$DbRow['TablePrefix'].'` AS `T` '. 27 'WHERE (`Language` = '.$this->System->Config['OriginalLanguage'].') '. 28 'AND (`VersionStart` <= '.$BuildNumber.') AND (`VersionEnd` >= '.$BuildNumber.')'. 29 ') AS `C2`) AS `Total`, "'.$DbRow['Name'].'" AS `Name` UNION '; 30 30 } 31 31 $Query = substr($Query, 0, - 6); … … 38 38 $Output .= '<table class="BaseTable">'; 39 39 $TableColumns = array( 40 41 42 43 40 array('Name' => 'Name', 'Title' => 'Jméno'), 41 array('Name' => 'Translated', 'Title' => 'Přeložených'), 42 array('Name' => 'Total', 'Title' => 'Anglických'), 43 array('Name' => 'Percent', 'Title' => 'Procenta'), 44 44 ); 45 45 … … 67 67 { 68 68 $this->Title = T('Progress'); 69 $LanguageList = GetLanguageList();69 $LanguageList = GetLanguageList(); 70 70 71 if(array_key_exists('Version', $_GET)) $_SESSION['StatVersion'] = $_GET['Version']; 72 if(!array_key_exists('StatVersion', $_SESSION)) 73 { 74 if($this->System->User->Licence(LICENCE_USER) and ($this->System->User->PreferredVersionGame != '')) 75 { 76 $_SESSION['StatVersion'] = $this->System->User->PreferredVersionGame; 77 } else 78 $_SESSION['StatVersion'] = $this->System->Config['Web']['GameVersion']; 79 } 71 if(array_key_exists('Version', $_GET)) $_SESSION['StatVersion'] = $_GET['Version']; 72 if(!array_key_exists('StatVersion', $_SESSION)) 73 { 74 if($this->System->User->Licence(LICENCE_USER) and ($this->System->User->PreferredVersionGame != '')) 75 { 76 $_SESSION['StatVersion'] = $this->System->User->PreferredVersionGame; 77 } else { 78 $_SESSION['StatVersion'] = $this->System->Config['Web']['GameVersion']; 79 } 80 } 80 81 81 if(!isset($_SESSION['language'])) 82 { 83 if($this->System->User->Licence(LICENCE_USER)) 84 { 85 $_SESSION['language'] = $this->System->User->Language; 86 } else $_SESSION['language'] = ''; 87 } 88 if(array_key_exists('language', $_GET)) { 89 if($_GET['language'] == '') $_SESSION['language'] = ''; 90 else { 91 $_SESSION['language'] = $_GET['language'] * 1; 82 if(!isset($_SESSION['language'])) 83 { 84 if($this->System->User->Licence(LICENCE_USER)) 85 { 86 $_SESSION['language'] = $this->System->User->Language; 87 } else { 88 $_SESSION['language'] = ''; 89 } 92 90 } 93 } 94 if(!array_key_exists($_SESSION['language'], $LanguageList)) $_SESSION['language'] = ''; 91 if(array_key_exists('language', $_GET)) 92 { 93 if($_GET['language'] == '') { 94 $_SESSION['language'] = ''; 95 } else { 96 $_SESSION['language'] = $_GET['language'] * 1; 97 } 98 } 99 if(!array_key_exists($_SESSION['language'], $LanguageList)) $_SESSION['language'] = ''; 95 100 96 // Show client version selection97 $Output = 'Verze klienta: ';98 $DbResult = $this->Database->query('SELECT `Version`, `Title` FROM `ClientVersion` WHERE `Imported`=1 ORDER BY `Version`');99 while($DbRow = $DbResult->fetch_assoc())100 $Output .= '<a href="?Version='.$DbRow['Version'].'" title="'.$DbRow['Title'].'">'.$DbRow['Version'].'</a> ';101 $Output .= '<br/>';101 // Show client version selection 102 $Output = 'Verze klienta: '; 103 $DbResult = $this->Database->query('SELECT `Version`, `Title` FROM `ClientVersion` WHERE `Imported`=1 ORDER BY `Version`'); 104 while($DbRow = $DbResult->fetch_assoc()) 105 $Output .= '<a href="?Version='.$DbRow['Version'].'" title="'.$DbRow['Title'].'">'.$DbRow['Version'].'</a> '; 106 $Output .= '<br/>'; 102 107 103 // Show language selection104 $Output .= 'Jazyk: ';105 $Lang = '<a href="?language=">Všechny</a>';106 if($_SESSION['language'] == '') $Output .= '<strong>'.$Lang.'</strong> ';107 else $Output .= $Lang;108 foreach($LanguageList as $Language)109 if($Language['Enabled'] == 1)110 {111 $Lang = ' <a href="?language='.$Language['Id'].'">'.$Language['Name'].'</a>';112 if($Language['Id'] == $_SESSION['language']) $Output .= '<strong>'.$Lang.'</strong> ';113 else $Output .= $Lang;114 }108 // Show language selection 109 $Output .= 'Jazyk: '; 110 $Lang = '<a href="?language=">Všechny</a>'; 111 if($_SESSION['language'] == '') $Output .= '<strong>'.$Lang.'</strong> '; 112 else $Output .= $Lang; 113 foreach($LanguageList as $Language) 114 if($Language['Enabled'] == 1) 115 { 116 $Lang = ' <a href="?language='.$Language['Id'].'">'.$Language['Name'].'</a>'; 117 if($Language['Id'] == $_SESSION['language']) $Output .= '<strong>'.$Lang.'</strong> '; 118 else $Output .= $Lang; 119 } 115 120 116 if(is_numeric($_SESSION['language'])) $LanguageName = $LanguageList[$_SESSION['language']]['Name'];117 else $LanguageName = 'Všechny';118 $Output .= '<br/><br /><h3>Statistika dokončení překladů jazyka '.$LanguageName.' pro verzi '.$_SESSION['StatVersion'].'</h3><br/>';119 $Output .= $this->ShowStatTable();121 if(is_numeric($_SESSION['language'])) $LanguageName = $LanguageList[$_SESSION['language']]['Name']; 122 else $LanguageName = 'Všechny'; 123 $Output .= '<br/><br /><h3>Statistika dokončení překladů jazyka '.$LanguageName.' pro verzi '.$_SESSION['StatVersion'].'</h3><br/>'; 124 $Output .= $this->ShowStatTable(); 120 125 121 126 return($Output); -
trunk/Modules/Translation/Save.php
r816 r826 213 213 214 214 // Update flag for experience info load 215 $this->Database->query('UPDATE `User` SET `NeedUpdate` = 1 WHERE `ID` = '.$this->System->User->Id); 215 //$this->Database->query('UPDATE `User` SET `NeedUpdate` = 1 WHERE `ID` = '.$this->System->User->Id); 216 UserLevelUpdate($this->System->User->Id); 216 217 } else $Output .= ShowMessage('Položka nenalezena', MESSAGE_CRITICAL); 217 218 } else -
trunk/Modules/Translation/Translation.php
r816 r826 7 7 include_once(dirname(__FILE__).'/Progress.php'); 8 8 include_once(dirname(__FILE__).'/LoadNames.php'); 9 include_once(dirname(__FILE__).'/UserLevel.php'); 9 10 10 11 class ModuleTranslation extends AppModule -
trunk/Modules/Translation/UserLevel.php
r824 r826 7 7 $index_level = 100; 8 8 $from_diakrit = 3; // higher xp for word with diacritics 9 $FontFile = dirname(__FILE__).'/images/FRIZQT__.ttf';10 9 11 10 function CheckDiakrit($Word) … … 22 21 } 23 22 24 function CreateImg($prefix, $user, $xp)25 {26 global $index_level, $FontFile;27 28 if($xp > 0)29 {30 $level = sqrt($xp / $index_level);31 $level = substr($level, 0, strpos($level, '.'));32 } else $level = 0;33 $xp_min = $level * $level * $index_level;34 $xp_max = ($level + 1) * ($level + 1) * $index_level;35 $xp_max = $xp_max - $xp_min;36 $xp = $xp - $xp_min;37 38 if($xp_max > 0) $Percent = ( $xp / $xp_max) * 100;39 else $Percent = 0;40 $Percent = substr($Percent, 0, 5);41 42 $PercentBar = $Percent * 2.5;43 $Image = ImageCreateTrueColor(250, 15);44 $Color1 = imagecolorallocate($Image, 214, 214, 214);45 $Color2 = imagecolorallocate($Image, 239, 131, 166);46 $Color3 = imagecolorallocate($Image, 225, 0, 0);47 imagefilledrectangle($Image, 0, 0, 250, 15, $Color1);48 imagefilledrectangle($Image, 0, 0, $PercentBar, 59, $Color2);49 ImageTTFText($Image, 11, 0, 10, 12, $Color3, $FontFile, $level.' Level');50 ImageTTFText($Image, 8, 0, 80, 12, $Color3, $FontFile, $xp.'/'.$xp_max.' xp '.$user);51 52 if(!file_exists(dirname(__FILE__).'/tmp/'.$prefix.'/')) mkdir(dirname(__FILE__).'/tmp/'.$prefix.'/');53 if(!file_exists(dirname(__FILE__).'/tmp/'.$prefix.'/'.$user.'/')) mkdir(dirname(__FILE__).'/tmp/'.$prefix.'/'.$user.'/');54 ImagePNG($Image, dirname(__FILE__).'/tmp/'.$prefix.'/'.$user.'/level.png');55 }56 57 23 function GetXPFromTranslation($UserId) 58 24 { … … 67 33 foreach($TranslationTree[$Group['Id']]['Items'] as $Index => $TextItem) 68 34 { 69 35 $GroupBy .= '`'.$TextItem['Column'].'`, '; 70 36 } 71 37 $GroupBy = substr($GroupBy, 0, -2); 72 38 73 $IDtran = $System->Database->query('SELECT * FROM `'.$Group['TablePrefix'].'` WHERE (`User` = '.$UserId.') AND (`Complete` = 1) AND (`Take` IS NOT NULL) '.$GroupBy); 39 $IDtran = $System->Database->query('SELECT * FROM `'.$Group['TablePrefix'].'` WHERE '. 40 '(`User` = '.$UserId.') AND (`Complete` = 1) AND (`Take` IS NOT NULL) '.$GroupBy); 74 41 while($Line = $IDtran->fetch_array()) 75 42 { … … 80 47 foreach($TranslationTree[$Group['Id']]['Items'] as $Index => $TextItem) 81 48 { 82 if(($Line[$TextItem['Column']] <> $LineComparison[$TextItem['Column']]) and (strlen($Line[$TextItem['Column']]) > (strlen($LineComparison[$TextItem['Column']]) * 0.5))) 49 if(($Line[$TextItem['Column']] <> $LineComparison[$TextItem['Column']]) and 50 (strlen($Line[$TextItem['Column']]) > (strlen($LineComparison[$TextItem['Column']]) * 0.5))) 83 51 { 84 52 $TextArr = explode(' ', $Line[$TextItem['Column']]); … … 91 59 } else 92 60 { 93 if (($Line[$TextItem['Column']] == $LineComparison[$TextItem['Column']]) and ('0' == $LineComparison['Language']) and ($LineComparison[$TextItem['Column']] <> '') and ($TextItem['Column'] <> 'ShortCut')) $translated = false; 61 if (($Line[$TextItem['Column']] == $LineComparison[$TextItem['Column']]) and 62 ('0' == $LineComparison['Language']) and ($LineComparison[$TextItem['Column']] <> '') and 63 ($TextItem['Column'] <> 'ShortCut')) $translated = false; 94 64 } 95 65 } … … 101 71 } 102 72 103 function ImgLevelUpdate()73 function UserLevelUpdate($UserId) 104 74 { 105 75 global $System, $TranslationTree, $Config; 106 76 107 77 // Main code for users 108 $DbResult = $System->Database->query('SELECT `ID`, `Name` FROM `User` WHERE ` NeedUpdate` = 1');78 $DbResult = $System->Database->query('SELECT `ID`, `Name` FROM `User` WHERE `Id` = '.$UserId); 109 79 if($DbResult->num_rows > 0) 110 80 { … … 127 97 $xp = GetXPFromTranslation($LineUser['ID']); 128 98 $System->Database->query('UPDATE `User` SET `XP` = '.$xp.', `TranslatedCount` = '.$TranslatedCount.' WHERE `User`.`ID` = '.$LineUser['ID']); 129 CreateImg('user', $LineUser['Name'], $xp);130 99 } 131 132 // Main code for translation teams133 $DbResult = $System->Database->query('SELECT `ID`, `Name`, (SELECT AVG(`XP`) FROM `User` WHERE `Team` = `Team`.`Id`) AS `Average` '.134 'FROM `Team` WHERE `ID` IN (SELECT `Team` FROM `User` WHERE `NeedUpdate` = 1)');135 while($LineTeam = $DbResult->fetch_array())136 {137 CreateImg('team', $LineTeam['Name'], substr($LineTeam['Average'], 0, strpos($LineTeam['Average'],'.'))); //image creation138 }139 $System->Database->query('UPDATE `User` SET `NeedUpdate` = 0');140 100 } 141 101 } 142 143 function ImgLevelShow()144 {145 global $System;146 147 // Do update for all users148 $System->Database->query('UPDATE `User` SET `NeedUpdate` = 1');149 ImgLevelUpdate();150 151 $Output = '<strong>Uživatelé</strong><br/>';152 $ID = $System->Database->query('SELECT `ID`, `Name` FROM `User`');153 while($LineUser = $ID->fetch_array())154 {155 $Output .= '<img src="'.$System->Link('/tmp/user/'.$LineUser['Name'].'/level.png').'"/> '.$LineUser['Name'].'<br />';156 }157 158 $Output .= '<br/><strong>Týmy</strong><br/>';159 $ID = $System->Database->query('SELECT `ID`, `Name` FROM `Team`');160 while($LineTeam = $ID->fetch_array())161 {162 $Output .= '<img src="'.$System->Link('/tmp/team/'.$LineTeam['Name'].'/level.png').'"/> '.$LineTeam['Name'].'<br />';163 }164 WriteLog('Přegenerovány obrázky úrovní překladatelů a týmů', LOG_TYPE_ADMINISTRATION);165 return($Output);166 }
Note:
See TracChangeset
for help on using the changeset viewer.