source: trunk/client/class/charts.php@ 12

Last change on this file since 12 was 2, checked in by root, 15 years ago

importo il progetto

File size: 5.8 KB
Line 
1<?php
2// charts.php v4.5
3// ------------------------------------------------------------------------
4// Copyright (c) 2003-2006, maani.us
5// ------------------------------------------------------------------------
6// This file is part of "PHP/SWF Charts"
7//
8// PHP/SWF Charts is a shareware. See http://www.maani.us/charts/ for
9// more information.
10// ------------------------------------------------------------------------
11
12//====================================
13function InsertChart( $flash_file, $library_path, $php_source, $width=470, $height=350, $bg_color="ffffff", $transparent=false, $license=null ){
14
15 $php_source=urlencode($php_source);
16 $library_path=urlencode($library_path);
17 $x=$_SESSION['max'];
18 $u=(strpos ($flash_file,"?")==false)? "?" : ((substr($flash_file, -1)=="&")? "":"&");
19
20
21 $html="<div style=\"text-align: right;\">";
22 if (strstr($_SERVER['HTTP_USER_AGENT'],"MSIE")){
23 $html.="<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' ";
24 $html.="width='".$width."' height='".$height."' id='charts$x'>";
25 $u=(strpos ($flash_file,"?")==false)? "?" : ((substr($flash_file, -1)=="&")? "":"&");
26 $html.="<param name='movie' value='".$flash_file.$u."library_path=".$library_path."&amp;php_source=".$php_source;
27 if($license!=null){$html.="&amp;license=".$license;}
28 $html.="'/> <param name='quality' value='high'/> <param name='bgcolor' value='#".$bg_color."'/> ";
29 if($transparent){$html.="<param name='wmode' value='transparent'/> ";}
30 $html.="</object>";
31 }else{
32 $html.="<embed src=\"".$flash_file.$u."library_path=".$library_path."&amp;php_source=".$php_source;
33 if($license!=null){$html.="&amp;license=".$license;}
34 $html.="\" quality=high bgcolor=#".$bg_color." width=".$width." height=".$height." name='charts' align='right' swLiveConnect='true' ";
35 if($transparent){$html.="wmode=transparent ";}
36 $html.="type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed>";
37 }
38 $html.="</div>";
39
40 return $html;
41
42
43}
44
45//====================================
46function SendChartData( $chart=array() ){
47
48
49 $xml="<chart>\r\n";
50 $Keys1= array_keys((array) $chart);
51 for ($i1=0;$i1<count($Keys1);$i1++){
52 if(is_array($chart[$Keys1[$i1]])){
53 $Keys2=array_keys($chart[$Keys1[$i1]]);
54 if(is_array($chart[$Keys1[$i1]][$Keys2[0]])){
55 $xml.="\t<".$Keys1[$i1].">\r\n";
56 for($i2=0;$i2<count($Keys2);$i2++){
57 $Keys3=array_keys((array) $chart[$Keys1[$i1]][$Keys2[$i2]]);
58 switch($Keys1[$i1]){
59 case "chart_data":
60 $xml.="\t\t<row>\r\n";
61 for($i3=0;$i3<count($Keys3);$i3++){
62 switch(true){
63 case ($chart[$Keys1[$i1]][$Keys2[$i2]][$Keys3[$i3]]==null):
64 $xml.="\t\t\t<null/>\r\n";
65 break;
66
67 case ($Keys2[$i2]>0 and $Keys3[$i3]>0):
68 $xml.="\t\t\t<number>".$chart[$Keys1[$i1]][$Keys2[$i2]][$Keys3[$i3]]."</number>\r\n";
69 break;
70
71 default:
72 $xml.="\t\t\t<string>".$chart[$Keys1[$i1]][$Keys2[$i2]][$Keys3[$i3]]."</string>\r\n";
73 break;
74 }
75 }
76 $xml.="\t\t</row>\r\n";
77 break;
78
79 case "chart_value_text":
80 $xml.="\t\t<row>\r\n";
81 $count=0;
82 for($i3=0;$i3<count($Keys3);$i3++){
83 if($chart[$Keys1[$i1]][$Keys2[$i2]][$Keys3[$i3]]==null){$xml.="\t\t\t<null/>\r\n";}
84 else{$xml.="\t\t\t<string>".$chart[$Keys1[$i1]][$Keys2[$i2]][$Keys3[$i3]]."</string>\r\n";}
85 }
86 $xml.="\t\t</row>\r\n";
87 break;
88
89 /*case "link_data_text":
90 $xml.="\t\t<row>\r\n";
91 $count=0;
92 for($i3=0;$i3<count($Keys3);$i3++){
93 if($chart[$Keys1[$i1]][$Keys2[$i2]][$Keys3[$i3]]==null){$xml.="\t\t\t<null/>\r\n";}
94 else{$xml.="\t\t\t<string>".$chart[$Keys1[$i1]][$Keys2[$i2]][$Keys3[$i3]]."</string>\r\n";}
95 }
96 $xml.="\t\t</row>\r\n";
97 break;*/
98
99 case "draw":
100 $text="";
101 $xml.="\t\t<".$chart[$Keys1[$i1]][$Keys2[$i2]]['type'];
102 for($i3=0;$i3<count($Keys3);$i3++){
103 if($Keys3[$i3]!="type"){
104 if($Keys3[$i3]=="text"){$text=$chart[$Keys1[$i1]][$Keys2[$i2]][$Keys3[$i3]];}
105 else{$xml.=" ".$Keys3[$i3]."=\"".$chart[$Keys1[$i1]][$Keys2[$i2]][$Keys3[$i3]]."\"";}
106 }
107 }
108 if($text!=""){$xml.=">".$text."</text>\r\n";}
109 else{$xml.=" />\r\n";}
110 break;
111
112
113 default://link, etc.
114 $xml.="\t\t<value";
115 for($i3=0;$i3<count($Keys3);$i3++){
116 $xml.=" ".$Keys3[$i3]."=\"".$chart[$Keys1[$i1]][$Keys2[$i2]][$Keys3[$i3]]."\"";
117 }
118 $xml.=" />\r\n";
119 break;
120 }
121 }
122 $xml.="\t</".$Keys1[$i1].">\r\n";
123 }else{
124 if($Keys1[$i1]=="chart_type" or $Keys1[$i1]=="series_color" or $Keys1[$i1]=="series_image" or $Keys1[$i1]=="series_explode" or $Keys1[$i1]=="axis_value_text"){
125 $xml.="\t<".$Keys1[$i1].">\r\n";
126 for($i2=0;$i2<count($Keys2);$i2++){
127 if($chart[$Keys1[$i1]][$Keys2[$i2]]==null){$xml.="\t\t<null/>\r\n";}
128 else{$xml.="\t\t<value>".$chart[$Keys1[$i1]][$Keys2[$i2]]."</value>\r\n";}
129 }
130 $xml.="\t</".$Keys1[$i1].">\r\n";
131 }else{//axis_category, etc.
132 $xml.="\t<".$Keys1[$i1];
133 for($i2=0;$i2<count($Keys2);$i2++){
134 $xml.=" ".$Keys2[$i2]."=\"".$chart[$Keys1[$i1]][$Keys2[$i2]]."\"";
135 }
136 $xml.=" />\r\n";
137 }
138 }
139 }else{//chart type, etc.
140 $xml.="\t<".$Keys1[$i1].">".$chart[$Keys1[$i1]]."</".$Keys1[$i1].">\r\n";
141 }
142 }
143 $xml.="</chart>\r\n";
144/* // stampa su file by Linuxap
145 mt_srand ((double)microtime()*1000000);
146 $maxran = 1000000;
147 $random_num = mt_rand(0, $maxran);
148 $fileout="./temp/$random_num";
149 $fp = fopen($fileout,"w");
150 fwrite($fp,$xml);
151 fclose($fp);
152*/
153 //echo $xml;
154//MODIFICHE PER TOGLIERE FILETEMP
155 return $xml; //return $fileout;
156}
157//====================================
158?>
Note: See TracBrowser for help on using the repository browser.