Changeset 816 for trunk/img_level.php
- Timestamp:
- Feb 22, 2015, 11:20:50 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/img_level.php
r771 r816 14 14 $Diakrit = array("á","č","ď","é","ě","í","ľ","ň","ó","ř","š","ť","ú", 15 15 "ů","ý","ž","Á","Č","Ď","É","Ě","Í","Ľ","Ň","Ó","Ř","Š","Ť","Ú","Ů","Ý","Ž"); 16 for($i = 0; $i < count($Diakrit); $i = $i + 1) 16 for($i = 0; $i < count($Diakrit); $i = $i + 1) 17 17 { 18 if(strpos($Word, $Diakrit[$i]) <> false) 18 if(strpos($Word, $Diakrit[$i]) <> false) 19 19 $Result = true; 20 20 } … … 22 22 } 23 23 24 function CreateImg($prefix, $user, $xp) 24 function CreateImg($prefix, $user, $xp) 25 25 { 26 global $index_level, $FontFile; 27 28 if($xp > 0) 26 global $index_level, $FontFile; 27 28 if($xp > 0) 29 29 { 30 30 $level = sqrt($xp / $index_level); … … 35 35 $xp_max = $xp_max - $xp_min; 36 36 $xp = $xp - $xp_min; 37 38 if($xp_max > 0) $Percent = ( $xp / $xp_max) * 100; 37 38 if($xp_max > 0) $Percent = ( $xp / $xp_max) * 100; 39 39 else $Percent = 0; 40 40 $Percent = substr($Percent, 0, 5); … … 49 49 ImageTTFText($Image, 11, 0, 10, 12, $Color3, $FontFile, $level.' Level'); 50 50 ImageTTFText($Image, 8, 0, 80, 12, $Color3, $FontFile, $xp.'/'.$xp_max.' xp '.$user); 51 51 52 52 if(!file_exists('tmp/'.$prefix.'/')) mkdir('tmp/'.$prefix.'/'); 53 53 if(!file_exists('tmp/'.$prefix.'/'.$user.'/')) mkdir('tmp/'.$prefix.'/'.$user.'/'); 54 ImagePNG($Image, 'tmp/'.$prefix.'/'.$user.'/level.png'); 54 ImagePNG($Image, 'tmp/'.$prefix.'/'.$user.'/level.png'); 55 55 } 56 56 57 function GetXPFromTranslation($UserId) 57 function GetXPFromTranslation($UserId) 58 58 { 59 59 global $System, $TranslationTree, $xp_from_word, $from_diakrit; 60 60 61 61 $xp = 0; 62 foreach($TranslationTree as $Group) 63 { 64 if($Group['TablePrefix'] != '') 62 foreach($TranslationTree as $Group) 63 { 64 if($Group['TablePrefix'] != '') 65 65 { 66 66 $GroupBy = 'GROUP BY '; 67 foreach($TranslationTree[$Group['Id']]['Items'] as $Index => $TextItem) 68 { 67 foreach($TranslationTree[$Group['Id']]['Items'] as $Index => $TextItem) 68 { 69 69 $GroupBy .= '`'.$TextItem['Column'].'`, '; 70 } 70 } 71 71 $GroupBy = substr($GroupBy, 0, -2); 72 72 73 73 $IDtran = $System->Database->query('SELECT * FROM `'.$Group['TablePrefix'].'` WHERE (`User` = '.$UserId.') AND (`Complete` = 1) AND (`Take` IS NOT NULL) '.$GroupBy); 74 while($Line = $IDtran->fetch_array()) 75 { 74 while($Line = $IDtran->fetch_array()) 75 { 76 76 $DbResult = $System->Database->query('SELECT * FROM `'.$Group['TablePrefix'].'` WHERE `ID` = '.$Line['Take']); 77 77 $LineComparison = $DbResult->fetch_assoc(); 78 $xp_translation = 0; 78 $xp_translation = 0; 79 79 $translated = true; 80 foreach($TranslationTree[$Group['Id']]['Items'] as $Index => $TextItem) 81 { 82 if(($Line[$TextItem['Column']] <> $LineComparison[$TextItem['Column']]) and (strlen($Line[$TextItem['Column']]) > (strlen($LineComparison[$TextItem['Column']]) * 0.5))) 83 { 80 foreach($TranslationTree[$Group['Id']]['Items'] as $Index => $TextItem) 81 { 82 if(($Line[$TextItem['Column']] <> $LineComparison[$TextItem['Column']]) and (strlen($Line[$TextItem['Column']]) > (strlen($LineComparison[$TextItem['Column']]) * 0.5))) 83 { 84 84 $TextArr = explode(' ', $Line[$TextItem['Column']]); 85 foreach($TextArr as $Word) 86 { 85 foreach($TextArr as $Word) 86 { 87 87 if(CheckDiakrit($Word)) $indikator = $from_diakrit; 88 88 else $indikator = 1; 89 89 $xp_translation = $xp_translation + ($indikator * $xp_from_word); 90 } 91 } else 90 } 91 } else 92 92 { 93 93 if (($Line[$TextItem['Column']] == $LineComparison[$TextItem['Column']]) and ('0' == $LineComparison['Language']) and ($LineComparison[$TextItem['Column']] <> '') and ($TextItem['Column'] <> 'ShortCut')) $translated = false; 94 94 } 95 } 95 } 96 96 if($translated) $xp = $xp + $xp_translation; // XP addition for entire translation if complete translated 97 97 } … … 102 102 103 103 function ImgLevelUpdate() 104 { 104 { 105 105 global $System, $TranslationTree, $Config; 106 106 … … 109 109 if($DbResult->num_rows > 0) 110 110 { 111 while($LineUser = $DbResult->fetch_array()) 111 while($LineUser = $DbResult->fetch_array()) 112 112 { 113 113 // Build TranslatedCount query … … 115 115 if(count($TranslationTree) > 0) 116 116 { 117 117 foreach($TranslationTree as $Group) 118 118 if($Group['TablePrefix'] != '') 119 119 { … … 124 124 $TranslatedCount = substr($TranslatedCount, 0, -3).')'; 125 125 } else $TranslatedCount = 0; 126 127 $xp = GetXPFromTranslation($LineUser['ID']); 126 127 $xp = GetXPFromTranslation($LineUser['ID']); 128 128 $System->Database->query('UPDATE `User` SET `XP` = '.$xp.', `TranslatedCount` = '.$TranslatedCount.' WHERE `User`.`ID` = '.$LineUser['ID']); 129 129 CreateImg('user', $LineUser['Name'], $xp); … … 133 133 $DbResult = $System->Database->query('SELECT `ID`, `Name`, (SELECT AVG(`XP`) FROM `User` WHERE `Team` = `Team`.`Id`) AS `Average` '. 134 134 'FROM `Team` WHERE `ID` IN (SELECT `Team` FROM `User` WHERE `NeedUpdate` = 1)'); 135 while($LineTeam = $DbResult->fetch_array()) 135 while($LineTeam = $DbResult->fetch_array()) 136 136 { 137 137 CreateImg('team', $LineTeam['Name'], substr($LineTeam['Average'], 0, strpos($LineTeam['Average'],'.'))); //image creation … … 144 144 { 145 145 global $System; 146 146 147 147 // Do update for all users 148 148 $System->Database->query('UPDATE `User` SET `NeedUpdate` = 1'); 149 149 ImgLevelUpdate(); 150 150 151 151 $Output = '<strong>Uživatelé</strong><br/>'; 152 152 $ID = $System->Database->query('SELECT `ID`, `Name` FROM `User`'); 153 while($LineUser = $ID->fetch_array()) 153 while($LineUser = $ID->fetch_array()) 154 154 { 155 155 $Output .= '<img src="tmp/user/'.$LineUser['Name'].'/level.png" /> '.$LineUser['Name'].'<br />'; … … 158 158 $Output .= '<br/><strong>Týmy</strong><br/>'; 159 159 $ID = $System->Database->query('SELECT `ID`, `Name` FROM `Team`'); 160 while($LineTeam = $ID->fetch_array()) 160 while($LineTeam = $ID->fetch_array()) 161 161 { 162 162 $Output .= '<img src="tmp/team/'.$LineTeam['Name'].'/level.png" /> '.$LineTeam['Name'].'<br />'; 163 163 } 164 WriteLog('Přegenerovány obrázky úrovní překladatelů a týmů', LOG_TYPE_ADMINISTRATION); 164 WriteLog('Přegenerovány obrázky úrovní překladatelů a týmů', LOG_TYPE_ADMINISTRATION); 165 165 return($Output); 166 166 }
Note:
See TracChangeset
for help on using the changeset viewer.