@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | - /* |
|
2 | + /* |
|
3 | 3 | pSplit - class to draw spline splitted charts |
4 | 4 | |
5 | 5 | Version : 2.1.3 |
@@ -13,119 +13,119 @@ discard block |
||
13 | 13 | You can find the whole class documentation on the pChart web site. |
14 | 14 | */ |
15 | 15 | |
16 | - define("TEXT_POS_TOP" , 690001); |
|
17 | - define("TEXT_POS_RIGHT" , 690002); |
|
16 | + define("TEXT_POS_TOP" , 690001); |
|
17 | + define("TEXT_POS_RIGHT" , 690002); |
|
18 | 18 | |
19 | - /* pSplit class definition */ |
|
20 | - class pSplit |
|
21 | - { |
|
22 | - var $pChartObject; |
|
19 | + /* pSplit class definition */ |
|
20 | + class pSplit |
|
21 | + { |
|
22 | + var $pChartObject; |
|
23 | 23 | |
24 | - /* Class creator */ |
|
25 | - function pSplit() |
|
24 | + /* Class creator */ |
|
25 | + function pSplit() |
|
26 | 26 | { } |
27 | 27 | |
28 | - /* Create the encoded string */ |
|
29 | - function drawSplitPath($Object,$Values,$Format="") |
|
28 | + /* Create the encoded string */ |
|
29 | + function drawSplitPath($Object,$Values,$Format="") |
|
30 | 30 | { |
31 | - $this->pChartObject = $Object; |
|
32 | - |
|
33 | - $Spacing = isset($Format["Spacing"]) ? $Format["Spacing"] : 20; |
|
34 | - $TextPadding = isset($Format["TextPadding"]) ? $Format["TextPadding"] : 2; |
|
35 | - $TextPos = isset($Format["TextPos"]) ? $Format["TextPos"] : TEXT_POS_TOP; |
|
36 | - $Surrounding = isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL; |
|
37 | - $Force = isset($Format["Force"]) ? $Format["Force"] : 70; |
|
38 | - $Segments = isset($Format["Segments"]) ? $Format["Segments"] : 15; |
|
39 | - $FontSize = $Object->FontSize; |
|
40 | - $X1 = $Object->GraphAreaX1; |
|
41 | - $Y1 = $Object->GraphAreaY1; |
|
42 | - $X2 = $Object->GraphAreaX2; |
|
43 | - $Y2 = $Object->GraphAreaY2; |
|
44 | - |
|
45 | - /* Data Processing */ |
|
46 | - $Data = $Values->getData(); |
|
47 | - $Palette = $Values->getPalette(); |
|
48 | - |
|
49 | - $LabelSerie = $Data["Abscissa"]; |
|
50 | - $DataSerie = ""; |
|
51 | - |
|
52 | - foreach($Data["Series"] as $SerieName => $Value) |
|
53 | - { if ( $SerieName != $LabelSerie && $DataSerie == "" ) { $DataSerie = $SerieName; } } |
|
54 | - |
|
55 | - $DataSerieSum = array_sum($Data["Series"][$DataSerie]["Data"]); |
|
56 | - $DataSerieCount = count($Data["Series"][$DataSerie]["Data"]); |
|
57 | - |
|
58 | - /* Scale Processing */ |
|
59 | - if ( $TextPos == TEXT_POS_RIGHT ) |
|
60 | - $YScale = (($Y2-$Y1) - (($DataSerieCount+1)*$Spacing)) / $DataSerieSum; |
|
61 | - else |
|
62 | - $YScale = (($Y2-$Y1) - ($DataSerieCount*$Spacing)) / $DataSerieSum; |
|
63 | - $LeftHeight = $DataSerieSum * $YScale; |
|
64 | - |
|
65 | - /* Re-compute graph width depending of the text mode choosen */ |
|
66 | - if ( $TextPos == TEXT_POS_RIGHT ) |
|
67 | - { |
|
68 | - $MaxWidth = 0; |
|
69 | - foreach($Data["Series"][$LabelSerie]["Data"] as $Key => $Label) |
|
31 | + $this->pChartObject = $Object; |
|
32 | + |
|
33 | + $Spacing = isset($Format["Spacing"]) ? $Format["Spacing"] : 20; |
|
34 | + $TextPadding = isset($Format["TextPadding"]) ? $Format["TextPadding"] : 2; |
|
35 | + $TextPos = isset($Format["TextPos"]) ? $Format["TextPos"] : TEXT_POS_TOP; |
|
36 | + $Surrounding = isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL; |
|
37 | + $Force = isset($Format["Force"]) ? $Format["Force"] : 70; |
|
38 | + $Segments = isset($Format["Segments"]) ? $Format["Segments"] : 15; |
|
39 | + $FontSize = $Object->FontSize; |
|
40 | + $X1 = $Object->GraphAreaX1; |
|
41 | + $Y1 = $Object->GraphAreaY1; |
|
42 | + $X2 = $Object->GraphAreaX2; |
|
43 | + $Y2 = $Object->GraphAreaY2; |
|
44 | + |
|
45 | + /* Data Processing */ |
|
46 | + $Data = $Values->getData(); |
|
47 | + $Palette = $Values->getPalette(); |
|
48 | + |
|
49 | + $LabelSerie = $Data["Abscissa"]; |
|
50 | + $DataSerie = ""; |
|
51 | + |
|
52 | + foreach($Data["Series"] as $SerieName => $Value) |
|
53 | + { if ( $SerieName != $LabelSerie && $DataSerie == "" ) { $DataSerie = $SerieName; } } |
|
54 | + |
|
55 | + $DataSerieSum = array_sum($Data["Series"][$DataSerie]["Data"]); |
|
56 | + $DataSerieCount = count($Data["Series"][$DataSerie]["Data"]); |
|
57 | + |
|
58 | + /* Scale Processing */ |
|
59 | + if ( $TextPos == TEXT_POS_RIGHT ) |
|
60 | + $YScale = (($Y2-$Y1) - (($DataSerieCount+1)*$Spacing)) / $DataSerieSum; |
|
61 | + else |
|
62 | + $YScale = (($Y2-$Y1) - ($DataSerieCount*$Spacing)) / $DataSerieSum; |
|
63 | + $LeftHeight = $DataSerieSum * $YScale; |
|
64 | + |
|
65 | + /* Re-compute graph width depending of the text mode choosen */ |
|
66 | + if ( $TextPos == TEXT_POS_RIGHT ) |
|
67 | + { |
|
68 | + $MaxWidth = 0; |
|
69 | + foreach($Data["Series"][$LabelSerie]["Data"] as $Key => $Label) |
|
70 | 70 | { |
71 | - $Boundardies = $Object->getTextBox(0,0,$Object->FontName,$Object->FontSize,0,$Label); |
|
72 | - if ( $Boundardies[1]["X"] > $MaxWidth ) { $MaxWidth = $Boundardies[1]["X"] + $TextPadding*2; } |
|
71 | + $Boundardies = $Object->getTextBox(0,0,$Object->FontName,$Object->FontSize,0,$Label); |
|
72 | + if ( $Boundardies[1]["X"] > $MaxWidth ) { $MaxWidth = $Boundardies[1]["X"] + $TextPadding*2; } |
|
73 | + } |
|
74 | + $X2 = $X2 - $MaxWidth; |
|
73 | 75 | } |
74 | - $X2 = $X2 - $MaxWidth; |
|
75 | - } |
|
76 | 76 | |
77 | - /* Drawing */ |
|
78 | - $LeftY = ((($Y2-$Y1) / 2) + $Y1) - ($LeftHeight/2); |
|
79 | - $RightY = $Y1; |
|
80 | - $VectorX = (($X2-$X1) / 2); |
|
77 | + /* Drawing */ |
|
78 | + $LeftY = ((($Y2-$Y1) / 2) + $Y1) - ($LeftHeight/2); |
|
79 | + $RightY = $Y1; |
|
80 | + $VectorX = (($X2-$X1) / 2); |
|
81 | 81 | |
82 | - foreach($Data["Series"][$DataSerie]["Data"] as $Key => $Value) |
|
83 | - { |
|
84 | - if ( isset($Data["Series"][$LabelSerie]["Data"][$Key]) ) |
|
82 | + foreach($Data["Series"][$DataSerie]["Data"] as $Key => $Value) |
|
83 | + { |
|
84 | + if ( isset($Data["Series"][$LabelSerie]["Data"][$Key]) ) |
|
85 | 85 | $Label = $Data["Series"][$LabelSerie]["Data"][$Key]; |
86 | - else |
|
86 | + else |
|
87 | 87 | $Label = "-"; |
88 | 88 | |
89 | - $LeftY1 = $LeftY; |
|
90 | - $LeftY2 = $LeftY + $Value * $YScale; |
|
89 | + $LeftY1 = $LeftY; |
|
90 | + $LeftY2 = $LeftY + $Value * $YScale; |
|
91 | 91 | |
92 | - $RightY1 = $RightY + $Spacing; |
|
93 | - $RightY2 = $RightY + $Spacing + $Value * $YScale;; |
|
92 | + $RightY1 = $RightY + $Spacing; |
|
93 | + $RightY2 = $RightY + $Spacing + $Value * $YScale;; |
|
94 | 94 | |
95 | - $Settings = array("R"=>$Palette[$Key]["R"],"G"=>$Palette[$Key]["G"],"B"=>$Palette[$Key]["B"],"Alpha"=>$Palette[$Key]["Alpha"],"NoDraw"=>TRUE,"Segments"=>$Segments,"Surrounding"=>$Surrounding); |
|
95 | + $Settings = array("R"=>$Palette[$Key]["R"],"G"=>$Palette[$Key]["G"],"B"=>$Palette[$Key]["B"],"Alpha"=>$Palette[$Key]["Alpha"],"NoDraw"=>TRUE,"Segments"=>$Segments,"Surrounding"=>$Surrounding); |
|
96 | 96 | |
97 | - $PolyGon = ""; |
|
97 | + $PolyGon = ""; |
|
98 | 98 | |
99 | - $Angle = $Object->getAngle($X2,$RightY1,$X1,$LeftY1); |
|
100 | - $VectorX1 = cos(deg2rad($Angle+90)) * $Force + ($X2-$X1)/2 + $X1; |
|
101 | - $VectorY1 = sin(deg2rad($Angle+90)) * $Force + ($RightY1-$LeftY1)/2 + $LeftY1; |
|
102 | - $VectorX2 = cos(deg2rad($Angle-90)) * $Force + ($X2-$X1)/2 + $X1; |
|
103 | - $VectorY2 = sin(deg2rad($Angle-90)) * $Force + ($RightY1-$LeftY1)/2 + $LeftY1; |
|
99 | + $Angle = $Object->getAngle($X2,$RightY1,$X1,$LeftY1); |
|
100 | + $VectorX1 = cos(deg2rad($Angle+90)) * $Force + ($X2-$X1)/2 + $X1; |
|
101 | + $VectorY1 = sin(deg2rad($Angle+90)) * $Force + ($RightY1-$LeftY1)/2 + $LeftY1; |
|
102 | + $VectorX2 = cos(deg2rad($Angle-90)) * $Force + ($X2-$X1)/2 + $X1; |
|
103 | + $VectorY2 = sin(deg2rad($Angle-90)) * $Force + ($RightY1-$LeftY1)/2 + $LeftY1; |
|
104 | 104 | |
105 | - $Points = $Object->drawBezier($X1,$LeftY1,$X2,$RightY1,$VectorX1,$VectorY1,$VectorX2,$VectorY2,$Settings); |
|
106 | - foreach($Points as $Key => $Pos) { $PolyGon[] = $Pos["X"]; $PolyGon[] = $Pos["Y"]; } |
|
105 | + $Points = $Object->drawBezier($X1,$LeftY1,$X2,$RightY1,$VectorX1,$VectorY1,$VectorX2,$VectorY2,$Settings); |
|
106 | + foreach($Points as $Key => $Pos) { $PolyGon[] = $Pos["X"]; $PolyGon[] = $Pos["Y"]; } |
|
107 | 107 | |
108 | 108 | |
109 | - $Angle = $Object->getAngle($X2,$RightY2,$X1,$LeftY2); |
|
110 | - $VectorX1 = cos(deg2rad($Angle+90)) * $Force + ($X2-$X1)/2 +$X1; |
|
111 | - $VectorY1 = sin(deg2rad($Angle+90)) * $Force + ($RightY2-$LeftY2)/2 + $LeftY2; |
|
112 | - $VectorX2 = cos(deg2rad($Angle-90)) * $Force + ($X2-$X1)/2 +$X1; |
|
113 | - $VectorY2 = sin(deg2rad($Angle-90)) * $Force + ($RightY2-$LeftY2)/2 + $LeftY2; |
|
109 | + $Angle = $Object->getAngle($X2,$RightY2,$X1,$LeftY2); |
|
110 | + $VectorX1 = cos(deg2rad($Angle+90)) * $Force + ($X2-$X1)/2 +$X1; |
|
111 | + $VectorY1 = sin(deg2rad($Angle+90)) * $Force + ($RightY2-$LeftY2)/2 + $LeftY2; |
|
112 | + $VectorX2 = cos(deg2rad($Angle-90)) * $Force + ($X2-$X1)/2 +$X1; |
|
113 | + $VectorY2 = sin(deg2rad($Angle-90)) * $Force + ($RightY2-$LeftY2)/2 + $LeftY2; |
|
114 | 114 | |
115 | - $Points = $Object->drawBezier($X1,$LeftY2,$X2,$RightY2,$VectorX1,$VectorY1,$VectorX2,$VectorY2,$Settings); |
|
116 | - $Points = array_reverse($Points); |
|
117 | - foreach($Points as $Key => $Pos) { $PolyGon[] = $Pos["X"]; $PolyGon[] = $Pos["Y"]; } |
|
115 | + $Points = $Object->drawBezier($X1,$LeftY2,$X2,$RightY2,$VectorX1,$VectorY1,$VectorX2,$VectorY2,$Settings); |
|
116 | + $Points = array_reverse($Points); |
|
117 | + foreach($Points as $Key => $Pos) { $PolyGon[] = $Pos["X"]; $PolyGon[] = $Pos["Y"]; } |
|
118 | 118 | |
119 | - $Object->drawPolygon($PolyGon,$Settings); |
|
119 | + $Object->drawPolygon($PolyGon,$Settings); |
|
120 | 120 | |
121 | - if ( $TextPos == TEXT_POS_RIGHT ) |
|
121 | + if ( $TextPos == TEXT_POS_RIGHT ) |
|
122 | 122 | $Object->drawText($X2+$TextPadding,($RightY2-$RightY1)/2+$RightY1,$Label,array("Align"=>TEXT_ALIGN_MIDDLELEFT)); |
123 | - else |
|
123 | + else |
|
124 | 124 | $Object->drawText($X2,$RightY1-$TextPadding,$Label,array("Align"=>TEXT_ALIGN_BOTTOMRIGHT)); |
125 | 125 | |
126 | - $LeftY = $LeftY2; |
|
127 | - $RightY = $RightY2; |
|
128 | - } |
|
126 | + $LeftY = $LeftY2; |
|
127 | + $RightY = $RightY2; |
|
128 | + } |
|
129 | + } |
|
129 | 130 | } |
130 | - } |
|
131 | 131 | ?> |
132 | 132 | \ No newline at end of file |
@@ -13,8 +13,8 @@ discard block |
||
13 | 13 | You can find the whole class documentation on the pChart web site. |
14 | 14 | */ |
15 | 15 | |
16 | - define("TEXT_POS_TOP" , 690001); |
|
17 | - define("TEXT_POS_RIGHT" , 690002); |
|
16 | + define("TEXT_POS_TOP", 690001); |
|
17 | + define("TEXT_POS_RIGHT", 690002); |
|
18 | 18 | |
19 | 19 | /* pSplit class definition */ |
20 | 20 | class pSplit |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | { } |
27 | 27 | |
28 | 28 | /* Create the encoded string */ |
29 | - function drawSplitPath($Object,$Values,$Format="") |
|
29 | + function drawSplitPath($Object, $Values, $Format = "") |
|
30 | 30 | { |
31 | 31 | $this->pChartObject = $Object; |
32 | 32 | |
33 | 33 | $Spacing = isset($Format["Spacing"]) ? $Format["Spacing"] : 20; |
34 | - $TextPadding = isset($Format["TextPadding"]) ? $Format["TextPadding"] : 2; |
|
34 | + $TextPadding = isset($Format["TextPadding"]) ? $Format["TextPadding"] : 2; |
|
35 | 35 | $TextPos = isset($Format["TextPos"]) ? $Format["TextPos"] : TEXT_POS_TOP; |
36 | - $Surrounding = isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL; |
|
37 | - $Force = isset($Format["Force"]) ? $Format["Force"] : 70; |
|
36 | + $Surrounding = isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL; |
|
37 | + $Force = isset($Format["Force"]) ? $Format["Force"] : 70; |
|
38 | 38 | $Segments = isset($Format["Segments"]) ? $Format["Segments"] : 15; |
39 | 39 | $FontSize = $Object->FontSize; |
40 | 40 | $X1 = $Object->GraphAreaX1; |
@@ -49,79 +49,79 @@ discard block |
||
49 | 49 | $LabelSerie = $Data["Abscissa"]; |
50 | 50 | $DataSerie = ""; |
51 | 51 | |
52 | - foreach($Data["Series"] as $SerieName => $Value) |
|
53 | - { if ( $SerieName != $LabelSerie && $DataSerie == "" ) { $DataSerie = $SerieName; } } |
|
52 | + foreach ($Data["Series"] as $SerieName => $Value) |
|
53 | + { if ($SerieName != $LabelSerie && $DataSerie == "") { $DataSerie = $SerieName; } } |
|
54 | 54 | |
55 | 55 | $DataSerieSum = array_sum($Data["Series"][$DataSerie]["Data"]); |
56 | 56 | $DataSerieCount = count($Data["Series"][$DataSerie]["Data"]); |
57 | 57 | |
58 | 58 | /* Scale Processing */ |
59 | - if ( $TextPos == TEXT_POS_RIGHT ) |
|
60 | - $YScale = (($Y2-$Y1) - (($DataSerieCount+1)*$Spacing)) / $DataSerieSum; |
|
59 | + if ($TextPos == TEXT_POS_RIGHT) |
|
60 | + $YScale = (($Y2 - $Y1) - (($DataSerieCount + 1)*$Spacing))/$DataSerieSum; |
|
61 | 61 | else |
62 | - $YScale = (($Y2-$Y1) - ($DataSerieCount*$Spacing)) / $DataSerieSum; |
|
63 | - $LeftHeight = $DataSerieSum * $YScale; |
|
62 | + $YScale = (($Y2 - $Y1) - ($DataSerieCount*$Spacing))/$DataSerieSum; |
|
63 | + $LeftHeight = $DataSerieSum*$YScale; |
|
64 | 64 | |
65 | 65 | /* Re-compute graph width depending of the text mode choosen */ |
66 | - if ( $TextPos == TEXT_POS_RIGHT ) |
|
66 | + if ($TextPos == TEXT_POS_RIGHT) |
|
67 | 67 | { |
68 | 68 | $MaxWidth = 0; |
69 | - foreach($Data["Series"][$LabelSerie]["Data"] as $Key => $Label) |
|
69 | + foreach ($Data["Series"][$LabelSerie]["Data"] as $Key => $Label) |
|
70 | 70 | { |
71 | - $Boundardies = $Object->getTextBox(0,0,$Object->FontName,$Object->FontSize,0,$Label); |
|
72 | - if ( $Boundardies[1]["X"] > $MaxWidth ) { $MaxWidth = $Boundardies[1]["X"] + $TextPadding*2; } |
|
71 | + $Boundardies = $Object->getTextBox(0, 0, $Object->FontName, $Object->FontSize, 0, $Label); |
|
72 | + if ($Boundardies[1]["X"] > $MaxWidth) { $MaxWidth = $Boundardies[1]["X"] + $TextPadding*2; } |
|
73 | 73 | } |
74 | 74 | $X2 = $X2 - $MaxWidth; |
75 | 75 | } |
76 | 76 | |
77 | 77 | /* Drawing */ |
78 | - $LeftY = ((($Y2-$Y1) / 2) + $Y1) - ($LeftHeight/2); |
|
78 | + $LeftY = ((($Y2 - $Y1)/2) + $Y1) - ($LeftHeight/2); |
|
79 | 79 | $RightY = $Y1; |
80 | - $VectorX = (($X2-$X1) / 2); |
|
80 | + $VectorX = (($X2 - $X1)/2); |
|
81 | 81 | |
82 | - foreach($Data["Series"][$DataSerie]["Data"] as $Key => $Value) |
|
82 | + foreach ($Data["Series"][$DataSerie]["Data"] as $Key => $Value) |
|
83 | 83 | { |
84 | - if ( isset($Data["Series"][$LabelSerie]["Data"][$Key]) ) |
|
84 | + if (isset($Data["Series"][$LabelSerie]["Data"][$Key])) |
|
85 | 85 | $Label = $Data["Series"][$LabelSerie]["Data"][$Key]; |
86 | 86 | else |
87 | 87 | $Label = "-"; |
88 | 88 | |
89 | 89 | $LeftY1 = $LeftY; |
90 | - $LeftY2 = $LeftY + $Value * $YScale; |
|
90 | + $LeftY2 = $LeftY + $Value*$YScale; |
|
91 | 91 | |
92 | 92 | $RightY1 = $RightY + $Spacing; |
93 | - $RightY2 = $RightY + $Spacing + $Value * $YScale;; |
|
93 | + $RightY2 = $RightY + $Spacing + $Value*$YScale; ; |
|
94 | 94 | |
95 | - $Settings = array("R"=>$Palette[$Key]["R"],"G"=>$Palette[$Key]["G"],"B"=>$Palette[$Key]["B"],"Alpha"=>$Palette[$Key]["Alpha"],"NoDraw"=>TRUE,"Segments"=>$Segments,"Surrounding"=>$Surrounding); |
|
95 | + $Settings = array("R"=>$Palette[$Key]["R"], "G"=>$Palette[$Key]["G"], "B"=>$Palette[$Key]["B"], "Alpha"=>$Palette[$Key]["Alpha"], "NoDraw"=>TRUE, "Segments"=>$Segments, "Surrounding"=>$Surrounding); |
|
96 | 96 | |
97 | 97 | $PolyGon = ""; |
98 | 98 | |
99 | - $Angle = $Object->getAngle($X2,$RightY1,$X1,$LeftY1); |
|
100 | - $VectorX1 = cos(deg2rad($Angle+90)) * $Force + ($X2-$X1)/2 + $X1; |
|
101 | - $VectorY1 = sin(deg2rad($Angle+90)) * $Force + ($RightY1-$LeftY1)/2 + $LeftY1; |
|
102 | - $VectorX2 = cos(deg2rad($Angle-90)) * $Force + ($X2-$X1)/2 + $X1; |
|
103 | - $VectorY2 = sin(deg2rad($Angle-90)) * $Force + ($RightY1-$LeftY1)/2 + $LeftY1; |
|
99 | + $Angle = $Object->getAngle($X2, $RightY1, $X1, $LeftY1); |
|
100 | + $VectorX1 = cos(deg2rad($Angle + 90))*$Force + ($X2 - $X1)/2 + $X1; |
|
101 | + $VectorY1 = sin(deg2rad($Angle + 90))*$Force + ($RightY1 - $LeftY1)/2 + $LeftY1; |
|
102 | + $VectorX2 = cos(deg2rad($Angle - 90))*$Force + ($X2 - $X1)/2 + $X1; |
|
103 | + $VectorY2 = sin(deg2rad($Angle - 90))*$Force + ($RightY1 - $LeftY1)/2 + $LeftY1; |
|
104 | 104 | |
105 | - $Points = $Object->drawBezier($X1,$LeftY1,$X2,$RightY1,$VectorX1,$VectorY1,$VectorX2,$VectorY2,$Settings); |
|
106 | - foreach($Points as $Key => $Pos) { $PolyGon[] = $Pos["X"]; $PolyGon[] = $Pos["Y"]; } |
|
105 | + $Points = $Object->drawBezier($X1, $LeftY1, $X2, $RightY1, $VectorX1, $VectorY1, $VectorX2, $VectorY2, $Settings); |
|
106 | + foreach ($Points as $Key => $Pos) { $PolyGon[] = $Pos["X"]; $PolyGon[] = $Pos["Y"]; } |
|
107 | 107 | |
108 | 108 | |
109 | - $Angle = $Object->getAngle($X2,$RightY2,$X1,$LeftY2); |
|
110 | - $VectorX1 = cos(deg2rad($Angle+90)) * $Force + ($X2-$X1)/2 +$X1; |
|
111 | - $VectorY1 = sin(deg2rad($Angle+90)) * $Force + ($RightY2-$LeftY2)/2 + $LeftY2; |
|
112 | - $VectorX2 = cos(deg2rad($Angle-90)) * $Force + ($X2-$X1)/2 +$X1; |
|
113 | - $VectorY2 = sin(deg2rad($Angle-90)) * $Force + ($RightY2-$LeftY2)/2 + $LeftY2; |
|
109 | + $Angle = $Object->getAngle($X2, $RightY2, $X1, $LeftY2); |
|
110 | + $VectorX1 = cos(deg2rad($Angle + 90))*$Force + ($X2 - $X1)/2 + $X1; |
|
111 | + $VectorY1 = sin(deg2rad($Angle + 90))*$Force + ($RightY2 - $LeftY2)/2 + $LeftY2; |
|
112 | + $VectorX2 = cos(deg2rad($Angle - 90))*$Force + ($X2 - $X1)/2 + $X1; |
|
113 | + $VectorY2 = sin(deg2rad($Angle - 90))*$Force + ($RightY2 - $LeftY2)/2 + $LeftY2; |
|
114 | 114 | |
115 | - $Points = $Object->drawBezier($X1,$LeftY2,$X2,$RightY2,$VectorX1,$VectorY1,$VectorX2,$VectorY2,$Settings); |
|
115 | + $Points = $Object->drawBezier($X1, $LeftY2, $X2, $RightY2, $VectorX1, $VectorY1, $VectorX2, $VectorY2, $Settings); |
|
116 | 116 | $Points = array_reverse($Points); |
117 | - foreach($Points as $Key => $Pos) { $PolyGon[] = $Pos["X"]; $PolyGon[] = $Pos["Y"]; } |
|
117 | + foreach ($Points as $Key => $Pos) { $PolyGon[] = $Pos["X"]; $PolyGon[] = $Pos["Y"]; } |
|
118 | 118 | |
119 | - $Object->drawPolygon($PolyGon,$Settings); |
|
119 | + $Object->drawPolygon($PolyGon, $Settings); |
|
120 | 120 | |
121 | - if ( $TextPos == TEXT_POS_RIGHT ) |
|
122 | - $Object->drawText($X2+$TextPadding,($RightY2-$RightY1)/2+$RightY1,$Label,array("Align"=>TEXT_ALIGN_MIDDLELEFT)); |
|
121 | + if ($TextPos == TEXT_POS_RIGHT) |
|
122 | + $Object->drawText($X2 + $TextPadding, ($RightY2 - $RightY1)/2 + $RightY1, $Label, array("Align"=>TEXT_ALIGN_MIDDLELEFT)); |
|
123 | 123 | else |
124 | - $Object->drawText($X2,$RightY1-$TextPadding,$Label,array("Align"=>TEXT_ALIGN_BOTTOMRIGHT)); |
|
124 | + $Object->drawText($X2, $RightY1 - $TextPadding, $Label, array("Align"=>TEXT_ALIGN_BOTTOMRIGHT)); |
|
125 | 125 | |
126 | 126 | $LeftY = $LeftY2; |
127 | 127 | $RightY = $RightY2; |
@@ -17,8 +17,7 @@ discard block |
||
17 | 17 | define("TEXT_POS_RIGHT" , 690002); |
18 | 18 | |
19 | 19 | /* pSplit class definition */ |
20 | - class pSplit |
|
21 | - { |
|
20 | + class pSplit { |
|
22 | 21 | var $pChartObject; |
23 | 22 | |
24 | 23 | /* Class creator */ |
@@ -26,8 +25,7 @@ discard block |
||
26 | 25 | { } |
27 | 26 | |
28 | 27 | /* Create the encoded string */ |
29 | - function drawSplitPath($Object,$Values,$Format="") |
|
30 | - { |
|
28 | + function drawSplitPath($Object,$Values,$Format="") { |
|
31 | 29 | $this->pChartObject = $Object; |
32 | 30 | |
33 | 31 | $Spacing = isset($Format["Spacing"]) ? $Format["Spacing"] : 20; |
@@ -63,11 +61,9 @@ discard block |
||
63 | 61 | $LeftHeight = $DataSerieSum * $YScale; |
64 | 62 | |
65 | 63 | /* Re-compute graph width depending of the text mode choosen */ |
66 | - if ( $TextPos == TEXT_POS_RIGHT ) |
|
67 | - { |
|
64 | + if ( $TextPos == TEXT_POS_RIGHT ) { |
|
68 | 65 | $MaxWidth = 0; |
69 | - foreach($Data["Series"][$LabelSerie]["Data"] as $Key => $Label) |
|
70 | - { |
|
66 | + foreach($Data["Series"][$LabelSerie]["Data"] as $Key => $Label) { |
|
71 | 67 | $Boundardies = $Object->getTextBox(0,0,$Object->FontName,$Object->FontSize,0,$Label); |
72 | 68 | if ( $Boundardies[1]["X"] > $MaxWidth ) { $MaxWidth = $Boundardies[1]["X"] + $TextPadding*2; } |
73 | 69 | } |
@@ -79,8 +75,7 @@ discard block |
||
79 | 75 | $RightY = $Y1; |
80 | 76 | $VectorX = (($X2-$X1) / 2); |
81 | 77 | |
82 | - foreach($Data["Series"][$DataSerie]["Data"] as $Key => $Value) |
|
83 | - { |
|
78 | + foreach($Data["Series"][$DataSerie]["Data"] as $Key => $Value) { |
|
84 | 79 | if ( isset($Data["Series"][$LabelSerie]["Data"][$Key]) ) |
85 | 80 | $Label = $Data["Series"][$LabelSerie]["Data"][$Key]; |
86 | 81 | else |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $Spacing = isset($Format["Spacing"]) ? $Format["Spacing"] : 20; |
34 | 34 | $TextPadding = isset($Format["TextPadding"]) ? $Format["TextPadding"] : 2; |
35 | 35 | $TextPos = isset($Format["TextPos"]) ? $Format["TextPos"] : TEXT_POS_TOP; |
36 | - $Surrounding = isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL; |
|
36 | + $Surrounding = isset($Format["Surrounding"]) ? $Format["Surrounding"] : null; |
|
37 | 37 | $Force = isset($Format["Force"]) ? $Format["Force"] : 70; |
38 | 38 | $Segments = isset($Format["Segments"]) ? $Format["Segments"] : 15; |
39 | 39 | $FontSize = $Object->FontSize; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $RightY1 = $RightY + $Spacing; |
93 | 93 | $RightY2 = $RightY + $Spacing + $Value * $YScale;; |
94 | 94 | |
95 | - $Settings = array("R"=>$Palette[$Key]["R"],"G"=>$Palette[$Key]["G"],"B"=>$Palette[$Key]["B"],"Alpha"=>$Palette[$Key]["Alpha"],"NoDraw"=>TRUE,"Segments"=>$Segments,"Surrounding"=>$Surrounding); |
|
95 | + $Settings = array("R"=>$Palette[$Key]["R"],"G"=>$Palette[$Key]["G"],"B"=>$Palette[$Key]["B"],"Alpha"=>$Palette[$Key]["Alpha"],"NoDraw"=>true,"Segments"=>$Segments,"Surrounding"=>$Surrounding); |
|
96 | 96 | |
97 | 97 | $PolyGon = ""; |
98 | 98 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | - /* |
|
2 | + /* |
|
3 | 3 | pStock - class to draw stock charts |
4 | 4 | |
5 | 5 | Version : 2.1.3 |
@@ -13,204 +13,204 @@ discard block |
||
13 | 13 | You can find the whole class documentation on the pChart web site. |
14 | 14 | */ |
15 | 15 | |
16 | - define("STOCK_MISSING_SERIE" , 180001); |
|
16 | + define("STOCK_MISSING_SERIE" , 180001); |
|
17 | 17 | |
18 | - /* pStock class definition */ |
|
19 | - class pStock |
|
20 | - { |
|
21 | - var $pChartObject; |
|
22 | - var $pDataObject; |
|
18 | + /* pStock class definition */ |
|
19 | + class pStock |
|
20 | + { |
|
21 | + var $pChartObject; |
|
22 | + var $pDataObject; |
|
23 | 23 | |
24 | - /* Class creator */ |
|
25 | - function pStock($pChartObject,$pDataObject) |
|
24 | + /* Class creator */ |
|
25 | + function pStock($pChartObject,$pDataObject) |
|
26 | 26 | { |
27 | - $this->pChartObject = $pChartObject; |
|
28 | - $this->pDataObject = $pDataObject; |
|
27 | + $this->pChartObject = $pChartObject; |
|
28 | + $this->pDataObject = $pDataObject; |
|
29 | 29 | } |
30 | 30 | |
31 | - /* Draw a stock chart */ |
|
32 | - function drawStockChart($Format="") |
|
31 | + /* Draw a stock chart */ |
|
32 | + function drawStockChart($Format="") |
|
33 | 33 | { |
34 | - $SerieOpen = isset($Format["SerieOpen"]) ? $Format["SerieOpen"] : "Open"; |
|
35 | - $SerieClose = isset($Format["SerieClose"]) ? $Format["SerieClose"] : "Close"; |
|
36 | - $SerieMin = isset($Format["SerieMin"]) ? $Format["SerieMin"] : "Min"; |
|
37 | - $SerieMax = isset($Format["SerieMax"]) ? $Format["SerieMax"] : "Max"; |
|
38 | - $SerieMedian = isset($Format["SerieMedian"]) ? $Format["SerieMedian"] : NULL; |
|
39 | - $LineWidth = isset($Format["LineWidth"]) ? $Format["LineWidth"] : 1; |
|
40 | - $LineR = isset($Format["LineR"]) ? $Format["LineR"] : 0; |
|
41 | - $LineG = isset($Format["LineG"]) ? $Format["LineG"] : 0; |
|
42 | - $LineB = isset($Format["LineB"]) ? $Format["LineB"] : 0; |
|
43 | - $LineAlpha = isset($Format["LineAlpha"]) ? $Format["LineAlpha"] : 100; |
|
44 | - $ExtremityWidth = isset($Format["ExtremityWidth"]) ? $Format["ExtremityWidth"] : 1; |
|
45 | - $ExtremityLength = isset($Format["ExtremityLength"]) ? $Format["ExtremityLength"] : 3; |
|
46 | - $ExtremityR = isset($Format["ExtremityR"]) ? $Format["ExtremityR"] : 0; |
|
47 | - $ExtremityG = isset($Format["ExtremityG"]) ? $Format["ExtremityG"] : 0; |
|
48 | - $ExtremityB = isset($Format["ExtremityB"]) ? $Format["ExtremityB"] : 0; |
|
49 | - $ExtremityAlpha = isset($Format["ExtremityAlpha"]) ? $Format["ExtremityAlpha"] : 100; |
|
50 | - $BoxWidth = isset($Format["BoxWidth"]) ? $Format["BoxWidth"] : 8; |
|
51 | - $BoxUpR = isset($Format["BoxUpR"]) ? $Format["BoxUpR"] : 188; |
|
52 | - $BoxUpG = isset($Format["BoxUpG"]) ? $Format["BoxUpG"] : 224; |
|
53 | - $BoxUpB = isset($Format["BoxUpB"]) ? $Format["BoxUpB"] : 46; |
|
54 | - $BoxUpAlpha = isset($Format["BoxUpAlpha"]) ? $Format["BoxUpAlpha"] : 100; |
|
55 | - $BoxUpSurrounding = isset($Format["BoxUpSurrounding"]) ? $Format["BoxUpSurrounding"] : NULL; |
|
56 | - $BoxUpBorderR = isset($Format["BoxUpBorderR"]) ? $Format["BoxUpBorderR"] : $BoxUpR-20; |
|
57 | - $BoxUpBorderG = isset($Format["BoxUpBorderG"]) ? $Format["BoxUpBorderG"] : $BoxUpG-20; |
|
58 | - $BoxUpBorderB = isset($Format["BoxUpBorderB"]) ? $Format["BoxUpBorderB"] : $BoxUpB-20; |
|
59 | - $BoxUpBorderAlpha = isset($Format["BoxUpBorderAlpha"]) ? $Format["BoxUpBorderAlpha"] : 100; |
|
60 | - $BoxDownR = isset($Format["BoxDownR"]) ? $Format["BoxDownR"] : 224; |
|
61 | - $BoxDownG = isset($Format["BoxDownG"]) ? $Format["BoxDownG"] : 100; |
|
62 | - $BoxDownB = isset($Format["BoxDownB"]) ? $Format["BoxDownB"] : 46; |
|
63 | - $BoxDownAlpha = isset($Format["BoxDownAlpha"]) ? $Format["BoxDownAlpha"] : 100; |
|
64 | - $BoxDownSurrounding= isset($Format["BoxDownSurrounding"]) ? $Format["BoxDownSurrounding"] : NULL; |
|
65 | - $BoxDownBorderR = isset($Format["BoxDownBorderR"]) ? $Format["BoxDownBorderR"] : $BoxDownR-20; |
|
66 | - $BoxDownBorderG = isset($Format["BoxDownBorderG"]) ? $Format["BoxDownBorderG"] : $BoxDownG-20; |
|
67 | - $BoxDownBorderB = isset($Format["BoxDownBorderB"]) ? $Format["BoxDownBorderB"] : $BoxDownB-20; |
|
68 | - $BoxDownBorderAlpha= isset($Format["BoxDownBorderAlpha"]) ? $Format["BoxDownBorderAlpha"] : 100; |
|
69 | - $ShadowOnBoxesOnly = isset($Format["ShadowOnBoxesOnly"]) ? $Format["ShadowOnBoxesOnly"] : TRUE; |
|
70 | - $MedianR = isset($Format["MedianR"]) ? $Format["MedianR"] : 255; |
|
71 | - $MedianG = isset($Format["MedianG"]) ? $Format["MedianG"] : 0; |
|
72 | - $MedianB = isset($Format["MedianB"]) ? $Format["MedianB"] : 0; |
|
73 | - $MedianAlpha = isset($Format["MedianAlpha"]) ? $Format["MedianAlpha"] : 100; |
|
74 | - $RecordImageMap = isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : FALSE; |
|
75 | - $ImageMapTitle = isset($Format["ImageMapTitle"]) ? $Format["ImageMapTitle"] : "Stock Chart"; |
|
76 | - |
|
77 | - |
|
78 | - /* Data Processing */ |
|
79 | - $Data = $this->pDataObject->getData(); |
|
80 | - $Palette = $this->pDataObject->getPalette(); |
|
81 | - |
|
82 | - if ( $BoxUpSurrounding != NULL ) { $BoxUpBorderR = $BoxUpR + $BoxUpSurrounding; $BoxUpBorderG = $BoxUpG + $BoxUpSurrounding; $BoxUpBorderB = $BoxUpB + $BoxUpSurrounding; } |
|
83 | - if ( $BoxDownSurrounding != NULL ) { $BoxDownBorderR = $BoxDownR + $BoxDownSurrounding; $BoxDownBorderG = $BoxDownG + $BoxDownSurrounding; $BoxDownBorderB = $BoxDownB + $BoxDownSurrounding; } |
|
84 | - |
|
85 | - if ( $LineWidth != 1 ) { $LineOffset = $LineWidth / 2; } |
|
86 | - $BoxOffset = $BoxWidth / 2; |
|
87 | - |
|
88 | - $Data = $this->pChartObject->DataSet->getData(); |
|
89 | - list($XMargin,$XDivs) = $this->pChartObject->scaleGetXSettings(); |
|
90 | - |
|
91 | - if ( !isset($Data["Series"][$SerieOpen]) || !isset($Data["Series"][$SerieClose]) || !isset($Data["Series"][$SerieMin]) || !isset($Data["Series"][$SerieMax]) ) |
|
92 | - return(STOCK_MISSING_SERIE); |
|
93 | - |
|
94 | - $Plots = ""; |
|
95 | - foreach($Data["Series"][$SerieOpen]["Data"] as $Key => $Value) |
|
96 | - { |
|
97 | - $Point = ""; |
|
98 | - if ( isset($Data["Series"][$SerieClose]["Data"][$Key]) || isset($Data["Series"][$SerieMin]["Data"][$Key]) || isset($Data["Series"][$SerieMax]["Data"][$Key]) ) |
|
34 | + $SerieOpen = isset($Format["SerieOpen"]) ? $Format["SerieOpen"] : "Open"; |
|
35 | + $SerieClose = isset($Format["SerieClose"]) ? $Format["SerieClose"] : "Close"; |
|
36 | + $SerieMin = isset($Format["SerieMin"]) ? $Format["SerieMin"] : "Min"; |
|
37 | + $SerieMax = isset($Format["SerieMax"]) ? $Format["SerieMax"] : "Max"; |
|
38 | + $SerieMedian = isset($Format["SerieMedian"]) ? $Format["SerieMedian"] : NULL; |
|
39 | + $LineWidth = isset($Format["LineWidth"]) ? $Format["LineWidth"] : 1; |
|
40 | + $LineR = isset($Format["LineR"]) ? $Format["LineR"] : 0; |
|
41 | + $LineG = isset($Format["LineG"]) ? $Format["LineG"] : 0; |
|
42 | + $LineB = isset($Format["LineB"]) ? $Format["LineB"] : 0; |
|
43 | + $LineAlpha = isset($Format["LineAlpha"]) ? $Format["LineAlpha"] : 100; |
|
44 | + $ExtremityWidth = isset($Format["ExtremityWidth"]) ? $Format["ExtremityWidth"] : 1; |
|
45 | + $ExtremityLength = isset($Format["ExtremityLength"]) ? $Format["ExtremityLength"] : 3; |
|
46 | + $ExtremityR = isset($Format["ExtremityR"]) ? $Format["ExtremityR"] : 0; |
|
47 | + $ExtremityG = isset($Format["ExtremityG"]) ? $Format["ExtremityG"] : 0; |
|
48 | + $ExtremityB = isset($Format["ExtremityB"]) ? $Format["ExtremityB"] : 0; |
|
49 | + $ExtremityAlpha = isset($Format["ExtremityAlpha"]) ? $Format["ExtremityAlpha"] : 100; |
|
50 | + $BoxWidth = isset($Format["BoxWidth"]) ? $Format["BoxWidth"] : 8; |
|
51 | + $BoxUpR = isset($Format["BoxUpR"]) ? $Format["BoxUpR"] : 188; |
|
52 | + $BoxUpG = isset($Format["BoxUpG"]) ? $Format["BoxUpG"] : 224; |
|
53 | + $BoxUpB = isset($Format["BoxUpB"]) ? $Format["BoxUpB"] : 46; |
|
54 | + $BoxUpAlpha = isset($Format["BoxUpAlpha"]) ? $Format["BoxUpAlpha"] : 100; |
|
55 | + $BoxUpSurrounding = isset($Format["BoxUpSurrounding"]) ? $Format["BoxUpSurrounding"] : NULL; |
|
56 | + $BoxUpBorderR = isset($Format["BoxUpBorderR"]) ? $Format["BoxUpBorderR"] : $BoxUpR-20; |
|
57 | + $BoxUpBorderG = isset($Format["BoxUpBorderG"]) ? $Format["BoxUpBorderG"] : $BoxUpG-20; |
|
58 | + $BoxUpBorderB = isset($Format["BoxUpBorderB"]) ? $Format["BoxUpBorderB"] : $BoxUpB-20; |
|
59 | + $BoxUpBorderAlpha = isset($Format["BoxUpBorderAlpha"]) ? $Format["BoxUpBorderAlpha"] : 100; |
|
60 | + $BoxDownR = isset($Format["BoxDownR"]) ? $Format["BoxDownR"] : 224; |
|
61 | + $BoxDownG = isset($Format["BoxDownG"]) ? $Format["BoxDownG"] : 100; |
|
62 | + $BoxDownB = isset($Format["BoxDownB"]) ? $Format["BoxDownB"] : 46; |
|
63 | + $BoxDownAlpha = isset($Format["BoxDownAlpha"]) ? $Format["BoxDownAlpha"] : 100; |
|
64 | + $BoxDownSurrounding= isset($Format["BoxDownSurrounding"]) ? $Format["BoxDownSurrounding"] : NULL; |
|
65 | + $BoxDownBorderR = isset($Format["BoxDownBorderR"]) ? $Format["BoxDownBorderR"] : $BoxDownR-20; |
|
66 | + $BoxDownBorderG = isset($Format["BoxDownBorderG"]) ? $Format["BoxDownBorderG"] : $BoxDownG-20; |
|
67 | + $BoxDownBorderB = isset($Format["BoxDownBorderB"]) ? $Format["BoxDownBorderB"] : $BoxDownB-20; |
|
68 | + $BoxDownBorderAlpha= isset($Format["BoxDownBorderAlpha"]) ? $Format["BoxDownBorderAlpha"] : 100; |
|
69 | + $ShadowOnBoxesOnly = isset($Format["ShadowOnBoxesOnly"]) ? $Format["ShadowOnBoxesOnly"] : TRUE; |
|
70 | + $MedianR = isset($Format["MedianR"]) ? $Format["MedianR"] : 255; |
|
71 | + $MedianG = isset($Format["MedianG"]) ? $Format["MedianG"] : 0; |
|
72 | + $MedianB = isset($Format["MedianB"]) ? $Format["MedianB"] : 0; |
|
73 | + $MedianAlpha = isset($Format["MedianAlpha"]) ? $Format["MedianAlpha"] : 100; |
|
74 | + $RecordImageMap = isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : FALSE; |
|
75 | + $ImageMapTitle = isset($Format["ImageMapTitle"]) ? $Format["ImageMapTitle"] : "Stock Chart"; |
|
76 | + |
|
77 | + |
|
78 | + /* Data Processing */ |
|
79 | + $Data = $this->pDataObject->getData(); |
|
80 | + $Palette = $this->pDataObject->getPalette(); |
|
81 | + |
|
82 | + if ( $BoxUpSurrounding != NULL ) { $BoxUpBorderR = $BoxUpR + $BoxUpSurrounding; $BoxUpBorderG = $BoxUpG + $BoxUpSurrounding; $BoxUpBorderB = $BoxUpB + $BoxUpSurrounding; } |
|
83 | + if ( $BoxDownSurrounding != NULL ) { $BoxDownBorderR = $BoxDownR + $BoxDownSurrounding; $BoxDownBorderG = $BoxDownG + $BoxDownSurrounding; $BoxDownBorderB = $BoxDownB + $BoxDownSurrounding; } |
|
84 | + |
|
85 | + if ( $LineWidth != 1 ) { $LineOffset = $LineWidth / 2; } |
|
86 | + $BoxOffset = $BoxWidth / 2; |
|
87 | + |
|
88 | + $Data = $this->pChartObject->DataSet->getData(); |
|
89 | + list($XMargin,$XDivs) = $this->pChartObject->scaleGetXSettings(); |
|
90 | + |
|
91 | + if ( !isset($Data["Series"][$SerieOpen]) || !isset($Data["Series"][$SerieClose]) || !isset($Data["Series"][$SerieMin]) || !isset($Data["Series"][$SerieMax]) ) |
|
92 | + return(STOCK_MISSING_SERIE); |
|
93 | + |
|
94 | + $Plots = ""; |
|
95 | + foreach($Data["Series"][$SerieOpen]["Data"] as $Key => $Value) |
|
96 | + { |
|
97 | + $Point = ""; |
|
98 | + if ( isset($Data["Series"][$SerieClose]["Data"][$Key]) || isset($Data["Series"][$SerieMin]["Data"][$Key]) || isset($Data["Series"][$SerieMax]["Data"][$Key]) ) |
|
99 | 99 | $Point = array($Value,$Data["Series"][$SerieClose]["Data"][$Key],$Data["Series"][$SerieMin]["Data"][$Key],$Data["Series"][$SerieMax]["Data"][$Key]); |
100 | - if ( $SerieMedian != NULL && isset($Data["Series"][$SerieMedian]["Data"][$Key]) ) |
|
100 | + if ( $SerieMedian != NULL && isset($Data["Series"][$SerieMedian]["Data"][$Key]) ) |
|
101 | 101 | $Point[] = $Data["Series"][$SerieMedian]["Data"][$Key]; |
102 | 102 | |
103 | - $Plots[] = $Point; |
|
104 | - } |
|
103 | + $Plots[] = $Point; |
|
104 | + } |
|
105 | 105 | |
106 | - $AxisID = $Data["Series"][$SerieOpen]["Axis"]; |
|
107 | - $Mode = $Data["Axis"][$AxisID]["Display"]; |
|
108 | - $Format = $Data["Axis"][$AxisID]["Format"]; |
|
109 | - $Unit = $Data["Axis"][$AxisID]["Unit"]; |
|
106 | + $AxisID = $Data["Series"][$SerieOpen]["Axis"]; |
|
107 | + $Mode = $Data["Axis"][$AxisID]["Display"]; |
|
108 | + $Format = $Data["Axis"][$AxisID]["Format"]; |
|
109 | + $Unit = $Data["Axis"][$AxisID]["Unit"]; |
|
110 | 110 | |
111 | - $YZero = $this->pChartObject->scaleComputeY(0,array("AxisID"=>$AxisID)); |
|
112 | - $XStep = ($this->pChartObject->GraphAreaX2-$this->pChartObject->GraphAreaX1-$XMargin*2)/$XDivs; |
|
111 | + $YZero = $this->pChartObject->scaleComputeY(0,array("AxisID"=>$AxisID)); |
|
112 | + $XStep = ($this->pChartObject->GraphAreaX2-$this->pChartObject->GraphAreaX1-$XMargin*2)/$XDivs; |
|
113 | 113 | |
114 | - $X = $this->pChartObject->GraphAreaX1 + $XMargin; |
|
115 | - $Y = $this->pChartObject->GraphAreaY1 + $XMargin; |
|
114 | + $X = $this->pChartObject->GraphAreaX1 + $XMargin; |
|
115 | + $Y = $this->pChartObject->GraphAreaY1 + $XMargin; |
|
116 | 116 | |
117 | - $LineSettings = array("R"=>$LineR,"G"=>$LineG,"B"=>$LineB,"Alpha"=>$LineAlpha); |
|
118 | - $ExtremitySettings = array("R"=>$ExtremityR,"G"=>$ExtremityG,"B"=>$ExtremityB,"Alpha"=>$ExtremityAlpha); |
|
119 | - $BoxUpSettings = array("R"=>$BoxUpR,"G"=>$BoxUpG,"B"=>$BoxUpB,"Alpha"=>$BoxUpAlpha,"BorderR"=>$BoxUpBorderR,"BorderG"=>$BoxUpBorderG,"BorderB"=>$BoxUpBorderB,"BorderAlpha"=>$BoxUpBorderAlpha); |
|
120 | - $BoxDownSettings = array("R"=>$BoxDownR,"G"=>$BoxDownG,"B"=>$BoxDownB,"Alpha"=>$BoxDownAlpha,"BorderR"=>$BoxDownBorderR,"BorderG"=>$BoxDownBorderG,"BorderB"=>$BoxDownBorderB,"BorderAlpha"=>$BoxDownBorderAlpha); |
|
121 | - $MedianSettings = array("R"=>$MedianR,"G"=>$MedianG,"B"=>$MedianB,"Alpha"=>$MedianAlpha); |
|
117 | + $LineSettings = array("R"=>$LineR,"G"=>$LineG,"B"=>$LineB,"Alpha"=>$LineAlpha); |
|
118 | + $ExtremitySettings = array("R"=>$ExtremityR,"G"=>$ExtremityG,"B"=>$ExtremityB,"Alpha"=>$ExtremityAlpha); |
|
119 | + $BoxUpSettings = array("R"=>$BoxUpR,"G"=>$BoxUpG,"B"=>$BoxUpB,"Alpha"=>$BoxUpAlpha,"BorderR"=>$BoxUpBorderR,"BorderG"=>$BoxUpBorderG,"BorderB"=>$BoxUpBorderB,"BorderAlpha"=>$BoxUpBorderAlpha); |
|
120 | + $BoxDownSettings = array("R"=>$BoxDownR,"G"=>$BoxDownG,"B"=>$BoxDownB,"Alpha"=>$BoxDownAlpha,"BorderR"=>$BoxDownBorderR,"BorderG"=>$BoxDownBorderG,"BorderB"=>$BoxDownBorderB,"BorderAlpha"=>$BoxDownBorderAlpha); |
|
121 | + $MedianSettings = array("R"=>$MedianR,"G"=>$MedianG,"B"=>$MedianB,"Alpha"=>$MedianAlpha); |
|
122 | 122 | |
123 | - foreach($Plots as $Key =>$Points) |
|
124 | - { |
|
125 | - $PosArray = $this->pChartObject->scaleComputeY($Points,array("AxisID"=>$AxisID)); |
|
123 | + foreach($Plots as $Key =>$Points) |
|
124 | + { |
|
125 | + $PosArray = $this->pChartObject->scaleComputeY($Points,array("AxisID"=>$AxisID)); |
|
126 | 126 | |
127 | - $Values = "Open :".$Data["Series"][$SerieOpen]["Data"][$Key]."<BR>Close : ".$Data["Series"][$SerieClose]["Data"][$Key]."<BR>Min : ".$Data["Series"][$SerieMin]["Data"][$Key]."<BR>Max : ".$Data["Series"][$SerieMax]["Data"][$Key]."<BR>"; |
|
128 | - if ( $SerieMedian != NULL ) { $Values = $Values."Median : ".$Data["Series"][$SerieMedian]["Data"][$Key]."<BR>"; } |
|
129 | - if ( $PosArray[0] > $PosArray[1] ) { $ImageMapColor = $this->pChartObject->toHTMLColor($BoxUpR,$BoxUpG,$BoxUpB); } else { $ImageMapColor = $this->pChartObject->toHTMLColor($BoxDownR,$BoxDownG,$BoxDownB); } |
|
127 | + $Values = "Open :".$Data["Series"][$SerieOpen]["Data"][$Key]."<BR>Close : ".$Data["Series"][$SerieClose]["Data"][$Key]."<BR>Min : ".$Data["Series"][$SerieMin]["Data"][$Key]."<BR>Max : ".$Data["Series"][$SerieMax]["Data"][$Key]."<BR>"; |
|
128 | + if ( $SerieMedian != NULL ) { $Values = $Values."Median : ".$Data["Series"][$SerieMedian]["Data"][$Key]."<BR>"; } |
|
129 | + if ( $PosArray[0] > $PosArray[1] ) { $ImageMapColor = $this->pChartObject->toHTMLColor($BoxUpR,$BoxUpG,$BoxUpB); } else { $ImageMapColor = $this->pChartObject->toHTMLColor($BoxDownR,$BoxDownG,$BoxDownB); } |
|
130 | 130 | |
131 | - if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT ) |
|
131 | + if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT ) |
|
132 | 132 | { |
133 | - if ( $YZero > $this->pChartObject->GraphAreaY2-1 ) { $YZero = $this->pChartObject->GraphAreaY2-1; } |
|
134 | - if ( $YZero < $this->pChartObject->GraphAreaY1+1 ) { $YZero = $this->pChartObject->GraphAreaY1+1; } |
|
133 | + if ( $YZero > $this->pChartObject->GraphAreaY2-1 ) { $YZero = $this->pChartObject->GraphAreaY2-1; } |
|
134 | + if ( $YZero < $this->pChartObject->GraphAreaY1+1 ) { $YZero = $this->pChartObject->GraphAreaY1+1; } |
|
135 | 135 | |
136 | - if ( $XDivs == 0 ) { $XStep = 0; } else { $XStep = ($this->pChartObject->GraphAreaX2-$this->pChartObject->GraphAreaX1-$XMargin*2)/$XDivs; } |
|
136 | + if ( $XDivs == 0 ) { $XStep = 0; } else { $XStep = ($this->pChartObject->GraphAreaX2-$this->pChartObject->GraphAreaX1-$XMargin*2)/$XDivs; } |
|
137 | 137 | |
138 | - if ( $ShadowOnBoxesOnly ) { $RestoreShadow = $this->pChartObject->Shadow; $this->pChartObject->Shadow = FALSE; } |
|
138 | + if ( $ShadowOnBoxesOnly ) { $RestoreShadow = $this->pChartObject->Shadow; $this->pChartObject->Shadow = FALSE; } |
|
139 | 139 | |
140 | - if ( $LineWidth == 1 ) |
|
141 | - $this->pChartObject->drawLine($X,$PosArray[2],$X,$PosArray[3],$LineSettings); |
|
142 | - else |
|
143 | - $this->pChartObject->drawFilledRectangle($X-$LineOffset,$PosArray[2],$X+$LineOffset,$PosArray[3],$LineSettings); |
|
140 | + if ( $LineWidth == 1 ) |
|
141 | + $this->pChartObject->drawLine($X,$PosArray[2],$X,$PosArray[3],$LineSettings); |
|
142 | + else |
|
143 | + $this->pChartObject->drawFilledRectangle($X-$LineOffset,$PosArray[2],$X+$LineOffset,$PosArray[3],$LineSettings); |
|
144 | 144 | |
145 | - if ( $ExtremityWidth == 1 ) |
|
146 | - { |
|
147 | - $this->pChartObject->drawLine($X-$ExtremityLength,$PosArray[2],$X+$ExtremityLength,$PosArray[2],$ExtremitySettings); |
|
148 | - $this->pChartObject->drawLine($X-$ExtremityLength,$PosArray[3],$X+$ExtremityLength,$PosArray[3],$ExtremitySettings); |
|
145 | + if ( $ExtremityWidth == 1 ) |
|
146 | + { |
|
147 | + $this->pChartObject->drawLine($X-$ExtremityLength,$PosArray[2],$X+$ExtremityLength,$PosArray[2],$ExtremitySettings); |
|
148 | + $this->pChartObject->drawLine($X-$ExtremityLength,$PosArray[3],$X+$ExtremityLength,$PosArray[3],$ExtremitySettings); |
|
149 | 149 | |
150 | - if ( $RecordImageMap ) { $this->pChartObject->addToImageMap("RECT",floor($X-$ExtremityLength).",".floor($PosArray[2]).",".floor($X+$ExtremityLength).",".floor($PosArray[3]),$ImageMapColor,$ImageMapTitle,$Values); } |
|
151 | - } |
|
152 | - else |
|
153 | - { |
|
154 | - $this->pChartObject->drawFilledRectangle($X-$ExtremityLength,$PosArray[2],$X+$ExtremityLength,$PosArray[2]-$ExtremityWidth,$ExtremitySettings); |
|
155 | - $this->pChartObject->drawFilledRectangle($X-$ExtremityLength,$PosArray[3],$X+$ExtremityLength,$PosArray[3]+$ExtremityWidth,$ExtremitySettings); |
|
150 | + if ( $RecordImageMap ) { $this->pChartObject->addToImageMap("RECT",floor($X-$ExtremityLength).",".floor($PosArray[2]).",".floor($X+$ExtremityLength).",".floor($PosArray[3]),$ImageMapColor,$ImageMapTitle,$Values); } |
|
151 | + } |
|
152 | + else |
|
153 | + { |
|
154 | + $this->pChartObject->drawFilledRectangle($X-$ExtremityLength,$PosArray[2],$X+$ExtremityLength,$PosArray[2]-$ExtremityWidth,$ExtremitySettings); |
|
155 | + $this->pChartObject->drawFilledRectangle($X-$ExtremityLength,$PosArray[3],$X+$ExtremityLength,$PosArray[3]+$ExtremityWidth,$ExtremitySettings); |
|
156 | 156 | |
157 | - if ( $RecordImageMap ) { $this->pChartObject->addToImageMap("RECT",floor($X-$ExtremityLength).",".floor($PosArray[2]-$ExtremityWidth).",".floor($X+$ExtremityLength).",".floor($PosArray[3]+$ExtremityWidth),$ImageMapColor,$ImageMapTitle,$Values); } |
|
158 | - } |
|
157 | + if ( $RecordImageMap ) { $this->pChartObject->addToImageMap("RECT",floor($X-$ExtremityLength).",".floor($PosArray[2]-$ExtremityWidth).",".floor($X+$ExtremityLength).",".floor($PosArray[3]+$ExtremityWidth),$ImageMapColor,$ImageMapTitle,$Values); } |
|
158 | + } |
|
159 | 159 | |
160 | - if ( $ShadowOnBoxesOnly ) { $this->pChartObject->Shadow = $RestoreShadow; } |
|
160 | + if ( $ShadowOnBoxesOnly ) { $this->pChartObject->Shadow = $RestoreShadow; } |
|
161 | 161 | |
162 | - if ( $PosArray[0] > $PosArray[1] ) |
|
163 | - $this->pChartObject->drawFilledRectangle($X-$BoxOffset,$PosArray[0],$X+$BoxOffset,$PosArray[1],$BoxUpSettings); |
|
164 | - else |
|
165 | - $this->pChartObject->drawFilledRectangle($X-$BoxOffset,$PosArray[0],$X+$BoxOffset,$PosArray[1],$BoxDownSettings); |
|
162 | + if ( $PosArray[0] > $PosArray[1] ) |
|
163 | + $this->pChartObject->drawFilledRectangle($X-$BoxOffset,$PosArray[0],$X+$BoxOffset,$PosArray[1],$BoxUpSettings); |
|
164 | + else |
|
165 | + $this->pChartObject->drawFilledRectangle($X-$BoxOffset,$PosArray[0],$X+$BoxOffset,$PosArray[1],$BoxDownSettings); |
|
166 | 166 | |
167 | - if ( isset($PosArray[4]) ) |
|
168 | - $this->pChartObject->drawLine($X-$ExtremityLength,$PosArray[4],$X+$ExtremityLength,$PosArray[4],$MedianSettings); |
|
167 | + if ( isset($PosArray[4]) ) |
|
168 | + $this->pChartObject->drawLine($X-$ExtremityLength,$PosArray[4],$X+$ExtremityLength,$PosArray[4],$MedianSettings); |
|
169 | 169 | |
170 | - $X = $X + $XStep; |
|
170 | + $X = $X + $XStep; |
|
171 | 171 | } |
172 | - elseif ( $Data["Orientation"] == SCALE_POS_TOPBOTTOM ) |
|
172 | + elseif ( $Data["Orientation"] == SCALE_POS_TOPBOTTOM ) |
|
173 | 173 | { |
174 | - if ( $YZero > $this->pChartObject->GraphAreaX2-1 ) { $YZero = $this->pChartObject->GraphAreaX2-1; } |
|
175 | - if ( $YZero < $this->pChartObject->GraphAreaX1+1 ) { $YZero = $this->pChartObject->GraphAreaX1+1; } |
|
174 | + if ( $YZero > $this->pChartObject->GraphAreaX2-1 ) { $YZero = $this->pChartObject->GraphAreaX2-1; } |
|
175 | + if ( $YZero < $this->pChartObject->GraphAreaX1+1 ) { $YZero = $this->pChartObject->GraphAreaX1+1; } |
|
176 | 176 | |
177 | - if ( $XDivs == 0 ) { $XStep = 0; } else { $XStep = ($this->pChartObject->GraphAreaY2-$this->pChartObject->GraphAreaY1-$XMargin*2)/$XDivs; } |
|
177 | + if ( $XDivs == 0 ) { $XStep = 0; } else { $XStep = ($this->pChartObject->GraphAreaY2-$this->pChartObject->GraphAreaY1-$XMargin*2)/$XDivs; } |
|
178 | 178 | |
179 | - if ( $LineWidth == 1 ) |
|
180 | - $this->pChartObject->drawLine($PosArray[2],$Y,$PosArray[3],$Y,$LineSettings); |
|
181 | - else |
|
182 | - $this->pChartObject->drawFilledRectangle($PosArray[2],$Y-$LineOffset,$PosArray[3],$Y+$LineOffset,$LineSettings); |
|
179 | + if ( $LineWidth == 1 ) |
|
180 | + $this->pChartObject->drawLine($PosArray[2],$Y,$PosArray[3],$Y,$LineSettings); |
|
181 | + else |
|
182 | + $this->pChartObject->drawFilledRectangle($PosArray[2],$Y-$LineOffset,$PosArray[3],$Y+$LineOffset,$LineSettings); |
|
183 | 183 | |
184 | - if ( $ShadowOnBoxesOnly ) { $RestoreShadow = $this->pChartObject->Shadow; $this->pChartObject->Shadow = FALSE; } |
|
184 | + if ( $ShadowOnBoxesOnly ) { $RestoreShadow = $this->pChartObject->Shadow; $this->pChartObject->Shadow = FALSE; } |
|
185 | 185 | |
186 | - if ( $ExtremityWidth == 1 ) |
|
187 | - { |
|
188 | - $this->pChartObject->drawLine($PosArray[2],$Y-$ExtremityLength,$PosArray[2],$Y+$ExtremityLength,$ExtremitySettings); |
|
189 | - $this->pChartObject->drawLine($PosArray[3],$Y-$ExtremityLength,$PosArray[3],$Y+$ExtremityLength,$ExtremitySettings); |
|
186 | + if ( $ExtremityWidth == 1 ) |
|
187 | + { |
|
188 | + $this->pChartObject->drawLine($PosArray[2],$Y-$ExtremityLength,$PosArray[2],$Y+$ExtremityLength,$ExtremitySettings); |
|
189 | + $this->pChartObject->drawLine($PosArray[3],$Y-$ExtremityLength,$PosArray[3],$Y+$ExtremityLength,$ExtremitySettings); |
|
190 | 190 | |
191 | - if ( $RecordImageMap ) { $this->pChartObject->addToImageMap("RECT",floor($PosArray[2]).",".floor($Y-$ExtremityLength).",".floor($PosArray[3]).",".floor($Y+$ExtremityLength),$ImageMapColor,$ImageMapTitle,$Values); } |
|
192 | - } |
|
193 | - else |
|
194 | - { |
|
195 | - $this->pChartObject->drawFilledRectangle($PosArray[2],$Y-$ExtremityLength,$PosArray[2]-$ExtremityWidth,$Y+$ExtremityLength,$ExtremitySettings); |
|
196 | - $this->pChartObject->drawFilledRectangle($PosArray[3],$Y-$ExtremityLength,$PosArray[3]+$ExtremityWidth,$Y+$ExtremityLength,$ExtremitySettings); |
|
191 | + if ( $RecordImageMap ) { $this->pChartObject->addToImageMap("RECT",floor($PosArray[2]).",".floor($Y-$ExtremityLength).",".floor($PosArray[3]).",".floor($Y+$ExtremityLength),$ImageMapColor,$ImageMapTitle,$Values); } |
|
192 | + } |
|
193 | + else |
|
194 | + { |
|
195 | + $this->pChartObject->drawFilledRectangle($PosArray[2],$Y-$ExtremityLength,$PosArray[2]-$ExtremityWidth,$Y+$ExtremityLength,$ExtremitySettings); |
|
196 | + $this->pChartObject->drawFilledRectangle($PosArray[3],$Y-$ExtremityLength,$PosArray[3]+$ExtremityWidth,$Y+$ExtremityLength,$ExtremitySettings); |
|
197 | 197 | |
198 | - if ( $RecordImageMap ) { $this->pChartObject->addToImageMap("RECT",floor($PosArray[2]-$ExtremityWidth).",".floor($Y-$ExtremityLength).",".floor($PosArray[3]+$ExtremityWidth).",".floor($Y+$ExtremityLength),$ImageMapColor,$ImageMapTitle,$Values); } |
|
199 | - } |
|
198 | + if ( $RecordImageMap ) { $this->pChartObject->addToImageMap("RECT",floor($PosArray[2]-$ExtremityWidth).",".floor($Y-$ExtremityLength).",".floor($PosArray[3]+$ExtremityWidth).",".floor($Y+$ExtremityLength),$ImageMapColor,$ImageMapTitle,$Values); } |
|
199 | + } |
|
200 | 200 | |
201 | - if ( $ShadowOnBoxesOnly ) { $this->pChartObject->Shadow = $RestoreShadow; } |
|
201 | + if ( $ShadowOnBoxesOnly ) { $this->pChartObject->Shadow = $RestoreShadow; } |
|
202 | 202 | |
203 | - if ( $PosArray[0] < $PosArray[1] ) |
|
204 | - $this->pChartObject->drawFilledRectangle($PosArray[0],$Y-$BoxOffset,$PosArray[1],$Y+$BoxOffset,$BoxUpSettings); |
|
205 | - else |
|
206 | - $this->pChartObject->drawFilledRectangle($PosArray[0],$Y-$BoxOffset,$PosArray[1],$Y+$BoxOffset,$BoxDownSettings); |
|
203 | + if ( $PosArray[0] < $PosArray[1] ) |
|
204 | + $this->pChartObject->drawFilledRectangle($PosArray[0],$Y-$BoxOffset,$PosArray[1],$Y+$BoxOffset,$BoxUpSettings); |
|
205 | + else |
|
206 | + $this->pChartObject->drawFilledRectangle($PosArray[0],$Y-$BoxOffset,$PosArray[1],$Y+$BoxOffset,$BoxDownSettings); |
|
207 | 207 | |
208 | - if ( isset($PosArray[4]) ) |
|
209 | - $this->pChartObject->drawLine($PosArray[4],$Y-$ExtremityLength,$PosArray[4],$Y+$ExtremityLength,$MedianSettings); |
|
208 | + if ( isset($PosArray[4]) ) |
|
209 | + $this->pChartObject->drawLine($PosArray[4],$Y-$ExtremityLength,$PosArray[4],$Y+$ExtremityLength,$MedianSettings); |
|
210 | 210 | |
211 | - $Y = $Y + $XStep; |
|
211 | + $Y = $Y + $XStep; |
|
212 | + } |
|
212 | 213 | } |
213 | - } |
|
214 | 214 | } |
215 | - } |
|
215 | + } |
|
216 | 216 | ?> |
217 | 217 | \ No newline at end of file |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | You can find the whole class documentation on the pChart web site. |
14 | 14 | */ |
15 | 15 | |
16 | - define("STOCK_MISSING_SERIE" , 180001); |
|
16 | + define("STOCK_MISSING_SERIE", 180001); |
|
17 | 17 | |
18 | 18 | /* pStock class definition */ |
19 | 19 | class pStock |
@@ -22,82 +22,82 @@ discard block |
||
22 | 22 | var $pDataObject; |
23 | 23 | |
24 | 24 | /* Class creator */ |
25 | - function pStock($pChartObject,$pDataObject) |
|
25 | + function pStock($pChartObject, $pDataObject) |
|
26 | 26 | { |
27 | 27 | $this->pChartObject = $pChartObject; |
28 | 28 | $this->pDataObject = $pDataObject; |
29 | 29 | } |
30 | 30 | |
31 | 31 | /* Draw a stock chart */ |
32 | - function drawStockChart($Format="") |
|
32 | + function drawStockChart($Format = "") |
|
33 | 33 | { |
34 | 34 | $SerieOpen = isset($Format["SerieOpen"]) ? $Format["SerieOpen"] : "Open"; |
35 | 35 | $SerieClose = isset($Format["SerieClose"]) ? $Format["SerieClose"] : "Close"; |
36 | 36 | $SerieMin = isset($Format["SerieMin"]) ? $Format["SerieMin"] : "Min"; |
37 | 37 | $SerieMax = isset($Format["SerieMax"]) ? $Format["SerieMax"] : "Max"; |
38 | - $SerieMedian = isset($Format["SerieMedian"]) ? $Format["SerieMedian"] : NULL; |
|
39 | - $LineWidth = isset($Format["LineWidth"]) ? $Format["LineWidth"] : 1; |
|
38 | + $SerieMedian = isset($Format["SerieMedian"]) ? $Format["SerieMedian"] : NULL; |
|
39 | + $LineWidth = isset($Format["LineWidth"]) ? $Format["LineWidth"] : 1; |
|
40 | 40 | $LineR = isset($Format["LineR"]) ? $Format["LineR"] : 0; |
41 | 41 | $LineG = isset($Format["LineG"]) ? $Format["LineG"] : 0; |
42 | 42 | $LineB = isset($Format["LineB"]) ? $Format["LineB"] : 0; |
43 | 43 | $LineAlpha = isset($Format["LineAlpha"]) ? $Format["LineAlpha"] : 100; |
44 | - $ExtremityWidth = isset($Format["ExtremityWidth"]) ? $Format["ExtremityWidth"] : 1; |
|
45 | - $ExtremityLength = isset($Format["ExtremityLength"]) ? $Format["ExtremityLength"] : 3; |
|
44 | + $ExtremityWidth = isset($Format["ExtremityWidth"]) ? $Format["ExtremityWidth"] : 1; |
|
45 | + $ExtremityLength = isset($Format["ExtremityLength"]) ? $Format["ExtremityLength"] : 3; |
|
46 | 46 | $ExtremityR = isset($Format["ExtremityR"]) ? $Format["ExtremityR"] : 0; |
47 | 47 | $ExtremityG = isset($Format["ExtremityG"]) ? $Format["ExtremityG"] : 0; |
48 | 48 | $ExtremityB = isset($Format["ExtremityB"]) ? $Format["ExtremityB"] : 0; |
49 | - $ExtremityAlpha = isset($Format["ExtremityAlpha"]) ? $Format["ExtremityAlpha"] : 100; |
|
50 | - $BoxWidth = isset($Format["BoxWidth"]) ? $Format["BoxWidth"] : 8; |
|
49 | + $ExtremityAlpha = isset($Format["ExtremityAlpha"]) ? $Format["ExtremityAlpha"] : 100; |
|
50 | + $BoxWidth = isset($Format["BoxWidth"]) ? $Format["BoxWidth"] : 8; |
|
51 | 51 | $BoxUpR = isset($Format["BoxUpR"]) ? $Format["BoxUpR"] : 188; |
52 | 52 | $BoxUpG = isset($Format["BoxUpG"]) ? $Format["BoxUpG"] : 224; |
53 | 53 | $BoxUpB = isset($Format["BoxUpB"]) ? $Format["BoxUpB"] : 46; |
54 | - $BoxUpAlpha = isset($Format["BoxUpAlpha"]) ? $Format["BoxUpAlpha"] : 100; |
|
55 | - $BoxUpSurrounding = isset($Format["BoxUpSurrounding"]) ? $Format["BoxUpSurrounding"] : NULL; |
|
56 | - $BoxUpBorderR = isset($Format["BoxUpBorderR"]) ? $Format["BoxUpBorderR"] : $BoxUpR-20; |
|
57 | - $BoxUpBorderG = isset($Format["BoxUpBorderG"]) ? $Format["BoxUpBorderG"] : $BoxUpG-20; |
|
58 | - $BoxUpBorderB = isset($Format["BoxUpBorderB"]) ? $Format["BoxUpBorderB"] : $BoxUpB-20; |
|
59 | - $BoxUpBorderAlpha = isset($Format["BoxUpBorderAlpha"]) ? $Format["BoxUpBorderAlpha"] : 100; |
|
54 | + $BoxUpAlpha = isset($Format["BoxUpAlpha"]) ? $Format["BoxUpAlpha"] : 100; |
|
55 | + $BoxUpSurrounding = isset($Format["BoxUpSurrounding"]) ? $Format["BoxUpSurrounding"] : NULL; |
|
56 | + $BoxUpBorderR = isset($Format["BoxUpBorderR"]) ? $Format["BoxUpBorderR"] : $BoxUpR - 20; |
|
57 | + $BoxUpBorderG = isset($Format["BoxUpBorderG"]) ? $Format["BoxUpBorderG"] : $BoxUpG - 20; |
|
58 | + $BoxUpBorderB = isset($Format["BoxUpBorderB"]) ? $Format["BoxUpBorderB"] : $BoxUpB - 20; |
|
59 | + $BoxUpBorderAlpha = isset($Format["BoxUpBorderAlpha"]) ? $Format["BoxUpBorderAlpha"] : 100; |
|
60 | 60 | $BoxDownR = isset($Format["BoxDownR"]) ? $Format["BoxDownR"] : 224; |
61 | 61 | $BoxDownG = isset($Format["BoxDownG"]) ? $Format["BoxDownG"] : 100; |
62 | 62 | $BoxDownB = isset($Format["BoxDownB"]) ? $Format["BoxDownB"] : 46; |
63 | - $BoxDownAlpha = isset($Format["BoxDownAlpha"]) ? $Format["BoxDownAlpha"] : 100; |
|
64 | - $BoxDownSurrounding= isset($Format["BoxDownSurrounding"]) ? $Format["BoxDownSurrounding"] : NULL; |
|
65 | - $BoxDownBorderR = isset($Format["BoxDownBorderR"]) ? $Format["BoxDownBorderR"] : $BoxDownR-20; |
|
66 | - $BoxDownBorderG = isset($Format["BoxDownBorderG"]) ? $Format["BoxDownBorderG"] : $BoxDownG-20; |
|
67 | - $BoxDownBorderB = isset($Format["BoxDownBorderB"]) ? $Format["BoxDownBorderB"] : $BoxDownB-20; |
|
68 | - $BoxDownBorderAlpha= isset($Format["BoxDownBorderAlpha"]) ? $Format["BoxDownBorderAlpha"] : 100; |
|
63 | + $BoxDownAlpha = isset($Format["BoxDownAlpha"]) ? $Format["BoxDownAlpha"] : 100; |
|
64 | + $BoxDownSurrounding = isset($Format["BoxDownSurrounding"]) ? $Format["BoxDownSurrounding"] : NULL; |
|
65 | + $BoxDownBorderR = isset($Format["BoxDownBorderR"]) ? $Format["BoxDownBorderR"] : $BoxDownR - 20; |
|
66 | + $BoxDownBorderG = isset($Format["BoxDownBorderG"]) ? $Format["BoxDownBorderG"] : $BoxDownG - 20; |
|
67 | + $BoxDownBorderB = isset($Format["BoxDownBorderB"]) ? $Format["BoxDownBorderB"] : $BoxDownB - 20; |
|
68 | + $BoxDownBorderAlpha = isset($Format["BoxDownBorderAlpha"]) ? $Format["BoxDownBorderAlpha"] : 100; |
|
69 | 69 | $ShadowOnBoxesOnly = isset($Format["ShadowOnBoxesOnly"]) ? $Format["ShadowOnBoxesOnly"] : TRUE; |
70 | 70 | $MedianR = isset($Format["MedianR"]) ? $Format["MedianR"] : 255; |
71 | 71 | $MedianG = isset($Format["MedianG"]) ? $Format["MedianG"] : 0; |
72 | 72 | $MedianB = isset($Format["MedianB"]) ? $Format["MedianB"] : 0; |
73 | - $MedianAlpha = isset($Format["MedianAlpha"]) ? $Format["MedianAlpha"] : 100; |
|
74 | - $RecordImageMap = isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : FALSE; |
|
75 | - $ImageMapTitle = isset($Format["ImageMapTitle"]) ? $Format["ImageMapTitle"] : "Stock Chart"; |
|
73 | + $MedianAlpha = isset($Format["MedianAlpha"]) ? $Format["MedianAlpha"] : 100; |
|
74 | + $RecordImageMap = isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : FALSE; |
|
75 | + $ImageMapTitle = isset($Format["ImageMapTitle"]) ? $Format["ImageMapTitle"] : "Stock Chart"; |
|
76 | 76 | |
77 | 77 | |
78 | 78 | /* Data Processing */ |
79 | 79 | $Data = $this->pDataObject->getData(); |
80 | 80 | $Palette = $this->pDataObject->getPalette(); |
81 | 81 | |
82 | - if ( $BoxUpSurrounding != NULL ) { $BoxUpBorderR = $BoxUpR + $BoxUpSurrounding; $BoxUpBorderG = $BoxUpG + $BoxUpSurrounding; $BoxUpBorderB = $BoxUpB + $BoxUpSurrounding; } |
|
83 | - if ( $BoxDownSurrounding != NULL ) { $BoxDownBorderR = $BoxDownR + $BoxDownSurrounding; $BoxDownBorderG = $BoxDownG + $BoxDownSurrounding; $BoxDownBorderB = $BoxDownB + $BoxDownSurrounding; } |
|
82 | + if ($BoxUpSurrounding != NULL) { $BoxUpBorderR = $BoxUpR + $BoxUpSurrounding; $BoxUpBorderG = $BoxUpG + $BoxUpSurrounding; $BoxUpBorderB = $BoxUpB + $BoxUpSurrounding; } |
|
83 | + if ($BoxDownSurrounding != NULL) { $BoxDownBorderR = $BoxDownR + $BoxDownSurrounding; $BoxDownBorderG = $BoxDownG + $BoxDownSurrounding; $BoxDownBorderB = $BoxDownB + $BoxDownSurrounding; } |
|
84 | 84 | |
85 | - if ( $LineWidth != 1 ) { $LineOffset = $LineWidth / 2; } |
|
86 | - $BoxOffset = $BoxWidth / 2; |
|
85 | + if ($LineWidth != 1) { $LineOffset = $LineWidth/2; } |
|
86 | + $BoxOffset = $BoxWidth/2; |
|
87 | 87 | |
88 | 88 | $Data = $this->pChartObject->DataSet->getData(); |
89 | - list($XMargin,$XDivs) = $this->pChartObject->scaleGetXSettings(); |
|
89 | + list($XMargin, $XDivs) = $this->pChartObject->scaleGetXSettings(); |
|
90 | 90 | |
91 | - if ( !isset($Data["Series"][$SerieOpen]) || !isset($Data["Series"][$SerieClose]) || !isset($Data["Series"][$SerieMin]) || !isset($Data["Series"][$SerieMax]) ) |
|
91 | + if (!isset($Data["Series"][$SerieOpen]) || !isset($Data["Series"][$SerieClose]) || !isset($Data["Series"][$SerieMin]) || !isset($Data["Series"][$SerieMax])) |
|
92 | 92 | return(STOCK_MISSING_SERIE); |
93 | 93 | |
94 | 94 | $Plots = ""; |
95 | - foreach($Data["Series"][$SerieOpen]["Data"] as $Key => $Value) |
|
95 | + foreach ($Data["Series"][$SerieOpen]["Data"] as $Key => $Value) |
|
96 | 96 | { |
97 | 97 | $Point = ""; |
98 | - if ( isset($Data["Series"][$SerieClose]["Data"][$Key]) || isset($Data["Series"][$SerieMin]["Data"][$Key]) || isset($Data["Series"][$SerieMax]["Data"][$Key]) ) |
|
99 | - $Point = array($Value,$Data["Series"][$SerieClose]["Data"][$Key],$Data["Series"][$SerieMin]["Data"][$Key],$Data["Series"][$SerieMax]["Data"][$Key]); |
|
100 | - if ( $SerieMedian != NULL && isset($Data["Series"][$SerieMedian]["Data"][$Key]) ) |
|
98 | + if (isset($Data["Series"][$SerieClose]["Data"][$Key]) || isset($Data["Series"][$SerieMin]["Data"][$Key]) || isset($Data["Series"][$SerieMax]["Data"][$Key])) |
|
99 | + $Point = array($Value, $Data["Series"][$SerieClose]["Data"][$Key], $Data["Series"][$SerieMin]["Data"][$Key], $Data["Series"][$SerieMax]["Data"][$Key]); |
|
100 | + if ($SerieMedian != NULL && isset($Data["Series"][$SerieMedian]["Data"][$Key])) |
|
101 | 101 | $Point[] = $Data["Series"][$SerieMedian]["Data"][$Key]; |
102 | 102 | |
103 | 103 | $Plots[] = $Point; |
@@ -108,105 +108,105 @@ discard block |
||
108 | 108 | $Format = $Data["Axis"][$AxisID]["Format"]; |
109 | 109 | $Unit = $Data["Axis"][$AxisID]["Unit"]; |
110 | 110 | |
111 | - $YZero = $this->pChartObject->scaleComputeY(0,array("AxisID"=>$AxisID)); |
|
112 | - $XStep = ($this->pChartObject->GraphAreaX2-$this->pChartObject->GraphAreaX1-$XMargin*2)/$XDivs; |
|
111 | + $YZero = $this->pChartObject->scaleComputeY(0, array("AxisID"=>$AxisID)); |
|
112 | + $XStep = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1 - $XMargin*2)/$XDivs; |
|
113 | 113 | |
114 | 114 | $X = $this->pChartObject->GraphAreaX1 + $XMargin; |
115 | 115 | $Y = $this->pChartObject->GraphAreaY1 + $XMargin; |
116 | 116 | |
117 | - $LineSettings = array("R"=>$LineR,"G"=>$LineG,"B"=>$LineB,"Alpha"=>$LineAlpha); |
|
118 | - $ExtremitySettings = array("R"=>$ExtremityR,"G"=>$ExtremityG,"B"=>$ExtremityB,"Alpha"=>$ExtremityAlpha); |
|
119 | - $BoxUpSettings = array("R"=>$BoxUpR,"G"=>$BoxUpG,"B"=>$BoxUpB,"Alpha"=>$BoxUpAlpha,"BorderR"=>$BoxUpBorderR,"BorderG"=>$BoxUpBorderG,"BorderB"=>$BoxUpBorderB,"BorderAlpha"=>$BoxUpBorderAlpha); |
|
120 | - $BoxDownSettings = array("R"=>$BoxDownR,"G"=>$BoxDownG,"B"=>$BoxDownB,"Alpha"=>$BoxDownAlpha,"BorderR"=>$BoxDownBorderR,"BorderG"=>$BoxDownBorderG,"BorderB"=>$BoxDownBorderB,"BorderAlpha"=>$BoxDownBorderAlpha); |
|
121 | - $MedianSettings = array("R"=>$MedianR,"G"=>$MedianG,"B"=>$MedianB,"Alpha"=>$MedianAlpha); |
|
117 | + $LineSettings = array("R"=>$LineR, "G"=>$LineG, "B"=>$LineB, "Alpha"=>$LineAlpha); |
|
118 | + $ExtremitySettings = array("R"=>$ExtremityR, "G"=>$ExtremityG, "B"=>$ExtremityB, "Alpha"=>$ExtremityAlpha); |
|
119 | + $BoxUpSettings = array("R"=>$BoxUpR, "G"=>$BoxUpG, "B"=>$BoxUpB, "Alpha"=>$BoxUpAlpha, "BorderR"=>$BoxUpBorderR, "BorderG"=>$BoxUpBorderG, "BorderB"=>$BoxUpBorderB, "BorderAlpha"=>$BoxUpBorderAlpha); |
|
120 | + $BoxDownSettings = array("R"=>$BoxDownR, "G"=>$BoxDownG, "B"=>$BoxDownB, "Alpha"=>$BoxDownAlpha, "BorderR"=>$BoxDownBorderR, "BorderG"=>$BoxDownBorderG, "BorderB"=>$BoxDownBorderB, "BorderAlpha"=>$BoxDownBorderAlpha); |
|
121 | + $MedianSettings = array("R"=>$MedianR, "G"=>$MedianG, "B"=>$MedianB, "Alpha"=>$MedianAlpha); |
|
122 | 122 | |
123 | - foreach($Plots as $Key =>$Points) |
|
123 | + foreach ($Plots as $Key =>$Points) |
|
124 | 124 | { |
125 | - $PosArray = $this->pChartObject->scaleComputeY($Points,array("AxisID"=>$AxisID)); |
|
125 | + $PosArray = $this->pChartObject->scaleComputeY($Points, array("AxisID"=>$AxisID)); |
|
126 | 126 | |
127 | 127 | $Values = "Open :".$Data["Series"][$SerieOpen]["Data"][$Key]."<BR>Close : ".$Data["Series"][$SerieClose]["Data"][$Key]."<BR>Min : ".$Data["Series"][$SerieMin]["Data"][$Key]."<BR>Max : ".$Data["Series"][$SerieMax]["Data"][$Key]."<BR>"; |
128 | - if ( $SerieMedian != NULL ) { $Values = $Values."Median : ".$Data["Series"][$SerieMedian]["Data"][$Key]."<BR>"; } |
|
129 | - if ( $PosArray[0] > $PosArray[1] ) { $ImageMapColor = $this->pChartObject->toHTMLColor($BoxUpR,$BoxUpG,$BoxUpB); } else { $ImageMapColor = $this->pChartObject->toHTMLColor($BoxDownR,$BoxDownG,$BoxDownB); } |
|
128 | + if ($SerieMedian != NULL) { $Values = $Values."Median : ".$Data["Series"][$SerieMedian]["Data"][$Key]."<BR>"; } |
|
129 | + if ($PosArray[0] > $PosArray[1]) { $ImageMapColor = $this->pChartObject->toHTMLColor($BoxUpR, $BoxUpG, $BoxUpB); } else { $ImageMapColor = $this->pChartObject->toHTMLColor($BoxDownR, $BoxDownG, $BoxDownB); } |
|
130 | 130 | |
131 | - if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT ) |
|
131 | + if ($Data["Orientation"] == SCALE_POS_LEFTRIGHT) |
|
132 | 132 | { |
133 | - if ( $YZero > $this->pChartObject->GraphAreaY2-1 ) { $YZero = $this->pChartObject->GraphAreaY2-1; } |
|
134 | - if ( $YZero < $this->pChartObject->GraphAreaY1+1 ) { $YZero = $this->pChartObject->GraphAreaY1+1; } |
|
133 | + if ($YZero > $this->pChartObject->GraphAreaY2 - 1) { $YZero = $this->pChartObject->GraphAreaY2 - 1; } |
|
134 | + if ($YZero < $this->pChartObject->GraphAreaY1 + 1) { $YZero = $this->pChartObject->GraphAreaY1 + 1; } |
|
135 | 135 | |
136 | - if ( $XDivs == 0 ) { $XStep = 0; } else { $XStep = ($this->pChartObject->GraphAreaX2-$this->pChartObject->GraphAreaX1-$XMargin*2)/$XDivs; } |
|
136 | + if ($XDivs == 0) { $XStep = 0; } else { $XStep = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1 - $XMargin*2)/$XDivs; } |
|
137 | 137 | |
138 | - if ( $ShadowOnBoxesOnly ) { $RestoreShadow = $this->pChartObject->Shadow; $this->pChartObject->Shadow = FALSE; } |
|
138 | + if ($ShadowOnBoxesOnly) { $RestoreShadow = $this->pChartObject->Shadow; $this->pChartObject->Shadow = FALSE; } |
|
139 | 139 | |
140 | - if ( $LineWidth == 1 ) |
|
141 | - $this->pChartObject->drawLine($X,$PosArray[2],$X,$PosArray[3],$LineSettings); |
|
140 | + if ($LineWidth == 1) |
|
141 | + $this->pChartObject->drawLine($X, $PosArray[2], $X, $PosArray[3], $LineSettings); |
|
142 | 142 | else |
143 | - $this->pChartObject->drawFilledRectangle($X-$LineOffset,$PosArray[2],$X+$LineOffset,$PosArray[3],$LineSettings); |
|
143 | + $this->pChartObject->drawFilledRectangle($X - $LineOffset, $PosArray[2], $X + $LineOffset, $PosArray[3], $LineSettings); |
|
144 | 144 | |
145 | - if ( $ExtremityWidth == 1 ) |
|
145 | + if ($ExtremityWidth == 1) |
|
146 | 146 | { |
147 | - $this->pChartObject->drawLine($X-$ExtremityLength,$PosArray[2],$X+$ExtremityLength,$PosArray[2],$ExtremitySettings); |
|
148 | - $this->pChartObject->drawLine($X-$ExtremityLength,$PosArray[3],$X+$ExtremityLength,$PosArray[3],$ExtremitySettings); |
|
147 | + $this->pChartObject->drawLine($X - $ExtremityLength, $PosArray[2], $X + $ExtremityLength, $PosArray[2], $ExtremitySettings); |
|
148 | + $this->pChartObject->drawLine($X - $ExtremityLength, $PosArray[3], $X + $ExtremityLength, $PosArray[3], $ExtremitySettings); |
|
149 | 149 | |
150 | - if ( $RecordImageMap ) { $this->pChartObject->addToImageMap("RECT",floor($X-$ExtremityLength).",".floor($PosArray[2]).",".floor($X+$ExtremityLength).",".floor($PosArray[3]),$ImageMapColor,$ImageMapTitle,$Values); } |
|
150 | + if ($RecordImageMap) { $this->pChartObject->addToImageMap("RECT", floor($X - $ExtremityLength).",".floor($PosArray[2]).",".floor($X + $ExtremityLength).",".floor($PosArray[3]), $ImageMapColor, $ImageMapTitle, $Values); } |
|
151 | 151 | } |
152 | 152 | else |
153 | 153 | { |
154 | - $this->pChartObject->drawFilledRectangle($X-$ExtremityLength,$PosArray[2],$X+$ExtremityLength,$PosArray[2]-$ExtremityWidth,$ExtremitySettings); |
|
155 | - $this->pChartObject->drawFilledRectangle($X-$ExtremityLength,$PosArray[3],$X+$ExtremityLength,$PosArray[3]+$ExtremityWidth,$ExtremitySettings); |
|
154 | + $this->pChartObject->drawFilledRectangle($X - $ExtremityLength, $PosArray[2], $X + $ExtremityLength, $PosArray[2] - $ExtremityWidth, $ExtremitySettings); |
|
155 | + $this->pChartObject->drawFilledRectangle($X - $ExtremityLength, $PosArray[3], $X + $ExtremityLength, $PosArray[3] + $ExtremityWidth, $ExtremitySettings); |
|
156 | 156 | |
157 | - if ( $RecordImageMap ) { $this->pChartObject->addToImageMap("RECT",floor($X-$ExtremityLength).",".floor($PosArray[2]-$ExtremityWidth).",".floor($X+$ExtremityLength).",".floor($PosArray[3]+$ExtremityWidth),$ImageMapColor,$ImageMapTitle,$Values); } |
|
157 | + if ($RecordImageMap) { $this->pChartObject->addToImageMap("RECT", floor($X - $ExtremityLength).",".floor($PosArray[2] - $ExtremityWidth).",".floor($X + $ExtremityLength).",".floor($PosArray[3] + $ExtremityWidth), $ImageMapColor, $ImageMapTitle, $Values); } |
|
158 | 158 | } |
159 | 159 | |
160 | - if ( $ShadowOnBoxesOnly ) { $this->pChartObject->Shadow = $RestoreShadow; } |
|
160 | + if ($ShadowOnBoxesOnly) { $this->pChartObject->Shadow = $RestoreShadow; } |
|
161 | 161 | |
162 | - if ( $PosArray[0] > $PosArray[1] ) |
|
163 | - $this->pChartObject->drawFilledRectangle($X-$BoxOffset,$PosArray[0],$X+$BoxOffset,$PosArray[1],$BoxUpSettings); |
|
162 | + if ($PosArray[0] > $PosArray[1]) |
|
163 | + $this->pChartObject->drawFilledRectangle($X - $BoxOffset, $PosArray[0], $X + $BoxOffset, $PosArray[1], $BoxUpSettings); |
|
164 | 164 | else |
165 | - $this->pChartObject->drawFilledRectangle($X-$BoxOffset,$PosArray[0],$X+$BoxOffset,$PosArray[1],$BoxDownSettings); |
|
165 | + $this->pChartObject->drawFilledRectangle($X - $BoxOffset, $PosArray[0], $X + $BoxOffset, $PosArray[1], $BoxDownSettings); |
|
166 | 166 | |
167 | - if ( isset($PosArray[4]) ) |
|
168 | - $this->pChartObject->drawLine($X-$ExtremityLength,$PosArray[4],$X+$ExtremityLength,$PosArray[4],$MedianSettings); |
|
167 | + if (isset($PosArray[4])) |
|
168 | + $this->pChartObject->drawLine($X - $ExtremityLength, $PosArray[4], $X + $ExtremityLength, $PosArray[4], $MedianSettings); |
|
169 | 169 | |
170 | 170 | $X = $X + $XStep; |
171 | 171 | } |
172 | - elseif ( $Data["Orientation"] == SCALE_POS_TOPBOTTOM ) |
|
172 | + elseif ($Data["Orientation"] == SCALE_POS_TOPBOTTOM) |
|
173 | 173 | { |
174 | - if ( $YZero > $this->pChartObject->GraphAreaX2-1 ) { $YZero = $this->pChartObject->GraphAreaX2-1; } |
|
175 | - if ( $YZero < $this->pChartObject->GraphAreaX1+1 ) { $YZero = $this->pChartObject->GraphAreaX1+1; } |
|
174 | + if ($YZero > $this->pChartObject->GraphAreaX2 - 1) { $YZero = $this->pChartObject->GraphAreaX2 - 1; } |
|
175 | + if ($YZero < $this->pChartObject->GraphAreaX1 + 1) { $YZero = $this->pChartObject->GraphAreaX1 + 1; } |
|
176 | 176 | |
177 | - if ( $XDivs == 0 ) { $XStep = 0; } else { $XStep = ($this->pChartObject->GraphAreaY2-$this->pChartObject->GraphAreaY1-$XMargin*2)/$XDivs; } |
|
177 | + if ($XDivs == 0) { $XStep = 0; } else { $XStep = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1 - $XMargin*2)/$XDivs; } |
|
178 | 178 | |
179 | - if ( $LineWidth == 1 ) |
|
180 | - $this->pChartObject->drawLine($PosArray[2],$Y,$PosArray[3],$Y,$LineSettings); |
|
179 | + if ($LineWidth == 1) |
|
180 | + $this->pChartObject->drawLine($PosArray[2], $Y, $PosArray[3], $Y, $LineSettings); |
|
181 | 181 | else |
182 | - $this->pChartObject->drawFilledRectangle($PosArray[2],$Y-$LineOffset,$PosArray[3],$Y+$LineOffset,$LineSettings); |
|
182 | + $this->pChartObject->drawFilledRectangle($PosArray[2], $Y - $LineOffset, $PosArray[3], $Y + $LineOffset, $LineSettings); |
|
183 | 183 | |
184 | - if ( $ShadowOnBoxesOnly ) { $RestoreShadow = $this->pChartObject->Shadow; $this->pChartObject->Shadow = FALSE; } |
|
184 | + if ($ShadowOnBoxesOnly) { $RestoreShadow = $this->pChartObject->Shadow; $this->pChartObject->Shadow = FALSE; } |
|
185 | 185 | |
186 | - if ( $ExtremityWidth == 1 ) |
|
186 | + if ($ExtremityWidth == 1) |
|
187 | 187 | { |
188 | - $this->pChartObject->drawLine($PosArray[2],$Y-$ExtremityLength,$PosArray[2],$Y+$ExtremityLength,$ExtremitySettings); |
|
189 | - $this->pChartObject->drawLine($PosArray[3],$Y-$ExtremityLength,$PosArray[3],$Y+$ExtremityLength,$ExtremitySettings); |
|
188 | + $this->pChartObject->drawLine($PosArray[2], $Y - $ExtremityLength, $PosArray[2], $Y + $ExtremityLength, $ExtremitySettings); |
|
189 | + $this->pChartObject->drawLine($PosArray[3], $Y - $ExtremityLength, $PosArray[3], $Y + $ExtremityLength, $ExtremitySettings); |
|
190 | 190 | |
191 | - if ( $RecordImageMap ) { $this->pChartObject->addToImageMap("RECT",floor($PosArray[2]).",".floor($Y-$ExtremityLength).",".floor($PosArray[3]).",".floor($Y+$ExtremityLength),$ImageMapColor,$ImageMapTitle,$Values); } |
|
191 | + if ($RecordImageMap) { $this->pChartObject->addToImageMap("RECT", floor($PosArray[2]).",".floor($Y - $ExtremityLength).",".floor($PosArray[3]).",".floor($Y + $ExtremityLength), $ImageMapColor, $ImageMapTitle, $Values); } |
|
192 | 192 | } |
193 | 193 | else |
194 | 194 | { |
195 | - $this->pChartObject->drawFilledRectangle($PosArray[2],$Y-$ExtremityLength,$PosArray[2]-$ExtremityWidth,$Y+$ExtremityLength,$ExtremitySettings); |
|
196 | - $this->pChartObject->drawFilledRectangle($PosArray[3],$Y-$ExtremityLength,$PosArray[3]+$ExtremityWidth,$Y+$ExtremityLength,$ExtremitySettings); |
|
195 | + $this->pChartObject->drawFilledRectangle($PosArray[2], $Y - $ExtremityLength, $PosArray[2] - $ExtremityWidth, $Y + $ExtremityLength, $ExtremitySettings); |
|
196 | + $this->pChartObject->drawFilledRectangle($PosArray[3], $Y - $ExtremityLength, $PosArray[3] + $ExtremityWidth, $Y + $ExtremityLength, $ExtremitySettings); |
|
197 | 197 | |
198 | - if ( $RecordImageMap ) { $this->pChartObject->addToImageMap("RECT",floor($PosArray[2]-$ExtremityWidth).",".floor($Y-$ExtremityLength).",".floor($PosArray[3]+$ExtremityWidth).",".floor($Y+$ExtremityLength),$ImageMapColor,$ImageMapTitle,$Values); } |
|
198 | + if ($RecordImageMap) { $this->pChartObject->addToImageMap("RECT", floor($PosArray[2] - $ExtremityWidth).",".floor($Y - $ExtremityLength).",".floor($PosArray[3] + $ExtremityWidth).",".floor($Y + $ExtremityLength), $ImageMapColor, $ImageMapTitle, $Values); } |
|
199 | 199 | } |
200 | 200 | |
201 | - if ( $ShadowOnBoxesOnly ) { $this->pChartObject->Shadow = $RestoreShadow; } |
|
201 | + if ($ShadowOnBoxesOnly) { $this->pChartObject->Shadow = $RestoreShadow; } |
|
202 | 202 | |
203 | - if ( $PosArray[0] < $PosArray[1] ) |
|
204 | - $this->pChartObject->drawFilledRectangle($PosArray[0],$Y-$BoxOffset,$PosArray[1],$Y+$BoxOffset,$BoxUpSettings); |
|
203 | + if ($PosArray[0] < $PosArray[1]) |
|
204 | + $this->pChartObject->drawFilledRectangle($PosArray[0], $Y - $BoxOffset, $PosArray[1], $Y + $BoxOffset, $BoxUpSettings); |
|
205 | 205 | else |
206 | - $this->pChartObject->drawFilledRectangle($PosArray[0],$Y-$BoxOffset,$PosArray[1],$Y+$BoxOffset,$BoxDownSettings); |
|
206 | + $this->pChartObject->drawFilledRectangle($PosArray[0], $Y - $BoxOffset, $PosArray[1], $Y + $BoxOffset, $BoxDownSettings); |
|
207 | 207 | |
208 | - if ( isset($PosArray[4]) ) |
|
209 | - $this->pChartObject->drawLine($PosArray[4],$Y-$ExtremityLength,$PosArray[4],$Y+$ExtremityLength,$MedianSettings); |
|
208 | + if (isset($PosArray[4])) |
|
209 | + $this->pChartObject->drawLine($PosArray[4], $Y - $ExtremityLength, $PosArray[4], $Y + $ExtremityLength, $MedianSettings); |
|
210 | 210 | |
211 | 211 | $Y = $Y + $XStep; |
212 | 212 | } |
@@ -16,21 +16,18 @@ discard block |
||
16 | 16 | define("STOCK_MISSING_SERIE" , 180001); |
17 | 17 | |
18 | 18 | /* pStock class definition */ |
19 | - class pStock |
|
20 | - { |
|
19 | + class pStock { |
|
21 | 20 | var $pChartObject; |
22 | 21 | var $pDataObject; |
23 | 22 | |
24 | 23 | /* Class creator */ |
25 | - function pStock($pChartObject,$pDataObject) |
|
26 | - { |
|
24 | + function pStock($pChartObject,$pDataObject) { |
|
27 | 25 | $this->pChartObject = $pChartObject; |
28 | 26 | $this->pDataObject = $pDataObject; |
29 | 27 | } |
30 | 28 | |
31 | 29 | /* Draw a stock chart */ |
32 | - function drawStockChart($Format="") |
|
33 | - { |
|
30 | + function drawStockChart($Format="") { |
|
34 | 31 | $SerieOpen = isset($Format["SerieOpen"]) ? $Format["SerieOpen"] : "Open"; |
35 | 32 | $SerieClose = isset($Format["SerieClose"]) ? $Format["SerieClose"] : "Close"; |
36 | 33 | $SerieMin = isset($Format["SerieMin"]) ? $Format["SerieMin"] : "Min"; |
@@ -92,8 +89,7 @@ discard block |
||
92 | 89 | return(STOCK_MISSING_SERIE); |
93 | 90 | |
94 | 91 | $Plots = ""; |
95 | - foreach($Data["Series"][$SerieOpen]["Data"] as $Key => $Value) |
|
96 | - { |
|
92 | + foreach($Data["Series"][$SerieOpen]["Data"] as $Key => $Value) { |
|
97 | 93 | $Point = ""; |
98 | 94 | if ( isset($Data["Series"][$SerieClose]["Data"][$Key]) || isset($Data["Series"][$SerieMin]["Data"][$Key]) || isset($Data["Series"][$SerieMax]["Data"][$Key]) ) |
99 | 95 | $Point = array($Value,$Data["Series"][$SerieClose]["Data"][$Key],$Data["Series"][$SerieMin]["Data"][$Key],$Data["Series"][$SerieMax]["Data"][$Key]); |
@@ -120,16 +116,14 @@ discard block |
||
120 | 116 | $BoxDownSettings = array("R"=>$BoxDownR,"G"=>$BoxDownG,"B"=>$BoxDownB,"Alpha"=>$BoxDownAlpha,"BorderR"=>$BoxDownBorderR,"BorderG"=>$BoxDownBorderG,"BorderB"=>$BoxDownBorderB,"BorderAlpha"=>$BoxDownBorderAlpha); |
121 | 117 | $MedianSettings = array("R"=>$MedianR,"G"=>$MedianG,"B"=>$MedianB,"Alpha"=>$MedianAlpha); |
122 | 118 | |
123 | - foreach($Plots as $Key =>$Points) |
|
124 | - { |
|
119 | + foreach($Plots as $Key =>$Points) { |
|
125 | 120 | $PosArray = $this->pChartObject->scaleComputeY($Points,array("AxisID"=>$AxisID)); |
126 | 121 | |
127 | 122 | $Values = "Open :".$Data["Series"][$SerieOpen]["Data"][$Key]."<BR>Close : ".$Data["Series"][$SerieClose]["Data"][$Key]."<BR>Min : ".$Data["Series"][$SerieMin]["Data"][$Key]."<BR>Max : ".$Data["Series"][$SerieMax]["Data"][$Key]."<BR>"; |
128 | 123 | if ( $SerieMedian != NULL ) { $Values = $Values."Median : ".$Data["Series"][$SerieMedian]["Data"][$Key]."<BR>"; } |
129 | 124 | if ( $PosArray[0] > $PosArray[1] ) { $ImageMapColor = $this->pChartObject->toHTMLColor($BoxUpR,$BoxUpG,$BoxUpB); } else { $ImageMapColor = $this->pChartObject->toHTMLColor($BoxDownR,$BoxDownG,$BoxDownB); } |
130 | 125 | |
131 | - if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT ) |
|
132 | - { |
|
126 | + if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT ) { |
|
133 | 127 | if ( $YZero > $this->pChartObject->GraphAreaY2-1 ) { $YZero = $this->pChartObject->GraphAreaY2-1; } |
134 | 128 | if ( $YZero < $this->pChartObject->GraphAreaY1+1 ) { $YZero = $this->pChartObject->GraphAreaY1+1; } |
135 | 129 | |
@@ -142,15 +136,12 @@ discard block |
||
142 | 136 | else |
143 | 137 | $this->pChartObject->drawFilledRectangle($X-$LineOffset,$PosArray[2],$X+$LineOffset,$PosArray[3],$LineSettings); |
144 | 138 | |
145 | - if ( $ExtremityWidth == 1 ) |
|
146 | - { |
|
139 | + if ( $ExtremityWidth == 1 ) { |
|
147 | 140 | $this->pChartObject->drawLine($X-$ExtremityLength,$PosArray[2],$X+$ExtremityLength,$PosArray[2],$ExtremitySettings); |
148 | 141 | $this->pChartObject->drawLine($X-$ExtremityLength,$PosArray[3],$X+$ExtremityLength,$PosArray[3],$ExtremitySettings); |
149 | 142 | |
150 | 143 | if ( $RecordImageMap ) { $this->pChartObject->addToImageMap("RECT",floor($X-$ExtremityLength).",".floor($PosArray[2]).",".floor($X+$ExtremityLength).",".floor($PosArray[3]),$ImageMapColor,$ImageMapTitle,$Values); } |
151 | - } |
|
152 | - else |
|
153 | - { |
|
144 | + } else { |
|
154 | 145 | $this->pChartObject->drawFilledRectangle($X-$ExtremityLength,$PosArray[2],$X+$ExtremityLength,$PosArray[2]-$ExtremityWidth,$ExtremitySettings); |
155 | 146 | $this->pChartObject->drawFilledRectangle($X-$ExtremityLength,$PosArray[3],$X+$ExtremityLength,$PosArray[3]+$ExtremityWidth,$ExtremitySettings); |
156 | 147 | |
@@ -168,9 +159,7 @@ discard block |
||
168 | 159 | $this->pChartObject->drawLine($X-$ExtremityLength,$PosArray[4],$X+$ExtremityLength,$PosArray[4],$MedianSettings); |
169 | 160 | |
170 | 161 | $X = $X + $XStep; |
171 | - } |
|
172 | - elseif ( $Data["Orientation"] == SCALE_POS_TOPBOTTOM ) |
|
173 | - { |
|
162 | + } elseif ( $Data["Orientation"] == SCALE_POS_TOPBOTTOM ) { |
|
174 | 163 | if ( $YZero > $this->pChartObject->GraphAreaX2-1 ) { $YZero = $this->pChartObject->GraphAreaX2-1; } |
175 | 164 | if ( $YZero < $this->pChartObject->GraphAreaX1+1 ) { $YZero = $this->pChartObject->GraphAreaX1+1; } |
176 | 165 | |
@@ -183,15 +172,12 @@ discard block |
||
183 | 172 | |
184 | 173 | if ( $ShadowOnBoxesOnly ) { $RestoreShadow = $this->pChartObject->Shadow; $this->pChartObject->Shadow = FALSE; } |
185 | 174 | |
186 | - if ( $ExtremityWidth == 1 ) |
|
187 | - { |
|
175 | + if ( $ExtremityWidth == 1 ) { |
|
188 | 176 | $this->pChartObject->drawLine($PosArray[2],$Y-$ExtremityLength,$PosArray[2],$Y+$ExtremityLength,$ExtremitySettings); |
189 | 177 | $this->pChartObject->drawLine($PosArray[3],$Y-$ExtremityLength,$PosArray[3],$Y+$ExtremityLength,$ExtremitySettings); |
190 | 178 | |
191 | 179 | if ( $RecordImageMap ) { $this->pChartObject->addToImageMap("RECT",floor($PosArray[2]).",".floor($Y-$ExtremityLength).",".floor($PosArray[3]).",".floor($Y+$ExtremityLength),$ImageMapColor,$ImageMapTitle,$Values); } |
192 | - } |
|
193 | - else |
|
194 | - { |
|
180 | + } else { |
|
195 | 181 | $this->pChartObject->drawFilledRectangle($PosArray[2],$Y-$ExtremityLength,$PosArray[2]-$ExtremityWidth,$Y+$ExtremityLength,$ExtremitySettings); |
196 | 182 | $this->pChartObject->drawFilledRectangle($PosArray[3],$Y-$ExtremityLength,$PosArray[3]+$ExtremityWidth,$Y+$ExtremityLength,$ExtremitySettings); |
197 | 183 |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $SerieClose = isset($Format["SerieClose"]) ? $Format["SerieClose"] : "Close"; |
36 | 36 | $SerieMin = isset($Format["SerieMin"]) ? $Format["SerieMin"] : "Min"; |
37 | 37 | $SerieMax = isset($Format["SerieMax"]) ? $Format["SerieMax"] : "Max"; |
38 | - $SerieMedian = isset($Format["SerieMedian"]) ? $Format["SerieMedian"] : NULL; |
|
38 | + $SerieMedian = isset($Format["SerieMedian"]) ? $Format["SerieMedian"] : null; |
|
39 | 39 | $LineWidth = isset($Format["LineWidth"]) ? $Format["LineWidth"] : 1; |
40 | 40 | $LineR = isset($Format["LineR"]) ? $Format["LineR"] : 0; |
41 | 41 | $LineG = isset($Format["LineG"]) ? $Format["LineG"] : 0; |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $BoxUpG = isset($Format["BoxUpG"]) ? $Format["BoxUpG"] : 224; |
53 | 53 | $BoxUpB = isset($Format["BoxUpB"]) ? $Format["BoxUpB"] : 46; |
54 | 54 | $BoxUpAlpha = isset($Format["BoxUpAlpha"]) ? $Format["BoxUpAlpha"] : 100; |
55 | - $BoxUpSurrounding = isset($Format["BoxUpSurrounding"]) ? $Format["BoxUpSurrounding"] : NULL; |
|
55 | + $BoxUpSurrounding = isset($Format["BoxUpSurrounding"]) ? $Format["BoxUpSurrounding"] : null; |
|
56 | 56 | $BoxUpBorderR = isset($Format["BoxUpBorderR"]) ? $Format["BoxUpBorderR"] : $BoxUpR-20; |
57 | 57 | $BoxUpBorderG = isset($Format["BoxUpBorderG"]) ? $Format["BoxUpBorderG"] : $BoxUpG-20; |
58 | 58 | $BoxUpBorderB = isset($Format["BoxUpBorderB"]) ? $Format["BoxUpBorderB"] : $BoxUpB-20; |
@@ -61,17 +61,17 @@ discard block |
||
61 | 61 | $BoxDownG = isset($Format["BoxDownG"]) ? $Format["BoxDownG"] : 100; |
62 | 62 | $BoxDownB = isset($Format["BoxDownB"]) ? $Format["BoxDownB"] : 46; |
63 | 63 | $BoxDownAlpha = isset($Format["BoxDownAlpha"]) ? $Format["BoxDownAlpha"] : 100; |
64 | - $BoxDownSurrounding= isset($Format["BoxDownSurrounding"]) ? $Format["BoxDownSurrounding"] : NULL; |
|
64 | + $BoxDownSurrounding= isset($Format["BoxDownSurrounding"]) ? $Format["BoxDownSurrounding"] : null; |
|
65 | 65 | $BoxDownBorderR = isset($Format["BoxDownBorderR"]) ? $Format["BoxDownBorderR"] : $BoxDownR-20; |
66 | 66 | $BoxDownBorderG = isset($Format["BoxDownBorderG"]) ? $Format["BoxDownBorderG"] : $BoxDownG-20; |
67 | 67 | $BoxDownBorderB = isset($Format["BoxDownBorderB"]) ? $Format["BoxDownBorderB"] : $BoxDownB-20; |
68 | 68 | $BoxDownBorderAlpha= isset($Format["BoxDownBorderAlpha"]) ? $Format["BoxDownBorderAlpha"] : 100; |
69 | - $ShadowOnBoxesOnly = isset($Format["ShadowOnBoxesOnly"]) ? $Format["ShadowOnBoxesOnly"] : TRUE; |
|
69 | + $ShadowOnBoxesOnly = isset($Format["ShadowOnBoxesOnly"]) ? $Format["ShadowOnBoxesOnly"] : true; |
|
70 | 70 | $MedianR = isset($Format["MedianR"]) ? $Format["MedianR"] : 255; |
71 | 71 | $MedianG = isset($Format["MedianG"]) ? $Format["MedianG"] : 0; |
72 | 72 | $MedianB = isset($Format["MedianB"]) ? $Format["MedianB"] : 0; |
73 | 73 | $MedianAlpha = isset($Format["MedianAlpha"]) ? $Format["MedianAlpha"] : 100; |
74 | - $RecordImageMap = isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : FALSE; |
|
74 | + $RecordImageMap = isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : false; |
|
75 | 75 | $ImageMapTitle = isset($Format["ImageMapTitle"]) ? $Format["ImageMapTitle"] : "Stock Chart"; |
76 | 76 | |
77 | 77 | |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | $Data = $this->pDataObject->getData(); |
80 | 80 | $Palette = $this->pDataObject->getPalette(); |
81 | 81 | |
82 | - if ( $BoxUpSurrounding != NULL ) { $BoxUpBorderR = $BoxUpR + $BoxUpSurrounding; $BoxUpBorderG = $BoxUpG + $BoxUpSurrounding; $BoxUpBorderB = $BoxUpB + $BoxUpSurrounding; } |
|
83 | - if ( $BoxDownSurrounding != NULL ) { $BoxDownBorderR = $BoxDownR + $BoxDownSurrounding; $BoxDownBorderG = $BoxDownG + $BoxDownSurrounding; $BoxDownBorderB = $BoxDownB + $BoxDownSurrounding; } |
|
82 | + if ( $BoxUpSurrounding != null ) { $BoxUpBorderR = $BoxUpR + $BoxUpSurrounding; $BoxUpBorderG = $BoxUpG + $BoxUpSurrounding; $BoxUpBorderB = $BoxUpB + $BoxUpSurrounding; } |
|
83 | + if ( $BoxDownSurrounding != null ) { $BoxDownBorderR = $BoxDownR + $BoxDownSurrounding; $BoxDownBorderG = $BoxDownG + $BoxDownSurrounding; $BoxDownBorderB = $BoxDownB + $BoxDownSurrounding; } |
|
84 | 84 | |
85 | 85 | if ( $LineWidth != 1 ) { $LineOffset = $LineWidth / 2; } |
86 | 86 | $BoxOffset = $BoxWidth / 2; |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $Point = ""; |
98 | 98 | if ( isset($Data["Series"][$SerieClose]["Data"][$Key]) || isset($Data["Series"][$SerieMin]["Data"][$Key]) || isset($Data["Series"][$SerieMax]["Data"][$Key]) ) |
99 | 99 | $Point = array($Value,$Data["Series"][$SerieClose]["Data"][$Key],$Data["Series"][$SerieMin]["Data"][$Key],$Data["Series"][$SerieMax]["Data"][$Key]); |
100 | - if ( $SerieMedian != NULL && isset($Data["Series"][$SerieMedian]["Data"][$Key]) ) |
|
100 | + if ( $SerieMedian != null && isset($Data["Series"][$SerieMedian]["Data"][$Key]) ) |
|
101 | 101 | $Point[] = $Data["Series"][$SerieMedian]["Data"][$Key]; |
102 | 102 | |
103 | 103 | $Plots[] = $Point; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | $PosArray = $this->pChartObject->scaleComputeY($Points,array("AxisID"=>$AxisID)); |
126 | 126 | |
127 | 127 | $Values = "Open :".$Data["Series"][$SerieOpen]["Data"][$Key]."<BR>Close : ".$Data["Series"][$SerieClose]["Data"][$Key]."<BR>Min : ".$Data["Series"][$SerieMin]["Data"][$Key]."<BR>Max : ".$Data["Series"][$SerieMax]["Data"][$Key]."<BR>"; |
128 | - if ( $SerieMedian != NULL ) { $Values = $Values."Median : ".$Data["Series"][$SerieMedian]["Data"][$Key]."<BR>"; } |
|
128 | + if ( $SerieMedian != null ) { $Values = $Values."Median : ".$Data["Series"][$SerieMedian]["Data"][$Key]."<BR>"; } |
|
129 | 129 | if ( $PosArray[0] > $PosArray[1] ) { $ImageMapColor = $this->pChartObject->toHTMLColor($BoxUpR,$BoxUpG,$BoxUpB); } else { $ImageMapColor = $this->pChartObject->toHTMLColor($BoxDownR,$BoxDownG,$BoxDownB); } |
130 | 130 | |
131 | 131 | if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT ) |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | |
136 | 136 | if ( $XDivs == 0 ) { $XStep = 0; } else { $XStep = ($this->pChartObject->GraphAreaX2-$this->pChartObject->GraphAreaX1-$XMargin*2)/$XDivs; } |
137 | 137 | |
138 | - if ( $ShadowOnBoxesOnly ) { $RestoreShadow = $this->pChartObject->Shadow; $this->pChartObject->Shadow = FALSE; } |
|
138 | + if ( $ShadowOnBoxesOnly ) { $RestoreShadow = $this->pChartObject->Shadow; $this->pChartObject->Shadow = false; } |
|
139 | 139 | |
140 | 140 | if ( $LineWidth == 1 ) |
141 | 141 | $this->pChartObject->drawLine($X,$PosArray[2],$X,$PosArray[3],$LineSettings); |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | else |
182 | 182 | $this->pChartObject->drawFilledRectangle($PosArray[2],$Y-$LineOffset,$PosArray[3],$Y+$LineOffset,$LineSettings); |
183 | 183 | |
184 | - if ( $ShadowOnBoxesOnly ) { $RestoreShadow = $this->pChartObject->Shadow; $this->pChartObject->Shadow = FALSE; } |
|
184 | + if ( $ShadowOnBoxesOnly ) { $RestoreShadow = $this->pChartObject->Shadow; $this->pChartObject->Shadow = false; } |
|
185 | 185 | |
186 | 186 | if ( $ExtremityWidth == 1 ) |
187 | 187 | { |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | - /* |
|
2 | + /* |
|
3 | 3 | pSurface - class to draw surface charts |
4 | 4 | |
5 | 5 | Version : 2.1.3 |
@@ -13,303 +13,303 @@ discard block |
||
13 | 13 | You can find the whole class documentation on the pChart web site. |
14 | 14 | */ |
15 | 15 | |
16 | - define("UNKNOWN" , 0.123456789); |
|
17 | - define("IGNORED" , -1); |
|
16 | + define("UNKNOWN" , 0.123456789); |
|
17 | + define("IGNORED" , -1); |
|
18 | 18 | |
19 | - define("LABEL_POSITION_LEFT" , 880001); |
|
20 | - define("LABEL_POSITION_RIGHT" , 880002); |
|
21 | - define("LABEL_POSITION_TOP" , 880003); |
|
22 | - define("LABEL_POSITION_BOTTOM" , 880004); |
|
19 | + define("LABEL_POSITION_LEFT" , 880001); |
|
20 | + define("LABEL_POSITION_RIGHT" , 880002); |
|
21 | + define("LABEL_POSITION_TOP" , 880003); |
|
22 | + define("LABEL_POSITION_BOTTOM" , 880004); |
|
23 | 23 | |
24 | - /* pStock class definition */ |
|
25 | - class pSurface |
|
26 | - { |
|
27 | - var $pChartObject; |
|
28 | - var $GridSizeX; |
|
29 | - var $GridSizeY; |
|
30 | - var $Points; |
|
24 | + /* pStock class definition */ |
|
25 | + class pSurface |
|
26 | + { |
|
27 | + var $pChartObject; |
|
28 | + var $GridSizeX; |
|
29 | + var $GridSizeY; |
|
30 | + var $Points; |
|
31 | 31 | |
32 | - /* Class creator */ |
|
33 | - function pSurface($pChartObject) |
|
32 | + /* Class creator */ |
|
33 | + function pSurface($pChartObject) |
|
34 | 34 | { |
35 | - $this->pChartObject = $pChartObject; |
|
36 | - $this->GridSize = 10; |
|
37 | - $this->Points = ""; |
|
35 | + $this->pChartObject = $pChartObject; |
|
36 | + $this->GridSize = 10; |
|
37 | + $this->Points = ""; |
|
38 | 38 | } |
39 | 39 | |
40 | - /* Define the grid size and initialise the 2D matrix */ |
|
41 | - function setGrid($XSize=10,$YSize=10) |
|
40 | + /* Define the grid size and initialise the 2D matrix */ |
|
41 | + function setGrid($XSize=10,$YSize=10) |
|
42 | 42 | { |
43 | - for($X=0; $X<=$XSize; $X++) { for($Y=0; $Y<=$YSize; $Y++) { $this->Points[$X][$Y]=UNKNOWN; } } |
|
43 | + for($X=0; $X<=$XSize; $X++) { for($Y=0; $Y<=$YSize; $Y++) { $this->Points[$X][$Y]=UNKNOWN; } } |
|
44 | 44 | |
45 | - $this->GridSizeX = $XSize; |
|
46 | - $this->GridSizeY = $YSize; |
|
45 | + $this->GridSizeX = $XSize; |
|
46 | + $this->GridSizeY = $YSize; |
|
47 | 47 | } |
48 | 48 | |
49 | - /* Add a point on the grid */ |
|
50 | - function addPoint($X,$Y,$Value,$Force=TRUE) |
|
49 | + /* Add a point on the grid */ |
|
50 | + function addPoint($X,$Y,$Value,$Force=TRUE) |
|
51 | 51 | { |
52 | - if ( $X < 0 || $X >$this->GridSizeX ) { return(0); } |
|
53 | - if ( $Y < 0 || $Y >$this->GridSizeY ) { return(0); } |
|
54 | - |
|
55 | - if ( $this->Points[$X][$Y] == UNKNOWN || $Force ) |
|
56 | - $this->Points[$X][$Y] = $Value; |
|
57 | - elseif ( $this->Points[$X][$Y] == UNKNOWN ) |
|
58 | - $this->Points[$X][$Y] = $Value; |
|
59 | - else |
|
60 | - $this->Points[$X][$Y] = ($this->Points[$X][$Y] + $Value)/2; |
|
52 | + if ( $X < 0 || $X >$this->GridSizeX ) { return(0); } |
|
53 | + if ( $Y < 0 || $Y >$this->GridSizeY ) { return(0); } |
|
54 | + |
|
55 | + if ( $this->Points[$X][$Y] == UNKNOWN || $Force ) |
|
56 | + $this->Points[$X][$Y] = $Value; |
|
57 | + elseif ( $this->Points[$X][$Y] == UNKNOWN ) |
|
58 | + $this->Points[$X][$Y] = $Value; |
|
59 | + else |
|
60 | + $this->Points[$X][$Y] = ($this->Points[$X][$Y] + $Value)/2; |
|
61 | 61 | } |
62 | 62 | |
63 | - /* Write the X labels */ |
|
64 | - function writeXLabels($Format="") |
|
63 | + /* Write the X labels */ |
|
64 | + function writeXLabels($Format="") |
|
65 | 65 | { |
66 | - $R = isset($Format["R"]) ? $Format["R"] : $this->pChartObject->FontColorR; |
|
67 | - $G = isset($Format["G"]) ? $Format["G"] : $this->pChartObject->FontColorG; |
|
68 | - $B = isset($Format["B"]) ? $Format["B"] : $this->pChartObject->FontColorB; |
|
69 | - $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : $this->pChartObject->FontColorA; |
|
70 | - $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0; |
|
71 | - $Padding = isset($Format["Padding"]) ? $Format["Padding"] : 5; |
|
72 | - $Position = isset($Format["Position"]) ? $Format["Position"] : LABEL_POSITION_TOP; |
|
73 | - $Labels = isset($Format["Labels"]) ? $Format["Labels"] : NULL; |
|
74 | - $CountOffset = isset($Format["CountOffset"]) ? $Format["CountOffset"] : 0; |
|
75 | - |
|
76 | - if ( $Labels != NULL && !is_array($Labels) ) { $Label = $Labels; $Labels = ""; $Labels[] = $Label; } |
|
77 | - |
|
78 | - $X0 = $this->pChartObject->GraphAreaX1; |
|
79 | - $XSize = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1) / ($this->GridSizeX+1); |
|
80 | - |
|
81 | - $Settings = array("Angle"=>$Angle,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha); |
|
82 | - if ( $Position == LABEL_POSITION_TOP ) |
|
83 | - { |
|
84 | - $YPos = $this->pChartObject->GraphAreaY1 - $Padding; |
|
85 | - if ($Angle == 0 ) { $Settings["Align"] = TEXT_ALIGN_BOTTOMMIDDLE; } |
|
86 | - if ($Angle != 0 ) { $Settings["Align"] = TEXT_ALIGN_MIDDLELEFT; } |
|
87 | - } |
|
88 | - elseif ( $Position == LABEL_POSITION_BOTTOM ) |
|
89 | - { |
|
90 | - $YPos = $this->pChartObject->GraphAreaY2 + $Padding; |
|
91 | - if ($Angle == 0 ) { $Settings["Align"] = TEXT_ALIGN_TOPMIDDLE; } |
|
92 | - if ($Angle != 0 ) { $Settings["Align"] = TEXT_ALIGN_MIDDLERIGHT; } |
|
93 | - } |
|
94 | - else |
|
95 | - return(-1); |
|
96 | - |
|
97 | - for($X=0;$X<=$this->GridSizeX;$X++) |
|
98 | - { |
|
99 | - $XPos = floor($X0+$X*$XSize + $XSize/2); |
|
100 | - |
|
101 | - if( $Labels == NULL || !isset($Labels[$X]) ) |
|
66 | + $R = isset($Format["R"]) ? $Format["R"] : $this->pChartObject->FontColorR; |
|
67 | + $G = isset($Format["G"]) ? $Format["G"] : $this->pChartObject->FontColorG; |
|
68 | + $B = isset($Format["B"]) ? $Format["B"] : $this->pChartObject->FontColorB; |
|
69 | + $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : $this->pChartObject->FontColorA; |
|
70 | + $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0; |
|
71 | + $Padding = isset($Format["Padding"]) ? $Format["Padding"] : 5; |
|
72 | + $Position = isset($Format["Position"]) ? $Format["Position"] : LABEL_POSITION_TOP; |
|
73 | + $Labels = isset($Format["Labels"]) ? $Format["Labels"] : NULL; |
|
74 | + $CountOffset = isset($Format["CountOffset"]) ? $Format["CountOffset"] : 0; |
|
75 | + |
|
76 | + if ( $Labels != NULL && !is_array($Labels) ) { $Label = $Labels; $Labels = ""; $Labels[] = $Label; } |
|
77 | + |
|
78 | + $X0 = $this->pChartObject->GraphAreaX1; |
|
79 | + $XSize = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1) / ($this->GridSizeX+1); |
|
80 | + |
|
81 | + $Settings = array("Angle"=>$Angle,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha); |
|
82 | + if ( $Position == LABEL_POSITION_TOP ) |
|
83 | + { |
|
84 | + $YPos = $this->pChartObject->GraphAreaY1 - $Padding; |
|
85 | + if ($Angle == 0 ) { $Settings["Align"] = TEXT_ALIGN_BOTTOMMIDDLE; } |
|
86 | + if ($Angle != 0 ) { $Settings["Align"] = TEXT_ALIGN_MIDDLELEFT; } |
|
87 | + } |
|
88 | + elseif ( $Position == LABEL_POSITION_BOTTOM ) |
|
89 | + { |
|
90 | + $YPos = $this->pChartObject->GraphAreaY2 + $Padding; |
|
91 | + if ($Angle == 0 ) { $Settings["Align"] = TEXT_ALIGN_TOPMIDDLE; } |
|
92 | + if ($Angle != 0 ) { $Settings["Align"] = TEXT_ALIGN_MIDDLERIGHT; } |
|
93 | + } |
|
94 | + else |
|
95 | + return(-1); |
|
96 | + |
|
97 | + for($X=0;$X<=$this->GridSizeX;$X++) |
|
98 | + { |
|
99 | + $XPos = floor($X0+$X*$XSize + $XSize/2); |
|
100 | + |
|
101 | + if( $Labels == NULL || !isset($Labels[$X]) ) |
|
102 | 102 | $Value = $X+$CountOffset; |
103 | - else |
|
103 | + else |
|
104 | 104 | $Value = $Labels[$X]; |
105 | 105 | |
106 | - $this->pChartObject->drawText($XPos,$YPos,$Value,$Settings); |
|
107 | - } |
|
106 | + $this->pChartObject->drawText($XPos,$YPos,$Value,$Settings); |
|
107 | + } |
|
108 | 108 | } |
109 | 109 | |
110 | - /* Write the Y labels */ |
|
111 | - function writeYLabels($Format="") |
|
110 | + /* Write the Y labels */ |
|
111 | + function writeYLabels($Format="") |
|
112 | 112 | { |
113 | - $R = isset($Format["R"]) ? $Format["R"] : $this->pChartObject->FontColorR; |
|
114 | - $G = isset($Format["G"]) ? $Format["G"] : $this->pChartObject->FontColorG; |
|
115 | - $B = isset($Format["B"]) ? $Format["B"] : $this->pChartObject->FontColorB; |
|
116 | - $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : $this->pChartObject->FontColorA; |
|
117 | - $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0; |
|
118 | - $Padding = isset($Format["Padding"]) ? $Format["Padding"] : 5; |
|
119 | - $Position = isset($Format["Position"]) ? $Format["Position"] : LABEL_POSITION_LEFT; |
|
120 | - $Labels = isset($Format["Labels"]) ? $Format["Labels"] : NULL; |
|
121 | - $CountOffset = isset($Format["CountOffset"]) ? $Format["CountOffset"] : 0; |
|
122 | - |
|
123 | - if ( $Labels != NULL && !is_array($Labels) ) { $Label = $Labels; $Labels = ""; $Labels[] = $Label; } |
|
124 | - |
|
125 | - $Y0 = $this->pChartObject->GraphAreaY1; |
|
126 | - $YSize = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1) / ($this->GridSizeY+1); |
|
127 | - |
|
128 | - $Settings = array("Angle"=>$Angle,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha); |
|
129 | - if ( $Position == LABEL_POSITION_LEFT ) |
|
130 | - { $XPos = $this->pChartObject->GraphAreaX1 - $Padding; $Settings["Align"] = TEXT_ALIGN_MIDDLERIGHT; } |
|
131 | - elseif ( $Position == LABEL_POSITION_RIGHT ) |
|
132 | - { $XPos = $this->pChartObject->GraphAreaX2 + $Padding; $Settings["Align"] = TEXT_ALIGN_MIDDLELEFT; } |
|
133 | - else |
|
134 | - return(-1); |
|
135 | - |
|
136 | - for($Y=0;$Y<=$this->GridSizeY;$Y++) |
|
137 | - { |
|
138 | - $YPos = floor($Y0+$Y*$YSize + $YSize/2); |
|
139 | - |
|
140 | - if( $Labels == NULL || !isset($Labels[$Y]) ) |
|
113 | + $R = isset($Format["R"]) ? $Format["R"] : $this->pChartObject->FontColorR; |
|
114 | + $G = isset($Format["G"]) ? $Format["G"] : $this->pChartObject->FontColorG; |
|
115 | + $B = isset($Format["B"]) ? $Format["B"] : $this->pChartObject->FontColorB; |
|
116 | + $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : $this->pChartObject->FontColorA; |
|
117 | + $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0; |
|
118 | + $Padding = isset($Format["Padding"]) ? $Format["Padding"] : 5; |
|
119 | + $Position = isset($Format["Position"]) ? $Format["Position"] : LABEL_POSITION_LEFT; |
|
120 | + $Labels = isset($Format["Labels"]) ? $Format["Labels"] : NULL; |
|
121 | + $CountOffset = isset($Format["CountOffset"]) ? $Format["CountOffset"] : 0; |
|
122 | + |
|
123 | + if ( $Labels != NULL && !is_array($Labels) ) { $Label = $Labels; $Labels = ""; $Labels[] = $Label; } |
|
124 | + |
|
125 | + $Y0 = $this->pChartObject->GraphAreaY1; |
|
126 | + $YSize = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1) / ($this->GridSizeY+1); |
|
127 | + |
|
128 | + $Settings = array("Angle"=>$Angle,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha); |
|
129 | + if ( $Position == LABEL_POSITION_LEFT ) |
|
130 | + { $XPos = $this->pChartObject->GraphAreaX1 - $Padding; $Settings["Align"] = TEXT_ALIGN_MIDDLERIGHT; } |
|
131 | + elseif ( $Position == LABEL_POSITION_RIGHT ) |
|
132 | + { $XPos = $this->pChartObject->GraphAreaX2 + $Padding; $Settings["Align"] = TEXT_ALIGN_MIDDLELEFT; } |
|
133 | + else |
|
134 | + return(-1); |
|
135 | + |
|
136 | + for($Y=0;$Y<=$this->GridSizeY;$Y++) |
|
137 | + { |
|
138 | + $YPos = floor($Y0+$Y*$YSize + $YSize/2); |
|
139 | + |
|
140 | + if( $Labels == NULL || !isset($Labels[$Y]) ) |
|
141 | 141 | $Value = $Y+$CountOffset; |
142 | - else |
|
142 | + else |
|
143 | 143 | $Value = $Labels[$Y]; |
144 | 144 | |
145 | - $this->pChartObject->drawText($XPos,$YPos,$Value,$Settings); |
|
146 | - } |
|
145 | + $this->pChartObject->drawText($XPos,$YPos,$Value,$Settings); |
|
146 | + } |
|
147 | 147 | } |
148 | 148 | |
149 | - /* Draw the area arround the specified Threshold */ |
|
150 | - function drawContour($Threshold,$Format="") |
|
149 | + /* Draw the area arround the specified Threshold */ |
|
150 | + function drawContour($Threshold,$Format="") |
|
151 | 151 | { |
152 | - $R = isset($Format["R"]) ? $Format["R"] : 0; |
|
153 | - $G = isset($Format["G"]) ? $Format["G"] : 0; |
|
154 | - $B = isset($Format["B"]) ? $Format["B"] : 0; |
|
155 | - $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100; |
|
156 | - $Ticks = isset($Format["Ticks"]) ? $Format["Ticks"] : 3; |
|
157 | - $Padding = isset($Format["Padding"]) ? $Format["Padding"] : 0; |
|
158 | - |
|
159 | - $X0 = $this->pChartObject->GraphAreaX1; |
|
160 | - $Y0 = $this->pChartObject->GraphAreaY1; |
|
161 | - $XSize = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1) / ($this->GridSizeX+1); |
|
162 | - $YSize = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1) / ($this->GridSizeY+1); |
|
163 | - |
|
164 | - $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks); |
|
165 | - |
|
166 | - for($X=0;$X<=$this->GridSizeX;$X++) |
|
167 | - { |
|
168 | - for($Y=0;$Y<=$this->GridSizeY;$Y++) |
|
152 | + $R = isset($Format["R"]) ? $Format["R"] : 0; |
|
153 | + $G = isset($Format["G"]) ? $Format["G"] : 0; |
|
154 | + $B = isset($Format["B"]) ? $Format["B"] : 0; |
|
155 | + $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100; |
|
156 | + $Ticks = isset($Format["Ticks"]) ? $Format["Ticks"] : 3; |
|
157 | + $Padding = isset($Format["Padding"]) ? $Format["Padding"] : 0; |
|
158 | + |
|
159 | + $X0 = $this->pChartObject->GraphAreaX1; |
|
160 | + $Y0 = $this->pChartObject->GraphAreaY1; |
|
161 | + $XSize = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1) / ($this->GridSizeX+1); |
|
162 | + $YSize = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1) / ($this->GridSizeY+1); |
|
163 | + |
|
164 | + $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks); |
|
165 | + |
|
166 | + for($X=0;$X<=$this->GridSizeX;$X++) |
|
169 | 167 | { |
170 | - $Value = $this->Points[$X][$Y]; |
|
168 | + for($Y=0;$Y<=$this->GridSizeY;$Y++) |
|
169 | + { |
|
170 | + $Value = $this->Points[$X][$Y]; |
|
171 | 171 | |
172 | - if ( $Value != UNKNOWN && $Value != IGNORED && $Value >= $Threshold) |
|
173 | - { |
|
174 | - $X1 = floor($X0+$X*$XSize)+$Padding; |
|
175 | - $Y1 = floor($Y0+$Y*$YSize)+$Padding; |
|
176 | - $X2 = floor($X0+$X*$XSize+$XSize); |
|
177 | - $Y2 = floor($Y0+$Y*$YSize+$YSize); |
|
172 | + if ( $Value != UNKNOWN && $Value != IGNORED && $Value >= $Threshold) |
|
173 | + { |
|
174 | + $X1 = floor($X0+$X*$XSize)+$Padding; |
|
175 | + $Y1 = floor($Y0+$Y*$YSize)+$Padding; |
|
176 | + $X2 = floor($X0+$X*$XSize+$XSize); |
|
177 | + $Y2 = floor($Y0+$Y*$YSize+$YSize); |
|
178 | 178 | |
179 | - if ( $X > 0 && $this->Points[$X-1][$Y] != UNKNOWN && $this->Points[$X-1][$Y] != IGNORED && $this->Points[$X-1][$Y] < $Threshold) |
|
179 | + if ( $X > 0 && $this->Points[$X-1][$Y] != UNKNOWN && $this->Points[$X-1][$Y] != IGNORED && $this->Points[$X-1][$Y] < $Threshold) |
|
180 | 180 | $this->pChartObject->drawLine($X1,$Y1,$X1,$Y2,$Color); |
181 | - if ( $Y > 0 && $this->Points[$X][$Y-1] != UNKNOWN && $this->Points[$X][$Y-1] != IGNORED && $this->Points[$X][$Y-1] < $Threshold) |
|
181 | + if ( $Y > 0 && $this->Points[$X][$Y-1] != UNKNOWN && $this->Points[$X][$Y-1] != IGNORED && $this->Points[$X][$Y-1] < $Threshold) |
|
182 | 182 | $this->pChartObject->drawLine($X1,$Y1,$X2,$Y1,$Color); |
183 | - if ( $X < $this->GridSizeX && $this->Points[$X+1][$Y] != UNKNOWN && $this->Points[$X+1][$Y] != IGNORED && $this->Points[$X+1][$Y] < $Threshold) |
|
183 | + if ( $X < $this->GridSizeX && $this->Points[$X+1][$Y] != UNKNOWN && $this->Points[$X+1][$Y] != IGNORED && $this->Points[$X+1][$Y] < $Threshold) |
|
184 | 184 | $this->pChartObject->drawLine($X2,$Y1,$X2,$Y2,$Color); |
185 | - if ( $Y < $this->GridSizeY && $this->Points[$X][$Y+1] != UNKNOWN && $this->Points[$X][$Y+1] != IGNORED && $this->Points[$X][$Y+1] < $Threshold) |
|
185 | + if ( $Y < $this->GridSizeY && $this->Points[$X][$Y+1] != UNKNOWN && $this->Points[$X][$Y+1] != IGNORED && $this->Points[$X][$Y+1] < $Threshold) |
|
186 | 186 | $this->pChartObject->drawLine($X1,$Y2,$X2,$Y2,$Color); |
187 | - } |
|
187 | + } |
|
188 | + } |
|
188 | 189 | } |
189 | - } |
|
190 | 190 | } |
191 | 191 | |
192 | - /* Draw the surface chart */ |
|
193 | - function drawSurface($Format="") |
|
192 | + /* Draw the surface chart */ |
|
193 | + function drawSurface($Format="") |
|
194 | 194 | { |
195 | - $Palette = isset($Format["Palette"]) ? $Format["Palette"] : NULL; |
|
196 | - $ShadeR1 = isset($Format["ShadeR1"]) ? $Format["ShadeR1"] : 77; |
|
197 | - $ShadeG1 = isset($Format["ShadeG1"]) ? $Format["ShadeG1"] : 205; |
|
198 | - $ShadeB1 = isset($Format["ShadeB1"]) ? $Format["ShadeB1"] : 21; |
|
199 | - $ShadeA1 = isset($Format["ShadeA1"]) ? $Format["ShadeA1"] : 40; |
|
200 | - $ShadeR2 = isset($Format["ShadeR2"]) ? $Format["ShadeR2"] : 227; |
|
201 | - $ShadeG2 = isset($Format["ShadeG2"]) ? $Format["ShadeG2"] : 135; |
|
202 | - $ShadeB2 = isset($Format["ShadeB2"]) ? $Format["ShadeB2"] : 61; |
|
203 | - $ShadeA2 = isset($Format["ShadeA2"]) ? $Format["ShadeA2"] : 100; |
|
204 | - $Border = isset($Format["Border"]) ? $Format["Border"] : FALSE; |
|
205 | - $BorderR = isset($Format["BorderR"]) ? $Format["BorderR"] : 0; |
|
206 | - $BorderG = isset($Format["BorderG"]) ? $Format["BorderG"] : 0; |
|
207 | - $BorderB = isset($Format["BorderB"]) ? $Format["BorderB"] : 0; |
|
208 | - $Surrounding = isset($Format["Surrounding"]) ? $Format["Surrounding"] : -1; |
|
209 | - $Padding = isset($Format["Padding"]) ? $Format["Padding"] : 1; |
|
210 | - |
|
211 | - $X0 = $this->pChartObject->GraphAreaX1; |
|
212 | - $Y0 = $this->pChartObject->GraphAreaY1; |
|
213 | - $XSize = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1) / ($this->GridSizeX+1); |
|
214 | - $YSize = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1) / ($this->GridSizeY+1); |
|
215 | - |
|
216 | - for($X=0;$X<=$this->GridSizeX;$X++) |
|
217 | - { |
|
218 | - for($Y=0;$Y<=$this->GridSizeY;$Y++) |
|
195 | + $Palette = isset($Format["Palette"]) ? $Format["Palette"] : NULL; |
|
196 | + $ShadeR1 = isset($Format["ShadeR1"]) ? $Format["ShadeR1"] : 77; |
|
197 | + $ShadeG1 = isset($Format["ShadeG1"]) ? $Format["ShadeG1"] : 205; |
|
198 | + $ShadeB1 = isset($Format["ShadeB1"]) ? $Format["ShadeB1"] : 21; |
|
199 | + $ShadeA1 = isset($Format["ShadeA1"]) ? $Format["ShadeA1"] : 40; |
|
200 | + $ShadeR2 = isset($Format["ShadeR2"]) ? $Format["ShadeR2"] : 227; |
|
201 | + $ShadeG2 = isset($Format["ShadeG2"]) ? $Format["ShadeG2"] : 135; |
|
202 | + $ShadeB2 = isset($Format["ShadeB2"]) ? $Format["ShadeB2"] : 61; |
|
203 | + $ShadeA2 = isset($Format["ShadeA2"]) ? $Format["ShadeA2"] : 100; |
|
204 | + $Border = isset($Format["Border"]) ? $Format["Border"] : FALSE; |
|
205 | + $BorderR = isset($Format["BorderR"]) ? $Format["BorderR"] : 0; |
|
206 | + $BorderG = isset($Format["BorderG"]) ? $Format["BorderG"] : 0; |
|
207 | + $BorderB = isset($Format["BorderB"]) ? $Format["BorderB"] : 0; |
|
208 | + $Surrounding = isset($Format["Surrounding"]) ? $Format["Surrounding"] : -1; |
|
209 | + $Padding = isset($Format["Padding"]) ? $Format["Padding"] : 1; |
|
210 | + |
|
211 | + $X0 = $this->pChartObject->GraphAreaX1; |
|
212 | + $Y0 = $this->pChartObject->GraphAreaY1; |
|
213 | + $XSize = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1) / ($this->GridSizeX+1); |
|
214 | + $YSize = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1) / ($this->GridSizeY+1); |
|
215 | + |
|
216 | + for($X=0;$X<=$this->GridSizeX;$X++) |
|
217 | + { |
|
218 | + for($Y=0;$Y<=$this->GridSizeY;$Y++) |
|
219 | 219 | { |
220 | - $Value = $this->Points[$X][$Y]; |
|
220 | + $Value = $this->Points[$X][$Y]; |
|
221 | 221 | |
222 | - if ( $Value != UNKNOWN && $Value != IGNORED ) |
|
223 | - { |
|
224 | - $X1 = floor($X0+$X*$XSize)+$Padding; |
|
225 | - $Y1 = floor($Y0+$Y*$YSize)+$Padding; |
|
226 | - $X2 = floor($X0+$X*$XSize+$XSize); |
|
227 | - $Y2 = floor($Y0+$Y*$YSize+$YSize); |
|
222 | + if ( $Value != UNKNOWN && $Value != IGNORED ) |
|
223 | + { |
|
224 | + $X1 = floor($X0+$X*$XSize)+$Padding; |
|
225 | + $Y1 = floor($Y0+$Y*$YSize)+$Padding; |
|
226 | + $X2 = floor($X0+$X*$XSize+$XSize); |
|
227 | + $Y2 = floor($Y0+$Y*$YSize+$YSize); |
|
228 | 228 | |
229 | - if ( $Palette != NULL ) |
|
229 | + if ( $Palette != NULL ) |
|
230 | 230 | { |
231 | - if ( isset($Palette[$Value]) && isset($Palette[$Value]["R"]) ) { $R = $Palette[$Value]["R"]; } else { $R = 0; } |
|
232 | - if ( isset($Palette[$Value]) && isset($Palette[$Value]["G"]) ) { $G = $Palette[$Value]["G"]; } else { $G = 0; } |
|
233 | - if ( isset($Palette[$Value]) && isset($Palette[$Value]["B"]) ) { $B = $Palette[$Value]["B"]; } else { $B = 0; } |
|
234 | - if ( isset($Palette[$Value]) && isset($Palette[$Value]["Alpha"]) ) { $Alpha = $Palette[$Value]["Alpha"]; } else { $Alpha = 1000; } |
|
231 | + if ( isset($Palette[$Value]) && isset($Palette[$Value]["R"]) ) { $R = $Palette[$Value]["R"]; } else { $R = 0; } |
|
232 | + if ( isset($Palette[$Value]) && isset($Palette[$Value]["G"]) ) { $G = $Palette[$Value]["G"]; } else { $G = 0; } |
|
233 | + if ( isset($Palette[$Value]) && isset($Palette[$Value]["B"]) ) { $B = $Palette[$Value]["B"]; } else { $B = 0; } |
|
234 | + if ( isset($Palette[$Value]) && isset($Palette[$Value]["Alpha"]) ) { $Alpha = $Palette[$Value]["Alpha"]; } else { $Alpha = 1000; } |
|
235 | 235 | } |
236 | - else |
|
236 | + else |
|
237 | 237 | { |
238 | - $R = (($ShadeR2-$ShadeR1)/100)*$Value + $ShadeR1; |
|
239 | - $G = (($ShadeG2-$ShadeG1)/100)*$Value + $ShadeG1; |
|
240 | - $B = (($ShadeB2-$ShadeB1)/100)*$Value + $ShadeB1; |
|
241 | - $Alpha = (($ShadeA2-$ShadeA1)/100)*$Value + $ShadeA1; |
|
238 | + $R = (($ShadeR2-$ShadeR1)/100)*$Value + $ShadeR1; |
|
239 | + $G = (($ShadeG2-$ShadeG1)/100)*$Value + $ShadeG1; |
|
240 | + $B = (($ShadeB2-$ShadeB1)/100)*$Value + $ShadeB1; |
|
241 | + $Alpha = (($ShadeA2-$ShadeA1)/100)*$Value + $ShadeA1; |
|
242 | 242 | } |
243 | 243 | |
244 | - $Settings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha); |
|
245 | - if ( $Border ) { $Settings["BorderR"] = $BorderR; $Settings["BorderG"] = $BorderG; $Settings["BorderB"] = $BorderB; } |
|
246 | - if ( $Surrounding != -1 ) { $Settings["BorderR"] = $R+$Surrounding; $Settings["BorderG"] = $G+$Surrounding; $Settings["BorderB"] = $B+$Surrounding; } |
|
244 | + $Settings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha); |
|
245 | + if ( $Border ) { $Settings["BorderR"] = $BorderR; $Settings["BorderG"] = $BorderG; $Settings["BorderB"] = $BorderB; } |
|
246 | + if ( $Surrounding != -1 ) { $Settings["BorderR"] = $R+$Surrounding; $Settings["BorderG"] = $G+$Surrounding; $Settings["BorderB"] = $B+$Surrounding; } |
|
247 | 247 | |
248 | - $this->pChartObject->drawFilledRectangle($X1,$Y1,$X2-1,$Y2-1,$Settings); |
|
249 | - } |
|
248 | + $this->pChartObject->drawFilledRectangle($X1,$Y1,$X2-1,$Y2-1,$Settings); |
|
249 | + } |
|
250 | + } |
|
250 | 251 | } |
251 | - } |
|
252 | 252 | } |
253 | 253 | |
254 | - /* Compute the missing points */ |
|
255 | - function computeMissing() |
|
254 | + /* Compute the missing points */ |
|
255 | + function computeMissing() |
|
256 | 256 | { |
257 | - $Missing = ""; |
|
258 | - for($X=0;$X<=$this->GridSizeX;$X++) |
|
259 | - { |
|
260 | - for($Y=0;$Y<=$this->GridSizeY;$Y++) |
|
257 | + $Missing = ""; |
|
258 | + for($X=0;$X<=$this->GridSizeX;$X++) |
|
259 | + { |
|
260 | + for($Y=0;$Y<=$this->GridSizeY;$Y++) |
|
261 | 261 | { |
262 | - if ( $this->Points[$X][$Y] == UNKNOWN ) |
|
263 | - $Missing[] = $X.",".$Y; |
|
262 | + if ( $this->Points[$X][$Y] == UNKNOWN ) |
|
263 | + $Missing[] = $X.",".$Y; |
|
264 | 264 | } |
265 | - } |
|
266 | - shuffle($Missing); |
|
265 | + } |
|
266 | + shuffle($Missing); |
|
267 | 267 | |
268 | - foreach($Missing as $Key => $Pos) |
|
269 | - { |
|
270 | - $Pos = preg_split("/,/",$Pos); |
|
271 | - $X = $Pos[0]; |
|
272 | - $Y = $Pos[1]; |
|
268 | + foreach($Missing as $Key => $Pos) |
|
269 | + { |
|
270 | + $Pos = preg_split("/,/",$Pos); |
|
271 | + $X = $Pos[0]; |
|
272 | + $Y = $Pos[1]; |
|
273 | 273 | |
274 | - if ( $this->Points[$X][$Y] == UNKNOWN ) |
|
274 | + if ( $this->Points[$X][$Y] == UNKNOWN ) |
|
275 | 275 | { |
276 | - $NearestNeighbor = $this->getNearestNeighbor($X,$Y); |
|
276 | + $NearestNeighbor = $this->getNearestNeighbor($X,$Y); |
|
277 | 277 | |
278 | - $Value = 0; $Points = 0; |
|
279 | - for($Xi=$X-$NearestNeighbor;$Xi<=$X+$NearestNeighbor;$Xi++) |
|
280 | - { |
|
281 | - for($Yi=$Y-$NearestNeighbor;$Yi<=$Y+$NearestNeighbor;$Yi++) |
|
278 | + $Value = 0; $Points = 0; |
|
279 | + for($Xi=$X-$NearestNeighbor;$Xi<=$X+$NearestNeighbor;$Xi++) |
|
282 | 280 | { |
283 | - if ($Xi >=0 && $Yi >= 0 && $Xi <= $this->GridSizeX && $Yi <= $this->GridSizeY && $this->Points[$Xi][$Yi] != UNKNOWN && $this->Points[$Xi][$Yi] != IGNORED) |
|
284 | - { |
|
285 | - $Value = $Value + $this->Points[$Xi][$Yi]; $Points++; |
|
286 | - } |
|
281 | + for($Yi=$Y-$NearestNeighbor;$Yi<=$Y+$NearestNeighbor;$Yi++) |
|
282 | + { |
|
283 | + if ($Xi >=0 && $Yi >= 0 && $Xi <= $this->GridSizeX && $Yi <= $this->GridSizeY && $this->Points[$Xi][$Yi] != UNKNOWN && $this->Points[$Xi][$Yi] != IGNORED) |
|
284 | + { |
|
285 | + $Value = $Value + $this->Points[$Xi][$Yi]; $Points++; |
|
286 | + } |
|
287 | + } |
|
287 | 288 | } |
288 | - } |
|
289 | 289 | |
290 | - if ( $Points != 0 ) { $this->Points[$X][$Y] = $Value / $Points; } |
|
290 | + if ( $Points != 0 ) { $this->Points[$X][$Y] = $Value / $Points; } |
|
291 | + } |
|
291 | 292 | } |
292 | - } |
|
293 | 293 | } |
294 | 294 | |
295 | - /* Return the nearest Neighbor distance of a point */ |
|
296 | - function getNearestNeighbor($Xp,$Yp) |
|
295 | + /* Return the nearest Neighbor distance of a point */ |
|
296 | + function getNearestNeighbor($Xp,$Yp) |
|
297 | 297 | { |
298 | - $Nearest = UNKNOWN; |
|
299 | - for($X=0;$X<=$this->GridSizeX;$X++) |
|
300 | - { |
|
301 | - for($Y=0;$Y<=$this->GridSizeY;$Y++) |
|
298 | + $Nearest = UNKNOWN; |
|
299 | + for($X=0;$X<=$this->GridSizeX;$X++) |
|
300 | + { |
|
301 | + for($Y=0;$Y<=$this->GridSizeY;$Y++) |
|
302 | 302 | { |
303 | - if ( $this->Points[$X][$Y] != UNKNOWN && $this->Points[$X][$Y] != IGNORED ) |
|
304 | - { |
|
305 | - $DistanceX = max($Xp,$X)-min($Xp,$X); |
|
306 | - $DistanceY = max($Yp,$Y)-min($Yp,$Y); |
|
307 | - $Distance = max($DistanceX,$DistanceY); |
|
308 | - if ( $Distance < $Nearest || $Nearest == UNKNOWN ) { $Nearest = $Distance; } |
|
309 | - } |
|
303 | + if ( $this->Points[$X][$Y] != UNKNOWN && $this->Points[$X][$Y] != IGNORED ) |
|
304 | + { |
|
305 | + $DistanceX = max($Xp,$X)-min($Xp,$X); |
|
306 | + $DistanceY = max($Yp,$Y)-min($Yp,$Y); |
|
307 | + $Distance = max($DistanceX,$DistanceY); |
|
308 | + if ( $Distance < $Nearest || $Nearest == UNKNOWN ) { $Nearest = $Distance; } |
|
309 | + } |
|
310 | 310 | } |
311 | - } |
|
312 | - return($Nearest); |
|
311 | + } |
|
312 | + return($Nearest); |
|
313 | + } |
|
313 | 314 | } |
314 | - } |
|
315 | 315 | ?> |
316 | 316 | \ No newline at end of file |
@@ -13,13 +13,13 @@ discard block |
||
13 | 13 | You can find the whole class documentation on the pChart web site. |
14 | 14 | */ |
15 | 15 | |
16 | - define("UNKNOWN" , 0.123456789); |
|
17 | - define("IGNORED" , -1); |
|
16 | + define("UNKNOWN", 0.123456789); |
|
17 | + define("IGNORED", -1); |
|
18 | 18 | |
19 | - define("LABEL_POSITION_LEFT" , 880001); |
|
20 | - define("LABEL_POSITION_RIGHT" , 880002); |
|
21 | - define("LABEL_POSITION_TOP" , 880003); |
|
22 | - define("LABEL_POSITION_BOTTOM" , 880004); |
|
19 | + define("LABEL_POSITION_LEFT", 880001); |
|
20 | + define("LABEL_POSITION_RIGHT", 880002); |
|
21 | + define("LABEL_POSITION_TOP", 880003); |
|
22 | + define("LABEL_POSITION_BOTTOM", 880004); |
|
23 | 23 | |
24 | 24 | /* pStock class definition */ |
25 | 25 | class pSurface |
@@ -38,159 +38,159 @@ discard block |
||
38 | 38 | } |
39 | 39 | |
40 | 40 | /* Define the grid size and initialise the 2D matrix */ |
41 | - function setGrid($XSize=10,$YSize=10) |
|
41 | + function setGrid($XSize = 10, $YSize = 10) |
|
42 | 42 | { |
43 | - for($X=0; $X<=$XSize; $X++) { for($Y=0; $Y<=$YSize; $Y++) { $this->Points[$X][$Y]=UNKNOWN; } } |
|
43 | + for ($X = 0; $X <= $XSize; $X++) { for ($Y = 0; $Y <= $YSize; $Y++) { $this->Points[$X][$Y] = UNKNOWN; } } |
|
44 | 44 | |
45 | 45 | $this->GridSizeX = $XSize; |
46 | 46 | $this->GridSizeY = $YSize; |
47 | 47 | } |
48 | 48 | |
49 | 49 | /* Add a point on the grid */ |
50 | - function addPoint($X,$Y,$Value,$Force=TRUE) |
|
50 | + function addPoint($X, $Y, $Value, $Force = TRUE) |
|
51 | 51 | { |
52 | - if ( $X < 0 || $X >$this->GridSizeX ) { return(0); } |
|
53 | - if ( $Y < 0 || $Y >$this->GridSizeY ) { return(0); } |
|
52 | + if ($X < 0 || $X > $this->GridSizeX) { return(0); } |
|
53 | + if ($Y < 0 || $Y > $this->GridSizeY) { return(0); } |
|
54 | 54 | |
55 | - if ( $this->Points[$X][$Y] == UNKNOWN || $Force ) |
|
55 | + if ($this->Points[$X][$Y] == UNKNOWN || $Force) |
|
56 | 56 | $this->Points[$X][$Y] = $Value; |
57 | - elseif ( $this->Points[$X][$Y] == UNKNOWN ) |
|
57 | + elseif ($this->Points[$X][$Y] == UNKNOWN) |
|
58 | 58 | $this->Points[$X][$Y] = $Value; |
59 | 59 | else |
60 | 60 | $this->Points[$X][$Y] = ($this->Points[$X][$Y] + $Value)/2; |
61 | 61 | } |
62 | 62 | |
63 | 63 | /* Write the X labels */ |
64 | - function writeXLabels($Format="") |
|
64 | + function writeXLabels($Format = "") |
|
65 | 65 | { |
66 | 66 | $R = isset($Format["R"]) ? $Format["R"] : $this->pChartObject->FontColorR; |
67 | 67 | $G = isset($Format["G"]) ? $Format["G"] : $this->pChartObject->FontColorG; |
68 | 68 | $B = isset($Format["B"]) ? $Format["B"] : $this->pChartObject->FontColorB; |
69 | 69 | $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : $this->pChartObject->FontColorA; |
70 | 70 | $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0; |
71 | - $Padding = isset($Format["Padding"]) ? $Format["Padding"] : 5; |
|
72 | - $Position = isset($Format["Position"]) ? $Format["Position"] : LABEL_POSITION_TOP; |
|
73 | - $Labels = isset($Format["Labels"]) ? $Format["Labels"] : NULL; |
|
74 | - $CountOffset = isset($Format["CountOffset"]) ? $Format["CountOffset"] : 0; |
|
71 | + $Padding = isset($Format["Padding"]) ? $Format["Padding"] : 5; |
|
72 | + $Position = isset($Format["Position"]) ? $Format["Position"] : LABEL_POSITION_TOP; |
|
73 | + $Labels = isset($Format["Labels"]) ? $Format["Labels"] : NULL; |
|
74 | + $CountOffset = isset($Format["CountOffset"]) ? $Format["CountOffset"] : 0; |
|
75 | 75 | |
76 | - if ( $Labels != NULL && !is_array($Labels) ) { $Label = $Labels; $Labels = ""; $Labels[] = $Label; } |
|
76 | + if ($Labels != NULL && !is_array($Labels)) { $Label = $Labels; $Labels = ""; $Labels[] = $Label; } |
|
77 | 77 | |
78 | 78 | $X0 = $this->pChartObject->GraphAreaX1; |
79 | - $XSize = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1) / ($this->GridSizeX+1); |
|
79 | + $XSize = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1)/($this->GridSizeX + 1); |
|
80 | 80 | |
81 | - $Settings = array("Angle"=>$Angle,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha); |
|
82 | - if ( $Position == LABEL_POSITION_TOP ) |
|
81 | + $Settings = array("Angle"=>$Angle, "R"=>$R, "G"=>$G, "B"=>$B, "Alpha"=>$Alpha); |
|
82 | + if ($Position == LABEL_POSITION_TOP) |
|
83 | 83 | { |
84 | - $YPos = $this->pChartObject->GraphAreaY1 - $Padding; |
|
85 | - if ($Angle == 0 ) { $Settings["Align"] = TEXT_ALIGN_BOTTOMMIDDLE; } |
|
86 | - if ($Angle != 0 ) { $Settings["Align"] = TEXT_ALIGN_MIDDLELEFT; } |
|
84 | + $YPos = $this->pChartObject->GraphAreaY1 - $Padding; |
|
85 | + if ($Angle == 0) { $Settings["Align"] = TEXT_ALIGN_BOTTOMMIDDLE; } |
|
86 | + if ($Angle != 0) { $Settings["Align"] = TEXT_ALIGN_MIDDLELEFT; } |
|
87 | 87 | } |
88 | - elseif ( $Position == LABEL_POSITION_BOTTOM ) |
|
88 | + elseif ($Position == LABEL_POSITION_BOTTOM) |
|
89 | 89 | { |
90 | - $YPos = $this->pChartObject->GraphAreaY2 + $Padding; |
|
91 | - if ($Angle == 0 ) { $Settings["Align"] = TEXT_ALIGN_TOPMIDDLE; } |
|
92 | - if ($Angle != 0 ) { $Settings["Align"] = TEXT_ALIGN_MIDDLERIGHT; } |
|
90 | + $YPos = $this->pChartObject->GraphAreaY2 + $Padding; |
|
91 | + if ($Angle == 0) { $Settings["Align"] = TEXT_ALIGN_TOPMIDDLE; } |
|
92 | + if ($Angle != 0) { $Settings["Align"] = TEXT_ALIGN_MIDDLERIGHT; } |
|
93 | 93 | } |
94 | 94 | else |
95 | 95 | return(-1); |
96 | 96 | |
97 | - for($X=0;$X<=$this->GridSizeX;$X++) |
|
97 | + for ($X = 0; $X <= $this->GridSizeX; $X++) |
|
98 | 98 | { |
99 | - $XPos = floor($X0+$X*$XSize + $XSize/2); |
|
99 | + $XPos = floor($X0 + $X*$XSize + $XSize/2); |
|
100 | 100 | |
101 | - if( $Labels == NULL || !isset($Labels[$X]) ) |
|
102 | - $Value = $X+$CountOffset; |
|
101 | + if ($Labels == NULL || !isset($Labels[$X])) |
|
102 | + $Value = $X + $CountOffset; |
|
103 | 103 | else |
104 | 104 | $Value = $Labels[$X]; |
105 | 105 | |
106 | - $this->pChartObject->drawText($XPos,$YPos,$Value,$Settings); |
|
106 | + $this->pChartObject->drawText($XPos, $YPos, $Value, $Settings); |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
110 | 110 | /* Write the Y labels */ |
111 | - function writeYLabels($Format="") |
|
111 | + function writeYLabels($Format = "") |
|
112 | 112 | { |
113 | 113 | $R = isset($Format["R"]) ? $Format["R"] : $this->pChartObject->FontColorR; |
114 | 114 | $G = isset($Format["G"]) ? $Format["G"] : $this->pChartObject->FontColorG; |
115 | 115 | $B = isset($Format["B"]) ? $Format["B"] : $this->pChartObject->FontColorB; |
116 | 116 | $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : $this->pChartObject->FontColorA; |
117 | 117 | $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0; |
118 | - $Padding = isset($Format["Padding"]) ? $Format["Padding"] : 5; |
|
119 | - $Position = isset($Format["Position"]) ? $Format["Position"] : LABEL_POSITION_LEFT; |
|
120 | - $Labels = isset($Format["Labels"]) ? $Format["Labels"] : NULL; |
|
121 | - $CountOffset = isset($Format["CountOffset"]) ? $Format["CountOffset"] : 0; |
|
118 | + $Padding = isset($Format["Padding"]) ? $Format["Padding"] : 5; |
|
119 | + $Position = isset($Format["Position"]) ? $Format["Position"] : LABEL_POSITION_LEFT; |
|
120 | + $Labels = isset($Format["Labels"]) ? $Format["Labels"] : NULL; |
|
121 | + $CountOffset = isset($Format["CountOffset"]) ? $Format["CountOffset"] : 0; |
|
122 | 122 | |
123 | - if ( $Labels != NULL && !is_array($Labels) ) { $Label = $Labels; $Labels = ""; $Labels[] = $Label; } |
|
123 | + if ($Labels != NULL && !is_array($Labels)) { $Label = $Labels; $Labels = ""; $Labels[] = $Label; } |
|
124 | 124 | |
125 | 125 | $Y0 = $this->pChartObject->GraphAreaY1; |
126 | - $YSize = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1) / ($this->GridSizeY+1); |
|
126 | + $YSize = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1)/($this->GridSizeY + 1); |
|
127 | 127 | |
128 | - $Settings = array("Angle"=>$Angle,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha); |
|
129 | - if ( $Position == LABEL_POSITION_LEFT ) |
|
128 | + $Settings = array("Angle"=>$Angle, "R"=>$R, "G"=>$G, "B"=>$B, "Alpha"=>$Alpha); |
|
129 | + if ($Position == LABEL_POSITION_LEFT) |
|
130 | 130 | { $XPos = $this->pChartObject->GraphAreaX1 - $Padding; $Settings["Align"] = TEXT_ALIGN_MIDDLERIGHT; } |
131 | - elseif ( $Position == LABEL_POSITION_RIGHT ) |
|
131 | + elseif ($Position == LABEL_POSITION_RIGHT) |
|
132 | 132 | { $XPos = $this->pChartObject->GraphAreaX2 + $Padding; $Settings["Align"] = TEXT_ALIGN_MIDDLELEFT; } |
133 | 133 | else |
134 | 134 | return(-1); |
135 | 135 | |
136 | - for($Y=0;$Y<=$this->GridSizeY;$Y++) |
|
136 | + for ($Y = 0; $Y <= $this->GridSizeY; $Y++) |
|
137 | 137 | { |
138 | - $YPos = floor($Y0+$Y*$YSize + $YSize/2); |
|
138 | + $YPos = floor($Y0 + $Y*$YSize + $YSize/2); |
|
139 | 139 | |
140 | - if( $Labels == NULL || !isset($Labels[$Y]) ) |
|
141 | - $Value = $Y+$CountOffset; |
|
140 | + if ($Labels == NULL || !isset($Labels[$Y])) |
|
141 | + $Value = $Y + $CountOffset; |
|
142 | 142 | else |
143 | 143 | $Value = $Labels[$Y]; |
144 | 144 | |
145 | - $this->pChartObject->drawText($XPos,$YPos,$Value,$Settings); |
|
145 | + $this->pChartObject->drawText($XPos, $YPos, $Value, $Settings); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
149 | 149 | /* Draw the area arround the specified Threshold */ |
150 | - function drawContour($Threshold,$Format="") |
|
150 | + function drawContour($Threshold, $Format = "") |
|
151 | 151 | { |
152 | 152 | $R = isset($Format["R"]) ? $Format["R"] : 0; |
153 | 153 | $G = isset($Format["G"]) ? $Format["G"] : 0; |
154 | 154 | $B = isset($Format["B"]) ? $Format["B"] : 0; |
155 | 155 | $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100; |
156 | 156 | $Ticks = isset($Format["Ticks"]) ? $Format["Ticks"] : 3; |
157 | - $Padding = isset($Format["Padding"]) ? $Format["Padding"] : 0; |
|
157 | + $Padding = isset($Format["Padding"]) ? $Format["Padding"] : 0; |
|
158 | 158 | |
159 | 159 | $X0 = $this->pChartObject->GraphAreaX1; |
160 | 160 | $Y0 = $this->pChartObject->GraphAreaY1; |
161 | - $XSize = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1) / ($this->GridSizeX+1); |
|
162 | - $YSize = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1) / ($this->GridSizeY+1); |
|
161 | + $XSize = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1)/($this->GridSizeX + 1); |
|
162 | + $YSize = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1)/($this->GridSizeY + 1); |
|
163 | 163 | |
164 | - $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks); |
|
164 | + $Color = array("R"=>$R, "G"=>$G, "B"=>$B, "Alpha"=>$Alpha, "Ticks"=>$Ticks); |
|
165 | 165 | |
166 | - for($X=0;$X<=$this->GridSizeX;$X++) |
|
166 | + for ($X = 0; $X <= $this->GridSizeX; $X++) |
|
167 | 167 | { |
168 | - for($Y=0;$Y<=$this->GridSizeY;$Y++) |
|
168 | + for ($Y = 0; $Y <= $this->GridSizeY; $Y++) |
|
169 | 169 | { |
170 | 170 | $Value = $this->Points[$X][$Y]; |
171 | 171 | |
172 | - if ( $Value != UNKNOWN && $Value != IGNORED && $Value >= $Threshold) |
|
172 | + if ($Value != UNKNOWN && $Value != IGNORED && $Value >= $Threshold) |
|
173 | 173 | { |
174 | - $X1 = floor($X0+$X*$XSize)+$Padding; |
|
175 | - $Y1 = floor($Y0+$Y*$YSize)+$Padding; |
|
176 | - $X2 = floor($X0+$X*$XSize+$XSize); |
|
177 | - $Y2 = floor($Y0+$Y*$YSize+$YSize); |
|
178 | - |
|
179 | - if ( $X > 0 && $this->Points[$X-1][$Y] != UNKNOWN && $this->Points[$X-1][$Y] != IGNORED && $this->Points[$X-1][$Y] < $Threshold) |
|
180 | - $this->pChartObject->drawLine($X1,$Y1,$X1,$Y2,$Color); |
|
181 | - if ( $Y > 0 && $this->Points[$X][$Y-1] != UNKNOWN && $this->Points[$X][$Y-1] != IGNORED && $this->Points[$X][$Y-1] < $Threshold) |
|
182 | - $this->pChartObject->drawLine($X1,$Y1,$X2,$Y1,$Color); |
|
183 | - if ( $X < $this->GridSizeX && $this->Points[$X+1][$Y] != UNKNOWN && $this->Points[$X+1][$Y] != IGNORED && $this->Points[$X+1][$Y] < $Threshold) |
|
184 | - $this->pChartObject->drawLine($X2,$Y1,$X2,$Y2,$Color); |
|
185 | - if ( $Y < $this->GridSizeY && $this->Points[$X][$Y+1] != UNKNOWN && $this->Points[$X][$Y+1] != IGNORED && $this->Points[$X][$Y+1] < $Threshold) |
|
186 | - $this->pChartObject->drawLine($X1,$Y2,$X2,$Y2,$Color); |
|
174 | + $X1 = floor($X0 + $X*$XSize) + $Padding; |
|
175 | + $Y1 = floor($Y0 + $Y*$YSize) + $Padding; |
|
176 | + $X2 = floor($X0 + $X*$XSize + $XSize); |
|
177 | + $Y2 = floor($Y0 + $Y*$YSize + $YSize); |
|
178 | + |
|
179 | + if ($X > 0 && $this->Points[$X - 1][$Y] != UNKNOWN && $this->Points[$X - 1][$Y] != IGNORED && $this->Points[$X - 1][$Y] < $Threshold) |
|
180 | + $this->pChartObject->drawLine($X1, $Y1, $X1, $Y2, $Color); |
|
181 | + if ($Y > 0 && $this->Points[$X][$Y - 1] != UNKNOWN && $this->Points[$X][$Y - 1] != IGNORED && $this->Points[$X][$Y - 1] < $Threshold) |
|
182 | + $this->pChartObject->drawLine($X1, $Y1, $X2, $Y1, $Color); |
|
183 | + if ($X < $this->GridSizeX && $this->Points[$X + 1][$Y] != UNKNOWN && $this->Points[$X + 1][$Y] != IGNORED && $this->Points[$X + 1][$Y] < $Threshold) |
|
184 | + $this->pChartObject->drawLine($X2, $Y1, $X2, $Y2, $Color); |
|
185 | + if ($Y < $this->GridSizeY && $this->Points[$X][$Y + 1] != UNKNOWN && $this->Points[$X][$Y + 1] != IGNORED && $this->Points[$X][$Y + 1] < $Threshold) |
|
186 | + $this->pChartObject->drawLine($X1, $Y2, $X2, $Y2, $Color); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | } |
190 | 190 | } |
191 | 191 | |
192 | 192 | /* Draw the surface chart */ |
193 | - function drawSurface($Format="") |
|
193 | + function drawSurface($Format = "") |
|
194 | 194 | { |
195 | 195 | $Palette = isset($Format["Palette"]) ? $Format["Palette"] : NULL; |
196 | 196 | $ShadeR1 = isset($Format["ShadeR1"]) ? $Format["ShadeR1"] : 77; |
@@ -201,51 +201,51 @@ discard block |
||
201 | 201 | $ShadeG2 = isset($Format["ShadeG2"]) ? $Format["ShadeG2"] : 135; |
202 | 202 | $ShadeB2 = isset($Format["ShadeB2"]) ? $Format["ShadeB2"] : 61; |
203 | 203 | $ShadeA2 = isset($Format["ShadeA2"]) ? $Format["ShadeA2"] : 100; |
204 | - $Border = isset($Format["Border"]) ? $Format["Border"] : FALSE; |
|
204 | + $Border = isset($Format["Border"]) ? $Format["Border"] : FALSE; |
|
205 | 205 | $BorderR = isset($Format["BorderR"]) ? $Format["BorderR"] : 0; |
206 | 206 | $BorderG = isset($Format["BorderG"]) ? $Format["BorderG"] : 0; |
207 | 207 | $BorderB = isset($Format["BorderB"]) ? $Format["BorderB"] : 0; |
208 | - $Surrounding = isset($Format["Surrounding"]) ? $Format["Surrounding"] : -1; |
|
208 | + $Surrounding = isset($Format["Surrounding"]) ? $Format["Surrounding"] : -1; |
|
209 | 209 | $Padding = isset($Format["Padding"]) ? $Format["Padding"] : 1; |
210 | 210 | |
211 | 211 | $X0 = $this->pChartObject->GraphAreaX1; |
212 | 212 | $Y0 = $this->pChartObject->GraphAreaY1; |
213 | - $XSize = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1) / ($this->GridSizeX+1); |
|
214 | - $YSize = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1) / ($this->GridSizeY+1); |
|
213 | + $XSize = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1)/($this->GridSizeX + 1); |
|
214 | + $YSize = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1)/($this->GridSizeY + 1); |
|
215 | 215 | |
216 | - for($X=0;$X<=$this->GridSizeX;$X++) |
|
216 | + for ($X = 0; $X <= $this->GridSizeX; $X++) |
|
217 | 217 | { |
218 | - for($Y=0;$Y<=$this->GridSizeY;$Y++) |
|
218 | + for ($Y = 0; $Y <= $this->GridSizeY; $Y++) |
|
219 | 219 | { |
220 | 220 | $Value = $this->Points[$X][$Y]; |
221 | 221 | |
222 | - if ( $Value != UNKNOWN && $Value != IGNORED ) |
|
222 | + if ($Value != UNKNOWN && $Value != IGNORED) |
|
223 | 223 | { |
224 | - $X1 = floor($X0+$X*$XSize)+$Padding; |
|
225 | - $Y1 = floor($Y0+$Y*$YSize)+$Padding; |
|
226 | - $X2 = floor($X0+$X*$XSize+$XSize); |
|
227 | - $Y2 = floor($Y0+$Y*$YSize+$YSize); |
|
224 | + $X1 = floor($X0 + $X*$XSize) + $Padding; |
|
225 | + $Y1 = floor($Y0 + $Y*$YSize) + $Padding; |
|
226 | + $X2 = floor($X0 + $X*$XSize + $XSize); |
|
227 | + $Y2 = floor($Y0 + $Y*$YSize + $YSize); |
|
228 | 228 | |
229 | - if ( $Palette != NULL ) |
|
229 | + if ($Palette != NULL) |
|
230 | 230 | { |
231 | - if ( isset($Palette[$Value]) && isset($Palette[$Value]["R"]) ) { $R = $Palette[$Value]["R"]; } else { $R = 0; } |
|
232 | - if ( isset($Palette[$Value]) && isset($Palette[$Value]["G"]) ) { $G = $Palette[$Value]["G"]; } else { $G = 0; } |
|
233 | - if ( isset($Palette[$Value]) && isset($Palette[$Value]["B"]) ) { $B = $Palette[$Value]["B"]; } else { $B = 0; } |
|
234 | - if ( isset($Palette[$Value]) && isset($Palette[$Value]["Alpha"]) ) { $Alpha = $Palette[$Value]["Alpha"]; } else { $Alpha = 1000; } |
|
231 | + if (isset($Palette[$Value]) && isset($Palette[$Value]["R"])) { $R = $Palette[$Value]["R"]; } else { $R = 0; } |
|
232 | + if (isset($Palette[$Value]) && isset($Palette[$Value]["G"])) { $G = $Palette[$Value]["G"]; } else { $G = 0; } |
|
233 | + if (isset($Palette[$Value]) && isset($Palette[$Value]["B"])) { $B = $Palette[$Value]["B"]; } else { $B = 0; } |
|
234 | + if (isset($Palette[$Value]) && isset($Palette[$Value]["Alpha"])) { $Alpha = $Palette[$Value]["Alpha"]; } else { $Alpha = 1000; } |
|
235 | 235 | } |
236 | 236 | else |
237 | 237 | { |
238 | - $R = (($ShadeR2-$ShadeR1)/100)*$Value + $ShadeR1; |
|
239 | - $G = (($ShadeG2-$ShadeG1)/100)*$Value + $ShadeG1; |
|
240 | - $B = (($ShadeB2-$ShadeB1)/100)*$Value + $ShadeB1; |
|
241 | - $Alpha = (($ShadeA2-$ShadeA1)/100)*$Value + $ShadeA1; |
|
238 | + $R = (($ShadeR2 - $ShadeR1)/100)*$Value + $ShadeR1; |
|
239 | + $G = (($ShadeG2 - $ShadeG1)/100)*$Value + $ShadeG1; |
|
240 | + $B = (($ShadeB2 - $ShadeB1)/100)*$Value + $ShadeB1; |
|
241 | + $Alpha = (($ShadeA2 - $ShadeA1)/100)*$Value + $ShadeA1; |
|
242 | 242 | } |
243 | 243 | |
244 | - $Settings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha); |
|
245 | - if ( $Border ) { $Settings["BorderR"] = $BorderR; $Settings["BorderG"] = $BorderG; $Settings["BorderB"] = $BorderB; } |
|
246 | - if ( $Surrounding != -1 ) { $Settings["BorderR"] = $R+$Surrounding; $Settings["BorderG"] = $G+$Surrounding; $Settings["BorderB"] = $B+$Surrounding; } |
|
244 | + $Settings = array("R"=>$R, "G"=>$G, "B"=>$B, "Alpha"=>$Alpha); |
|
245 | + if ($Border) { $Settings["BorderR"] = $BorderR; $Settings["BorderG"] = $BorderG; $Settings["BorderB"] = $BorderB; } |
|
246 | + if ($Surrounding != -1) { $Settings["BorderR"] = $R + $Surrounding; $Settings["BorderG"] = $G + $Surrounding; $Settings["BorderB"] = $B + $Surrounding; } |
|
247 | 247 | |
248 | - $this->pChartObject->drawFilledRectangle($X1,$Y1,$X2-1,$Y2-1,$Settings); |
|
248 | + $this->pChartObject->drawFilledRectangle($X1, $Y1, $X2 - 1, $Y2 - 1, $Settings); |
|
249 | 249 | } |
250 | 250 | } |
251 | 251 | } |
@@ -255,57 +255,57 @@ discard block |
||
255 | 255 | function computeMissing() |
256 | 256 | { |
257 | 257 | $Missing = ""; |
258 | - for($X=0;$X<=$this->GridSizeX;$X++) |
|
258 | + for ($X = 0; $X <= $this->GridSizeX; $X++) |
|
259 | 259 | { |
260 | - for($Y=0;$Y<=$this->GridSizeY;$Y++) |
|
260 | + for ($Y = 0; $Y <= $this->GridSizeY; $Y++) |
|
261 | 261 | { |
262 | - if ( $this->Points[$X][$Y] == UNKNOWN ) |
|
262 | + if ($this->Points[$X][$Y] == UNKNOWN) |
|
263 | 263 | $Missing[] = $X.",".$Y; |
264 | 264 | } |
265 | 265 | } |
266 | 266 | shuffle($Missing); |
267 | 267 | |
268 | - foreach($Missing as $Key => $Pos) |
|
268 | + foreach ($Missing as $Key => $Pos) |
|
269 | 269 | { |
270 | - $Pos = preg_split("/,/",$Pos); |
|
270 | + $Pos = preg_split("/,/", $Pos); |
|
271 | 271 | $X = $Pos[0]; |
272 | 272 | $Y = $Pos[1]; |
273 | 273 | |
274 | - if ( $this->Points[$X][$Y] == UNKNOWN ) |
|
274 | + if ($this->Points[$X][$Y] == UNKNOWN) |
|
275 | 275 | { |
276 | - $NearestNeighbor = $this->getNearestNeighbor($X,$Y); |
|
276 | + $NearestNeighbor = $this->getNearestNeighbor($X, $Y); |
|
277 | 277 | |
278 | 278 | $Value = 0; $Points = 0; |
279 | - for($Xi=$X-$NearestNeighbor;$Xi<=$X+$NearestNeighbor;$Xi++) |
|
279 | + for ($Xi = $X - $NearestNeighbor; $Xi <= $X + $NearestNeighbor; $Xi++) |
|
280 | 280 | { |
281 | - for($Yi=$Y-$NearestNeighbor;$Yi<=$Y+$NearestNeighbor;$Yi++) |
|
281 | + for ($Yi = $Y - $NearestNeighbor; $Yi <= $Y + $NearestNeighbor; $Yi++) |
|
282 | 282 | { |
283 | - if ($Xi >=0 && $Yi >= 0 && $Xi <= $this->GridSizeX && $Yi <= $this->GridSizeY && $this->Points[$Xi][$Yi] != UNKNOWN && $this->Points[$Xi][$Yi] != IGNORED) |
|
283 | + if ($Xi >= 0 && $Yi >= 0 && $Xi <= $this->GridSizeX && $Yi <= $this->GridSizeY && $this->Points[$Xi][$Yi] != UNKNOWN && $this->Points[$Xi][$Yi] != IGNORED) |
|
284 | 284 | { |
285 | 285 | $Value = $Value + $this->Points[$Xi][$Yi]; $Points++; |
286 | 286 | } |
287 | 287 | } |
288 | 288 | } |
289 | 289 | |
290 | - if ( $Points != 0 ) { $this->Points[$X][$Y] = $Value / $Points; } |
|
290 | + if ($Points != 0) { $this->Points[$X][$Y] = $Value/$Points; } |
|
291 | 291 | } |
292 | 292 | } |
293 | 293 | } |
294 | 294 | |
295 | 295 | /* Return the nearest Neighbor distance of a point */ |
296 | - function getNearestNeighbor($Xp,$Yp) |
|
296 | + function getNearestNeighbor($Xp, $Yp) |
|
297 | 297 | { |
298 | 298 | $Nearest = UNKNOWN; |
299 | - for($X=0;$X<=$this->GridSizeX;$X++) |
|
299 | + for ($X = 0; $X <= $this->GridSizeX; $X++) |
|
300 | 300 | { |
301 | - for($Y=0;$Y<=$this->GridSizeY;$Y++) |
|
301 | + for ($Y = 0; $Y <= $this->GridSizeY; $Y++) |
|
302 | 302 | { |
303 | - if ( $this->Points[$X][$Y] != UNKNOWN && $this->Points[$X][$Y] != IGNORED ) |
|
303 | + if ($this->Points[$X][$Y] != UNKNOWN && $this->Points[$X][$Y] != IGNORED) |
|
304 | 304 | { |
305 | - $DistanceX = max($Xp,$X)-min($Xp,$X); |
|
306 | - $DistanceY = max($Yp,$Y)-min($Yp,$Y); |
|
307 | - $Distance = max($DistanceX,$DistanceY); |
|
308 | - if ( $Distance < $Nearest || $Nearest == UNKNOWN ) { $Nearest = $Distance; } |
|
305 | + $DistanceX = max($Xp, $X) - min($Xp, $X); |
|
306 | + $DistanceY = max($Yp, $Y) - min($Yp, $Y); |
|
307 | + $Distance = max($DistanceX, $DistanceY); |
|
308 | + if ($Distance < $Nearest || $Nearest == UNKNOWN) { $Nearest = $Distance; } |
|
309 | 309 | } |
310 | 310 | } |
311 | 311 | } |
@@ -22,24 +22,21 @@ discard block |
||
22 | 22 | define("LABEL_POSITION_BOTTOM" , 880004); |
23 | 23 | |
24 | 24 | /* pStock class definition */ |
25 | - class pSurface |
|
26 | - { |
|
25 | + class pSurface { |
|
27 | 26 | var $pChartObject; |
28 | 27 | var $GridSizeX; |
29 | 28 | var $GridSizeY; |
30 | 29 | var $Points; |
31 | 30 | |
32 | 31 | /* Class creator */ |
33 | - function pSurface($pChartObject) |
|
34 | - { |
|
32 | + function pSurface($pChartObject) { |
|
35 | 33 | $this->pChartObject = $pChartObject; |
36 | 34 | $this->GridSize = 10; |
37 | 35 | $this->Points = ""; |
38 | 36 | } |
39 | 37 | |
40 | 38 | /* Define the grid size and initialise the 2D matrix */ |
41 | - function setGrid($XSize=10,$YSize=10) |
|
42 | - { |
|
39 | + function setGrid($XSize=10,$YSize=10) { |
|
43 | 40 | for($X=0; $X<=$XSize; $X++) { for($Y=0; $Y<=$YSize; $Y++) { $this->Points[$X][$Y]=UNKNOWN; } } |
44 | 41 | |
45 | 42 | $this->GridSizeX = $XSize; |
@@ -47,8 +44,7 @@ discard block |
||
47 | 44 | } |
48 | 45 | |
49 | 46 | /* Add a point on the grid */ |
50 | - function addPoint($X,$Y,$Value,$Force=TRUE) |
|
51 | - { |
|
47 | + function addPoint($X,$Y,$Value,$Force=TRUE) { |
|
52 | 48 | if ( $X < 0 || $X >$this->GridSizeX ) { return(0); } |
53 | 49 | if ( $Y < 0 || $Y >$this->GridSizeY ) { return(0); } |
54 | 50 | |
@@ -61,8 +57,7 @@ discard block |
||
61 | 57 | } |
62 | 58 | |
63 | 59 | /* Write the X labels */ |
64 | - function writeXLabels($Format="") |
|
65 | - { |
|
60 | + function writeXLabels($Format="") { |
|
66 | 61 | $R = isset($Format["R"]) ? $Format["R"] : $this->pChartObject->FontColorR; |
67 | 62 | $G = isset($Format["G"]) ? $Format["G"] : $this->pChartObject->FontColorG; |
68 | 63 | $B = isset($Format["B"]) ? $Format["B"] : $this->pChartObject->FontColorB; |
@@ -79,23 +74,18 @@ discard block |
||
79 | 74 | $XSize = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1) / ($this->GridSizeX+1); |
80 | 75 | |
81 | 76 | $Settings = array("Angle"=>$Angle,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha); |
82 | - if ( $Position == LABEL_POSITION_TOP ) |
|
83 | - { |
|
77 | + if ( $Position == LABEL_POSITION_TOP ) { |
|
84 | 78 | $YPos = $this->pChartObject->GraphAreaY1 - $Padding; |
85 | 79 | if ($Angle == 0 ) { $Settings["Align"] = TEXT_ALIGN_BOTTOMMIDDLE; } |
86 | 80 | if ($Angle != 0 ) { $Settings["Align"] = TEXT_ALIGN_MIDDLELEFT; } |
87 | - } |
|
88 | - elseif ( $Position == LABEL_POSITION_BOTTOM ) |
|
89 | - { |
|
81 | + } elseif ( $Position == LABEL_POSITION_BOTTOM ) { |
|
90 | 82 | $YPos = $this->pChartObject->GraphAreaY2 + $Padding; |
91 | 83 | if ($Angle == 0 ) { $Settings["Align"] = TEXT_ALIGN_TOPMIDDLE; } |
92 | 84 | if ($Angle != 0 ) { $Settings["Align"] = TEXT_ALIGN_MIDDLERIGHT; } |
93 | - } |
|
94 | - else |
|
85 | + } else |
|
95 | 86 | return(-1); |
96 | 87 | |
97 | - for($X=0;$X<=$this->GridSizeX;$X++) |
|
98 | - { |
|
88 | + for($X=0;$X<=$this->GridSizeX;$X++) { |
|
99 | 89 | $XPos = floor($X0+$X*$XSize + $XSize/2); |
100 | 90 | |
101 | 91 | if( $Labels == NULL || !isset($Labels[$X]) ) |
@@ -108,8 +98,7 @@ discard block |
||
108 | 98 | } |
109 | 99 | |
110 | 100 | /* Write the Y labels */ |
111 | - function writeYLabels($Format="") |
|
112 | - { |
|
101 | + function writeYLabels($Format="") { |
|
113 | 102 | $R = isset($Format["R"]) ? $Format["R"] : $this->pChartObject->FontColorR; |
114 | 103 | $G = isset($Format["G"]) ? $Format["G"] : $this->pChartObject->FontColorG; |
115 | 104 | $B = isset($Format["B"]) ? $Format["B"] : $this->pChartObject->FontColorB; |
@@ -127,14 +116,11 @@ discard block |
||
127 | 116 | |
128 | 117 | $Settings = array("Angle"=>$Angle,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha); |
129 | 118 | if ( $Position == LABEL_POSITION_LEFT ) |
130 | - { $XPos = $this->pChartObject->GraphAreaX1 - $Padding; $Settings["Align"] = TEXT_ALIGN_MIDDLERIGHT; } |
|
131 | - elseif ( $Position == LABEL_POSITION_RIGHT ) |
|
132 | - { $XPos = $this->pChartObject->GraphAreaX2 + $Padding; $Settings["Align"] = TEXT_ALIGN_MIDDLELEFT; } |
|
133 | - else |
|
119 | + { $XPos = $this->pChartObject->GraphAreaX1 - $Padding; $Settings["Align"] = TEXT_ALIGN_MIDDLERIGHT; } elseif ( $Position == LABEL_POSITION_RIGHT ) |
|
120 | + { $XPos = $this->pChartObject->GraphAreaX2 + $Padding; $Settings["Align"] = TEXT_ALIGN_MIDDLELEFT; } else |
|
134 | 121 | return(-1); |
135 | 122 | |
136 | - for($Y=0;$Y<=$this->GridSizeY;$Y++) |
|
137 | - { |
|
123 | + for($Y=0;$Y<=$this->GridSizeY;$Y++) { |
|
138 | 124 | $YPos = floor($Y0+$Y*$YSize + $YSize/2); |
139 | 125 | |
140 | 126 | if( $Labels == NULL || !isset($Labels[$Y]) ) |
@@ -147,8 +133,7 @@ discard block |
||
147 | 133 | } |
148 | 134 | |
149 | 135 | /* Draw the area arround the specified Threshold */ |
150 | - function drawContour($Threshold,$Format="") |
|
151 | - { |
|
136 | + function drawContour($Threshold,$Format="") { |
|
152 | 137 | $R = isset($Format["R"]) ? $Format["R"] : 0; |
153 | 138 | $G = isset($Format["G"]) ? $Format["G"] : 0; |
154 | 139 | $B = isset($Format["B"]) ? $Format["B"] : 0; |
@@ -163,14 +148,11 @@ discard block |
||
163 | 148 | |
164 | 149 | $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks); |
165 | 150 | |
166 | - for($X=0;$X<=$this->GridSizeX;$X++) |
|
167 | - { |
|
168 | - for($Y=0;$Y<=$this->GridSizeY;$Y++) |
|
169 | - { |
|
151 | + for($X=0;$X<=$this->GridSizeX;$X++) { |
|
152 | + for($Y=0;$Y<=$this->GridSizeY;$Y++) { |
|
170 | 153 | $Value = $this->Points[$X][$Y]; |
171 | 154 | |
172 | - if ( $Value != UNKNOWN && $Value != IGNORED && $Value >= $Threshold) |
|
173 | - { |
|
155 | + if ( $Value != UNKNOWN && $Value != IGNORED && $Value >= $Threshold) { |
|
174 | 156 | $X1 = floor($X0+$X*$XSize)+$Padding; |
175 | 157 | $Y1 = floor($Y0+$Y*$YSize)+$Padding; |
176 | 158 | $X2 = floor($X0+$X*$XSize+$XSize); |
@@ -190,8 +172,7 @@ discard block |
||
190 | 172 | } |
191 | 173 | |
192 | 174 | /* Draw the surface chart */ |
193 | - function drawSurface($Format="") |
|
194 | - { |
|
175 | + function drawSurface($Format="") { |
|
195 | 176 | $Palette = isset($Format["Palette"]) ? $Format["Palette"] : NULL; |
196 | 177 | $ShadeR1 = isset($Format["ShadeR1"]) ? $Format["ShadeR1"] : 77; |
197 | 178 | $ShadeG1 = isset($Format["ShadeG1"]) ? $Format["ShadeG1"] : 205; |
@@ -213,28 +194,22 @@ discard block |
||
213 | 194 | $XSize = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1) / ($this->GridSizeX+1); |
214 | 195 | $YSize = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1) / ($this->GridSizeY+1); |
215 | 196 | |
216 | - for($X=0;$X<=$this->GridSizeX;$X++) |
|
217 | - { |
|
218 | - for($Y=0;$Y<=$this->GridSizeY;$Y++) |
|
219 | - { |
|
197 | + for($X=0;$X<=$this->GridSizeX;$X++) { |
|
198 | + for($Y=0;$Y<=$this->GridSizeY;$Y++) { |
|
220 | 199 | $Value = $this->Points[$X][$Y]; |
221 | 200 | |
222 | - if ( $Value != UNKNOWN && $Value != IGNORED ) |
|
223 | - { |
|
201 | + if ( $Value != UNKNOWN && $Value != IGNORED ) { |
|
224 | 202 | $X1 = floor($X0+$X*$XSize)+$Padding; |
225 | 203 | $Y1 = floor($Y0+$Y*$YSize)+$Padding; |
226 | 204 | $X2 = floor($X0+$X*$XSize+$XSize); |
227 | 205 | $Y2 = floor($Y0+$Y*$YSize+$YSize); |
228 | 206 | |
229 | - if ( $Palette != NULL ) |
|
230 | - { |
|
207 | + if ( $Palette != NULL ) { |
|
231 | 208 | if ( isset($Palette[$Value]) && isset($Palette[$Value]["R"]) ) { $R = $Palette[$Value]["R"]; } else { $R = 0; } |
232 | 209 | if ( isset($Palette[$Value]) && isset($Palette[$Value]["G"]) ) { $G = $Palette[$Value]["G"]; } else { $G = 0; } |
233 | 210 | if ( isset($Palette[$Value]) && isset($Palette[$Value]["B"]) ) { $B = $Palette[$Value]["B"]; } else { $B = 0; } |
234 | 211 | if ( isset($Palette[$Value]) && isset($Palette[$Value]["Alpha"]) ) { $Alpha = $Palette[$Value]["Alpha"]; } else { $Alpha = 1000; } |
235 | - } |
|
236 | - else |
|
237 | - { |
|
212 | + } else { |
|
238 | 213 | $R = (($ShadeR2-$ShadeR1)/100)*$Value + $ShadeR1; |
239 | 214 | $G = (($ShadeG2-$ShadeG1)/100)*$Value + $ShadeG1; |
240 | 215 | $B = (($ShadeB2-$ShadeB1)/100)*$Value + $ShadeB1; |
@@ -252,36 +227,28 @@ discard block |
||
252 | 227 | } |
253 | 228 | |
254 | 229 | /* Compute the missing points */ |
255 | - function computeMissing() |
|
256 | - { |
|
230 | + function computeMissing() { |
|
257 | 231 | $Missing = ""; |
258 | - for($X=0;$X<=$this->GridSizeX;$X++) |
|
259 | - { |
|
260 | - for($Y=0;$Y<=$this->GridSizeY;$Y++) |
|
261 | - { |
|
232 | + for($X=0;$X<=$this->GridSizeX;$X++) { |
|
233 | + for($Y=0;$Y<=$this->GridSizeY;$Y++) { |
|
262 | 234 | if ( $this->Points[$X][$Y] == UNKNOWN ) |
263 | 235 | $Missing[] = $X.",".$Y; |
264 | 236 | } |
265 | 237 | } |
266 | 238 | shuffle($Missing); |
267 | 239 | |
268 | - foreach($Missing as $Key => $Pos) |
|
269 | - { |
|
240 | + foreach($Missing as $Key => $Pos) { |
|
270 | 241 | $Pos = preg_split("/,/",$Pos); |
271 | 242 | $X = $Pos[0]; |
272 | 243 | $Y = $Pos[1]; |
273 | 244 | |
274 | - if ( $this->Points[$X][$Y] == UNKNOWN ) |
|
275 | - { |
|
245 | + if ( $this->Points[$X][$Y] == UNKNOWN ) { |
|
276 | 246 | $NearestNeighbor = $this->getNearestNeighbor($X,$Y); |
277 | 247 | |
278 | 248 | $Value = 0; $Points = 0; |
279 | - for($Xi=$X-$NearestNeighbor;$Xi<=$X+$NearestNeighbor;$Xi++) |
|
280 | - { |
|
281 | - for($Yi=$Y-$NearestNeighbor;$Yi<=$Y+$NearestNeighbor;$Yi++) |
|
282 | - { |
|
283 | - if ($Xi >=0 && $Yi >= 0 && $Xi <= $this->GridSizeX && $Yi <= $this->GridSizeY && $this->Points[$Xi][$Yi] != UNKNOWN && $this->Points[$Xi][$Yi] != IGNORED) |
|
284 | - { |
|
249 | + for($Xi=$X-$NearestNeighbor;$Xi<=$X+$NearestNeighbor;$Xi++) { |
|
250 | + for($Yi=$Y-$NearestNeighbor;$Yi<=$Y+$NearestNeighbor;$Yi++) { |
|
251 | + if ($Xi >=0 && $Yi >= 0 && $Xi <= $this->GridSizeX && $Yi <= $this->GridSizeY && $this->Points[$Xi][$Yi] != UNKNOWN && $this->Points[$Xi][$Yi] != IGNORED) { |
|
285 | 252 | $Value = $Value + $this->Points[$Xi][$Yi]; $Points++; |
286 | 253 | } |
287 | 254 | } |
@@ -293,15 +260,11 @@ discard block |
||
293 | 260 | } |
294 | 261 | |
295 | 262 | /* Return the nearest Neighbor distance of a point */ |
296 | - function getNearestNeighbor($Xp,$Yp) |
|
297 | - { |
|
263 | + function getNearestNeighbor($Xp,$Yp) { |
|
298 | 264 | $Nearest = UNKNOWN; |
299 | - for($X=0;$X<=$this->GridSizeX;$X++) |
|
300 | - { |
|
301 | - for($Y=0;$Y<=$this->GridSizeY;$Y++) |
|
302 | - { |
|
303 | - if ( $this->Points[$X][$Y] != UNKNOWN && $this->Points[$X][$Y] != IGNORED ) |
|
304 | - { |
|
265 | + for($X=0;$X<=$this->GridSizeX;$X++) { |
|
266 | + for($Y=0;$Y<=$this->GridSizeY;$Y++) { |
|
267 | + if ( $this->Points[$X][$Y] != UNKNOWN && $this->Points[$X][$Y] != IGNORED ) { |
|
305 | 268 | $DistanceX = max($Xp,$X)-min($Xp,$X); |
306 | 269 | $DistanceY = max($Yp,$Y)-min($Yp,$Y); |
307 | 270 | $Distance = max($DistanceX,$DistanceY); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | /* Add a point on the grid */ |
50 | - function addPoint($X,$Y,$Value,$Force=TRUE) |
|
50 | + function addPoint($X,$Y,$Value,$Force=true) |
|
51 | 51 | { |
52 | 52 | if ( $X < 0 || $X >$this->GridSizeX ) { return(0); } |
53 | 53 | if ( $Y < 0 || $Y >$this->GridSizeY ) { return(0); } |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0; |
71 | 71 | $Padding = isset($Format["Padding"]) ? $Format["Padding"] : 5; |
72 | 72 | $Position = isset($Format["Position"]) ? $Format["Position"] : LABEL_POSITION_TOP; |
73 | - $Labels = isset($Format["Labels"]) ? $Format["Labels"] : NULL; |
|
73 | + $Labels = isset($Format["Labels"]) ? $Format["Labels"] : null; |
|
74 | 74 | $CountOffset = isset($Format["CountOffset"]) ? $Format["CountOffset"] : 0; |
75 | 75 | |
76 | - if ( $Labels != NULL && !is_array($Labels) ) { $Label = $Labels; $Labels = ""; $Labels[] = $Label; } |
|
76 | + if ( $Labels != null && !is_array($Labels) ) { $Label = $Labels; $Labels = ""; $Labels[] = $Label; } |
|
77 | 77 | |
78 | 78 | $X0 = $this->pChartObject->GraphAreaX1; |
79 | 79 | $XSize = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1) / ($this->GridSizeX+1); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | { |
99 | 99 | $XPos = floor($X0+$X*$XSize + $XSize/2); |
100 | 100 | |
101 | - if( $Labels == NULL || !isset($Labels[$X]) ) |
|
101 | + if( $Labels == null || !isset($Labels[$X]) ) |
|
102 | 102 | $Value = $X+$CountOffset; |
103 | 103 | else |
104 | 104 | $Value = $Labels[$X]; |
@@ -117,10 +117,10 @@ discard block |
||
117 | 117 | $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0; |
118 | 118 | $Padding = isset($Format["Padding"]) ? $Format["Padding"] : 5; |
119 | 119 | $Position = isset($Format["Position"]) ? $Format["Position"] : LABEL_POSITION_LEFT; |
120 | - $Labels = isset($Format["Labels"]) ? $Format["Labels"] : NULL; |
|
120 | + $Labels = isset($Format["Labels"]) ? $Format["Labels"] : null; |
|
121 | 121 | $CountOffset = isset($Format["CountOffset"]) ? $Format["CountOffset"] : 0; |
122 | 122 | |
123 | - if ( $Labels != NULL && !is_array($Labels) ) { $Label = $Labels; $Labels = ""; $Labels[] = $Label; } |
|
123 | + if ( $Labels != null && !is_array($Labels) ) { $Label = $Labels; $Labels = ""; $Labels[] = $Label; } |
|
124 | 124 | |
125 | 125 | $Y0 = $this->pChartObject->GraphAreaY1; |
126 | 126 | $YSize = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1) / ($this->GridSizeY+1); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | { |
138 | 138 | $YPos = floor($Y0+$Y*$YSize + $YSize/2); |
139 | 139 | |
140 | - if( $Labels == NULL || !isset($Labels[$Y]) ) |
|
140 | + if( $Labels == null || !isset($Labels[$Y]) ) |
|
141 | 141 | $Value = $Y+$CountOffset; |
142 | 142 | else |
143 | 143 | $Value = $Labels[$Y]; |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | /* Draw the surface chart */ |
193 | 193 | function drawSurface($Format="") |
194 | 194 | { |
195 | - $Palette = isset($Format["Palette"]) ? $Format["Palette"] : NULL; |
|
195 | + $Palette = isset($Format["Palette"]) ? $Format["Palette"] : null; |
|
196 | 196 | $ShadeR1 = isset($Format["ShadeR1"]) ? $Format["ShadeR1"] : 77; |
197 | 197 | $ShadeG1 = isset($Format["ShadeG1"]) ? $Format["ShadeG1"] : 205; |
198 | 198 | $ShadeB1 = isset($Format["ShadeB1"]) ? $Format["ShadeB1"] : 21; |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | $ShadeG2 = isset($Format["ShadeG2"]) ? $Format["ShadeG2"] : 135; |
202 | 202 | $ShadeB2 = isset($Format["ShadeB2"]) ? $Format["ShadeB2"] : 61; |
203 | 203 | $ShadeA2 = isset($Format["ShadeA2"]) ? $Format["ShadeA2"] : 100; |
204 | - $Border = isset($Format["Border"]) ? $Format["Border"] : FALSE; |
|
204 | + $Border = isset($Format["Border"]) ? $Format["Border"] : false; |
|
205 | 205 | $BorderR = isset($Format["BorderR"]) ? $Format["BorderR"] : 0; |
206 | 206 | $BorderG = isset($Format["BorderG"]) ? $Format["BorderG"] : 0; |
207 | 207 | $BorderB = isset($Format["BorderB"]) ? $Format["BorderB"] : 0; |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $X2 = floor($X0+$X*$XSize+$XSize); |
227 | 227 | $Y2 = floor($Y0+$Y*$YSize+$YSize); |
228 | 228 | |
229 | - if ( $Palette != NULL ) |
|
229 | + if ( $Palette != null ) |
|
230 | 230 | { |
231 | 231 | if ( isset($Palette[$Value]) && isset($Palette[$Value]["R"]) ) { $R = $Palette[$Value]["R"]; } else { $R = 0; } |
232 | 232 | if ( isset($Palette[$Value]) && isset($Palette[$Value]["G"]) ) { $G = $Palette[$Value]["G"]; } else { $G = 0; } |
@@ -7,15 +7,15 @@ |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | class views_handler_argument_boincteam_id extends views_handler_argument_numeric { |
10 | - function construct() { |
|
10 | + function construct() { |
|
11 | 11 | parent::construct(); |
12 | - } |
|
12 | + } |
|
13 | 13 | |
14 | - function set_argument($arg) { |
|
14 | + function set_argument($arg) { |
|
15 | 15 | // When setting the ID argument, convert to BOINC ID |
16 | 16 | $id = is_numeric($arg) ? $arg : 0; |
17 | 17 | $boinc_id = db_result(db_query("SELECT team_id FROM {boincteam} WHERE nid = %d", $id)); |
18 | 18 | $this->argument = $boinc_id; |
19 | 19 | return $this->validate_arg($boinc_id); |
20 | - } |
|
20 | + } |
|
21 | 21 | } |
@@ -13,80 +13,80 @@ |
||
13 | 13 | */ |
14 | 14 | function boincteam_forum_views_data() { |
15 | 15 | |
16 | - // ----------------------------------------------------------------------------------------------- |
|
17 | - // Definition for team table |
|
18 | - // ----------------------------------------------------------------------------------------------- |
|
16 | + // ----------------------------------------------------------------------------------------------- |
|
17 | + // Definition for team table |
|
18 | + // ----------------------------------------------------------------------------------------------- |
|
19 | 19 | |
20 | - $data['boincteam_forum_node']['table']['group'] = t('BOINC'); |
|
20 | + $data['boincteam_forum_node']['table']['group'] = t('BOINC'); |
|
21 | 21 | |
22 | - $data['boincteam_forum_node']['table']['base'] = array( |
|
23 | - 'field' => 'nid', |
|
24 | - 'title' => t('BOINC team forum topic'), |
|
25 | - 'help' => t('Forum topics for a team'), |
|
26 | - ); |
|
22 | + $data['boincteam_forum_node']['table']['base'] = array( |
|
23 | + 'field' => 'nid', |
|
24 | + 'title' => t('BOINC team forum topic'), |
|
25 | + 'help' => t('Forum topics for a team'), |
|
26 | + ); |
|
27 | 27 | |
28 | - // Describe each of the individual fields in this table to Views. For |
|
29 | - // each field, you may define what field, sort, argument, and/or filter |
|
30 | - // handlers it supports. This will determine where in the Views interface you |
|
31 | - // may use the field. |
|
28 | + // Describe each of the individual fields in this table to Views. For |
|
29 | + // each field, you may define what field, sort, argument, and/or filter |
|
30 | + // handlers it supports. This will determine where in the Views interface you |
|
31 | + // may use the field. |
|
32 | 32 | |
33 | - // Primary keys allowed as arguments |
|
33 | + // Primary keys allowed as arguments |
|
34 | 34 | |
35 | - $data['boincteam_forum_node']['tfid'] = array( |
|
35 | + $data['boincteam_forum_node']['tfid'] = array( |
|
36 | 36 | 'title' => t('Team forum ID'), |
37 | 37 | 'help' => t('The ID of the team forum containing this topic.'), |
38 | 38 | 'field' => array( |
39 | - 'handler' => 'views_handler_field_numeric', |
|
40 | - 'click sortable' => TRUE |
|
39 | + 'handler' => 'views_handler_field_numeric', |
|
40 | + 'click sortable' => TRUE |
|
41 | 41 | ), |
42 | 42 | 'argument' => array( |
43 | - 'handler' => 'views_handler_argument_numeric', |
|
44 | - 'name field' => 'title', // the field to display in the summary. |
|
45 | - 'numeric' => TRUE, |
|
46 | - 'validate type' => 'id' |
|
43 | + 'handler' => 'views_handler_argument_numeric', |
|
44 | + 'name field' => 'title', // the field to display in the summary. |
|
45 | + 'numeric' => TRUE, |
|
46 | + 'validate type' => 'id' |
|
47 | 47 | ), |
48 | 48 | 'relationship' => array( |
49 | - 'base' => 'boincteam_forum', |
|
50 | - 'field' => 'tfid', |
|
51 | - 'handler' => 'views_handler_relationship', |
|
52 | - 'label' => t('Team Forum') |
|
49 | + 'base' => 'boincteam_forum', |
|
50 | + 'field' => 'tfid', |
|
51 | + 'handler' => 'views_handler_relationship', |
|
52 | + 'label' => t('Team Forum') |
|
53 | 53 | ), |
54 | 54 | 'filter' => array( |
55 | - 'handler' => 'views_handler_filter_numeric' |
|
55 | + 'handler' => 'views_handler_filter_numeric' |
|
56 | 56 | ), |
57 | 57 | 'sort' => array( |
58 | - 'handler' => 'views_handler_sort_numeric' |
|
58 | + 'handler' => 'views_handler_sort_numeric' |
|
59 | 59 | ) |
60 | - ); |
|
60 | + ); |
|
61 | 61 | |
62 | - // Foreign key fields |
|
62 | + // Foreign key fields |
|
63 | 63 | |
64 | - $data['boincteam_forum_node']['nid'] = array( |
|
64 | + $data['boincteam_forum_node']['nid'] = array( |
|
65 | 65 | 'title' => t('Team forum node'), |
66 | 66 | 'help' => t('The node containing the content of this team forum topic.'), |
67 | 67 | // This is a foreign key to the {node} table. When the view is configured |
68 | 68 | // with this relationship, all the fields for the related user node will be |
69 | 69 | // available. |
70 | 70 | 'relationship' => array( |
71 | - 'base' => 'node', |
|
72 | - 'field' => 'nid', |
|
73 | - 'handler' => 'views_handler_relationship', |
|
74 | - 'label' => t('Team Forum Topic Node') |
|
71 | + 'base' => 'node', |
|
72 | + 'field' => 'nid', |
|
73 | + 'handler' => 'views_handler_relationship', |
|
74 | + 'label' => t('Team Forum Topic Node') |
|
75 | 75 | ), |
76 | 76 | 'field' => array( |
77 | - 'handler' => 'views_handler_field_numeric', |
|
78 | - 'click sortable' => TRUE |
|
77 | + 'handler' => 'views_handler_field_numeric', |
|
78 | + 'click sortable' => TRUE |
|
79 | 79 | ), |
80 | 80 | 'filter' => array( |
81 | - 'handler' => 'views_handler_filter_numeric' |
|
81 | + 'handler' => 'views_handler_filter_numeric' |
|
82 | 82 | ), |
83 | 83 | 'sort' => array( |
84 | - 'handler' => 'views_handler_sort_numeric' |
|
84 | + 'handler' => 'views_handler_sort_numeric' |
|
85 | 85 | ) |
86 | - ); |
|
86 | + ); |
|
87 | 87 | |
88 | - // Descriptions of general fields (alphabetized) |
|
89 | - // ... |
|
88 | + // Descriptions of general fields (alphabetized) |
|
89 | + // ... |
|
90 | 90 | |
91 | - return $data; |
|
91 | + return $data; |
|
92 | 92 | } |
@@ -37,12 +37,12 @@ discard block |
||
37 | 37 | 'help' => t('The ID of the team forum containing this topic.'), |
38 | 38 | 'field' => array( |
39 | 39 | 'handler' => 'views_handler_field_numeric', |
40 | - 'click sortable' => TRUE |
|
40 | + 'click sortable' => true |
|
41 | 41 | ), |
42 | 42 | 'argument' => array( |
43 | 43 | 'handler' => 'views_handler_argument_numeric', |
44 | 44 | 'name field' => 'title', // the field to display in the summary. |
45 | - 'numeric' => TRUE, |
|
45 | + 'numeric' => true, |
|
46 | 46 | 'validate type' => 'id' |
47 | 47 | ), |
48 | 48 | 'relationship' => array( |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | ), |
76 | 76 | 'field' => array( |
77 | 77 | 'handler' => 'views_handler_field_numeric', |
78 | - 'click sortable' => TRUE |
|
78 | + 'click sortable' => true |
|
79 | 79 | ), |
80 | 80 | 'filter' => array( |
81 | 81 | 'handler' => 'views_handler_filter_numeric' |
@@ -444,7 +444,7 @@ |
||
444 | 444 | function boincteam_views_handlers() { |
445 | 445 | return array( |
446 | 446 | 'info' => array( |
447 | - 'path' => drupal_get_path('module', 'boincteam') . '/views', |
|
447 | + 'path' => drupal_get_path('module', 'boincteam').'/views', |
|
448 | 448 | ), |
449 | 449 | 'handlers' => array( |
450 | 450 | 'views_handler_argument_boincteam_id' => array( |
@@ -49,16 +49,16 @@ discard block |
||
49 | 49 | // Primary keys allowed as arguments |
50 | 50 | |
51 | 51 | $data['team']['id'] = array( |
52 | - 'title' => bts('Team ID', array(), NULL, 'boinc:team-id'), |
|
52 | + 'title' => bts('Team ID', array(), null, 'boinc:team-id'), |
|
53 | 53 | 'help' => t('The BOINC ID of the team.'), |
54 | 54 | 'field' => array( |
55 | 55 | 'handler' => 'views_handler_field_numeric', |
56 | - 'click sortable' => TRUE |
|
56 | + 'click sortable' => true |
|
57 | 57 | ), |
58 | 58 | 'argument' => array( |
59 | 59 | 'handler' => 'views_handler_argument_boincteam_id', // custom handler |
60 | 60 | 'name field' => 'title', // the field to display in the summary. |
61 | - 'numeric' => TRUE, |
|
61 | + 'numeric' => true, |
|
62 | 62 | 'validate type' => 'id' |
63 | 63 | ), |
64 | 64 | 'relationship' => array( |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | // Foreign key fields |
80 | 80 | |
81 | 81 | $data['team']['userid'] = array( |
82 | - 'title' => bts('Founder', array(), NULL, 'boinc:view-team-info'), |
|
82 | + 'title' => bts('Founder', array(), null, 'boinc:view-team-info'), |
|
83 | 83 | 'help' => t('The founder of this team.'), |
84 | 84 | // This is a foreign key to the {user} table. When the view is configured |
85 | 85 | // with this relationship, all the fields for the related user node will be |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | 'argument' => array( |
88 | 88 | 'handler' => 'views_handler_argument_boincuser_id', |
89 | 89 | 'name field' => 'title', |
90 | - 'numeric' => TRUE, |
|
90 | + 'numeric' => true, |
|
91 | 91 | 'validate type' => 'id' |
92 | 92 | ), |
93 | 93 | 'relationship' => array( |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | ), |
99 | 99 | 'field' => array( |
100 | 100 | 'handler' => 'views_handler_field_numeric', |
101 | - 'click sortable' => TRUE |
|
101 | + 'click sortable' => true |
|
102 | 102 | ), |
103 | 103 | 'filter' => array( |
104 | 104 | 'handler' => 'views_handler_filter_numeric' |
@@ -141,11 +141,11 @@ discard block |
||
141 | 141 | */ |
142 | 142 | |
143 | 143 | $data['team']['country'] = array( |
144 | - 'title' => bts('Country', array(), NULL, 'boinc:country-of-origin'), |
|
144 | + 'title' => bts('Country', array(), null, 'boinc:country-of-origin'), |
|
145 | 145 | 'help' => t('The country of a team.'), |
146 | 146 | 'field' => array( |
147 | 147 | 'handler' => 'views_handler_field', |
148 | - 'click sortable' => TRUE |
|
148 | + 'click sortable' => true |
|
149 | 149 | ), |
150 | 150 | 'filter' => array( |
151 | 151 | 'handler' => 'views_handler_filter_string' |
@@ -155,12 +155,12 @@ discard block |
||
155 | 155 | ) |
156 | 156 | ); |
157 | 157 | $data['team']['expavg_credit'] = array( |
158 | - 'title' => bts('Recent average credit', array(), NULL, 'boinc:user-or-team-RAC'), |
|
158 | + 'title' => bts('Recent average credit', array(), null, 'boinc:user-or-team-RAC'), |
|
159 | 159 | 'help' => t('A decaying average of team credit per day.'), |
160 | 160 | 'field' => array( |
161 | 161 | 'handler' => 'views_handler_field_numeric', |
162 | - 'click sortable' => TRUE, |
|
163 | - 'float' => TRUE |
|
162 | + 'click sortable' => true, |
|
163 | + 'float' => true |
|
164 | 164 | ), |
165 | 165 | 'filter' => array( |
166 | 166 | 'handler' => 'views_handler_filter_numeric' |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | ) |
171 | 171 | ); |
172 | 172 | $data['team']['name'] = array( |
173 | - 'title' => bts('Name', array(), NULL, 'boinc:user-or-team-name'), |
|
173 | + 'title' => bts('Name', array(), null, 'boinc:user-or-team-name'), |
|
174 | 174 | 'help' => t('The name of the team.'), |
175 | 175 | 'field' => array( |
176 | 176 | 'handler' => 'views_handler_field', |
177 | - 'click sortable' => TRUE |
|
177 | + 'click sortable' => true |
|
178 | 178 | ), |
179 | 179 | 'filter' => array( |
180 | 180 | 'handler' => 'views_handler_filter_string' |
@@ -184,11 +184,11 @@ discard block |
||
184 | 184 | ) |
185 | 185 | ); |
186 | 186 | $data['team']['nusers'] = array( |
187 | - 'title' => bts('Members', array(), NULL, 'boinc:team-members'), |
|
187 | + 'title' => bts('Members', array(), null, 'boinc:team-members'), |
|
188 | 188 | 'help' => t('Count of team members.'), |
189 | 189 | 'field' => array( |
190 | 190 | 'handler' => 'views_handler_field_numeric', |
191 | - 'click sortable' => TRUE |
|
191 | + 'click sortable' => true |
|
192 | 192 | ), |
193 | 193 | 'filter' => array( |
194 | 194 | 'handler' => 'views_handler_filter_numeric' |
@@ -198,12 +198,12 @@ discard block |
||
198 | 198 | ) |
199 | 199 | ); |
200 | 200 | $data['team']['total_credit'] = array( |
201 | - 'title' => bts('Total credit', array(), NULL, 'boinc:user-or-team-total-credits'), |
|
201 | + 'title' => bts('Total credit', array(), null, 'boinc:user-or-team-total-credits'), |
|
202 | 202 | 'help' => t('The total team accumulated BOINC credit.'), |
203 | 203 | 'field' => array( |
204 | 204 | 'handler' => 'views_handler_field_numeric', |
205 | - 'click sortable' => TRUE, |
|
206 | - 'float' => TRUE |
|
205 | + 'click sortable' => true, |
|
206 | + 'float' => true |
|
207 | 207 | ), |
208 | 208 | 'filter' => array( |
209 | 209 | 'handler' => 'views_handler_filter_numeric' |
@@ -249,16 +249,16 @@ discard block |
||
249 | 249 | // Primary keys allowed as arguments |
250 | 250 | |
251 | 251 | $data['team_admin']['teamid'] = array( |
252 | - 'title' => bts('Team ID', array(), NULL, 'boinc:team-id'), |
|
252 | + 'title' => bts('Team ID', array(), null, 'boinc:team-id'), |
|
253 | 253 | 'help' => t('The BOINC ID of the team on which this user is an admin.'), |
254 | 254 | 'field' => array( |
255 | 255 | 'handler' => 'views_handler_field_numeric', |
256 | - 'click sortable' => TRUE |
|
256 | + 'click sortable' => true |
|
257 | 257 | ), |
258 | 258 | 'argument' => array( |
259 | 259 | 'handler' => 'views_handler_argument_boincteam_id', // custom handler |
260 | 260 | 'name field' => 'title', // the field to display in the summary. |
261 | - 'numeric' => TRUE, |
|
261 | + 'numeric' => true, |
|
262 | 262 | 'validate type' => 'id' |
263 | 263 | ), |
264 | 264 | 'relationship' => array( |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | // Foreign key fields |
279 | 279 | |
280 | 280 | $data['team_admin']['userid'] = array( |
281 | - 'title' => bts('User ID', array(), NULL, 'boinc:user-details'), |
|
281 | + 'title' => bts('User ID', array(), null, 'boinc:user-details'), |
|
282 | 282 | 'help' => t('The user that is a team admin.'), |
283 | 283 | // This is a foreign key to the {user} table. When the view is configured |
284 | 284 | // with this relationship, all the fields for the related user node will be |
@@ -286,18 +286,18 @@ discard block |
||
286 | 286 | 'argument' => array( |
287 | 287 | 'handler' => 'views_handler_argument_boincteam_id', |
288 | 288 | 'name field' => 'title', |
289 | - 'numeric' => TRUE, |
|
289 | + 'numeric' => true, |
|
290 | 290 | 'validate type' => 'id' |
291 | 291 | ), |
292 | 292 | 'relationship' => array( |
293 | 293 | 'base' => 'user', |
294 | 294 | 'field' => 'userid', |
295 | 295 | 'handler' => 'views_handler_relationship', |
296 | - 'label' => bts('User', array(), NULL, 'boinc:user-on-team') |
|
296 | + 'label' => bts('User', array(), null, 'boinc:user-on-team') |
|
297 | 297 | ), |
298 | 298 | 'field' => array( |
299 | 299 | 'handler' => 'views_handler_field_numeric', |
300 | - 'click sortable' => TRUE |
|
300 | + 'click sortable' => true |
|
301 | 301 | ), |
302 | 302 | 'filter' => array( |
303 | 303 | 'handler' => 'views_handler_filter_numeric' |
@@ -310,11 +310,11 @@ discard block |
||
310 | 310 | // Descriptions of general fields (alphabetized) |
311 | 311 | |
312 | 312 | $data['team_admin']['create_time'] = array( |
313 | - 'title' => bts('Admin since', array(), NULL, 'boinc:team-when-user-became-an-admin'), |
|
313 | + 'title' => bts('Admin since', array(), null, 'boinc:team-when-user-became-an-admin'), |
|
314 | 314 | 'help' => t('When the BOINC user became a team admin.'), |
315 | 315 | 'field' => array( |
316 | 316 | 'handler' => 'views_handler_field_date', |
317 | - 'click sortable' => TRUE |
|
317 | + 'click sortable' => true |
|
318 | 318 | ), |
319 | 319 | 'filter' => array( |
320 | 320 | 'handler' => 'views_handler_filter_date' |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | // Primary keys allowed as arguments |
339 | 339 | |
340 | 340 | $data['team_delta']['teamid'] = array( |
341 | - 'title' => bts('Team ID', array(), NULL, 'boinc:team-id'), |
|
341 | + 'title' => bts('Team ID', array(), null, 'boinc:team-id'), |
|
342 | 342 | 'help' => t('The team ID for this team history event.'), |
343 | 343 | // This is a foreign key to the {team} table. When the view is configured |
344 | 344 | // with this relationship, all the fields for the related user node will be |
@@ -346,12 +346,12 @@ discard block |
||
346 | 346 | 'argument' => array( |
347 | 347 | 'handler' => 'views_handler_argument_boincteam_id', |
348 | 348 | 'name field' => 'title', |
349 | - 'numeric' => TRUE, |
|
349 | + 'numeric' => true, |
|
350 | 350 | 'validate type' => 'id' |
351 | 351 | ), |
352 | 352 | 'field' => array( |
353 | 353 | 'handler' => 'views_handler_field_numeric', |
354 | - 'click sortable' => TRUE |
|
354 | + 'click sortable' => true |
|
355 | 355 | ), |
356 | 356 | 'filter' => array( |
357 | 357 | 'handler' => 'views_handler_filter_numeric' |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | // Foreign key fields |
365 | 365 | |
366 | 366 | $data['team_delta']['userid'] = array( |
367 | - 'title' => bts('User ID', array(), NULL, 'boinc:user-details'), |
|
367 | + 'title' => bts('User ID', array(), null, 'boinc:user-details'), |
|
368 | 368 | 'help' => t('The user for this team history event.'), |
369 | 369 | 'relationship' => array( |
370 | 370 | 'base' => 'user', |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | ), |
375 | 375 | 'field' => array( |
376 | 376 | 'handler' => 'views_handler_field_numeric', |
377 | - 'click sortable' => TRUE |
|
377 | + 'click sortable' => true |
|
378 | 378 | ), |
379 | 379 | 'filter' => array( |
380 | 380 | 'handler' => 'views_handler_filter_numeric' |
@@ -387,11 +387,11 @@ discard block |
||
387 | 387 | // Descriptions of general fields (alphabetized) |
388 | 388 | |
389 | 389 | $data['team_delta']['joining'] = array( |
390 | - 'title' => bts('User joined', array(), NULL, 'boinc:user-joined-or-leaving-team'), |
|
390 | + 'title' => bts('User joined', array(), null, 'boinc:user-joined-or-leaving-team'), |
|
391 | 391 | 'help' => t('Whether the event is the user joining the team or leaving.'), |
392 | 392 | 'field' => array( |
393 | 393 | 'handler' => 'views_handler_field_numeric', |
394 | - 'click sortable' => TRUE |
|
394 | + 'click sortable' => true |
|
395 | 395 | ), |
396 | 396 | 'filter' => array( |
397 | 397 | 'handler' => 'views_handler_filter_numeric' |
@@ -401,11 +401,11 @@ discard block |
||
401 | 401 | ) |
402 | 402 | ); |
403 | 403 | $data['team_delta']['timestamp'] = array( |
404 | - 'title' => bts('Timestamp', array(), NULL, 'boinc:team-history-timestamp'), |
|
404 | + 'title' => bts('Timestamp', array(), null, 'boinc:team-history-timestamp'), |
|
405 | 405 | 'help' => t('When the BOINC team history event took place.'), |
406 | 406 | 'field' => array( |
407 | 407 | 'handler' => 'views_handler_field_date', |
408 | - 'click sortable' => TRUE |
|
408 | + 'click sortable' => true |
|
409 | 409 | ), |
410 | 410 | 'filter' => array( |
411 | 411 | 'handler' => 'views_handler_filter_date' |
@@ -415,13 +415,13 @@ discard block |
||
415 | 415 | ) |
416 | 416 | ); |
417 | 417 | $data['team_delta']['total_credit'] = array( |
418 | - 'title' => bts('Total credit', array(), NULL, 'user-or-team-total-credits'), |
|
418 | + 'title' => bts('Total credit', array(), null, 'user-or-team-total-credits'), |
|
419 | 419 | 'help' => t('The total accumulated BOINC credit of the user when the |
420 | 420 | history event took place.'), |
421 | 421 | 'field' => array( |
422 | 422 | 'handler' => 'views_handler_field_numeric', |
423 | - 'click sortable' => TRUE, |
|
424 | - 'float' => TRUE |
|
423 | + 'click sortable' => true, |
|
424 | + 'float' => true |
|
425 | 425 | ), |
426 | 426 | 'filter' => array( |
427 | 427 | 'handler' => 'views_handler_filter_numeric' |
@@ -13,103 +13,103 @@ discard block |
||
13 | 13 | */ |
14 | 14 | function boincteam_views_data() { |
15 | 15 | |
16 | - // ----------------------------------------------------------------------------------------------- |
|
17 | - // Definition for team table |
|
18 | - // ----------------------------------------------------------------------------------------------- |
|
16 | + // ----------------------------------------------------------------------------------------------- |
|
17 | + // Definition for team table |
|
18 | + // ----------------------------------------------------------------------------------------------- |
|
19 | 19 | |
20 | - $data['team']['table']['group'] = t('BOINC'); |
|
20 | + $data['team']['table']['group'] = t('BOINC'); |
|
21 | 21 | |
22 | - $data['team']['table']['base'] = array( |
|
23 | - 'field' => 'id', |
|
24 | - 'title' => t('BOINC team'), |
|
25 | - 'help' => t('BOINC data for a team'), |
|
26 | - 'database' => 'boinc_rw' |
|
27 | - ); |
|
22 | + $data['team']['table']['base'] = array( |
|
23 | + 'field' => 'id', |
|
24 | + 'title' => t('BOINC team'), |
|
25 | + 'help' => t('BOINC data for a team'), |
|
26 | + 'database' => 'boinc_rw' |
|
27 | + ); |
|
28 | 28 | |
29 | - // This table references the {user} table. |
|
30 | - // This join creates an 'implicit' relationship to the user table, so that when |
|
31 | - // "User" is the base table, the fields are automatically available. |
|
29 | + // This table references the {user} table. |
|
30 | + // This join creates an 'implicit' relationship to the user table, so that when |
|
31 | + // "User" is the base table, the fields are automatically available. |
|
32 | 32 | |
33 | - // Index this array by the table name to which this table refers. |
|
34 | - // 'left_field' is the primary key in the referenced table. |
|
35 | - // 'field' is the foreign key in this table. |
|
33 | + // Index this array by the table name to which this table refers. |
|
34 | + // 'left_field' is the primary key in the referenced table. |
|
35 | + // 'field' is the foreign key in this table. |
|
36 | 36 | |
37 | - $data['team']['table']['join'] = array( |
|
37 | + $data['team']['table']['join'] = array( |
|
38 | 38 | 'user' => array( |
39 | - 'left_field' => 'id', |
|
40 | - 'field' => 'userid', |
|
39 | + 'left_field' => 'id', |
|
40 | + 'field' => 'userid', |
|
41 | 41 | ), |
42 | - ); |
|
42 | + ); |
|
43 | 43 | |
44 | - // Describe each of the individual fields in this table to Views. For |
|
45 | - // each field, you may define what field, sort, argument, and/or filter |
|
46 | - // handlers it supports. This will determine where in the Views interface you |
|
47 | - // may use the field. |
|
44 | + // Describe each of the individual fields in this table to Views. For |
|
45 | + // each field, you may define what field, sort, argument, and/or filter |
|
46 | + // handlers it supports. This will determine where in the Views interface you |
|
47 | + // may use the field. |
|
48 | 48 | |
49 | - // Primary keys allowed as arguments |
|
49 | + // Primary keys allowed as arguments |
|
50 | 50 | |
51 | - $data['team']['id'] = array( |
|
51 | + $data['team']['id'] = array( |
|
52 | 52 | 'title' => bts('Team ID', array(), NULL, 'boinc:team-id'), |
53 | 53 | 'help' => t('The BOINC ID of the team.'), |
54 | 54 | 'field' => array( |
55 | - 'handler' => 'views_handler_field_numeric', |
|
56 | - 'click sortable' => TRUE |
|
55 | + 'handler' => 'views_handler_field_numeric', |
|
56 | + 'click sortable' => TRUE |
|
57 | 57 | ), |
58 | 58 | 'argument' => array( |
59 | - 'handler' => 'views_handler_argument_boincteam_id', // custom handler |
|
60 | - 'name field' => 'title', // the field to display in the summary. |
|
61 | - 'numeric' => TRUE, |
|
62 | - 'validate type' => 'id' |
|
59 | + 'handler' => 'views_handler_argument_boincteam_id', // custom handler |
|
60 | + 'name field' => 'title', // the field to display in the summary. |
|
61 | + 'numeric' => TRUE, |
|
62 | + 'validate type' => 'id' |
|
63 | 63 | ), |
64 | 64 | 'relationship' => array( |
65 | - 'base' => 'team_delta', |
|
66 | - 'field' => 'id', |
|
67 | - 'base field' => 'teamid', |
|
68 | - 'handler' => 'views_handler_relationship', |
|
69 | - 'label' => t('Team History') |
|
65 | + 'base' => 'team_delta', |
|
66 | + 'field' => 'id', |
|
67 | + 'base field' => 'teamid', |
|
68 | + 'handler' => 'views_handler_relationship', |
|
69 | + 'label' => t('Team History') |
|
70 | 70 | ), |
71 | 71 | 'filter' => array( |
72 | - 'handler' => 'views_handler_filter_numeric' |
|
72 | + 'handler' => 'views_handler_filter_numeric' |
|
73 | 73 | ), |
74 | 74 | 'sort' => array( |
75 | - 'handler' => 'views_handler_sort_numeric' |
|
75 | + 'handler' => 'views_handler_sort_numeric' |
|
76 | 76 | ) |
77 | - ); |
|
77 | + ); |
|
78 | 78 | |
79 | - // Foreign key fields |
|
79 | + // Foreign key fields |
|
80 | 80 | |
81 | - $data['team']['userid'] = array( |
|
81 | + $data['team']['userid'] = array( |
|
82 | 82 | 'title' => bts('Founder', array(), NULL, 'boinc:view-team-info'), |
83 | 83 | 'help' => t('The founder of this team.'), |
84 | 84 | // This is a foreign key to the {user} table. When the view is configured |
85 | 85 | // with this relationship, all the fields for the related user node will be |
86 | 86 | // available. |
87 | 87 | 'argument' => array( |
88 | - 'handler' => 'views_handler_argument_boincuser_id', |
|
89 | - 'name field' => 'title', |
|
90 | - 'numeric' => TRUE, |
|
91 | - 'validate type' => 'id' |
|
88 | + 'handler' => 'views_handler_argument_boincuser_id', |
|
89 | + 'name field' => 'title', |
|
90 | + 'numeric' => TRUE, |
|
91 | + 'validate type' => 'id' |
|
92 | 92 | ), |
93 | 93 | 'relationship' => array( |
94 | - 'base' => 'user', |
|
95 | - 'field' => 'userid', |
|
96 | - 'handler' => 'views_handler_relationship', |
|
97 | - 'label' => t('User') |
|
94 | + 'base' => 'user', |
|
95 | + 'field' => 'userid', |
|
96 | + 'handler' => 'views_handler_relationship', |
|
97 | + 'label' => t('User') |
|
98 | 98 | ), |
99 | 99 | 'field' => array( |
100 | - 'handler' => 'views_handler_field_numeric', |
|
101 | - 'click sortable' => TRUE |
|
100 | + 'handler' => 'views_handler_field_numeric', |
|
101 | + 'click sortable' => TRUE |
|
102 | 102 | ), |
103 | 103 | 'filter' => array( |
104 | - 'handler' => 'views_handler_filter_numeric' |
|
104 | + 'handler' => 'views_handler_filter_numeric' |
|
105 | 105 | ), |
106 | 106 | 'sort' => array( |
107 | - 'handler' => 'views_handler_sort_numeric' |
|
107 | + 'handler' => 'views_handler_sort_numeric' |
|
108 | 108 | ) |
109 | - ); |
|
109 | + ); |
|
110 | 110 | |
111 | - // Descriptions of general fields (alphabetized) |
|
112 | - /* |
|
111 | + // Descriptions of general fields (alphabetized) |
|
112 | + /* |
|
113 | 113 | $data['team']['create_time'] = array( |
114 | 114 | 'title' => bts('Team established', array(), NULL, 'boinc:date-team-established'), |
115 | 115 | 'help' => t('When the BOINC team was created.'), |
@@ -140,298 +140,298 @@ discard block |
||
140 | 140 | ); |
141 | 141 | */ |
142 | 142 | |
143 | - $data['team']['country'] = array( |
|
143 | + $data['team']['country'] = array( |
|
144 | 144 | 'title' => bts('Country', array(), NULL, 'boinc:country-of-origin'), |
145 | 145 | 'help' => t('The country of a team.'), |
146 | 146 | 'field' => array( |
147 | - 'handler' => 'views_handler_field', |
|
148 | - 'click sortable' => TRUE |
|
147 | + 'handler' => 'views_handler_field', |
|
148 | + 'click sortable' => TRUE |
|
149 | 149 | ), |
150 | 150 | 'filter' => array( |
151 | - 'handler' => 'views_handler_filter_string' |
|
151 | + 'handler' => 'views_handler_filter_string' |
|
152 | 152 | ), |
153 | 153 | 'sort' => array( |
154 | - 'handler' => 'views_handler_sort_string' |
|
154 | + 'handler' => 'views_handler_sort_string' |
|
155 | 155 | ) |
156 | - ); |
|
157 | - $data['team']['expavg_credit'] = array( |
|
156 | + ); |
|
157 | + $data['team']['expavg_credit'] = array( |
|
158 | 158 | 'title' => bts('Recent average credit', array(), NULL, 'boinc:user-or-team-RAC'), |
159 | 159 | 'help' => t('A decaying average of team credit per day.'), |
160 | 160 | 'field' => array( |
161 | - 'handler' => 'views_handler_field_numeric', |
|
162 | - 'click sortable' => TRUE, |
|
163 | - 'float' => TRUE |
|
161 | + 'handler' => 'views_handler_field_numeric', |
|
162 | + 'click sortable' => TRUE, |
|
163 | + 'float' => TRUE |
|
164 | 164 | ), |
165 | 165 | 'filter' => array( |
166 | - 'handler' => 'views_handler_filter_numeric' |
|
166 | + 'handler' => 'views_handler_filter_numeric' |
|
167 | 167 | ), |
168 | 168 | 'sort' => array( |
169 | - 'handler' => 'views_handler_sort_numeric' |
|
169 | + 'handler' => 'views_handler_sort_numeric' |
|
170 | 170 | ) |
171 | - ); |
|
172 | - $data['team']['name'] = array( |
|
171 | + ); |
|
172 | + $data['team']['name'] = array( |
|
173 | 173 | 'title' => bts('Name', array(), NULL, 'boinc:user-or-team-name'), |
174 | 174 | 'help' => t('The name of the team.'), |
175 | 175 | 'field' => array( |
176 | - 'handler' => 'views_handler_field', |
|
177 | - 'click sortable' => TRUE |
|
176 | + 'handler' => 'views_handler_field', |
|
177 | + 'click sortable' => TRUE |
|
178 | 178 | ), |
179 | 179 | 'filter' => array( |
180 | - 'handler' => 'views_handler_filter_string' |
|
180 | + 'handler' => 'views_handler_filter_string' |
|
181 | 181 | ), |
182 | 182 | 'sort' => array( |
183 | - 'handler' => 'views_handler_sort_string' |
|
183 | + 'handler' => 'views_handler_sort_string' |
|
184 | 184 | ) |
185 | - ); |
|
186 | - $data['team']['nusers'] = array( |
|
185 | + ); |
|
186 | + $data['team']['nusers'] = array( |
|
187 | 187 | 'title' => bts('Members', array(), NULL, 'boinc:team-members'), |
188 | 188 | 'help' => t('Count of team members.'), |
189 | 189 | 'field' => array( |
190 | - 'handler' => 'views_handler_field_numeric', |
|
191 | - 'click sortable' => TRUE |
|
190 | + 'handler' => 'views_handler_field_numeric', |
|
191 | + 'click sortable' => TRUE |
|
192 | 192 | ), |
193 | 193 | 'filter' => array( |
194 | - 'handler' => 'views_handler_filter_numeric' |
|
194 | + 'handler' => 'views_handler_filter_numeric' |
|
195 | 195 | ), |
196 | 196 | 'sort' => array( |
197 | - 'handler' => 'views_handler_sort_numeric' |
|
197 | + 'handler' => 'views_handler_sort_numeric' |
|
198 | 198 | ) |
199 | - ); |
|
200 | - $data['team']['total_credit'] = array( |
|
199 | + ); |
|
200 | + $data['team']['total_credit'] = array( |
|
201 | 201 | 'title' => bts('Total credit', array(), NULL, 'boinc:user-or-team-total-credits'), |
202 | 202 | 'help' => t('The total team accumulated BOINC credit.'), |
203 | 203 | 'field' => array( |
204 | - 'handler' => 'views_handler_field_numeric', |
|
205 | - 'click sortable' => TRUE, |
|
206 | - 'float' => TRUE |
|
204 | + 'handler' => 'views_handler_field_numeric', |
|
205 | + 'click sortable' => TRUE, |
|
206 | + 'float' => TRUE |
|
207 | 207 | ), |
208 | 208 | 'filter' => array( |
209 | - 'handler' => 'views_handler_filter_numeric' |
|
209 | + 'handler' => 'views_handler_filter_numeric' |
|
210 | 210 | ), |
211 | 211 | 'sort' => array( |
212 | - 'handler' => 'views_handler_sort_numeric' |
|
212 | + 'handler' => 'views_handler_sort_numeric' |
|
213 | 213 | ) |
214 | - ); |
|
214 | + ); |
|
215 | 215 | |
216 | - // ----------------------------------------------------------------------------------------------- |
|
217 | - // Definition for team_admin table |
|
218 | - // ----------------------------------------------------------------------------------------------- |
|
216 | + // ----------------------------------------------------------------------------------------------- |
|
217 | + // Definition for team_admin table |
|
218 | + // ----------------------------------------------------------------------------------------------- |
|
219 | 219 | |
220 | - $data['team_admin']['table']['group'] = t('BOINC'); |
|
220 | + $data['team_admin']['table']['group'] = t('BOINC'); |
|
221 | 221 | |
222 | - $data['team_admin']['table']['base'] = array( |
|
223 | - 'field' => 'id', |
|
224 | - 'title' => t('BOINC team admins'), |
|
225 | - 'help' => t('BOINC admins for a team'), |
|
226 | - 'database' => 'boinc_rw' |
|
227 | - ); |
|
222 | + $data['team_admin']['table']['base'] = array( |
|
223 | + 'field' => 'id', |
|
224 | + 'title' => t('BOINC team admins'), |
|
225 | + 'help' => t('BOINC admins for a team'), |
|
226 | + 'database' => 'boinc_rw' |
|
227 | + ); |
|
228 | 228 | |
229 | - // This table references the {team} table. |
|
230 | - // This join creates an 'implicit' relationship to the team table, so that when |
|
231 | - // "Team" is the base table, the fields are automatically available. |
|
229 | + // This table references the {team} table. |
|
230 | + // This join creates an 'implicit' relationship to the team table, so that when |
|
231 | + // "Team" is the base table, the fields are automatically available. |
|
232 | 232 | |
233 | - // Index this array by the table name to which this table refers. |
|
234 | - // 'left_field' is the primary key in the referenced table. |
|
235 | - // 'field' is the foreign key in this table. |
|
233 | + // Index this array by the table name to which this table refers. |
|
234 | + // 'left_field' is the primary key in the referenced table. |
|
235 | + // 'field' is the foreign key in this table. |
|
236 | 236 | |
237 | - $data['team_admin']['table']['join'] = array( |
|
237 | + $data['team_admin']['table']['join'] = array( |
|
238 | 238 | 'team' => array( |
239 | - 'left_field' => 'id', |
|
240 | - 'field' => 'teamid', |
|
239 | + 'left_field' => 'id', |
|
240 | + 'field' => 'teamid', |
|
241 | 241 | ), |
242 | - ); |
|
242 | + ); |
|
243 | 243 | |
244 | - // Describe each of the individual fields in this table to Views. For |
|
245 | - // each field, you may define what field, sort, argument, and/or filter |
|
246 | - // handlers it supports. This will determine where in the Views interface you |
|
247 | - // may use the field. |
|
244 | + // Describe each of the individual fields in this table to Views. For |
|
245 | + // each field, you may define what field, sort, argument, and/or filter |
|
246 | + // handlers it supports. This will determine where in the Views interface you |
|
247 | + // may use the field. |
|
248 | 248 | |
249 | - // Primary keys allowed as arguments |
|
249 | + // Primary keys allowed as arguments |
|
250 | 250 | |
251 | - $data['team_admin']['teamid'] = array( |
|
251 | + $data['team_admin']['teamid'] = array( |
|
252 | 252 | 'title' => bts('Team ID', array(), NULL, 'boinc:team-id'), |
253 | 253 | 'help' => t('The BOINC ID of the team on which this user is an admin.'), |
254 | 254 | 'field' => array( |
255 | - 'handler' => 'views_handler_field_numeric', |
|
256 | - 'click sortable' => TRUE |
|
255 | + 'handler' => 'views_handler_field_numeric', |
|
256 | + 'click sortable' => TRUE |
|
257 | 257 | ), |
258 | 258 | 'argument' => array( |
259 | - 'handler' => 'views_handler_argument_boincteam_id', // custom handler |
|
260 | - 'name field' => 'title', // the field to display in the summary. |
|
261 | - 'numeric' => TRUE, |
|
262 | - 'validate type' => 'id' |
|
259 | + 'handler' => 'views_handler_argument_boincteam_id', // custom handler |
|
260 | + 'name field' => 'title', // the field to display in the summary. |
|
261 | + 'numeric' => TRUE, |
|
262 | + 'validate type' => 'id' |
|
263 | 263 | ), |
264 | 264 | 'relationship' => array( |
265 | - 'base' => 'team', |
|
266 | - 'field' => 'teamid', |
|
267 | - 'handler' => 'views_handler_relationship', |
|
268 | - 'label' => t('Team') |
|
265 | + 'base' => 'team', |
|
266 | + 'field' => 'teamid', |
|
267 | + 'handler' => 'views_handler_relationship', |
|
268 | + 'label' => t('Team') |
|
269 | 269 | ), |
270 | 270 | 'filter' => array( |
271 | - 'handler' => 'views_handler_filter_numeric' |
|
271 | + 'handler' => 'views_handler_filter_numeric' |
|
272 | 272 | ), |
273 | 273 | 'sort' => array( |
274 | - 'handler' => 'views_handler_sort_numeric' |
|
274 | + 'handler' => 'views_handler_sort_numeric' |
|
275 | 275 | ) |
276 | - ); |
|
276 | + ); |
|
277 | 277 | |
278 | - // Foreign key fields |
|
278 | + // Foreign key fields |
|
279 | 279 | |
280 | - $data['team_admin']['userid'] = array( |
|
280 | + $data['team_admin']['userid'] = array( |
|
281 | 281 | 'title' => bts('User ID', array(), NULL, 'boinc:user-details'), |
282 | 282 | 'help' => t('The user that is a team admin.'), |
283 | 283 | // This is a foreign key to the {user} table. When the view is configured |
284 | 284 | // with this relationship, all the fields for the related user node will be |
285 | 285 | // available. |
286 | 286 | 'argument' => array( |
287 | - 'handler' => 'views_handler_argument_boincteam_id', |
|
288 | - 'name field' => 'title', |
|
289 | - 'numeric' => TRUE, |
|
290 | - 'validate type' => 'id' |
|
287 | + 'handler' => 'views_handler_argument_boincteam_id', |
|
288 | + 'name field' => 'title', |
|
289 | + 'numeric' => TRUE, |
|
290 | + 'validate type' => 'id' |
|
291 | 291 | ), |
292 | 292 | 'relationship' => array( |
293 | - 'base' => 'user', |
|
294 | - 'field' => 'userid', |
|
295 | - 'handler' => 'views_handler_relationship', |
|
296 | - 'label' => bts('User', array(), NULL, 'boinc:user-on-team') |
|
293 | + 'base' => 'user', |
|
294 | + 'field' => 'userid', |
|
295 | + 'handler' => 'views_handler_relationship', |
|
296 | + 'label' => bts('User', array(), NULL, 'boinc:user-on-team') |
|
297 | 297 | ), |
298 | 298 | 'field' => array( |
299 | - 'handler' => 'views_handler_field_numeric', |
|
300 | - 'click sortable' => TRUE |
|
299 | + 'handler' => 'views_handler_field_numeric', |
|
300 | + 'click sortable' => TRUE |
|
301 | 301 | ), |
302 | 302 | 'filter' => array( |
303 | - 'handler' => 'views_handler_filter_numeric' |
|
303 | + 'handler' => 'views_handler_filter_numeric' |
|
304 | 304 | ), |
305 | 305 | 'sort' => array( |
306 | - 'handler' => 'views_handler_sort_numeric' |
|
306 | + 'handler' => 'views_handler_sort_numeric' |
|
307 | 307 | ) |
308 | - ); |
|
308 | + ); |
|
309 | 309 | |
310 | - // Descriptions of general fields (alphabetized) |
|
310 | + // Descriptions of general fields (alphabetized) |
|
311 | 311 | |
312 | - $data['team_admin']['create_time'] = array( |
|
312 | + $data['team_admin']['create_time'] = array( |
|
313 | 313 | 'title' => bts('Admin since', array(), NULL, 'boinc:team-when-user-became-an-admin'), |
314 | 314 | 'help' => t('When the BOINC user became a team admin.'), |
315 | 315 | 'field' => array( |
316 | - 'handler' => 'views_handler_field_date', |
|
317 | - 'click sortable' => TRUE |
|
316 | + 'handler' => 'views_handler_field_date', |
|
317 | + 'click sortable' => TRUE |
|
318 | 318 | ), |
319 | 319 | 'filter' => array( |
320 | - 'handler' => 'views_handler_filter_date' |
|
320 | + 'handler' => 'views_handler_filter_date' |
|
321 | 321 | ), |
322 | 322 | 'sort' => array( |
323 | - 'handler' => 'views_handler_sort_date' |
|
323 | + 'handler' => 'views_handler_sort_date' |
|
324 | 324 | ) |
325 | - ); |
|
325 | + ); |
|
326 | 326 | |
327 | - // ----------------------------------------------------------------------------------------------- |
|
328 | - // Definition for team_delta table |
|
329 | - // ----------------------------------------------------------------------------------------------- |
|
327 | + // ----------------------------------------------------------------------------------------------- |
|
328 | + // Definition for team_delta table |
|
329 | + // ----------------------------------------------------------------------------------------------- |
|
330 | 330 | |
331 | - $data['team_delta']['table']['group'] = t('BOINC'); |
|
331 | + $data['team_delta']['table']['group'] = t('BOINC'); |
|
332 | 332 | |
333 | - // Describe each of the individual fields in this table to Views. For |
|
334 | - // each field, you may define what field, sort, argument, and/or filter |
|
335 | - // handlers it supports. This will determine where in the Views interface you |
|
336 | - // may use the field. |
|
333 | + // Describe each of the individual fields in this table to Views. For |
|
334 | + // each field, you may define what field, sort, argument, and/or filter |
|
335 | + // handlers it supports. This will determine where in the Views interface you |
|
336 | + // may use the field. |
|
337 | 337 | |
338 | - // Primary keys allowed as arguments |
|
338 | + // Primary keys allowed as arguments |
|
339 | 339 | |
340 | - $data['team_delta']['teamid'] = array( |
|
340 | + $data['team_delta']['teamid'] = array( |
|
341 | 341 | 'title' => bts('Team ID', array(), NULL, 'boinc:team-id'), |
342 | 342 | 'help' => t('The team ID for this team history event.'), |
343 | 343 | // This is a foreign key to the {team} table. When the view is configured |
344 | 344 | // with this relationship, all the fields for the related user node will be |
345 | 345 | // available. |
346 | 346 | 'argument' => array( |
347 | - 'handler' => 'views_handler_argument_boincteam_id', |
|
348 | - 'name field' => 'title', |
|
349 | - 'numeric' => TRUE, |
|
350 | - 'validate type' => 'id' |
|
347 | + 'handler' => 'views_handler_argument_boincteam_id', |
|
348 | + 'name field' => 'title', |
|
349 | + 'numeric' => TRUE, |
|
350 | + 'validate type' => 'id' |
|
351 | 351 | ), |
352 | 352 | 'field' => array( |
353 | - 'handler' => 'views_handler_field_numeric', |
|
354 | - 'click sortable' => TRUE |
|
353 | + 'handler' => 'views_handler_field_numeric', |
|
354 | + 'click sortable' => TRUE |
|
355 | 355 | ), |
356 | 356 | 'filter' => array( |
357 | - 'handler' => 'views_handler_filter_numeric' |
|
357 | + 'handler' => 'views_handler_filter_numeric' |
|
358 | 358 | ), |
359 | 359 | 'sort' => array( |
360 | - 'handler' => 'views_handler_sort_numeric' |
|
360 | + 'handler' => 'views_handler_sort_numeric' |
|
361 | 361 | ) |
362 | - ); |
|
362 | + ); |
|
363 | 363 | |
364 | - // Foreign key fields |
|
364 | + // Foreign key fields |
|
365 | 365 | |
366 | - $data['team_delta']['userid'] = array( |
|
366 | + $data['team_delta']['userid'] = array( |
|
367 | 367 | 'title' => bts('User ID', array(), NULL, 'boinc:user-details'), |
368 | 368 | 'help' => t('The user for this team history event.'), |
369 | 369 | 'relationship' => array( |
370 | - 'base' => 'user', |
|
371 | - 'field' => 'userid', |
|
372 | - 'handler' => 'views_handler_relationship', |
|
373 | - 'label' => t('User') |
|
370 | + 'base' => 'user', |
|
371 | + 'field' => 'userid', |
|
372 | + 'handler' => 'views_handler_relationship', |
|
373 | + 'label' => t('User') |
|
374 | 374 | ), |
375 | 375 | 'field' => array( |
376 | - 'handler' => 'views_handler_field_numeric', |
|
377 | - 'click sortable' => TRUE |
|
376 | + 'handler' => 'views_handler_field_numeric', |
|
377 | + 'click sortable' => TRUE |
|
378 | 378 | ), |
379 | 379 | 'filter' => array( |
380 | - 'handler' => 'views_handler_filter_numeric' |
|
380 | + 'handler' => 'views_handler_filter_numeric' |
|
381 | 381 | ), |
382 | 382 | 'sort' => array( |
383 | - 'handler' => 'views_handler_sort_numeric' |
|
383 | + 'handler' => 'views_handler_sort_numeric' |
|
384 | 384 | ) |
385 | - ); |
|
385 | + ); |
|
386 | 386 | |
387 | - // Descriptions of general fields (alphabetized) |
|
387 | + // Descriptions of general fields (alphabetized) |
|
388 | 388 | |
389 | - $data['team_delta']['joining'] = array( |
|
389 | + $data['team_delta']['joining'] = array( |
|
390 | 390 | 'title' => bts('User joined', array(), NULL, 'boinc:user-joined-or-leaving-team'), |
391 | 391 | 'help' => t('Whether the event is the user joining the team or leaving.'), |
392 | 392 | 'field' => array( |
393 | - 'handler' => 'views_handler_field_numeric', |
|
394 | - 'click sortable' => TRUE |
|
393 | + 'handler' => 'views_handler_field_numeric', |
|
394 | + 'click sortable' => TRUE |
|
395 | 395 | ), |
396 | 396 | 'filter' => array( |
397 | - 'handler' => 'views_handler_filter_numeric' |
|
397 | + 'handler' => 'views_handler_filter_numeric' |
|
398 | 398 | ), |
399 | 399 | 'sort' => array( |
400 | - 'handler' => 'views_handler_sort_numeric' |
|
400 | + 'handler' => 'views_handler_sort_numeric' |
|
401 | 401 | ) |
402 | - ); |
|
403 | - $data['team_delta']['timestamp'] = array( |
|
402 | + ); |
|
403 | + $data['team_delta']['timestamp'] = array( |
|
404 | 404 | 'title' => bts('Timestamp', array(), NULL, 'boinc:team-history-timestamp'), |
405 | 405 | 'help' => t('When the BOINC team history event took place.'), |
406 | 406 | 'field' => array( |
407 | - 'handler' => 'views_handler_field_date', |
|
408 | - 'click sortable' => TRUE |
|
407 | + 'handler' => 'views_handler_field_date', |
|
408 | + 'click sortable' => TRUE |
|
409 | 409 | ), |
410 | 410 | 'filter' => array( |
411 | - 'handler' => 'views_handler_filter_date' |
|
411 | + 'handler' => 'views_handler_filter_date' |
|
412 | 412 | ), |
413 | 413 | 'sort' => array( |
414 | - 'handler' => 'views_handler_sort_date' |
|
414 | + 'handler' => 'views_handler_sort_date' |
|
415 | 415 | ) |
416 | - ); |
|
417 | - $data['team_delta']['total_credit'] = array( |
|
416 | + ); |
|
417 | + $data['team_delta']['total_credit'] = array( |
|
418 | 418 | 'title' => bts('Total credit', array(), NULL, 'user-or-team-total-credits'), |
419 | 419 | 'help' => t('The total accumulated BOINC credit of the user when the |
420 | 420 | history event took place.'), |
421 | 421 | 'field' => array( |
422 | - 'handler' => 'views_handler_field_numeric', |
|
423 | - 'click sortable' => TRUE, |
|
424 | - 'float' => TRUE |
|
422 | + 'handler' => 'views_handler_field_numeric', |
|
423 | + 'click sortable' => TRUE, |
|
424 | + 'float' => TRUE |
|
425 | 425 | ), |
426 | 426 | 'filter' => array( |
427 | - 'handler' => 'views_handler_filter_numeric' |
|
427 | + 'handler' => 'views_handler_filter_numeric' |
|
428 | 428 | ), |
429 | 429 | 'sort' => array( |
430 | - 'handler' => 'views_handler_sort_numeric' |
|
430 | + 'handler' => 'views_handler_sort_numeric' |
|
431 | 431 | ) |
432 | - ); |
|
432 | + ); |
|
433 | 433 | |
434 | - return $data; |
|
434 | + return $data; |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | /* |
@@ -442,14 +442,14 @@ discard block |
||
442 | 442 | */ |
443 | 443 | |
444 | 444 | function boincteam_views_handlers() { |
445 | - return array( |
|
445 | + return array( |
|
446 | 446 | 'info' => array( |
447 | - 'path' => drupal_get_path('module', 'boincteam') . '/views', |
|
447 | + 'path' => drupal_get_path('module', 'boincteam') . '/views', |
|
448 | 448 | ), |
449 | 449 | 'handlers' => array( |
450 | - 'views_handler_argument_boincteam_id' => array( |
|
450 | + 'views_handler_argument_boincteam_id' => array( |
|
451 | 451 | 'parent' => 'views_handler_argument_numeric' |
452 | - ) |
|
452 | + ) |
|
453 | 453 | ) |
454 | - ); |
|
454 | + ); |
|
455 | 455 | } |
@@ -65,15 +65,15 @@ discard block |
||
65 | 65 | */ |
66 | 66 | function boincwork_admin_prefs_upload_form_validate($form, &$form_state) { |
67 | 67 | |
68 | - $xsd = './' . drupal_get_path('module', 'boincwork') . '/includes/projectprefs.xsd'; |
|
68 | + $xsd = './'.drupal_get_path('module', 'boincwork').'/includes/projectprefs.xsd'; |
|
69 | 69 | libxml_use_internal_errors(true); |
70 | 70 | $xml = new DomDocument(); |
71 | 71 | $xml->loadXML($form_state['values']['prefs_xml'], LIBXML_NOBLANKS); |
72 | 72 | if (!$xml->schemaValidate($xsd)) { |
73 | 73 | $errors = libxml_get_errors(); |
74 | 74 | $lines = explode("\r", $form_state['values']['prefs_xml']); |
75 | - drupal_set_message("{$errors[0]->message} at line {$errors[0]->line}" . |
|
76 | - ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), 'error'); |
|
75 | + drupal_set_message("{$errors[0]->message} at line {$errors[0]->line}". |
|
76 | + ': <br/>'.htmlentities($lines[$errors[0]->line - 1]), 'error'); |
|
77 | 77 | form_set_error('upload', t('XML file failed validation')); |
78 | 78 | } |
79 | 79 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | "{$path}/minimum" => t('Minimum') |
102 | 102 | ); |
103 | 103 | variable_set('jump_use_js_presets-Array', 1); |
104 | - drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js'); |
|
104 | + drupal_add_js(drupal_get_path('module', 'jump').'/jump.js'); |
|
105 | 105 | $output .= '<div class="simple-form-controls"><div class="form-item venue">'; |
106 | 106 | $output .= '<label>Preset:</label>'; |
107 | 107 | $output .= jump_quickly($preset_options, 'presets'); |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | '#type' => 'submit', |
151 | 151 | '#value' => t('Save configuration') |
152 | 152 | ); |
153 | - $form['saveuseconfigxml'] = array ( |
|
153 | + $form['saveuseconfigxml'] = array( |
|
154 | 154 | '#type' => 'submit', |
155 | 155 | '#value' => t('Save configuration with disk usage settings from config.xml'), |
156 | 156 | '#validate' => array('boincwork_admin_prefs_preset_saveuseconfigxml'), |
@@ -175,33 +175,33 @@ discard block |
||
175 | 175 | // Verify all non-boolean user input values and notify form API of failures |
176 | 176 | |
177 | 177 | // Processing preferences |
178 | - if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', t('Invalid setting for') . " \"{$form['processor']['idle_time_to_run']['#title']} [x] {$form['processor']['idle_time_to_run']['#field_suffix']}\""); |
|
179 | - if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', t('Invalid setting for') . " \"{$form['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['processor']['suspend_if_no_recent_input']['#field_suffix']}\""); |
|
180 | - if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', t('Invalid setting for') . " \"{$form['processor']['suspend_cpu_usage']['#title']} [x] {$form['processor']['suspend_cpu_usage']['#field_suffix']}\""); |
|
181 | - if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', t('Invalid setting for') . " \"{$form['processor']['start_hour']['#title']} [x] {$form['processor']['start_hour']['#field_suffix']}\""); |
|
182 | - if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', t('Invalid setting for') . " \"{$form['processor']['end_hour']['#title']} [x] {$form['processor']['end_hour']['#field_suffix']}\""); |
|
183 | - if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', t('Invalid setting for') . " \"{$form['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['processor']['cpu_scheduling_period_minutes']['#field_suffix']}\""); |
|
184 | - if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', t('Invalid setting for') . " \"{$form['processor']['max_ncpus_pct']['#title']} [x] {$form['processor']['max_ncpus_pct']['#field_suffix']}\""); |
|
185 | - if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', t('Invalid setting for') . " \"{$form['processor']['cpu_usage_limit']['#title']} [x] {$form['processor']['cpu_usage_limit']['#field_suffix']}\""); |
|
178 | + if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', t('Invalid setting for')." \"{$form['processor']['idle_time_to_run']['#title']} [x] {$form['processor']['idle_time_to_run']['#field_suffix']}\""); |
|
179 | + if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', t('Invalid setting for')." \"{$form['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['processor']['suspend_if_no_recent_input']['#field_suffix']}\""); |
|
180 | + if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', t('Invalid setting for')." \"{$form['processor']['suspend_cpu_usage']['#title']} [x] {$form['processor']['suspend_cpu_usage']['#field_suffix']}\""); |
|
181 | + if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', t('Invalid setting for')." \"{$form['processor']['start_hour']['#title']} [x] {$form['processor']['start_hour']['#field_suffix']}\""); |
|
182 | + if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', t('Invalid setting for')." \"{$form['processor']['end_hour']['#title']} [x] {$form['processor']['end_hour']['#field_suffix']}\""); |
|
183 | + if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', t('Invalid setting for')." \"{$form['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['processor']['cpu_scheduling_period_minutes']['#field_suffix']}\""); |
|
184 | + if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', t('Invalid setting for')." \"{$form['processor']['max_ncpus_pct']['#title']} [x] {$form['processor']['max_ncpus_pct']['#field_suffix']}\""); |
|
185 | + if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', t('Invalid setting for')." \"{$form['processor']['cpu_usage_limit']['#title']} [x] {$form['processor']['cpu_usage_limit']['#field_suffix']}\""); |
|
186 | 186 | |
187 | 187 | // Storage preferences |
188 | - if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', t('Invalid setting for') . " \"{$form['storage']['disk_max_used_gb']['#title']} [x] {$form['storage']['disk_max_used_gb']['#field_suffix']}\""); |
|
189 | - if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', t('Invalid setting for') . " \"{$form['storage']['disk_min_free_gb']['#title']} [x] {$form['storage']['disk_min_free_gb']['#field_suffix']}\""); |
|
190 | - if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', t('Invalid setting for') . " \"{$form['storage']['disk_max_used_pct']['#title']} [x] {$form['storage']['disk_max_used_pct']['#field_suffix']}\""); |
|
191 | - if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', t('Invalid setting for') . " \"{$form['storage']['disk_interval']['#title']} [x] {$form['storage']['disk_interval']['#field_suffix']}\""); |
|
192 | - if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', t('Invalid setting for') . " \"{$form['storage']['vm_max_used_pct']['#title']} [x] {$form['storage']['vm_max_used_pct']['#field_suffix']}\""); |
|
193 | - if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', t('Invalid setting for') . " \"{$form['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['storage']['ram_max_used_busy_pct']['#field_suffix']}\""); |
|
194 | - if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', t('Invalid setting for') . " \"{$form['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['storage']['ram_max_used_idle_pct']['#field_suffix']}\""); |
|
188 | + if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', t('Invalid setting for')." \"{$form['storage']['disk_max_used_gb']['#title']} [x] {$form['storage']['disk_max_used_gb']['#field_suffix']}\""); |
|
189 | + if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', t('Invalid setting for')." \"{$form['storage']['disk_min_free_gb']['#title']} [x] {$form['storage']['disk_min_free_gb']['#field_suffix']}\""); |
|
190 | + if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', t('Invalid setting for')." \"{$form['storage']['disk_max_used_pct']['#title']} [x] {$form['storage']['disk_max_used_pct']['#field_suffix']}\""); |
|
191 | + if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', t('Invalid setting for')." \"{$form['storage']['disk_interval']['#title']} [x] {$form['storage']['disk_interval']['#field_suffix']}\""); |
|
192 | + if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', t('Invalid setting for')." \"{$form['storage']['vm_max_used_pct']['#title']} [x] {$form['storage']['vm_max_used_pct']['#field_suffix']}\""); |
|
193 | + if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', t('Invalid setting for')." \"{$form['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['storage']['ram_max_used_busy_pct']['#field_suffix']}\""); |
|
194 | + if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', t('Invalid setting for')." \"{$form['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['storage']['ram_max_used_idle_pct']['#field_suffix']}\""); |
|
195 | 195 | |
196 | 196 | // Network preferences |
197 | - if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', t('Invalid setting for') . " \"{$form['network']['work_buf_min_days']['#title']} [x] {$form['network']['work_buf_min_days']['#field_suffix']}\""); |
|
198 | - if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', t('Invalid setting for') . " \"{$form['network']['work_buf_additional_days']['#title']} [x] {$form['network']['work_buf_additional_days']['#field_suffix']}\""); |
|
199 | - if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', t('Invalid setting for') . " \"{$form['network']['max_bytes_sec_down']['#title']} [x] {$form['network']['max_bytes_sec_down']['#field_suffix']}\""); |
|
200 | - if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', t('Invalid setting for') . " \"{$form['network']['max_bytes_sec_up']['#title']} [x] {$form['network']['max_bytes_sec_up']['#field_suffix']}\""); |
|
201 | - if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', t('Invalid setting for') . " \"{$form['network']['net_start_hour']['#title']} [x] {$form['network']['net_start_hour']['#field_suffix']}\""); |
|
202 | - if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', t('Invalid setting for') . " \"{$form['network']['net_end_hour']['#title']} [x] {$form['network']['net_end_hour']['#field_suffix']}\""); |
|
203 | - if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', t('Invalid setting for') . " \"{$form['network']['daily_xfer_limit_mb']['#title']} [x] {$form['network']['daily_xfer_limit_mb']['#field_suffix']}\""); |
|
204 | - if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', t('Invalid setting for') . " \"{$form['network']['daily_xfer_limit_mb']['#title']} [x] {$form['network']['daily_xfer_limit_mb']['#field_suffix']}\""); |
|
197 | + if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', t('Invalid setting for')." \"{$form['network']['work_buf_min_days']['#title']} [x] {$form['network']['work_buf_min_days']['#field_suffix']}\""); |
|
198 | + if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', t('Invalid setting for')." \"{$form['network']['work_buf_additional_days']['#title']} [x] {$form['network']['work_buf_additional_days']['#field_suffix']}\""); |
|
199 | + if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', t('Invalid setting for')." \"{$form['network']['max_bytes_sec_down']['#title']} [x] {$form['network']['max_bytes_sec_down']['#field_suffix']}\""); |
|
200 | + if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', t('Invalid setting for')." \"{$form['network']['max_bytes_sec_up']['#title']} [x] {$form['network']['max_bytes_sec_up']['#field_suffix']}\""); |
|
201 | + if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', t('Invalid setting for')." \"{$form['network']['net_start_hour']['#title']} [x] {$form['network']['net_start_hour']['#field_suffix']}\""); |
|
202 | + if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', t('Invalid setting for')." \"{$form['network']['net_end_hour']['#title']} [x] {$form['network']['net_end_hour']['#field_suffix']}\""); |
|
203 | + if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', t('Invalid setting for')." \"{$form['network']['daily_xfer_limit_mb']['#title']} [x] {$form['network']['daily_xfer_limit_mb']['#field_suffix']}\""); |
|
204 | + if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', t('Invalid setting for')." \"{$form['network']['daily_xfer_limit_mb']['#title']} [x] {$form['network']['daily_xfer_limit_mb']['#field_suffix']}\""); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | // Processing preferences |
218 | 218 | $prefs['run_on_batteries'] = ($values['processor']['run_on_batteries']) ? 0 : 1; |
219 | 219 | $prefs['run_if_user_active'] = ($values['processor']['run_if_user_active']) ? 0 : 1; |
220 | - $prefs['run_gpu_if_user_active'] = ($values['processor']['run_gpu_if_user_active']) ? 0: 1; |
|
220 | + $prefs['run_gpu_if_user_active'] = ($values['processor']['run_gpu_if_user_active']) ? 0 : 1; |
|
221 | 221 | $prefs['idle_time_to_run'] = $values['processor']['idle_time_to_run']; |
222 | 222 | $prefs['suspend_if_no_recent_input'] = $values['processor']['suspend_if_no_recent_input']; |
223 | 223 | $prefs['suspend_cpu_usage'] = $values['processor']['suspend_cpu_usage']; |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | |
268 | 268 | // Get the full configuration |
269 | 269 | $all_presets = boincwork_get_preset_prefs(); |
270 | - $all_presets = (array) $all_presets['general_preferences']; |
|
270 | + $all_presets = (array)$all_presets['general_preferences']; |
|
271 | 271 | |
272 | 272 | // Check for sane config |
273 | 273 | if (isset($all_presets['preset'])) { |
@@ -10,80 +10,80 @@ discard block |
||
10 | 10 | * Allow configuration of general options for preference pages |
11 | 11 | */ |
12 | 12 | function boincwork_admin_prefs_options_form(&$form_state) { |
13 | - $form = array(); |
|
14 | - $form['beta'] = array( |
|
13 | + $form = array(); |
|
14 | + $form['beta'] = array( |
|
15 | 15 | '#type' => 'checkbox', |
16 | 16 | '#title' => t('Allow users to opt in to test beta applications'), |
17 | 17 | '#default_value' => variable_get('boinc_prefs_options_beta', 0), |
18 | 18 | '#required' => TRUE |
19 | - ); |
|
20 | - $form['submit'] = array( |
|
19 | + ); |
|
20 | + $form['submit'] = array( |
|
21 | 21 | '#type' => 'submit', |
22 | 22 | '#value' => t('Submit') |
23 | - ); |
|
24 | - // Add the official mechanical things and return |
|
25 | - //drupal_prepare_form('boincwork_admin_prefs_upload_form', $form, $form_state); |
|
26 | - return $form; |
|
23 | + ); |
|
24 | + // Add the official mechanical things and return |
|
25 | + //drupal_prepare_form('boincwork_admin_prefs_upload_form', $form, $form_state); |
|
26 | + return $form; |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
30 | - * Handle validation of preference general settings form. |
|
31 | - */ |
|
30 | + * Handle validation of preference general settings form. |
|
31 | + */ |
|
32 | 32 | function boincwork_admin_prefs_options_form_validate($form, &$form_state) { |
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
36 | - * Handle submission of preference general settings form. |
|
37 | - */ |
|
36 | + * Handle submission of preference general settings form. |
|
37 | + */ |
|
38 | 38 | function boincwork_admin_prefs_options_form_submit($form, &$form_state) { |
39 | - variable_set('boinc_prefs_options_beta', $form_state['values']['beta']); |
|
40 | - drupal_set_message('Preference options have been updated.'); |
|
39 | + variable_set('boinc_prefs_options_beta', $form_state['values']['beta']); |
|
40 | + drupal_set_message('Preference options have been updated.'); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
44 | 44 | * |
45 | 45 | */ |
46 | 46 | function boincwork_admin_prefs_upload_form(&$form_state) { |
47 | - $form = array(); |
|
48 | - $form['prefs_xml'] = array( |
|
47 | + $form = array(); |
|
48 | + $form['prefs_xml'] = array( |
|
49 | 49 | '#type' => 'textarea', |
50 | 50 | '#title' => t('Project specific preferences XML'), |
51 | 51 | '#default_value' => variable_get('boinc_project_specific_prefs_config', "<project_specific_preferences>\n\n</project_specific_preferences>"), |
52 | 52 | '#required' => TRUE |
53 | - ); |
|
54 | - $form['submit'] = array( |
|
53 | + ); |
|
54 | + $form['submit'] = array( |
|
55 | 55 | '#type' => 'submit', |
56 | 56 | '#value' => t('Submit') |
57 | - ); |
|
58 | - // Add the official mechanical things and return |
|
59 | - //drupal_prepare_form('boincwork_admin_prefs_upload_form', $form, $form_state); |
|
60 | - return $form; |
|
57 | + ); |
|
58 | + // Add the official mechanical things and return |
|
59 | + //drupal_prepare_form('boincwork_admin_prefs_upload_form', $form, $form_state); |
|
60 | + return $form; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
64 | - * Handle validation of preference upload form. |
|
65 | - */ |
|
64 | + * Handle validation of preference upload form. |
|
65 | + */ |
|
66 | 66 | function boincwork_admin_prefs_upload_form_validate($form, &$form_state) { |
67 | 67 | |
68 | - $xsd = './' . drupal_get_path('module', 'boincwork') . '/includes/projectprefs.xsd'; |
|
69 | - libxml_use_internal_errors(true); |
|
70 | - $xml = new DomDocument(); |
|
71 | - $xml->loadXML($form_state['values']['prefs_xml'], LIBXML_NOBLANKS); |
|
72 | - if (!$xml->schemaValidate($xsd)) { |
|
68 | + $xsd = './' . drupal_get_path('module', 'boincwork') . '/includes/projectprefs.xsd'; |
|
69 | + libxml_use_internal_errors(true); |
|
70 | + $xml = new DomDocument(); |
|
71 | + $xml->loadXML($form_state['values']['prefs_xml'], LIBXML_NOBLANKS); |
|
72 | + if (!$xml->schemaValidate($xsd)) { |
|
73 | 73 | $errors = libxml_get_errors(); |
74 | 74 | $lines = explode("\r", $form_state['values']['prefs_xml']); |
75 | 75 | drupal_set_message("{$errors[0]->message} at line {$errors[0]->line}" . |
76 | - ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), 'error'); |
|
76 | + ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), 'error'); |
|
77 | 77 | form_set_error('upload', t('XML file failed validation')); |
78 | - } |
|
78 | + } |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
82 | - * Handle submission of preference upload form. |
|
83 | - */ |
|
82 | + * Handle submission of preference upload form. |
|
83 | + */ |
|
84 | 84 | function boincwork_admin_prefs_upload_form_submit($form, &$form_state) { |
85 | - variable_set('boinc_project_specific_prefs_config', $form_state['values']['prefs_xml']); |
|
86 | - drupal_set_message('The XML has been validated and any changes to |
|
85 | + variable_set('boinc_project_specific_prefs_config', $form_state['values']['prefs_xml']); |
|
86 | + drupal_set_message('The XML has been validated and any changes to |
|
87 | 87 | preferences are now in place.'); |
88 | 88 | } |
89 | 89 | |
@@ -91,14 +91,14 @@ discard block |
||
91 | 91 | * |
92 | 92 | */ |
93 | 93 | function boincwork_admin_prefs_presets_page($preset = 'standard') { |
94 | - // Configure preference presets |
|
95 | - if (function_exists('jump_quickly')) { |
|
94 | + // Configure preference presets |
|
95 | + if (function_exists('jump_quickly')) { |
|
96 | 96 | $path = 'admin/boinc/prefs/presets'; |
97 | 97 | $preset_options = array( |
98 | - "{$path}/standard" => t('Standard'), |
|
99 | - "{$path}/maximum" => t('Maximum'), |
|
100 | - "{$path}/green" => t('Green'), |
|
101 | - "{$path}/minimum" => t('Minimum') |
|
98 | + "{$path}/standard" => t('Standard'), |
|
99 | + "{$path}/maximum" => t('Maximum'), |
|
100 | + "{$path}/green" => t('Green'), |
|
101 | + "{$path}/minimum" => t('Minimum') |
|
102 | 102 | ); |
103 | 103 | variable_set('jump_use_js_presets-Array', 1); |
104 | 104 | drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js'); |
@@ -106,15 +106,15 @@ discard block |
||
106 | 106 | $output .= '<label>Preset:</label>'; |
107 | 107 | $output .= jump_quickly($preset_options, 'presets'); |
108 | 108 | $output .= '</div></div>'; |
109 | - } |
|
110 | - $output .= drupal_get_form('boincwork_admin_prefs_presets_form', $preset); |
|
109 | + } |
|
110 | + $output .= drupal_get_form('boincwork_admin_prefs_presets_form', $preset); |
|
111 | 111 | |
112 | - $output .= '<div>'; |
|
113 | - $output .= bts('Usage: \'Save configuration\' will save the above preferences into the drupal database. These will be the preset computing (global) preferences that will fill in the preferences form once a user loads the Account Preferences page.', array(), NULL, 'boinc:admin-boinc-preference-presets'); |
|
114 | - $output .= '<p>'; |
|
115 | - $output .= bts('\'Save configuration with disk usage settings from config.xml\' will save the above preferences into the drupal database, but also load disk usage settings from the BOINC project\'s config.xml file. These will overwrite any disk usage settings you have placed above. Caution: A user\'s personal preferences will not change if you load the disk usage settings from config.xml here into the drupal database. They must change their preference settings manually.', array(), NULL, 'boinc:admin-boinc-preference-presets'); |
|
116 | - $output .= '</div>'; |
|
117 | - return $output; |
|
112 | + $output .= '<div>'; |
|
113 | + $output .= bts('Usage: \'Save configuration\' will save the above preferences into the drupal database. These will be the preset computing (global) preferences that will fill in the preferences form once a user loads the Account Preferences page.', array(), NULL, 'boinc:admin-boinc-preference-presets'); |
|
114 | + $output .= '<p>'; |
|
115 | + $output .= bts('\'Save configuration with disk usage settings from config.xml\' will save the above preferences into the drupal database, but also load disk usage settings from the BOINC project\'s config.xml file. These will overwrite any disk usage settings you have placed above. Caution: A user\'s personal preferences will not change if you load the disk usage settings from config.xml here into the drupal database. They must change their preference settings manually.', array(), NULL, 'boinc:admin-boinc-preference-presets'); |
|
116 | + $output .= '</div>'; |
|
117 | + return $output; |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -122,141 +122,141 @@ discard block |
||
122 | 122 | */ |
123 | 123 | function boincwork_admin_prefs_presets_form(&$form_state, $preset = 'standard') { |
124 | 124 | |
125 | - // Check database for preset prefs |
|
126 | - if (!variable_get('boincwork_preset_prefs', null)) |
|
125 | + // Check database for preset prefs |
|
126 | + if (!variable_get('boincwork_preset_prefs', null)) |
|
127 | 127 | drupal_set_message(bts('No presets found in database, loading a default set of preferences for each preset. These will be saved to the database once you click \'Save configuration\'.', array(), NULL, 'boinc:admin-boinc-preference-presets'), 'status'); |
128 | 128 | |
129 | - // Load a copy of the general prefs form |
|
130 | - $form = boincwork_generalprefs_form($form_state, NULL, $preset); |
|
131 | - if ($key = array_search('boincwork_generalprefs_form_submit', $form['#submit'])) { |
|
129 | + // Load a copy of the general prefs form |
|
130 | + $form = boincwork_generalprefs_form($form_state, NULL, $preset); |
|
131 | + if ($key = array_search('boincwork_generalprefs_form_submit', $form['#submit'])) { |
|
132 | 132 | unset($form['#submit'][$key]); |
133 | - } |
|
134 | - $form['#submit'][] = 'boincwork_admin_prefs_presets_form_submit'; |
|
133 | + } |
|
134 | + $form['#submit'][] = 'boincwork_admin_prefs_presets_form_submit'; |
|
135 | 135 | |
136 | - // Just keep the necessary items |
|
137 | - $form['processor'] = $form['prefs']['advanced']['processor']; |
|
138 | - $form['storage'] = $form['prefs']['advanced']['storage']; |
|
139 | - $form['network'] = $form['prefs']['advanced']['network']; |
|
140 | - unset($form['prefs']); |
|
136 | + // Just keep the necessary items |
|
137 | + $form['processor'] = $form['prefs']['advanced']['processor']; |
|
138 | + $form['storage'] = $form['prefs']['advanced']['storage']; |
|
139 | + $form['network'] = $form['prefs']['advanced']['network']; |
|
140 | + unset($form['prefs']); |
|
141 | 141 | |
142 | - // Tweak some things so it behaves a little better |
|
143 | - $form['#tree'] = TRUE; |
|
144 | - $form['processor']['#collapsible'] = TRUE; |
|
145 | - $form['storage']['#collapsible'] = TRUE; |
|
146 | - $form['network']['#collapsible'] = TRUE; |
|
142 | + // Tweak some things so it behaves a little better |
|
143 | + $form['#tree'] = TRUE; |
|
144 | + $form['processor']['#collapsible'] = TRUE; |
|
145 | + $form['storage']['#collapsible'] = TRUE; |
|
146 | + $form['network']['#collapsible'] = TRUE; |
|
147 | 147 | |
148 | - // Add a submit button and a hidden field to pass the preset |
|
149 | - $form['submit'] = array( |
|
148 | + // Add a submit button and a hidden field to pass the preset |
|
149 | + $form['submit'] = array( |
|
150 | 150 | '#type' => 'submit', |
151 | 151 | '#value' => t('Save configuration') |
152 | - ); |
|
153 | - $form['saveuseconfigxml'] = array ( |
|
154 | - '#type' => 'submit', |
|
155 | - '#value' => t('Save configuration with disk usage settings from config.xml'), |
|
156 | - '#validate' => array('boincwork_admin_prefs_preset_saveuseconfigxml'), |
|
157 | - ); |
|
158 | - $form['preset'] = array( |
|
152 | + ); |
|
153 | + $form['saveuseconfigxml'] = array ( |
|
154 | + '#type' => 'submit', |
|
155 | + '#value' => t('Save configuration with disk usage settings from config.xml'), |
|
156 | + '#validate' => array('boincwork_admin_prefs_preset_saveuseconfigxml'), |
|
157 | + ); |
|
158 | + $form['preset'] = array( |
|
159 | 159 | '#type' => 'hidden', |
160 | 160 | '#value' => $preset |
161 | - ); |
|
161 | + ); |
|
162 | 162 | |
163 | - // Add the official mechanical things and return |
|
164 | - drupal_prepare_form('boincwork_admin_prefs_presets_form', $form, $form_state); |
|
165 | - return $form; |
|
163 | + // Add the official mechanical things and return |
|
164 | + drupal_prepare_form('boincwork_admin_prefs_presets_form', $form, $form_state); |
|
165 | + return $form; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
169 | - * Validate the preference presets form. |
|
170 | - */ |
|
169 | + * Validate the preference presets form. |
|
170 | + */ |
|
171 | 171 | function boincwork_admin_prefs_presets_form_validate($form, &$form_state) { |
172 | - require_boinc('util'); |
|
173 | - $values = $form_state['values']; |
|
172 | + require_boinc('util'); |
|
173 | + $values = $form_state['values']; |
|
174 | 174 | |
175 | - // Verify all non-boolean user input values and notify form API of failures |
|
175 | + // Verify all non-boolean user input values and notify form API of failures |
|
176 | 176 | |
177 | - // Processing preferences |
|
178 | - if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', t('Invalid setting for') . " \"{$form['processor']['idle_time_to_run']['#title']} [x] {$form['processor']['idle_time_to_run']['#field_suffix']}\""); |
|
179 | - if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', t('Invalid setting for') . " \"{$form['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['processor']['suspend_if_no_recent_input']['#field_suffix']}\""); |
|
180 | - if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', t('Invalid setting for') . " \"{$form['processor']['suspend_cpu_usage']['#title']} [x] {$form['processor']['suspend_cpu_usage']['#field_suffix']}\""); |
|
181 | - if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', t('Invalid setting for') . " \"{$form['processor']['start_hour']['#title']} [x] {$form['processor']['start_hour']['#field_suffix']}\""); |
|
182 | - if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', t('Invalid setting for') . " \"{$form['processor']['end_hour']['#title']} [x] {$form['processor']['end_hour']['#field_suffix']}\""); |
|
183 | - if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', t('Invalid setting for') . " \"{$form['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['processor']['cpu_scheduling_period_minutes']['#field_suffix']}\""); |
|
184 | - if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', t('Invalid setting for') . " \"{$form['processor']['max_ncpus_pct']['#title']} [x] {$form['processor']['max_ncpus_pct']['#field_suffix']}\""); |
|
185 | - if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', t('Invalid setting for') . " \"{$form['processor']['cpu_usage_limit']['#title']} [x] {$form['processor']['cpu_usage_limit']['#field_suffix']}\""); |
|
177 | + // Processing preferences |
|
178 | + if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', t('Invalid setting for') . " \"{$form['processor']['idle_time_to_run']['#title']} [x] {$form['processor']['idle_time_to_run']['#field_suffix']}\""); |
|
179 | + if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', t('Invalid setting for') . " \"{$form['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['processor']['suspend_if_no_recent_input']['#field_suffix']}\""); |
|
180 | + if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', t('Invalid setting for') . " \"{$form['processor']['suspend_cpu_usage']['#title']} [x] {$form['processor']['suspend_cpu_usage']['#field_suffix']}\""); |
|
181 | + if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', t('Invalid setting for') . " \"{$form['processor']['start_hour']['#title']} [x] {$form['processor']['start_hour']['#field_suffix']}\""); |
|
182 | + if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', t('Invalid setting for') . " \"{$form['processor']['end_hour']['#title']} [x] {$form['processor']['end_hour']['#field_suffix']}\""); |
|
183 | + if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', t('Invalid setting for') . " \"{$form['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['processor']['cpu_scheduling_period_minutes']['#field_suffix']}\""); |
|
184 | + if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', t('Invalid setting for') . " \"{$form['processor']['max_ncpus_pct']['#title']} [x] {$form['processor']['max_ncpus_pct']['#field_suffix']}\""); |
|
185 | + if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', t('Invalid setting for') . " \"{$form['processor']['cpu_usage_limit']['#title']} [x] {$form['processor']['cpu_usage_limit']['#field_suffix']}\""); |
|
186 | 186 | |
187 | - // Storage preferences |
|
188 | - if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', t('Invalid setting for') . " \"{$form['storage']['disk_max_used_gb']['#title']} [x] {$form['storage']['disk_max_used_gb']['#field_suffix']}\""); |
|
189 | - if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', t('Invalid setting for') . " \"{$form['storage']['disk_min_free_gb']['#title']} [x] {$form['storage']['disk_min_free_gb']['#field_suffix']}\""); |
|
190 | - if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', t('Invalid setting for') . " \"{$form['storage']['disk_max_used_pct']['#title']} [x] {$form['storage']['disk_max_used_pct']['#field_suffix']}\""); |
|
191 | - if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', t('Invalid setting for') . " \"{$form['storage']['disk_interval']['#title']} [x] {$form['storage']['disk_interval']['#field_suffix']}\""); |
|
192 | - if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', t('Invalid setting for') . " \"{$form['storage']['vm_max_used_pct']['#title']} [x] {$form['storage']['vm_max_used_pct']['#field_suffix']}\""); |
|
193 | - if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', t('Invalid setting for') . " \"{$form['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['storage']['ram_max_used_busy_pct']['#field_suffix']}\""); |
|
194 | - if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', t('Invalid setting for') . " \"{$form['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['storage']['ram_max_used_idle_pct']['#field_suffix']}\""); |
|
187 | + // Storage preferences |
|
188 | + if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', t('Invalid setting for') . " \"{$form['storage']['disk_max_used_gb']['#title']} [x] {$form['storage']['disk_max_used_gb']['#field_suffix']}\""); |
|
189 | + if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', t('Invalid setting for') . " \"{$form['storage']['disk_min_free_gb']['#title']} [x] {$form['storage']['disk_min_free_gb']['#field_suffix']}\""); |
|
190 | + if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', t('Invalid setting for') . " \"{$form['storage']['disk_max_used_pct']['#title']} [x] {$form['storage']['disk_max_used_pct']['#field_suffix']}\""); |
|
191 | + if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', t('Invalid setting for') . " \"{$form['storage']['disk_interval']['#title']} [x] {$form['storage']['disk_interval']['#field_suffix']}\""); |
|
192 | + if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', t('Invalid setting for') . " \"{$form['storage']['vm_max_used_pct']['#title']} [x] {$form['storage']['vm_max_used_pct']['#field_suffix']}\""); |
|
193 | + if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', t('Invalid setting for') . " \"{$form['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['storage']['ram_max_used_busy_pct']['#field_suffix']}\""); |
|
194 | + if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', t('Invalid setting for') . " \"{$form['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['storage']['ram_max_used_idle_pct']['#field_suffix']}\""); |
|
195 | 195 | |
196 | - // Network preferences |
|
197 | - if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', t('Invalid setting for') . " \"{$form['network']['work_buf_min_days']['#title']} [x] {$form['network']['work_buf_min_days']['#field_suffix']}\""); |
|
198 | - if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', t('Invalid setting for') . " \"{$form['network']['work_buf_additional_days']['#title']} [x] {$form['network']['work_buf_additional_days']['#field_suffix']}\""); |
|
199 | - if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', t('Invalid setting for') . " \"{$form['network']['max_bytes_sec_down']['#title']} [x] {$form['network']['max_bytes_sec_down']['#field_suffix']}\""); |
|
200 | - if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', t('Invalid setting for') . " \"{$form['network']['max_bytes_sec_up']['#title']} [x] {$form['network']['max_bytes_sec_up']['#field_suffix']}\""); |
|
201 | - if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', t('Invalid setting for') . " \"{$form['network']['net_start_hour']['#title']} [x] {$form['network']['net_start_hour']['#field_suffix']}\""); |
|
202 | - if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', t('Invalid setting for') . " \"{$form['network']['net_end_hour']['#title']} [x] {$form['network']['net_end_hour']['#field_suffix']}\""); |
|
203 | - if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', t('Invalid setting for') . " \"{$form['network']['daily_xfer_limit_mb']['#title']} [x] {$form['network']['daily_xfer_limit_mb']['#field_suffix']}\""); |
|
204 | - if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', t('Invalid setting for') . " \"{$form['network']['daily_xfer_limit_mb']['#title']} [x] {$form['network']['daily_xfer_limit_mb']['#field_suffix']}\""); |
|
196 | + // Network preferences |
|
197 | + if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', t('Invalid setting for') . " \"{$form['network']['work_buf_min_days']['#title']} [x] {$form['network']['work_buf_min_days']['#field_suffix']}\""); |
|
198 | + if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', t('Invalid setting for') . " \"{$form['network']['work_buf_additional_days']['#title']} [x] {$form['network']['work_buf_additional_days']['#field_suffix']}\""); |
|
199 | + if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', t('Invalid setting for') . " \"{$form['network']['max_bytes_sec_down']['#title']} [x] {$form['network']['max_bytes_sec_down']['#field_suffix']}\""); |
|
200 | + if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', t('Invalid setting for') . " \"{$form['network']['max_bytes_sec_up']['#title']} [x] {$form['network']['max_bytes_sec_up']['#field_suffix']}\""); |
|
201 | + if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', t('Invalid setting for') . " \"{$form['network']['net_start_hour']['#title']} [x] {$form['network']['net_start_hour']['#field_suffix']}\""); |
|
202 | + if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', t('Invalid setting for') . " \"{$form['network']['net_end_hour']['#title']} [x] {$form['network']['net_end_hour']['#field_suffix']}\""); |
|
203 | + if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', t('Invalid setting for') . " \"{$form['network']['daily_xfer_limit_mb']['#title']} [x] {$form['network']['daily_xfer_limit_mb']['#field_suffix']}\""); |
|
204 | + if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', t('Invalid setting for') . " \"{$form['network']['daily_xfer_limit_mb']['#title']} [x] {$form['network']['daily_xfer_limit_mb']['#field_suffix']}\""); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
208 | - * Handle post-validation submission of preference presets form. |
|
209 | - */ |
|
208 | + * Handle post-validation submission of preference presets form. |
|
209 | + */ |
|
210 | 210 | function boincwork_admin_prefs_presets_form_submit($form, &$form_state) { |
211 | - $values = $form_state['values']; |
|
212 | - $preset = $form_state['values']['preset']; |
|
211 | + $values = $form_state['values']; |
|
212 | + $preset = $form_state['values']['preset']; |
|
213 | 213 | |
214 | - // Load baseline settings from configuration |
|
215 | - $prefs = boincwork_get_preset_prefs($preset); |
|
214 | + // Load baseline settings from configuration |
|
215 | + $prefs = boincwork_get_preset_prefs($preset); |
|
216 | 216 | |
217 | - // Processing preferences |
|
218 | - $prefs['run_on_batteries'] = ($values['processor']['run_on_batteries']) ? 0 : 1; |
|
219 | - $prefs['run_if_user_active'] = ($values['processor']['run_if_user_active']) ? 0 : 1; |
|
220 | - $prefs['run_gpu_if_user_active'] = ($values['processor']['run_gpu_if_user_active']) ? 0: 1; |
|
221 | - $prefs['idle_time_to_run'] = $values['processor']['idle_time_to_run']; |
|
222 | - $prefs['suspend_if_no_recent_input'] = $values['processor']['suspend_if_no_recent_input']; |
|
223 | - $prefs['suspend_cpu_usage'] = $values['processor']['suspend_cpu_usage']; |
|
224 | - $prefs['start_hour'] = $values['processor']['start_hour']; |
|
225 | - $prefs['end_hour'] = $values['processor']['end_hour']; |
|
226 | - $prefs['leave_apps_in_memory'] = ($values['processor']['leave_apps_in_memory']) ? 1 : 0; |
|
227 | - $prefs['cpu_scheduling_period_minutes'] = $values['processor']['cpu_scheduling_period_minutes']; |
|
228 | - $prefs['max_ncpus_pct'] = $values['processor']['max_ncpus_pct']; |
|
229 | - $prefs['cpu_usage_limit'] = $values['processor']['cpu_usage_limit']; |
|
217 | + // Processing preferences |
|
218 | + $prefs['run_on_batteries'] = ($values['processor']['run_on_batteries']) ? 0 : 1; |
|
219 | + $prefs['run_if_user_active'] = ($values['processor']['run_if_user_active']) ? 0 : 1; |
|
220 | + $prefs['run_gpu_if_user_active'] = ($values['processor']['run_gpu_if_user_active']) ? 0: 1; |
|
221 | + $prefs['idle_time_to_run'] = $values['processor']['idle_time_to_run']; |
|
222 | + $prefs['suspend_if_no_recent_input'] = $values['processor']['suspend_if_no_recent_input']; |
|
223 | + $prefs['suspend_cpu_usage'] = $values['processor']['suspend_cpu_usage']; |
|
224 | + $prefs['start_hour'] = $values['processor']['start_hour']; |
|
225 | + $prefs['end_hour'] = $values['processor']['end_hour']; |
|
226 | + $prefs['leave_apps_in_memory'] = ($values['processor']['leave_apps_in_memory']) ? 1 : 0; |
|
227 | + $prefs['cpu_scheduling_period_minutes'] = $values['processor']['cpu_scheduling_period_minutes']; |
|
228 | + $prefs['max_ncpus_pct'] = $values['processor']['max_ncpus_pct']; |
|
229 | + $prefs['cpu_usage_limit'] = $values['processor']['cpu_usage_limit']; |
|
230 | 230 | |
231 | - // Storage preferences |
|
232 | - $prefs['disk_max_used_gb'] = $values['storage']['disk_max_used_gb']; |
|
233 | - $prefs['disk_min_free_gb'] = $values['storage']['disk_min_free_gb']; |
|
234 | - $prefs['disk_max_used_pct'] = $values['storage']['disk_max_used_pct']; |
|
235 | - $prefs['disk_interval'] = $values['storage']['disk_interval']; |
|
236 | - $prefs['vm_max_used_pct'] = $values['storage']['vm_max_used_pct']; |
|
237 | - $prefs['ram_max_used_busy_pct'] = $values['storage']['ram_max_used_busy_pct']; |
|
238 | - $prefs['ram_max_used_idle_pct'] = $values['storage']['ram_max_used_idle_pct']; |
|
231 | + // Storage preferences |
|
232 | + $prefs['disk_max_used_gb'] = $values['storage']['disk_max_used_gb']; |
|
233 | + $prefs['disk_min_free_gb'] = $values['storage']['disk_min_free_gb']; |
|
234 | + $prefs['disk_max_used_pct'] = $values['storage']['disk_max_used_pct']; |
|
235 | + $prefs['disk_interval'] = $values['storage']['disk_interval']; |
|
236 | + $prefs['vm_max_used_pct'] = $values['storage']['vm_max_used_pct']; |
|
237 | + $prefs['ram_max_used_busy_pct'] = $values['storage']['ram_max_used_busy_pct']; |
|
238 | + $prefs['ram_max_used_idle_pct'] = $values['storage']['ram_max_used_idle_pct']; |
|
239 | 239 | |
240 | - // Network preferences |
|
241 | - $prefs['work_buf_min_days'] = $values['network']['work_buf_min_days']; |
|
242 | - $prefs['work_buf_additional_days'] = $values['network']['work_buf_additional_days']; |
|
243 | - $prefs['confirm_before_connecting'] = ($values['network']['confirm_before_connecting']) ? 1 : 0; |
|
244 | - $prefs['hangup_if_dialed'] = ($values['network']['hangup_if_dialed']) ? 1 : 0; |
|
245 | - $prefs['max_bytes_sec_down'] = $values['network']['max_bytes_sec_down']*1000; |
|
246 | - $prefs['max_bytes_sec_up'] = $values['network']['max_bytes_sec_up']*1000; |
|
247 | - $prefs['net_start_hour'] = $values['network']['net_start_hour']; |
|
248 | - $prefs['net_end_hour'] = $values['network']['net_end_hour']; |
|
249 | - $prefs['daily_xfer_limit_mb'] = $values['network']['daily_xfer_limit_mb']; |
|
250 | - $prefs['daily_xfer_period_days'] = $values['network']['daily_xfer_period_days']; |
|
251 | - $prefs['dont_verify_images'] = ($values['network']['dont_verify_images']) ? 1 : 0; |
|
240 | + // Network preferences |
|
241 | + $prefs['work_buf_min_days'] = $values['network']['work_buf_min_days']; |
|
242 | + $prefs['work_buf_additional_days'] = $values['network']['work_buf_additional_days']; |
|
243 | + $prefs['confirm_before_connecting'] = ($values['network']['confirm_before_connecting']) ? 1 : 0; |
|
244 | + $prefs['hangup_if_dialed'] = ($values['network']['hangup_if_dialed']) ? 1 : 0; |
|
245 | + $prefs['max_bytes_sec_down'] = $values['network']['max_bytes_sec_down']*1000; |
|
246 | + $prefs['max_bytes_sec_up'] = $values['network']['max_bytes_sec_up']*1000; |
|
247 | + $prefs['net_start_hour'] = $values['network']['net_start_hour']; |
|
248 | + $prefs['net_end_hour'] = $values['network']['net_end_hour']; |
|
249 | + $prefs['daily_xfer_limit_mb'] = $values['network']['daily_xfer_limit_mb']; |
|
250 | + $prefs['daily_xfer_period_days'] = $values['network']['daily_xfer_period_days']; |
|
251 | + $prefs['dont_verify_images'] = ($values['network']['dont_verify_images']) ? 1 : 0; |
|
252 | 252 | |
253 | - //Remove @attributes to match new format (see boincwork.forms.inc |
|
254 | - //function boincwork_generalprefs_form) |
|
255 | - unset($prefs['@attributes']['preset']); |
|
253 | + //Remove @attributes to match new format (see boincwork.forms.inc |
|
254 | + //function boincwork_generalprefs_form) |
|
255 | + unset($prefs['@attributes']['preset']); |
|
256 | 256 | |
257 | - // Update the configuration |
|
258 | - boincwork_save_preset_prefs($prefs, $preset); |
|
259 | - drupal_set_message(t('The "@name" preset has been updated.', |
|
257 | + // Update the configuration |
|
258 | + boincwork_save_preset_prefs($prefs, $preset); |
|
259 | + drupal_set_message(t('The "@name" preset has been updated.', |
|
260 | 260 | array('@name' => $preset))); |
261 | 261 | } |
262 | 262 | |
@@ -265,26 +265,26 @@ discard block |
||
265 | 265 | */ |
266 | 266 | function boincwork_save_preset_prefs($updated_prefs, $preset = 'standard') { |
267 | 267 | |
268 | - // Get the full configuration |
|
269 | - $all_presets = boincwork_get_preset_prefs(); |
|
270 | - $all_presets = (array) $all_presets['general_preferences']; |
|
268 | + // Get the full configuration |
|
269 | + $all_presets = boincwork_get_preset_prefs(); |
|
270 | + $all_presets = (array) $all_presets['general_preferences']; |
|
271 | 271 | |
272 | - // Check for sane config |
|
273 | - if (isset($all_presets['preset'])) { |
|
272 | + // Check for sane config |
|
273 | + if (isset($all_presets['preset'])) { |
|
274 | 274 | if (!is_numeric(key($all_presets['preset']))) { |
275 | - $all_presets['preset'] = array($all_presets['preset']); |
|
275 | + $all_presets['preset'] = array($all_presets['preset']); |
|
276 | 276 | } |
277 | 277 | foreach ($all_presets['preset'] as $key => $old_preset) { |
278 | - // Find the preset being updated and... update it |
|
279 | - if (isset($old_preset['@attributes']['name']) AND $old_preset['@attributes']['name'] == $preset) { |
|
278 | + // Find the preset being updated and... update it |
|
279 | + if (isset($old_preset['@attributes']['name']) AND $old_preset['@attributes']['name'] == $preset) { |
|
280 | 280 | $all_presets['preset'][$key] = $updated_prefs + $old_preset; |
281 | - } |
|
281 | + } |
|
282 | + } |
|
282 | 283 | } |
283 | - } |
|
284 | 284 | |
285 | - // Convert prefs back to XML and save to database |
|
286 | - $all_presets = array('general_preferences' => $all_presets); |
|
287 | - variable_set('boincwork_preset_prefs', save_configuration($all_presets)); |
|
285 | + // Convert prefs back to XML and save to database |
|
286 | + $all_presets = array('general_preferences' => $all_presets); |
|
287 | + variable_set('boincwork_preset_prefs', save_configuration($all_presets)); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | '#type' => 'checkbox', |
16 | 16 | '#title' => t('Allow users to opt in to test beta applications'), |
17 | 17 | '#default_value' => variable_get('boinc_prefs_options_beta', 0), |
18 | - '#required' => TRUE |
|
18 | + '#required' => true |
|
19 | 19 | ); |
20 | 20 | $form['submit'] = array( |
21 | 21 | '#type' => 'submit', |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | '#type' => 'textarea', |
50 | 50 | '#title' => t('Project specific preferences XML'), |
51 | 51 | '#default_value' => variable_get('boinc_project_specific_prefs_config', "<project_specific_preferences>\n\n</project_specific_preferences>"), |
52 | - '#required' => TRUE |
|
52 | + '#required' => true |
|
53 | 53 | ); |
54 | 54 | $form['submit'] = array( |
55 | 55 | '#type' => 'submit', |
@@ -110,9 +110,9 @@ discard block |
||
110 | 110 | $output .= drupal_get_form('boincwork_admin_prefs_presets_form', $preset); |
111 | 111 | |
112 | 112 | $output .= '<div>'; |
113 | - $output .= bts('Usage: \'Save configuration\' will save the above preferences into the drupal database. These will be the preset computing (global) preferences that will fill in the preferences form once a user loads the Account Preferences page.', array(), NULL, 'boinc:admin-boinc-preference-presets'); |
|
113 | + $output .= bts('Usage: \'Save configuration\' will save the above preferences into the drupal database. These will be the preset computing (global) preferences that will fill in the preferences form once a user loads the Account Preferences page.', array(), null, 'boinc:admin-boinc-preference-presets'); |
|
114 | 114 | $output .= '<p>'; |
115 | - $output .= bts('\'Save configuration with disk usage settings from config.xml\' will save the above preferences into the drupal database, but also load disk usage settings from the BOINC project\'s config.xml file. These will overwrite any disk usage settings you have placed above. Caution: A user\'s personal preferences will not change if you load the disk usage settings from config.xml here into the drupal database. They must change their preference settings manually.', array(), NULL, 'boinc:admin-boinc-preference-presets'); |
|
115 | + $output .= bts('\'Save configuration with disk usage settings from config.xml\' will save the above preferences into the drupal database, but also load disk usage settings from the BOINC project\'s config.xml file. These will overwrite any disk usage settings you have placed above. Caution: A user\'s personal preferences will not change if you load the disk usage settings from config.xml here into the drupal database. They must change their preference settings manually.', array(), null, 'boinc:admin-boinc-preference-presets'); |
|
116 | 116 | $output .= '</div>'; |
117 | 117 | return $output; |
118 | 118 | } |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | |
125 | 125 | // Check database for preset prefs |
126 | 126 | if (!variable_get('boincwork_preset_prefs', null)) |
127 | - drupal_set_message(bts('No presets found in database, loading a default set of preferences for each preset. These will be saved to the database once you click \'Save configuration\'.', array(), NULL, 'boinc:admin-boinc-preference-presets'), 'status'); |
|
127 | + drupal_set_message(bts('No presets found in database, loading a default set of preferences for each preset. These will be saved to the database once you click \'Save configuration\'.', array(), null, 'boinc:admin-boinc-preference-presets'), 'status'); |
|
128 | 128 | |
129 | 129 | // Load a copy of the general prefs form |
130 | - $form = boincwork_generalprefs_form($form_state, NULL, $preset); |
|
130 | + $form = boincwork_generalprefs_form($form_state, null, $preset); |
|
131 | 131 | if ($key = array_search('boincwork_generalprefs_form_submit', $form['#submit'])) { |
132 | 132 | unset($form['#submit'][$key]); |
133 | 133 | } |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | unset($form['prefs']); |
141 | 141 | |
142 | 142 | // Tweak some things so it behaves a little better |
143 | - $form['#tree'] = TRUE; |
|
144 | - $form['processor']['#collapsible'] = TRUE; |
|
145 | - $form['storage']['#collapsible'] = TRUE; |
|
146 | - $form['network']['#collapsible'] = TRUE; |
|
143 | + $form['#tree'] = true; |
|
144 | + $form['processor']['#collapsible'] = true; |
|
145 | + $form['storage']['#collapsible'] = true; |
|
146 | + $form['network']['#collapsible'] = true; |
|
147 | 147 | |
148 | 148 | // Add a submit button and a hidden field to pass the preset |
149 | 149 | $form['submit'] = array( |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | } |
277 | 277 | foreach ($all_presets['preset'] as $key => $old_preset) { |
278 | 278 | // Find the preset being updated and... update it |
279 | - if (isset($old_preset['@attributes']['name']) AND $old_preset['@attributes']['name'] == $preset) { |
|
279 | + if (isset($old_preset['@attributes']['name']) and $old_preset['@attributes']['name'] == $preset) { |
|
280 | 280 | $all_presets['preset'][$key] = $updated_prefs + $old_preset; |
281 | 281 | } |
282 | 282 | } |
@@ -7,15 +7,15 @@ |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | class views_handler_argument_boincuser_id extends views_handler_argument_numeric { |
10 | - function construct() { |
|
10 | + function construct() { |
|
11 | 11 | parent::construct(); |
12 | - } |
|
12 | + } |
|
13 | 13 | |
14 | - function set_argument($arg) { |
|
14 | + function set_argument($arg) { |
|
15 | 15 | // When setting the ID argument, convert to BOINC ID |
16 | 16 | $id = is_numeric($arg) ? $arg : 0; |
17 | 17 | $boinc_id = db_result(db_query("SELECT boinc_id FROM {boincuser} WHERE uid = %d", $id)); |
18 | 18 | $this->argument = $boinc_id; |
19 | 19 | return $this->validate_arg($boinc_id); |
20 | - } |
|
20 | + } |
|
21 | 21 | } |
@@ -6,15 +6,15 @@ |
||
6 | 6 | */ |
7 | 7 | |
8 | 8 | class views_handler_field_boincwork_host_app_et_avg extends views_handler_field { |
9 | - function construct() { |
|
9 | + function construct() { |
|
10 | 10 | parent::construct(); |
11 | - } |
|
11 | + } |
|
12 | 12 | |
13 | - function render($values) { |
|
13 | + function render($values) { |
|
14 | 14 | $gflops = 0; |
15 | 15 | if ($values->host_app_version_et_avg) { |
16 | - $gflops = 1e-9 / $values->host_app_version_et_avg; |
|
16 | + $gflops = 1e-9 / $values->host_app_version_et_avg; |
|
17 | 17 | } |
18 | 18 | return round($gflops, 2) . ' GFLOPS'; |
19 | - } |
|
19 | + } |
|
20 | 20 | } |
@@ -13,8 +13,8 @@ |
||
13 | 13 | function render($values) { |
14 | 14 | $gflops = 0; |
15 | 15 | if ($values->host_app_version_et_avg) { |
16 | - $gflops = 1e-9 / $values->host_app_version_et_avg; |
|
16 | + $gflops = 1e-9/$values->host_app_version_et_avg; |
|
17 | 17 | } |
18 | - return round($gflops, 2) . ' GFLOPS'; |
|
18 | + return round($gflops, 2).' GFLOPS'; |
|
19 | 19 | } |
20 | 20 | } |