Changeset 46 for trunk/Application/View
- Timestamp:
- Jul 27, 2014, 9:05:14 PM (10 years ago)
- Location:
- trunk/Application/View
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application/View/Graph.php
r45 r46 6 6 class GraphView extends View 7 7 { 8 var $DefaultWidth; 9 var $DefaultHeight; 10 11 function __construct($System) 12 { 13 parent::__construct($System); 14 $this->DefaultWidth = 800; 15 $this->DefaultHeight = 200; 16 } 17 8 18 function Render() 9 19 { 10 if(array_key_exists('Debug', $_GET)) $Debug = $_GET['Debug']; 20 if(array_key_exists('Debug', $_GET)) $Debug = $_GET['Debug']; 11 21 else $Debug = 0; 12 22 13 23 if(!array_key_exists('From', $_GET)) die('Musíte zadat čas počátku'); 14 24 $StartTime = addslashes($_GET['From']); … … 18 28 $TimeDifference = $EndTime - $StartTime; 19 29 if(!array_key_exists('Measure', $_GET)) die('Musíte zadat měřenou veličinu'); 20 $MeasureId = addslashes($_GET['Measure']); 21 if(!array_key_exists('Width', $_GET)) $Width = $ DefaultWidth;30 $MeasureId = addslashes($_GET['Measure']); 31 if(!array_key_exists('Width', $_GET)) $Width = $this->DefaultWidth; 22 32 else $Width = addslashes($_GET['Width']); 23 if(!array_key_exists('Height', $_GET)) $Height = $ DefaultHeight;33 if(!array_key_exists('Height', $_GET)) $Height = $this->DefaultHeight; 24 34 else $Height = addslashes($_GET['Height']); 25 35 if(!array_key_exists('Differential', $_GET)) $Differential = $this->Config['Application']['DefaultVariables']['Differential']; … … 50 60 $Points = $Measure->GetValues($StartTime, $EndTime, $Level); 51 61 52 if($Debug) echo('Points count: '.count($Points).'<br/>'); 53 //if($Debug) foreach($Points as $Index => $Item) 54 // echo($Index.': '.$Item['min'].'<br >');62 if($Debug) echo('Points count: '.count($Points).'<br/>'); 63 //if($Debug) foreach($Points as $Index => $Item) 64 // echo($Index.': '.$Item['min'].'<br/>'); 55 65 56 66 // Calculate total max, avg, min value … … 73 83 $AvgValue = $AvgValue / count($Points); //round( * $Measure['Divider']) / $Measure['Divider']; 74 84 75 // Generate polygon and recalculate y values to fit graph height 85 // Generate polygon and recalculate y values to fit graph height 76 86 $PointsMin = array(0, $Height - 1); 77 87 $PointsAvg = array(0, $Height - 1); 78 88 $PointsMax = array(0, $Height - 1); 79 89 if(($MaxValue - $MinValue) == 0) $MaxValue = $MinValue + 1; 80 { 90 { 81 91 foreach($Points as $Index => $Item) 82 92 { … … 87 97 $PointsMax[] = $Index * $Width / $Measure->DivisionCount; 88 98 $PointsMax[] = $Height - 1 - ($Points[$Index]['Max'] - $MinValue) / ($MaxValue - $MinValue) * $Height * $this->Config['Application']['ValueToImageHeigthCoefficient']; 89 //echo($Index.' - '.$Item.' '.$Points[$Index].'<br >');99 //echo($Index.' - '.$Item.' '.$Points[$Index].'<br/>'); 90 100 } 91 101 } … … 107 117 //array_unshift($Points, 0); 108 118 //$Points[] = $Width - 1; 109 //$Points[] = $Height - 1; 119 //$Points[] = $Height - 1; echo('sds'); 120 110 121 111 122 //print_r($PointsMax); 112 123 113 124 // Generate image 114 if(!$Debug) 125 if(!$Debug) 115 126 { 116 127 Header('Content-type: image/png'); 117 Header('Cache-Control: no-cache'); // Dynamic graph - no cache 128 Header('Cache-Control: no-cache'); // Dynamic graph - no cache 118 129 $Image = @imagecreate($Width, $Height); 119 130 $BackgroundColor = imagecolorallocate($Image, 255, 255, 255); … … 132 143 imagefilledpolygon($Image, $PointsAvg, count($PointsAvg) / 2, $LightGreen); 133 144 imagefilledpolygon($Image, $PointsMin, count($PointsMin) / 2, $LightBlue); 134 145 135 146 $TimeMarks = array(1, 60, 60*60, 60*60*24, 60*60*24*7, 60*60*24*30, 60*60*24*365, 60*60*24*365*10); 136 147 137 148 $TimeRange = $EndTime - $StartTime; 138 149 $TimeMarksIndex = 0; … … 140 151 if($TimeMarksIndex < 2) $TimeMarksIndex = 2; 141 152 $MajorTimeMarks = $TimeMarks[$TimeMarksIndex - 1]; 142 $MinorTimeMarks = $TimeMarks[$TimeMarksIndex - 2]; 143 144 $TimeShift = $Measure->AlignTime($StartTime, $MajorTimeMarks) - $StartTime; 153 $MinorTimeMarks = $TimeMarks[$TimeMarksIndex - 2]; 154 155 $TimeShift = $Measure->AlignTime($StartTime, $MajorTimeMarks) - $StartTime; 145 156 //imagestring($Image, 10, 40, 50, $TimeShift, $Black); 146 157 147 158 // Zobraz měřítko Y 148 159 $VerticalLinesDistance = $Height / $VerticalLinesCount; … … 152 163 for($X = 1; $X < $Width; $X = $X + 3) imagesetpixel($Image, $X, $Y, $Gray); 153 164 //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED); 154 } 155 156 $TimeShift = $Measure->AlignTime($StartTime, $MinorTimeMarks) - $StartTime; 157 165 } 166 167 $TimeShift = $Measure->AlignTime($StartTime, $MinorTimeMarks) - $StartTime; 168 158 169 // Zobraz měřítko X 159 170 $LastTextEnd = 0; 160 171 for($Time = $StartTime; $Time < $EndTime; $Time += $MajorTimeMarks) 161 172 { 162 $X = round(($Time - $StartTime + $TimeShift) / $TimeRange * $Width) % $Width; 173 $X = round(($Time - $StartTime + $TimeShift) / $TimeRange * $Width) % $Width; 163 174 //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED); 164 175 if(($MajorTimeMarks > 60 * 60 * 24)) $Text = date('j.n.Y', $Time + $TimeShift); … … 172 183 } 173 184 else for($Y = 0; $Y < $Height; $Y = $Y + 3) imagesetpixel($Image, $X, $Y, $Gray); 174 } 175 185 } 186 176 187 // Popisky osy Y 177 188 for($I = 1; $I <= $VerticalLinesCount; $I++) … … 183 194 if(($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10) 184 195 imagettftext($Image, $FontSize, 0, 2, $Y - ($BoundBox[5] - $BoundBox[1]) / 2, $Black, $FontFile, $Text); 185 } 196 } 186 197 $GenerationTime = floor(($this->System->GetMicrotime() - $StopWatchStart) * 1000 ) / 1000; 187 198 … … 208 219 imagepng($Image); 209 220 imagedestroy($Image); 210 } 221 } 211 222 } 212 223 } -
trunk/Application/View/Main.php
r45 r46 24 24 'caption' => 'Měsíc', 25 25 'period' => 2592000, // 3600 * 24 * 30, 26 ), 26 ), 27 27 'year' => array( 28 28 'caption' => 'Rok', … … 46 46 for($I = 1; $I < 32; $I++) 47 47 { 48 if($I == $TimeParts['mday']) $Selected = ' selected="1"'; else $Selected = ''; 48 if($I == $TimeParts['mday']) $Selected = ' selected="1"'; else $Selected = ''; 49 49 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 50 50 } … … 54 54 $Output .= '<select name="Month">'; 55 55 foreach($this->Months as $Index => $Month) 56 { 56 { 57 57 if($Index == $TimeParts['mon']) $Selected = ' selected="1"'; else $Selected = ''; 58 58 if($Index > 0) $Output .= '<option value="'.$Index.'"'.$Selected.'>'.$Month.'</option>'; … … 63 63 $Output .= '<select name="Year">'; 64 64 for($I = 2000; $I < 2010; $I++) 65 { 65 { 66 66 if($I == $TimeParts['year']) $Selected = ' selected="1"'; else $Selected = ''; 67 67 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; … … 72 72 $Output .= '<select name="Hour">'; 73 73 for($I = 0; $I < 24; $I++) 74 { 74 { 75 75 if($I == $TimeParts['hours']) $Selected = ' selected="1"'; else $Selected = ''; 76 76 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; … … 80 80 // Minute selection 81 81 $Output .= '<select name="Minute">'; 82 for($I = 0; $I < 60; $I++) 82 for($I = 0; $I < 60; $I++) 83 83 { 84 84 if($I == $TimeParts['minutes']) $Selected = ' selected="1"'; else $Selected = ''; … … 99 99 { 100 100 $Debug = 0; 101 102 101 foreach($this->Config['Application']['DefaultVariables'] as $Index => $Variable) 103 102 { … … 112 111 $_SESSION['TimeEnd'] = time() - 60; 113 112 $_SESSION['TimeStart'] = $_SESSION['TimeEnd'] - $this->GraphTimeRanges[$_SESSION['Period']]['period']; 114 } 113 } 115 114 116 115 $Output = '<div class="Title">Statistiky</div>'; … … 130 129 } 131 130 } 132 break; 131 break; 133 132 case 'SetTimeNow': 134 if(array_key_exists('Time', $_GET)) 133 if(array_key_exists('Time', $_GET)) 135 134 { 136 135 if(($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd')) … … 142 141 break; 143 142 } 144 $Output .= '<strong>Časový úsek:</strong><br >';143 $Output .= '<strong>Časový úsek:</strong><br/>'; 145 144 // Show graf time range menu 146 145 if($_SESSION['TimeSpecify'] == 0) … … 150 149 $Output .= '<a href="?Period='.$Index.'">'.$Item['caption'].'</a> '; 151 150 $Output .= '<br/>'; 152 $Output .= '<a href="?TimeSpecify=1">Přesnější nastavení...</a><br >';151 $Output .= '<a href="?TimeSpecify=1">Přesnější nastavení...</a><br/>'; 153 152 } else { 154 153 $Output .= '<table cellspacing="0" cellpadding="2" border="0">'; … … 156 155 $Output .= '<tr><td>Konec:</td><td>'.$this->EditTime('TimeEnd').'</td></tr>'; 157 156 $Output .= '</table>'; 158 $Output .= '<a href="?TimeSpecify=0">Jednoduché nastavení...</a><br >';157 $Output .= '<a href="?TimeSpecify=0">Jednoduché nastavení...</a><br/>'; 159 158 } 160 159 $Output .= '<br/>'.$this->Graph(); … … 162 161 $Output .= '<br/>'.$this->MeasureTable(); 163 162 return($Output); 164 } 165 163 } 164 166 165 function Graph() 167 166 { 168 167 $Output = '<strong>Graf:</strong><br/>'; 169 $Output .= '<img alt="Graf" src="?M=Graph&Measure='.$_SESSION['Measure'].'&From='.$_SESSION['TimeStart'].'&To='.$_SESSION['TimeEnd'].'&Width='.$this->Config['Application']['GraphSize']['Width'].'&Height='.$this->Config['Application']['GraphSize']['Height'].'&Differential='.$_SESSION['Differential'].'" width="'.$this->Config['Application']['GraphSize']['Width'].'" height="'.$this->Config['Application']['GraphSize']['Height'].'"><br>'; 170 $Output .= '<a href="?Measure='.$_SESSION['Measure'].'&TimeStart='.$_SESSION['TimeStart'].'&TimeEnd='.$_SESSION['TimeEnd'].'&TimeSpecify=1&Differential='.$_SESSION['Differential'].'">Odkaz na vybraný graf</a><br>'; 168 $Output .= '<img alt="Graf" src="?M=Graph&Measure='.$_SESSION['Measure']. 169 '&From='.$_SESSION['TimeStart'].'&To='.$_SESSION['TimeEnd'].'&Width='. 170 $this->Config['Application']['ImageWidth'].'&Height='.$this->Config['Application']['ImageHeight']. 171 '&Differential='.$_SESSION['Differential'].'" width="'.$this->Config['Application']['ImageWidth']. 172 '" height="'.$this->Config['Application']['ImageHeight'].'"/><br/>'; 173 $Output .= '<a href="?Measure='.$_SESSION['Measure'].'&TimeStart='.$_SESSION['TimeStart'].'&TimeEnd='.$_SESSION['TimeEnd'].'&TimeSpecify=1&Differential='.$_SESSION['Differential'].'">Odkaz na vybraný graf</a><br/>'; 171 174 //print_r(GetValues($Measure, $TimeStart, $TimeEnd)); 172 175 return($Output); 173 176 } 174 177 175 178 function MeasureTable() 176 179 { … … 202 205 $LastMeasureValue = ' '; 203 206 } 204 if($Measure['Continuity'] == 1) $Interpolate = 'Ano'; 207 if($Measure['Continuity'] == 1) $Interpolate = 'Ano'; 205 208 else $Interpolate = 'Ne'; 206 209 if($Measure['Info'] == '') $Measure['Info'] = ' '; … … 214 217 //print_r(gd_info()); 215 218 //print_r($_SESSION); 216 219 217 220 //ShowPage($Output); 218 221 //echo(AddPrefixMultipliers('-0.000000071112345', 'B')); -
trunk/Application/View/Page.php
r40 r46 11 11 12 12 function ShowHeader($Title, $Path) 13 { 13 { 14 14 $BodyParam = ''; 15 15 if($this->Load != '') $BodyParam .= ' onload="'.$this->Load.'"'; 16 16 if($this->Unload != '') $BodyParam .= ' onunload="'.$this->Unload.'"'; 17 17 $Output = '<?xml version="1.0" encoding="'.$this->Config['Web']['Charset'].'"?>'."\n". 18 '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'.19 '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">'.18 '<!DOCTYPE html>'. 19 '<html>'. 20 20 '<head><link rel="stylesheet" href="Application/Style/Style.css" type="text/css" media="all" />'. 21 '<meta http-equiv="content-type" content=" application/xhtml+xml; charset='.$this->Config['Web']['Charset'].'" />'.21 '<meta http-equiv="content-type" content="text/html; charset='.$this->Config['Web']['Charset'].'" />'. 22 22 '<script type="text/javascript" src="Application/Style/Global.js"></script>'. 23 23 '<title>'.$this->Config['Web']['Title'].' - '.$Path.'</title> … … 25 25 return($Output); 26 26 } 27 27 28 28 function ShowFooter() 29 29 { 30 30 global $ScriptTimeStart; 31 31 32 32 $Time = round($this->System->GetMicrotime() - $ScriptTimeStart, 2); 33 33 $Output = '<div class="Footer"> … … 39 39 if($this->Config['Web']['ShowRuntimeInfo'] == true) $Output .= '<li>Doba generování: '.$Time.' s / '.ini_get('max_execution_time').' s</li><li>Použitá paměť: '.HumanSize(memory_get_peak_usage(FALSE)).' / '.ini_get('memory_limit').'B</li>'; 40 40 $Output .= '</ul></div></body></html>'; 41 return($Output); 41 return($Output); 42 42 } 43 43 44 44 function GetOutput($Content) 45 { 45 { 46 46 global $Config; 47 47 48 48 $Output = $this->ShowHeader($this->FullTitle, $this->ShortTitle).$Content; 49 49 $Output .= $this->ShowFooter(); … … 54 54 55 55 function SystemMessage($Text) 56 { 56 { 57 57 return('<table align="center"><tr><td><div class="SystemMessage"><h3>Systémová zpráva</h3><div>'.$Text.'</div></div</td></tr></table>'); 58 58 //ShowFooter(); 59 59 //die(); 60 60 } 61 61 62 62 function AccessDenied() 63 63 { 64 return($this->GetOutput($this->SystemMessage($this->System->Translate('AccessDenied')))); 64 return($this->GetOutput($this->SystemMessage($this->System->Translate('AccessDenied')))); 65 65 } 66 66 }
Note:
See TracChangeset
for help on using the changeset viewer.