Commit 892f74111a5bb66bb0412f5c5b90ff27c92803bb
1 parent
8b77c7d0
Exists in
master
and in
112 other branches
format help
Showing
13 changed files
with
11 additions
and
3679 deletions
Show diff stats
js/resources/css/amda.css
@@ -227,22 +227,23 @@ background-image: url(../images/16x16/error.png) !important; | @@ -227,22 +227,23 @@ background-image: url(../images/16x16/error.png) !important; | ||
227 | } | 227 | } |
228 | 228 | ||
229 | 229 | ||
230 | -.infoWindow ul { | ||
231 | - padding-top: 3px; | ||
232 | - margin-left: 30px; | ||
233 | - list-style-type: circle; | 230 | +.infoWindow ul { |
231 | + margin-left: 20px; | ||
232 | + list-style-type: disc; | ||
234 | } | 233 | } |
235 | 234 | ||
236 | -.infoWindow li { | ||
237 | - padding-top: 3px; | ||
238 | - list-style-type: circle; | 235 | +.infoWindow li { |
236 | + list-style-type: disc; | ||
239 | } | 237 | } |
240 | - | 238 | + |
239 | +.infoWindow b { | ||
240 | + color: #555555; | ||
241 | + } | ||
242 | + | ||
241 | .infoWindow h2 { | 243 | .infoWindow h2 { |
242 | padding-bottom: 3px; | 244 | padding-bottom: 3px; |
243 | margin-bottom: 1em; | 245 | margin-bottom: 1em; |
244 | color: #555555; | 246 | color: #555555; |
245 | - color: #555555; | ||
246 | } | 247 | } |
247 | 248 | ||
248 | .infoMsg h2 { | 249 | .infoMsg h2 { |
@@ -256,7 +257,7 @@ background-image: url(../images/16x16/error.png) !important; | @@ -256,7 +257,7 @@ background-image: url(../images/16x16/error.png) !important; | ||
256 | } | 257 | } |
257 | 258 | ||
258 | .infoMsg li { | 259 | .infoMsg li { |
259 | - list-style-type: circle; | 260 | + list-style-type: disc; |
260 | } | 261 | } |
261 | 262 | ||
262 | .plotPanelBgColor td div { | 263 | .plotPanelBgColor td div { |
php/XML/dd2tree.xsl deleted
@@ -1,93 +0,0 @@ | @@ -1,93 +0,0 @@ | ||
1 | -<xsl:stylesheet version="1.0" | ||
2 | -xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | ||
3 | - | ||
4 | -<xsl:output method="xml"/> | ||
5 | - | ||
6 | -<xsl:template match="dataRoot/dataCenter"> | ||
7 | -<dataRoot> | ||
8 | - <dataCenter name="AMDA" desc="AMDA_Internal_Data_Base" xml:id="myLocalData-treeRootNode"> | ||
9 | - <xsl:for-each select="mission"> | ||
10 | - <mission att="{@attention}" name="{@name}" rank="{@rank}" xml:id="{@name}" desc="{@desc}" target="{target}" available="{@available}"> | ||
11 | - <xsl:choose> | ||
12 | - <xsl:when test="group"> | ||
13 | - <xsl:for-each select="group"> | ||
14 | - <group att="{@attention}" name="{@name}" xml:id="{@xml:id}" desc="{@desc}" restricted="{@restricted}"> | ||
15 | - <xsl:for-each select="instrument"> | ||
16 | - <instrument att="{@attention}" name="{@name}" xml:id="{@xml:id}" desc="{@desc}" restricted="{@restricted}"> | ||
17 | - <xsl:for-each select="dataset"> | ||
18 | - <xsl:apply-templates select="."/> | ||
19 | - </xsl:for-each> | ||
20 | - </instrument> | ||
21 | - </xsl:for-each> | ||
22 | - </group> | ||
23 | - </xsl:for-each> | ||
24 | - </xsl:when> | ||
25 | - <xsl:when test="simulationModel"> | ||
26 | - <xsl:for-each select="simulationModel"> | ||
27 | - <simulationModel att="{@attention}" name="{@name}" xml:id="{@xml:id}" desc="{@desc}" restricted="{@restricted}"> | ||
28 | - <xsl:for-each select="instrument"> | ||
29 | - <instrument att="{@attention}" name="{@name}" xml:id="{@xml:id}" desc="{@desc}" restricted="{@restricted}"> | ||
30 | - <xsl:for-each select="dataset"> | ||
31 | - <xsl:apply-templates select="."/> | ||
32 | - </xsl:for-each> | ||
33 | - </instrument> | ||
34 | - </xsl:for-each> | ||
35 | - </simulationModel> | ||
36 | - </xsl:for-each> | ||
37 | - </xsl:when> | ||
38 | - <xsl:when test="observatory"> | ||
39 | - <xsl:for-each select="observatory"> | ||
40 | - <observatory att="{@attention}" name="{@name}" xml:id="{@xml:id}" desc="{@desc}" restricted="{@restricted}"> | ||
41 | - <xsl:for-each select="instrument"> | ||
42 | - <instrument att="{@attention}" name="{@name}" xml:id="{@xml:id}" desc="{@desc}"> | ||
43 | - <xsl:for-each select="dataset"> | ||
44 | - <xsl:apply-templates select="."/> | ||
45 | - </xsl:for-each> | ||
46 | - </instrument> | ||
47 | - </xsl:for-each> | ||
48 | - </observatory> | ||
49 | - </xsl:for-each> | ||
50 | - </xsl:when> | ||
51 | - <xsl:otherwise> | ||
52 | - <xsl:for-each select="instrument"> | ||
53 | - <instrument att="{@attention}" name="{@name}" xml:id="{parent::mission/@name}:{@name}" desc="{@desc}" restricted="{@restricted}"> | ||
54 | - <xsl:for-each select="datasetGroup"> | ||
55 | - <datasetGroup att="{@attention}" name="{@name}" xml:id="{@xml:id}" desc="{@desc}" restricted="{@restricted}"> | ||
56 | - <xsl:for-each select="dataset"> | ||
57 | - <xsl:apply-templates select="."/> | ||
58 | - </xsl:for-each> | ||
59 | - </datasetGroup> | ||
60 | - </xsl:for-each> | ||
61 | - <xsl:for-each select="dataset"> | ||
62 | - <xsl:apply-templates select="."/> | ||
63 | - </xsl:for-each> | ||
64 | - </instrument> | ||
65 | - </xsl:for-each> | ||
66 | - </xsl:otherwise> | ||
67 | - </xsl:choose> | ||
68 | - </mission> | ||
69 | - </xsl:for-each> | ||
70 | - </dataCenter> | ||
71 | -</dataRoot> | ||
72 | -</xsl:template> | ||
73 | - | ||
74 | -<xsl:template match="dataset"> | ||
75 | - <dataset att="{@attention}" restricted="{@restricted}" name="{@name}" xml:id="{@xml:id}" sampling="{sampling}" maxSampling="{maxSampling}" dataStart="{dataStart}" dataStop="{dataStop}" dataSource="{dataSource}" target="{target}"> | ||
76 | - <xsl:for-each select="parameter"> | ||
77 | - <xsl:choose> | ||
78 | - <xsl:when test="count(./child::*) > 0 "> | ||
79 | - <parameter name="{@name}" units="{@units}" display_type="{@display_type}" xml:id="{@xml:id}"> | ||
80 | - <xsl:for-each select="component"> | ||
81 | - <component name="{@name}" xml:id="{@xml:id}"/> | ||
82 | - </xsl:for-each> | ||
83 | - </parameter> | ||
84 | - </xsl:when> | ||
85 | - <xsl:otherwise> | ||
86 | - <parameter name="{@name}" display_type="{@display_type}" units="{@units}" xml:id="{@xml:id}" /> | ||
87 | - </xsl:otherwise> | ||
88 | - </xsl:choose> | ||
89 | - </xsl:for-each> | ||
90 | - </dataset> | ||
91 | - | ||
92 | -</xsl:template> | ||
93 | -</xsl:stylesheet> | ||
94 | \ No newline at end of file | 0 | \ No newline at end of file |
php/XML/xml2all.xsl deleted
@@ -1,18 +0,0 @@ | @@ -1,18 +0,0 @@ | ||
1 | -<xsl:stylesheet version="1.0" | ||
2 | -xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
3 | -xmlns:php="http://php.net/xsl"> | ||
4 | - | ||
5 | -<xsl:output method="text"/> | ||
6 | - | ||
7 | -<xsl:template match="/timetable"> | ||
8 | -#Time Table generated by AMDA @ CDPP; | ||
9 | -#Description: <xsl:value-of select="description"/>; | ||
10 | -#Historic: <xsl:value-of select="history"/>; | ||
11 | -#Creation Date : <xsl:value-of select="created"/>; | ||
12 | -#<xsl:text> </xsl:text> | ||
13 | - <xsl:for-each select="intervals"> | ||
14 | - <xsl:value-of select="php:function('timeFormat', string(start))"/><xsl:text> </xsl:text><xsl:value-of select="php:function('timeFormat', string(stop))"/> | ||
15 | - <xsl:text> </xsl:text> | ||
16 | - </xsl:for-each> | ||
17 | -</xsl:template> | ||
18 | -</xsl:stylesheet> |
php/XML/xml2iso.xsl deleted
@@ -1,19 +0,0 @@ | @@ -1,19 +0,0 @@ | ||
1 | -<xsl:stylesheet version="1.0" | ||
2 | -xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
3 | -xmlns:php="http://php.net/xsl"> | ||
4 | - | ||
5 | -<xsl:output method="text"/> | ||
6 | - | ||
7 | -<xsl:template match="/timetable"> | ||
8 | -#Time Table generated by AMDA @ CDPP; | ||
9 | -#Name: <xsl:value-of select="name"/>; | ||
10 | -#Description: <xsl:value-of select="description"/>; | ||
11 | -#Historic: <xsl:value-of select="history"/>; | ||
12 | -#Creation Date : <xsl:value-of select="created"/>; | ||
13 | -#<xsl:text> </xsl:text> | ||
14 | - <xsl:for-each select="intervals"> | ||
15 | - <xsl:value-of select="start"/><xsl:text> </xsl:text><xsl:value-of select="stop"/> | ||
16 | - <xsl:text> </xsl:text> | ||
17 | - </xsl:for-each> | ||
18 | -</xsl:template> | ||
19 | -</xsl:stylesheet> |
php/XML/xml2vot.xsl deleted
@@ -1,40 +0,0 @@ | @@ -1,40 +0,0 @@ | ||
1 | -<xsl:stylesheet version="1.0" | ||
2 | -xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | ||
3 | - | ||
4 | -<xsl:output method="xml"/> | ||
5 | - | ||
6 | -<xsl:template match="/timetable"> | ||
7 | - <VOTABLE version='1.1'> | ||
8 | - <DESCRIPTION> | ||
9 | - Time Table generated by AMDA @ CDPP; | ||
10 | - Name: <xsl:value-of select="name"/>; | ||
11 | - Description: <xsl:value-of select="description"/>; | ||
12 | - Historic: <xsl:value-of select="history"/>; | ||
13 | - Creation Date : <xsl:value-of select="created"/>; | ||
14 | - </DESCRIPTION> | ||
15 | -<RESOURCE> | ||
16 | -<DESCRIPTION> | ||
17 | - AMDA @ CDPP | ||
18 | -</DESCRIPTION> | ||
19 | -<TABLE> | ||
20 | -<FIELD datatype='char' name='Start Time' ID='TimeIntervalStart' ucd='time.start'> | ||
21 | - <DESCRIPTION>time tag for beginning of interval</DESCRIPTION> | ||
22 | -</FIELD> | ||
23 | -<FIELD datatype='char' name='Stop Time' ID='TimeIntervalStop' ucd='time.stop'> | ||
24 | - <DESCRIPTION>time tag for end of interval</DESCRIPTION> | ||
25 | -</FIELD> | ||
26 | -<DATA> | ||
27 | - <TABLEDATA> | ||
28 | - <xsl:for-each select="intervals"> | ||
29 | - <TR> | ||
30 | - <TD><xsl:value-of select="start"/></TD> | ||
31 | - <TD><xsl:value-of select="stop"/></TD> | ||
32 | - </TR> | ||
33 | - </xsl:for-each> | ||
34 | - </TABLEDATA> | ||
35 | - </DATA> | ||
36 | - </TABLE> | ||
37 | - </RESOURCE> | ||
38 | - </VOTABLE> | ||
39 | -</xsl:template> | ||
40 | -</xsl:stylesheet> |
php/arguments.php deleted
@@ -1,345 +0,0 @@ | @@ -1,345 +0,0 @@ | ||
1 | -<?php | ||
2 | -/** | ||
3 | - * arguments.php | ||
4 | - * | ||
5 | - * @version $Id: arguments.php 2681 2014-11-28 17:08:06Z elena $ | ||
6 | - */ | ||
7 | - | ||
8 | -/* | ||
9 | - * info for spectra energies | ||
10 | - * | ||
11 | - */ | ||
12 | - | ||
13 | -function getInfo($dataSet, $infoName) | ||
14 | -{ | ||
15 | - $amda = new AmdaClient(); | ||
16 | - $info = $amda->getInfo($dataSet, $infoName); | ||
17 | - | ||
18 | - return explode(";",$info); | ||
19 | -} | ||
20 | - | ||
21 | -/* | ||
22 | - * special plotting arguments | ||
23 | - * | ||
24 | - */ | ||
25 | -function addPlottingSettings($option) { | ||
26 | - | ||
27 | - $argsXML = new DomDocument('1.0'); | ||
28 | - $argsXML->load(SettingsXML); | ||
29 | - $xPath = new domxpath($argsXML); | ||
30 | - | ||
31 | - if ($option) | ||
32 | - $plotGroups = array($option); | ||
33 | - else | ||
34 | - $plotGroups = array('Color', 'Symbol', 'Scale'); | ||
35 | - | ||
36 | - foreach ($plotGroups as $plotGroup) { | ||
37 | - $group = $xPath->query("//group[@name='".$plotGroup."']"); | ||
38 | - $groupChildren = $group->item(0)->getElementsByTagName('value'); | ||
39 | - $args = array(); | ||
40 | - $number = 0; | ||
41 | - foreach ($groupChildren as $groupChild) { | ||
42 | - if ($plotGroup == "Symbol") $args[] = array("arg" => $number, "value" => $groupChild->nodeValue); | ||
43 | - else $args[] = array("arg" => $groupChild->nodeValue, "value" => $groupChild->nodeValue); | ||
44 | - $number++; | ||
45 | - } | ||
46 | - $grp[] = array("groupS" => $plotGroup, "args" => $args); | ||
47 | - } | ||
48 | - | ||
49 | - return $grp; | ||
50 | -} | ||
51 | - | ||
52 | - | ||
53 | -require_once 'config.php'; | ||
54 | - | ||
55 | -define('USERWSDIR', USERPATH."/".$_GET['sessionID']."/WS/"); | ||
56 | - | ||
57 | -$RefFrame = array("GSE", "GSM", "SM"); | ||
58 | -$OrbitPresentation = array("LINE", "TICKS", "CYL"); | ||
59 | - | ||
60 | -$paramID = $_GET['paramID']; | ||
61 | -$isPlot = $_GET['application'] == 'plot' ? true : false; | ||
62 | - | ||
63 | -// convert user WS | ||
64 | - if (!$paramID) { | ||
65 | - $paramID = $argv[1]; | ||
66 | - $isPlot = true; | ||
67 | - } | ||
68 | - | ||
69 | - // to correct 'restricted' parameters | ||
70 | - if (strpos($paramID, restricted) !== false) { | ||
71 | - $paramID = str_replace(restricted,"",$paramID); | ||
72 | - } | ||
73 | -// define('ArgumentsXML', Param.'Args/paramArguments.xml'); | ||
74 | -define('SettingsXML', Param.'Args/paramPlotSettings.xml'); | ||
75 | - | ||
76 | -$noargs = array('success' => false); | ||
77 | - | ||
78 | -// this is WS param => plot settings | ||
79 | -if (strncmp(strtolower($paramID), 'ws_', 3) == 0) { | ||
80 | - $grp = addPlottingSettings(); | ||
81 | - exit(json_encode($grp)); | ||
82 | -} | ||
83 | -// this is WSD param => plot settings if SIZE = 1 | ||
84 | -if (strncmp(strtolower($paramID), 'wsd_', 4) == 0) { | ||
85 | - $infoMgr = new ParamsInfoMgr(); | ||
86 | - $info = $infoMgr->GetParamInfo($paramID); | ||
87 | - | ||
88 | - if (!$info || $info['success'] == false) | ||
89 | - exit(json_encode($noargs)); | ||
90 | - | ||
91 | - if ($info['infos']['size'] == 1) { | ||
92 | - $grp = addPlottingSettings(); | ||
93 | - exit(json_encode($grp)); | ||
94 | - } | ||
95 | - exit(json_encode($noargs)); | ||
96 | -} | ||
97 | -// this is SIMU param => make param | ||
98 | -if ((strncmp(strtolower($paramID), "impex___", 8) == 0 )||(strncmp(strtolower($paramID), "spase___", 8) == 0 )) { | ||
99 | - if ((strncmp(strtolower($paramID), "impex___lesia_", 14) == 0 )||(strncmp(strtolower($paramID), "spase___IMPEX_NumericalOutput_lesia_", 36) == 0 )) {} | ||
100 | - else { | ||
101 | - $mySimuArgsMgr = new SimuArgsMgr(); | ||
102 | - $mySimuArgsMgr->init($paramID); | ||
103 | - $grp = $mySimuArgsMgr->makeSimuArgs(); | ||
104 | - if ($grp) | ||
105 | - exit(json_encode($grp)); | ||
106 | - else exit(); | ||
107 | - } | ||
108 | -} | ||
109 | - | ||
110 | -// themis_cesr | ||
111 | -$objToTest = str_replace("_", " ", $paramID); | ||
112 | -if (sscanf($objToTest, "th%s pe%s %s", $X, $mode, $property) == 3){ | ||
113 | - switch ($property) { | ||
114 | - case "n" : $grp = addPlottingSettings(); | ||
115 | - exit(json_encode($grp)); | ||
116 | - case "v" : foreach ($RefFrame as $frame) $frame_args[] = array("arg" => $frame); | ||
117 | - $grp[] = array("group" => "RefFrame", "args" => $frame_args); | ||
118 | - exit(json_encode($grp)); | ||
119 | - case "t" :$grp = addPlottingSettings(); | ||
120 | - exit(json_encode($grp)); | ||
121 | - case "sp" : $grp = addPlottingSettings(); | ||
122 | - $args[] = array("arg" => "spectrogram"); | ||
123 | - for ($i = 0; $i < 32; $i++) { | ||
124 | - $args[] = array("arg" => $i+1, "value" => $i+1); | ||
125 | - } | ||
126 | - $grp[] = array("group" => "Channel", "args" => $args); | ||
127 | - exit(json_encode($grp)); | ||
128 | - } | ||
129 | -} | ||
130 | - | ||
131 | -// Remote Data | ||
132 | -//TODO add method of paramInfoMgr class | ||
133 | - $nameXml = RemoteData."PARAMS/".$paramID.".xml"; | ||
134 | - $isRemote = file_exists($nameXml); | ||
135 | - if ($isRemote) { | ||
136 | - $infoDom = new DomDocument("1.0"); | ||
137 | - if (!$infoDom->load($nameXml)) | ||
138 | - exit(); | ||
139 | - $size = $infoDom->getElementsByTagName('DIMENSION')->item(0)->nodeValue; | ||
140 | - if ($size == 1) { | ||
141 | - $grp = addPlottingSettings(); | ||
142 | - exit(json_encode($grp)); | ||
143 | - } | ||
144 | - | ||
145 | - $dispay_type = $infoDom->getElementsByTagName('DISPLAY_TYPE')->item(0)->nodeValue; | ||
146 | - | ||
147 | - exit(); | ||
148 | - } | ||
149 | - | ||
150 | - | ||
151 | -$infoMgr = new ParamsInfoMgr(); | ||
152 | -$info = $infoMgr->GetParamInfo($paramID); | ||
153 | - | ||
154 | -if (sscanf($paramID,"%[^'('](%d:%d)",$par,$cstart,$cstop) == 3) | ||
155 | -{ | ||
156 | - $isComponent = false; | ||
157 | -} | ||
158 | -else if (sscanf($paramID,"%[^'('](%d)",$par,$cstart) == 2) | ||
159 | -{ | ||
160 | - $isComponent = true; | ||
161 | -} | ||
162 | -else { | ||
163 | - $par = $paramID; | ||
164 | - $isComponent = false; | ||
165 | -} | ||
166 | - | ||
167 | -if (!$info['success'] && $isComponent) { | ||
168 | - // component | ||
169 | - $size = 1; | ||
170 | -} | ||
171 | -else { | ||
172 | - $codeinfo = $info['codeinfos']; | ||
173 | - $ddinfo = $info['ddinfos']; | ||
174 | - $size = $codeinfo ? $codeinfo['size'] : $ddinfo['parameter']['size']; | ||
175 | - $display_type = $ddinfo['parameter']['display_type']; | ||
176 | - $validmin = $codeinfo ? $codeinfo['validmin'] : -1; | ||
177 | -} | ||
178 | - | ||
179 | -switch ($size) { | ||
180 | - // scalar - so color + symbol for all | ||
181 | - case 1 : | ||
182 | - $grp = addPlottingSettings(); | ||
183 | - break; | ||
184 | - case 3 : | ||
185 | - // component | ||
186 | - if ($isComponent) $grp = addPlottingSettings(); | ||
187 | - if ($validmin === "0") $grp = addPlottingSettings('Scale'); | ||
188 | - | ||
189 | - if ($codeinfo && $codeinfo['frame'] && strtolower($codeinfo['frame']) == 'gse') { | ||
190 | - foreach ($RefFrame as $frame) $frame_args[] = array("arg" => $frame); | ||
191 | - $grp[] = array("group" => "RefFrame", "args" => $frame_args); | ||
192 | - } | ||
193 | - | ||
194 | - if ($codeinfo && $codeinfo['plottype'] && strtolower($codeinfo['plottype']) == 'orbit' && !$isComponent) { | ||
195 | - foreach ($OrbitPresentation as $frame) $type_args[] = array("arg" => $frame); | ||
196 | - $grp[] = array("group" => "OrbitPresentation", "args" => $type_args); | ||
197 | - } | ||
198 | - | ||
199 | - if ($ddinfo && $ddinfo['parameter']['display_type'] && $ddinfo['parameter']['display_type'] == 'orbit' && !$isComponent) { | ||
200 | - foreach ($OrbitPresentation as $frame) $type_args[] = array("arg" => $frame); | ||
201 | - $grp[] = array("group" => "OrbitPresentation", "args" => $type_args); | ||
202 | - } | ||
203 | - | ||
204 | - break; | ||
205 | - | ||
206 | - default: | ||
207 | - if ($display_type == 'spectrogram' || $display_type == 'stack_plot') { | ||
208 | - if ($isPlot) $args[] = array("arg" => $display_type); | ||
209 | - | ||
210 | - // error_log( $ddinfo['dataset']['id']." ".$codeinfo['energychannel'].PHP_EOL,1, email); | ||
211 | - $info = getInfo($ddinfo['dataset']['id'],$codeinfo['energychannel']); | ||
212 | - $args_bckgrd[] = array("arg" => "0", "value" => "none"); | ||
213 | - for ($i = 0; $i < $size; $i++) { | ||
214 | - $args[] = array("arg" => strval($i+1), "value" => $info[$i]); | ||
215 | - $args_bckgrd[] = array("arg" => strval($i+1), "value" => $info[$i]); | ||
216 | - } | ||
217 | - // automatic generated args - simple case | ||
218 | - if ($isPlot) $grp = addPlottingSettings(); | ||
219 | - $grp[] = array("group" => "Channel", "args" => $args); | ||
220 | - | ||
221 | - if ($display_type == 'spectrogram' && $isPlot) | ||
222 | - { | ||
223 | - $grp[] = array("group" => "backgrdChan", "args" => $args_bckgrd); | ||
224 | - $grp[] = array("group" => "backgrdVal", "args" => array("value" => "0")); | ||
225 | - $grp[] = array("group" => "minCount", "args" => array("value" => "0")); | ||
226 | - $grp[] = array("group" => "maxCount", "args" => array("value" => "0")); | ||
227 | - } | ||
228 | - } | ||
229 | - | ||
230 | -} | ||
231 | - | ||
232 | - | ||
233 | -$paramArgsFile = Param.'Args/'.$par.'.xml'; | ||
234 | -if (!file_exists($paramArgsFile)) exit(json_encode($grp)); | ||
235 | - | ||
236 | - | ||
237 | -$grp = array(); | ||
238 | - | ||
239 | -// specific parameter settings if exists | ||
240 | - | ||
241 | -$paramXML = new DomDocument('1.0'); | ||
242 | - | ||
243 | -$paramXML->load($paramArgsFile); | ||
244 | -// arguments | ||
245 | -$specialArgs = $paramXML->getElementsByTagName('specialArgs'); | ||
246 | -$paramArgs = $paramXML->getElementsByTagName('args'); | ||
247 | - | ||
248 | -if ($specialArgs->length > 0) { | ||
249 | - //spectra => tables | ||
250 | - $specialGroups = $specialArgs->item(0)->getElementsByTagName('group'); | ||
251 | - | ||
252 | - if ($specialGroups->length > 0) { | ||
253 | - | ||
254 | - foreach ($specialGroups as $spGroup) { | ||
255 | - | ||
256 | - $group = $spGroup->getAttribute('name'); | ||
257 | - if (!$isPlot && $group == 'anode' && $specialGroups->length > 1) | ||
258 | - continue; | ||
259 | - $groupType = $spGroup->getAttribute('type'); | ||
260 | - $units = $spGroup->getAttribute('units'); | ||
261 | - | ||
262 | - if ($groupType != 'multi') { | ||
263 | - $argMax = $spGroup->getAttribute('number'); | ||
264 | - $argAll = $spGroup->getElementsByTagName('value'); | ||
265 | - | ||
266 | - $args = array(); | ||
267 | - | ||
268 | - if ($argAll->length > 0) { | ||
269 | - if ($group == 'anode') $args[] = array("arg" => 'all', "value" => "all"); | ||
270 | - | ||
271 | - for ($i = 0; $i < $argAll->length; $i++) { | ||
272 | - $args[] = array("arg" => $i+1, "value" => $argAll->item($i)->nodeValue); | ||
273 | - } | ||
274 | - } | ||
275 | - // create manually | ||
276 | - else { | ||
277 | - if ($group == 'anode') $args[] = array("arg" => 'all'); | ||
278 | - for ($i = 0; $i < $argMax; $i++) { | ||
279 | - $args[] = array("arg" => $i+1); | ||
280 | - } | ||
281 | - } | ||
282 | - // energy or angle (3D) | ||
283 | - $groupType = $group == "energy" ? "groupE" : "group"; | ||
284 | - $grp[] = array($groupType => $group, "units" => $units, "args" => $args); | ||
285 | - } | ||
286 | - //variable time table | ||
287 | - else { | ||
288 | - $args = array(); | ||
289 | - | ||
290 | - $args[] = array("arg" => 'energyMin', "value" => $spGroup->getAttribute('emin')); | ||
291 | - $args[] = array("arg" => 'energyMax', "value" => $spGroup->getAttribute('emax')); | ||
292 | - | ||
293 | - $grp[] = array("groupEmulti" => $group, "units" => $units, "args" => $args); | ||
294 | - } | ||
295 | - } | ||
296 | - | ||
297 | - } | ||
298 | -} | ||
299 | - | ||
300 | -if ($paramArgs->length > 0) { | ||
301 | - // special args | ||
302 | - $argSpecial = $paramArgs->item(0)->getElementsByTagName('group'); | ||
303 | - | ||
304 | - if ($argSpecial->length > 0) { | ||
305 | - foreach ($argSpecial as $group) { | ||
306 | - if (!$isPlot && $group->getAttribute('name') == 'elevationAsTime') continue; | ||
307 | - $args = array(); | ||
308 | - $groupChildren = $group->getElementsByTagName('value'); | ||
309 | - if ($groupChildren->length > 0) { | ||
310 | - $hasArgs = $group->getAttribute('args'); | ||
311 | - $num = 0; | ||
312 | - $N_args = $groupChildren->length; | ||
313 | - foreach ($groupChildren as $child) { | ||
314 | - $num++; | ||
315 | - if ($hasArgs) { | ||
316 | - if ($hasArgs != 'reverse') { | ||
317 | - $argValue = $child->nodeValue; | ||
318 | - if (!$isPlot && $argValue == 'spectrogram') $argValue = 'all'; | ||
319 | - $args[] = array("arg" => $num, "value" => $argValue); | ||
320 | - } | ||
321 | - else { | ||
322 | - $args[] = array("arg" => $N_args - $num, "value" => $child->nodeValue); | ||
323 | - } | ||
324 | - } | ||
325 | - else { | ||
326 | - $args[] = array("arg" => $child->nodeValue, "value" => $child->nodeValue); | ||
327 | - } | ||
328 | - } | ||
329 | - } // create manually | ||
330 | - else { | ||
331 | - $args[] = array("arg" => "all"); | ||
332 | - $argMax = $group->getAttribute('number'); | ||
333 | - for ($i = 0; $i < $argMax; $i++) { | ||
334 | - $args[] = array("arg" => $i+1); | ||
335 | - } | ||
336 | - } | ||
337 | - $grp[] = array("group" => $group->getAttribute('name'), "units" => $group->getAttribute('units'), "args" => $args); | ||
338 | - } | ||
339 | - } | ||
340 | - | ||
341 | - } | ||
342 | - | ||
343 | - exit(json_encode($grp)); | ||
344 | - | ||
345 | -?> | ||
346 | \ No newline at end of file | 0 | \ No newline at end of file |
php/firephp/FirePHP.class.php deleted
@@ -1,1784 +0,0 @@ | @@ -1,1784 +0,0 @@ | ||
1 | -<?php | ||
2 | -/** | ||
3 | - * *** BEGIN LICENSE BLOCK ***** | ||
4 | - * | ||
5 | - * This file is part of FirePHP (http://www.firephp.org/). | ||
6 | - * | ||
7 | - * Software License Agreement (New BSD License) | ||
8 | - * | ||
9 | - * Copyright (c) 2006-2010, Christoph Dorn | ||
10 | - * All rights reserved. | ||
11 | - * | ||
12 | - * Redistribution and use in source and binary forms, with or without modification, | ||
13 | - * are permitted provided that the following conditions are met: | ||
14 | - * | ||
15 | - * * Redistributions of source code must retain the above copyright notice, | ||
16 | - * this list of conditions and the following disclaimer. | ||
17 | - * | ||
18 | - * * Redistributions in binary form must reproduce the above copyright notice, | ||
19 | - * this list of conditions and the following disclaimer in the documentation | ||
20 | - * and/or other materials provided with the distribution. | ||
21 | - * | ||
22 | - * * Neither the name of Christoph Dorn nor the names of its | ||
23 | - * contributors may be used to endorse or promote products derived from this | ||
24 | - * software without specific prior written permission. | ||
25 | - * | ||
26 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
27 | - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
28 | - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
29 | - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
30 | - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
31 | - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
32 | - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
33 | - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
34 | - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
35 | - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
36 | - * | ||
37 | - * ***** END LICENSE BLOCK ***** | ||
38 | - * | ||
39 | - * @copyright Copyright (C) 2007-2009 Christoph Dorn | ||
40 | - * @author Christoph Dorn <christoph@christophdorn.com> | ||
41 | - * @license http://www.opensource.org/licenses/bsd-license.php | ||
42 | - * @package FirePHPCore | ||
43 | - */ | ||
44 | - | ||
45 | -/** | ||
46 | - * @see http://code.google.com/p/firephp/issues/detail?id=112 | ||
47 | - */ | ||
48 | -if (!defined('E_STRICT')) { | ||
49 | - define('E_STRICT', 2048); | ||
50 | -} | ||
51 | -if (!defined('E_RECOVERABLE_ERROR')) { | ||
52 | - define('E_RECOVERABLE_ERROR', 4096); | ||
53 | -} | ||
54 | -if (!defined('E_DEPRECATED')) { | ||
55 | - define('E_DEPRECATED', 8192); | ||
56 | -} | ||
57 | -if (!defined('E_USER_DEPRECATED')) { | ||
58 | - define('E_USER_DEPRECATED', 16384); | ||
59 | -} | ||
60 | - | ||
61 | -/** | ||
62 | - * Sends the given data to the FirePHP Firefox Extension. | ||
63 | - * The data can be displayed in the Firebug Console or in the | ||
64 | - * "Server" request tab. | ||
65 | - * | ||
66 | - * For more information see: http://www.firephp.org/ | ||
67 | - * | ||
68 | - * @copyright Copyright (C) 2007-2009 Christoph Dorn | ||
69 | - * @author Christoph Dorn <christoph@christophdorn.com> | ||
70 | - * @license http://www.opensource.org/licenses/bsd-license.php | ||
71 | - * @package FirePHPCore | ||
72 | - */ | ||
73 | -class FirePHP { | ||
74 | - | ||
75 | - /** | ||
76 | - * FirePHP version | ||
77 | - * | ||
78 | - * @var string | ||
79 | - */ | ||
80 | - const VERSION = '0.3'; // @pinf replace '0.3' with '%%package.version%%' | ||
81 | - | ||
82 | - /** | ||
83 | - * Firebug LOG level | ||
84 | - * | ||
85 | - * Logs a message to firebug console. | ||
86 | - * | ||
87 | - * @var string | ||
88 | - */ | ||
89 | - const LOG = 'LOG'; | ||
90 | - | ||
91 | - /** | ||
92 | - * Firebug INFO level | ||
93 | - * | ||
94 | - * Logs a message to firebug console and displays an info icon before the message. | ||
95 | - * | ||
96 | - * @var string | ||
97 | - */ | ||
98 | - const INFO = 'INFO'; | ||
99 | - | ||
100 | - /** | ||
101 | - * Firebug WARN level | ||
102 | - * | ||
103 | - * Logs a message to firebug console, displays an warning icon before the message and colors the line turquoise. | ||
104 | - * | ||
105 | - * @var string | ||
106 | - */ | ||
107 | - const WARN = 'WARN'; | ||
108 | - | ||
109 | - /** | ||
110 | - * Firebug ERROR level | ||
111 | - * | ||
112 | - * Logs a message to firebug console, displays an error icon before the message and colors the line yellow. Also increments the firebug error count. | ||
113 | - * | ||
114 | - * @var string | ||
115 | - */ | ||
116 | - const ERROR = 'ERROR'; | ||
117 | - | ||
118 | - /** | ||
119 | - * Dumps a variable to firebug's server panel | ||
120 | - * | ||
121 | - * @var string | ||
122 | - */ | ||
123 | - const DUMP = 'DUMP'; | ||
124 | - | ||
125 | - /** | ||
126 | - * Displays a stack trace in firebug console | ||
127 | - * | ||
128 | - * @var string | ||
129 | - */ | ||
130 | - const TRACE = 'TRACE'; | ||
131 | - | ||
132 | - /** | ||
133 | - * Displays an exception in firebug console | ||
134 | - * | ||
135 | - * Increments the firebug error count. | ||
136 | - * | ||
137 | - * @var string | ||
138 | - */ | ||
139 | - const EXCEPTION = 'EXCEPTION'; | ||
140 | - | ||
141 | - /** | ||
142 | - * Displays an table in firebug console | ||
143 | - * | ||
144 | - * @var string | ||
145 | - */ | ||
146 | - const TABLE = 'TABLE'; | ||
147 | - | ||
148 | - /** | ||
149 | - * Starts a group in firebug console | ||
150 | - * | ||
151 | - * @var string | ||
152 | - */ | ||
153 | - const GROUP_START = 'GROUP_START'; | ||
154 | - | ||
155 | - /** | ||
156 | - * Ends a group in firebug console | ||
157 | - * | ||
158 | - * @var string | ||
159 | - */ | ||
160 | - const GROUP_END = 'GROUP_END'; | ||
161 | - | ||
162 | - /** | ||
163 | - * Singleton instance of FirePHP | ||
164 | - * | ||
165 | - * @var FirePHP | ||
166 | - */ | ||
167 | - protected static $instance = null; | ||
168 | - | ||
169 | - /** | ||
170 | - * Flag whether we are logging from within the exception handler | ||
171 | - * | ||
172 | - * @var boolean | ||
173 | - */ | ||
174 | - protected $inExceptionHandler = false; | ||
175 | - | ||
176 | - /** | ||
177 | - * Flag whether to throw PHP errors that have been converted to ErrorExceptions | ||
178 | - * | ||
179 | - * @var boolean | ||
180 | - */ | ||
181 | - protected $throwErrorExceptions = true; | ||
182 | - | ||
183 | - /** | ||
184 | - * Flag whether to convert PHP assertion errors to Exceptions | ||
185 | - * | ||
186 | - * @var boolean | ||
187 | - */ | ||
188 | - protected $convertAssertionErrorsToExceptions = true; | ||
189 | - | ||
190 | - /** | ||
191 | - * Flag whether to throw PHP assertion errors that have been converted to Exceptions | ||
192 | - * | ||
193 | - * @var boolean | ||
194 | - */ | ||
195 | - protected $throwAssertionExceptions = false; | ||
196 | - | ||
197 | - /** | ||
198 | - * Wildfire protocol message index | ||
199 | - * | ||
200 | - * @var int | ||
201 | - */ | ||
202 | - protected $messageIndex = 1; | ||
203 | - | ||
204 | - /** | ||
205 | - * Options for the library | ||
206 | - * | ||
207 | - * @var array | ||
208 | - */ | ||
209 | - protected $options = array('maxDepth' => 10, | ||
210 | - 'maxObjectDepth' => 5, | ||
211 | - 'maxArrayDepth' => 5, | ||
212 | - 'useNativeJsonEncode' => true, | ||
213 | - 'includeLineNumbers' => true); | ||
214 | - | ||
215 | - /** | ||
216 | - * Filters used to exclude object members when encoding | ||
217 | - * | ||
218 | - * @var array | ||
219 | - */ | ||
220 | - protected $objectFilters = array( | ||
221 | - 'firephp' => array('objectStack', 'instance', 'json_objectStack'), | ||
222 | - 'firephp_test_class' => array('objectStack', 'instance', 'json_objectStack') | ||
223 | - ); | ||
224 | - | ||
225 | - /** | ||
226 | - * A stack of objects used to detect recursion during object encoding | ||
227 | - * | ||
228 | - * @var object | ||
229 | - */ | ||
230 | - protected $objectStack = array(); | ||
231 | - | ||
232 | - /** | ||
233 | - * Flag to enable/disable logging | ||
234 | - * | ||
235 | - * @var boolean | ||
236 | - */ | ||
237 | - protected $enabled = true; | ||
238 | - | ||
239 | - /** | ||
240 | - * The insight console to log to if applicable | ||
241 | - * | ||
242 | - * @var object | ||
243 | - */ | ||
244 | - protected $logToInsightConsole = null; | ||
245 | - | ||
246 | - /** | ||
247 | - * When the object gets serialized only include specific object members. | ||
248 | - * | ||
249 | - * @return array | ||
250 | - */ | ||
251 | - public function __sleep() | ||
252 | - { | ||
253 | - return array('options','objectFilters','enabled'); | ||
254 | - } | ||
255 | - | ||
256 | - /** | ||
257 | - * Gets singleton instance of FirePHP | ||
258 | - * | ||
259 | - * @param boolean $AutoCreate | ||
260 | - * @return FirePHP | ||
261 | - */ | ||
262 | - public static function getInstance($AutoCreate = false) | ||
263 | - { | ||
264 | - if ($AutoCreate===true && !self::$instance) { | ||
265 | - self::init(); | ||
266 | - } | ||
267 | - return self::$instance; | ||
268 | - } | ||
269 | - | ||
270 | - /** | ||
271 | - * Creates FirePHP object and stores it for singleton access | ||
272 | - * | ||
273 | - * @return FirePHP | ||
274 | - */ | ||
275 | - public static function init() | ||
276 | - { | ||
277 | - return self::setInstance(new self()); | ||
278 | - } | ||
279 | - | ||
280 | - /** | ||
281 | - * Set the instance of the FirePHP singleton | ||
282 | - * | ||
283 | - * @param FirePHP $instance The FirePHP object instance | ||
284 | - * @return FirePHP | ||
285 | - */ | ||
286 | - public static function setInstance($instance) | ||
287 | - { | ||
288 | - return self::$instance = $instance; | ||
289 | - } | ||
290 | - | ||
291 | - /** | ||
292 | - * Set an Insight console to direct all logging calls to | ||
293 | - * | ||
294 | - * @param object $console The console object to log to | ||
295 | - * @return void | ||
296 | - */ | ||
297 | - public function setLogToInsightConsole($console) | ||
298 | - { | ||
299 | - if(is_string($console)) { | ||
300 | - if(get_class($this)!='FirePHP_Insight' && !is_subclass_of($this, 'FirePHP_Insight')) { | ||
301 | - throw new Exception('FirePHP instance not an instance or subclass of FirePHP_Insight!'); | ||
302 | - } | ||
303 | - $this->logToInsightConsole = $this->to('request')->console($console); | ||
304 | - } else { | ||
305 | - $this->logToInsightConsole = $console; | ||
306 | - } | ||
307 | - } | ||
308 | - | ||
309 | - /** | ||
310 | - * Enable and disable logging to Firebug | ||
311 | - * | ||
312 | - * @param boolean $Enabled TRUE to enable, FALSE to disable | ||
313 | - * @return void | ||
314 | - */ | ||
315 | - public function setEnabled($Enabled) | ||
316 | - { | ||
317 | - $this->enabled = $Enabled; | ||
318 | - } | ||
319 | - | ||
320 | - /** | ||
321 | - * Check if logging is enabled | ||
322 | - * | ||
323 | - * @return boolean TRUE if enabled | ||
324 | - */ | ||
325 | - public function getEnabled() | ||
326 | - { | ||
327 | - return $this->enabled; | ||
328 | - } | ||
329 | - | ||
330 | - /** | ||
331 | - * Specify a filter to be used when encoding an object | ||
332 | - * | ||
333 | - * Filters are used to exclude object members. | ||
334 | - * | ||
335 | - * @param string $Class The class name of the object | ||
336 | - * @param array $Filter An array of members to exclude | ||
337 | - * @return void | ||
338 | - */ | ||
339 | - public function setObjectFilter($Class, $Filter) | ||
340 | - { | ||
341 | - $this->objectFilters[strtolower($Class)] = $Filter; | ||
342 | - } | ||
343 | - | ||
344 | - /** | ||
345 | - * Set some options for the library | ||
346 | - * | ||
347 | - * Options: | ||
348 | - * - maxDepth: The maximum depth to traverse (default: 10) | ||
349 | - * - maxObjectDepth: The maximum depth to traverse objects (default: 5) | ||
350 | - * - maxArrayDepth: The maximum depth to traverse arrays (default: 5) | ||
351 | - * - useNativeJsonEncode: If true will use json_encode() (default: true) | ||
352 | - * - includeLineNumbers: If true will include line numbers and filenames (default: true) | ||
353 | - * | ||
354 | - * @param array $Options The options to be set | ||
355 | - * @return void | ||
356 | - */ | ||
357 | - public function setOptions($Options) | ||
358 | - { | ||
359 | - $this->options = array_merge($this->options,$Options); | ||
360 | - } | ||
361 | - | ||
362 | - /** | ||
363 | - * Get options from the library | ||
364 | - * | ||
365 | - * @return array The currently set options | ||
366 | - */ | ||
367 | - public function getOptions() | ||
368 | - { | ||
369 | - return $this->options; | ||
370 | - } | ||
371 | - | ||
372 | - /** | ||
373 | - * Set an option for the library | ||
374 | - * | ||
375 | - * @param string $Name | ||
376 | - * @param mixed $Value | ||
377 | - * @throws Exception | ||
378 | - * @return void | ||
379 | - */ | ||
380 | - public function setOption($Name, $Value) | ||
381 | - { | ||
382 | - if (!isset($this->options[$Name])) { | ||
383 | - throw $this->newException('Unknown option: ' . $Name); | ||
384 | - } | ||
385 | - $this->options[$Name] = $Value; | ||
386 | - } | ||
387 | - | ||
388 | - /** | ||
389 | - * Get an option from the library | ||
390 | - * | ||
391 | - * @param string $Name | ||
392 | - * @throws Exception | ||
393 | - * @return mixed | ||
394 | - */ | ||
395 | - public function getOption($Name) | ||
396 | - { | ||
397 | - if (!isset($this->options[$Name])) { | ||
398 | - throw $this->newException('Unknown option: ' . $Name); | ||
399 | - } | ||
400 | - return $this->options[$Name]; | ||
401 | - } | ||
402 | - | ||
403 | - /** | ||
404 | - * Register FirePHP as your error handler | ||
405 | - * | ||
406 | - * Will throw exceptions for each php error. | ||
407 | - * | ||
408 | - * @return mixed Returns a string containing the previously defined error handler (if any) | ||
409 | - */ | ||
410 | - public function registerErrorHandler($throwErrorExceptions = false) | ||
411 | - { | ||
412 | - //NOTE: The following errors will not be caught by this error handler: | ||
413 | - // E_ERROR, E_PARSE, E_CORE_ERROR, | ||
414 | - // E_CORE_WARNING, E_COMPILE_ERROR, | ||
415 | - // E_COMPILE_WARNING, E_STRICT | ||
416 | - | ||
417 | - $this->throwErrorExceptions = $throwErrorExceptions; | ||
418 | - | ||
419 | - return set_error_handler(array($this,'errorHandler')); | ||
420 | - } | ||
421 | - | ||
422 | - /** | ||
423 | - * FirePHP's error handler | ||
424 | - * | ||
425 | - * Throws exception for each php error that will occur. | ||
426 | - * | ||
427 | - * @param int $errno | ||
428 | - * @param string $errstr | ||
429 | - * @param string $errfile | ||
430 | - * @param int $errline | ||
431 | - * @param array $errcontext | ||
432 | - */ | ||
433 | - public function errorHandler($errno, $errstr, $errfile, $errline, $errcontext) | ||
434 | - { | ||
435 | - // Don't throw exception if error reporting is switched off | ||
436 | - if (error_reporting() == 0) { | ||
437 | - return; | ||
438 | - } | ||
439 | - // Only throw exceptions for errors we are asking for | ||
440 | - if (error_reporting() & $errno) { | ||
441 | - | ||
442 | - $exception = new ErrorException($errstr, 0, $errno, $errfile, $errline); | ||
443 | - if ($this->throwErrorExceptions) { | ||
444 | - throw $exception; | ||
445 | - } else { | ||
446 | - $this->fb($exception); | ||
447 | - } | ||
448 | - } | ||
449 | - } | ||
450 | - | ||
451 | - /** | ||
452 | - * Register FirePHP as your exception handler | ||
453 | - * | ||
454 | - * @return mixed Returns the name of the previously defined exception handler, | ||
455 | - * or NULL on error. | ||
456 | - * If no previous handler was defined, NULL is also returned. | ||
457 | - */ | ||
458 | - public function registerExceptionHandler() | ||
459 | - { | ||
460 | - return set_exception_handler(array($this,'exceptionHandler')); | ||
461 | - } | ||
462 | - | ||
463 | - /** | ||
464 | - * FirePHP's exception handler | ||
465 | - * | ||
466 | - * Logs all exceptions to your firebug console and then stops the script. | ||
467 | - * | ||
468 | - * @param Exception $Exception | ||
469 | - * @throws Exception | ||
470 | - */ | ||
471 | - function exceptionHandler($Exception) | ||
472 | - { | ||
473 | - | ||
474 | - $this->inExceptionHandler = true; | ||
475 | - | ||
476 | - header('HTTP/1.1 500 Internal Server Error'); | ||
477 | - | ||
478 | - try { | ||
479 | - $this->fb($Exception); | ||
480 | - } catch (Exception $e) { | ||
481 | - echo 'We had an exception: ' . $e; | ||
482 | - } | ||
483 | - $this->inExceptionHandler = false; | ||
484 | - } | ||
485 | - | ||
486 | - /** | ||
487 | - * Register FirePHP driver as your assert callback | ||
488 | - * | ||
489 | - * @param boolean $convertAssertionErrorsToExceptions | ||
490 | - * @param boolean $throwAssertionExceptions | ||
491 | - * @return mixed Returns the original setting or FALSE on errors | ||
492 | - */ | ||
493 | - public function registerAssertionHandler($convertAssertionErrorsToExceptions = true, $throwAssertionExceptions = false) | ||
494 | - { | ||
495 | - $this->convertAssertionErrorsToExceptions = $convertAssertionErrorsToExceptions; | ||
496 | - $this->throwAssertionExceptions = $throwAssertionExceptions; | ||
497 | - | ||
498 | - if ($throwAssertionExceptions && !$convertAssertionErrorsToExceptions) { | ||
499 | - throw $this->newException('Cannot throw assertion exceptions as assertion errors are not being converted to exceptions!'); | ||
500 | - } | ||
501 | - | ||
502 | - return assert_options(ASSERT_CALLBACK, array($this, 'assertionHandler')); | ||
503 | - } | ||
504 | - | ||
505 | - /** | ||
506 | - * FirePHP's assertion handler | ||
507 | - * | ||
508 | - * Logs all assertions to your firebug console and then stops the script. | ||
509 | - * | ||
510 | - * @param string $file File source of assertion | ||
511 | - * @param int $line Line source of assertion | ||
512 | - * @param mixed $code Assertion code | ||
513 | - */ | ||
514 | - public function assertionHandler($file, $line, $code) | ||
515 | - { | ||
516 | - if ($this->convertAssertionErrorsToExceptions) { | ||
517 | - | ||
518 | - $exception = new ErrorException('Assertion Failed - Code[ '.$code.' ]', 0, null, $file, $line); | ||
519 | - | ||
520 | - if ($this->throwAssertionExceptions) { | ||
521 | - throw $exception; | ||
522 | - } else { | ||
523 | - $this->fb($exception); | ||
524 | - } | ||
525 | - | ||
526 | - } else { | ||
527 | - $this->fb($code, 'Assertion Failed', FirePHP::ERROR, array('File'=>$file,'Line'=>$line)); | ||
528 | - } | ||
529 | - } | ||
530 | - | ||
531 | - /** | ||
532 | - * Start a group for following messages. | ||
533 | - * | ||
534 | - * Options: | ||
535 | - * Collapsed: [true|false] | ||
536 | - * Color: [#RRGGBB|ColorName] | ||
537 | - * | ||
538 | - * @param string $Name | ||
539 | - * @param array $Options OPTIONAL Instructions on how to log the group | ||
540 | - * @return true | ||
541 | - * @throws Exception | ||
542 | - */ | ||
543 | - public function group($Name, $Options = null) | ||
544 | - { | ||
545 | - | ||
546 | - if (!$Name) { | ||
547 | - throw $this->newException('You must specify a label for the group!'); | ||
548 | - } | ||
549 | - | ||
550 | - if ($Options) { | ||
551 | - if (!is_array($Options)) { | ||
552 | - throw $this->newException('Options must be defined as an array!'); | ||
553 | - } | ||
554 | - if (array_key_exists('Collapsed', $Options)) { | ||
555 | - $Options['Collapsed'] = ($Options['Collapsed'])?'true':'false'; | ||
556 | - } | ||
557 | - } | ||
558 | - | ||
559 | - return $this->fb(null, $Name, FirePHP::GROUP_START, $Options); | ||
560 | - } | ||
561 | - | ||
562 | - /** | ||
563 | - * Ends a group you have started before | ||
564 | - * | ||
565 | - * @return true | ||
566 | - * @throws Exception | ||
567 | - */ | ||
568 | - public function groupEnd() | ||
569 | - { | ||
570 | - return $this->fb(null, null, FirePHP::GROUP_END); | ||
571 | - } | ||
572 | - | ||
573 | - /** | ||
574 | - * Log object with label to firebug console | ||
575 | - * | ||
576 | - * @see FirePHP::LOG | ||
577 | - * @param mixes $Object | ||
578 | - * @param string $Label | ||
579 | - * @return true | ||
580 | - * @throws Exception | ||
581 | - */ | ||
582 | - public function log($Object, $Label = null, $Options = array()) | ||
583 | - { | ||
584 | - return $this->fb($Object, $Label, FirePHP::LOG, $Options); | ||
585 | - } | ||
586 | - | ||
587 | - /** | ||
588 | - * Log object with label to firebug console | ||
589 | - * | ||
590 | - * @see FirePHP::INFO | ||
591 | - * @param mixes $Object | ||
592 | - * @param string $Label | ||
593 | - * @return true | ||
594 | - * @throws Exception | ||
595 | - */ | ||
596 | - public function info($Object, $Label = null, $Options = array()) | ||
597 | - { | ||
598 | - return $this->fb($Object, $Label, FirePHP::INFO, $Options); | ||
599 | - } | ||
600 | - | ||
601 | - /** | ||
602 | - * Log object with label to firebug console | ||
603 | - * | ||
604 | - * @see FirePHP::WARN | ||
605 | - * @param mixes $Object | ||
606 | - * @param string $Label | ||
607 | - * @return true | ||
608 | - * @throws Exception | ||
609 | - */ | ||
610 | - public function warn($Object, $Label = null, $Options = array()) | ||
611 | - { | ||
612 | - return $this->fb($Object, $Label, FirePHP::WARN, $Options); | ||
613 | - } | ||
614 | - | ||
615 | - /** | ||
616 | - * Log object with label to firebug console | ||
617 | - * | ||
618 | - * @see FirePHP::ERROR | ||
619 | - * @param mixes $Object | ||
620 | - * @param string $Label | ||
621 | - * @return true | ||
622 | - * @throws Exception | ||
623 | - */ | ||
624 | - public function error($Object, $Label = null, $Options = array()) | ||
625 | - { | ||
626 | - return $this->fb($Object, $Label, FirePHP::ERROR, $Options); | ||
627 | - } | ||
628 | - | ||
629 | - /** | ||
630 | - * Dumps key and variable to firebug server panel | ||
631 | - * | ||
632 | - * @see FirePHP::DUMP | ||
633 | - * @param string $Key | ||
634 | - * @param mixed $Variable | ||
635 | - * @return true | ||
636 | - * @throws Exception | ||
637 | - */ | ||
638 | - public function dump($Key, $Variable, $Options = array()) | ||
639 | - { | ||
640 | - if (!is_string($Key)) { | ||
641 | - throw $this->newException('Key passed to dump() is not a string'); | ||
642 | - } | ||
643 | - if (strlen($Key)>100) { | ||
644 | - throw $this->newException('Key passed to dump() is longer than 100 characters'); | ||
645 | - } | ||
646 | - if (!preg_match_all('/^[a-zA-Z0-9-_\.:]*$/', $Key, $m)) { | ||
647 | - throw $this->newException('Key passed to dump() contains invalid characters [a-zA-Z0-9-_\.:]'); | ||
648 | - } | ||
649 | - return $this->fb($Variable, $Key, FirePHP::DUMP, $Options); | ||
650 | - } | ||
651 | - | ||
652 | - /** | ||
653 | - * Log a trace in the firebug console | ||
654 | - * | ||
655 | - * @see FirePHP::TRACE | ||
656 | - * @param string $Label | ||
657 | - * @return true | ||
658 | - * @throws Exception | ||
659 | - */ | ||
660 | - public function trace($Label) | ||
661 | - { | ||
662 | - return $this->fb($Label, FirePHP::TRACE); | ||
663 | - } | ||
664 | - | ||
665 | - /** | ||
666 | - * Log a table in the firebug console | ||
667 | - * | ||
668 | - * @see FirePHP::TABLE | ||
669 | - * @param string $Label | ||
670 | - * @param string $Table | ||
671 | - * @return true | ||
672 | - * @throws Exception | ||
673 | - */ | ||
674 | - public function table($Label, $Table, $Options = array()) | ||
675 | - { | ||
676 | - return $this->fb($Table, $Label, FirePHP::TABLE, $Options); | ||
677 | - } | ||
678 | - | ||
679 | - /** | ||
680 | - * Insight API wrapper | ||
681 | - * | ||
682 | - * @see Insight_Helper::to() | ||
683 | - */ | ||
684 | - public static function to() | ||
685 | - { | ||
686 | - $instance = self::getInstance(); | ||
687 | - if (!method_exists($instance, "_to")) { | ||
688 | - throw new Exception("FirePHP::to() implementation not loaded"); | ||
689 | - } | ||
690 | - $args = func_get_args(); | ||
691 | - return call_user_func_array(array($instance, '_to'), $args); | ||
692 | - } | ||
693 | - | ||
694 | - /** | ||
695 | - * Insight API wrapper | ||
696 | - * | ||
697 | - * @see Insight_Helper::plugin() | ||
698 | - */ | ||
699 | - public static function plugin() | ||
700 | - { | ||
701 | - $instance = self::getInstance(); | ||
702 | - if (!method_exists($instance, "_plugin")) { | ||
703 | - throw new Exception("FirePHP::plugin() implementation not loaded"); | ||
704 | - } | ||
705 | - $args = func_get_args(); | ||
706 | - return call_user_func_array(array($instance, '_plugin'), $args); | ||
707 | - } | ||
708 | - | ||
709 | - /** | ||
710 | - * Check if FirePHP is installed on client | ||
711 | - * | ||
712 | - * @return boolean | ||
713 | - */ | ||
714 | - public function detectClientExtension() | ||
715 | - { | ||
716 | - // Check if FirePHP is installed on client via User-Agent header | ||
717 | - if (@preg_match_all('/\sFirePHP\/([\.\d]*)\s?/si',$this->getUserAgent(),$m) && | ||
718 | - version_compare($m[1][0],'0.0.6','>=')) { | ||
719 | - return true; | ||
720 | - } else | ||
721 | - // Check if FirePHP is installed on client via X-FirePHP-Version header | ||
722 | - if (@preg_match_all('/^([\.\d]*)$/si',$this->getRequestHeader("X-FirePHP-Version"),$m) && | ||
723 | - version_compare($m[1][0],'0.0.6','>=')) { | ||
724 | - return true; | ||
725 | - } | ||
726 | - return false; | ||
727 | - } | ||
728 | - | ||
729 | - /** | ||
730 | - * Log varible to Firebug | ||
731 | - * | ||
732 | - * @see http://www.firephp.org/Wiki/Reference/Fb | ||
733 | - * @param mixed $Object The variable to be logged | ||
734 | - * @return true Return TRUE if message was added to headers, FALSE otherwise | ||
735 | - * @throws Exception | ||
736 | - */ | ||
737 | - public function fb($Object) | ||
738 | - { | ||
739 | - if($this instanceof FirePHP_Insight && method_exists($this, '_logUpgradeClientMessage')) { | ||
740 | - if(!FirePHP_Insight::$upgradeClientMessageLogged) { // avoid infinite recursion as _logUpgradeClientMessage() logs a message | ||
741 | - $this->_logUpgradeClientMessage(); | ||
742 | - } | ||
743 | - } | ||
744 | - | ||
745 | - static $insightGroupStack = array(); | ||
746 | - | ||
747 | - if (!$this->getEnabled()) { | ||
748 | - return false; | ||
749 | - } | ||
750 | - | ||
751 | - if ($this->headersSent($filename, $linenum)) { | ||
752 | - // If we are logging from within the exception handler we cannot throw another exception | ||
753 | - if ($this->inExceptionHandler) { | ||
754 | - // Simply echo the error out to the page | ||
755 | - echo '<div style="border: 2px solid red; font-family: Arial; font-size: 12px; background-color: lightgray; padding: 5px;"><span style="color: red; font-weight: bold;">FirePHP ERROR:</span> Headers already sent in <b>'.$filename.'</b> on line <b>'.$linenum.'</b>. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.</div>'; | ||
756 | - } else { | ||
757 | - throw $this->newException('Headers already sent in '.$filename.' on line '.$linenum.'. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.'); | ||
758 | - } | ||
759 | - } | ||
760 | - | ||
761 | - $Type = null; | ||
762 | - $Label = null; | ||
763 | - $Options = array(); | ||
764 | - | ||
765 | - if (func_num_args()==1) { | ||
766 | - } else | ||
767 | - if (func_num_args()==2) { | ||
768 | - switch(func_get_arg(1)) { | ||
769 | - case self::LOG: | ||
770 | - case self::INFO: | ||
771 | - case self::WARN: | ||
772 | - case self::ERROR: | ||
773 | - case self::DUMP: | ||
774 | - case self::TRACE: | ||
775 | - case self::EXCEPTION: | ||
776 | - case self::TABLE: | ||
777 | - case self::GROUP_START: | ||
778 | - case self::GROUP_END: | ||
779 | - $Type = func_get_arg(1); | ||
780 | - break; | ||
781 | - default: | ||
782 | - $Label = func_get_arg(1); | ||
783 | - break; | ||
784 | - } | ||
785 | - } else | ||
786 | - if (func_num_args()==3) { | ||
787 | - $Type = func_get_arg(2); | ||
788 | - $Label = func_get_arg(1); | ||
789 | - } else | ||
790 | - if (func_num_args()==4) { | ||
791 | - $Type = func_get_arg(2); | ||
792 | - $Label = func_get_arg(1); | ||
793 | - $Options = func_get_arg(3); | ||
794 | - } else { | ||
795 | - throw $this->newException('Wrong number of arguments to fb() function!'); | ||
796 | - } | ||
797 | - | ||
798 | - if($this->logToInsightConsole!==null && (get_class($this)=='FirePHP_Insight' || is_subclass_of($this, 'FirePHP_Insight'))) { | ||
799 | - $msg = $this->logToInsightConsole; | ||
800 | - if ($Object instanceof Exception) { | ||
801 | - $Type = self::EXCEPTION; | ||
802 | - } | ||
803 | - if($Label && $Type!=self::TABLE && $Type!=self::GROUP_START) { | ||
804 | - $msg = $msg->label($Label); | ||
805 | - } | ||
806 | - switch($Type) { | ||
807 | - case self::DUMP: | ||
808 | - case self::LOG: | ||
809 | - return $msg->log($Object); | ||
810 | - case self::INFO: | ||
811 | - return $msg->info($Object); | ||
812 | - case self::WARN: | ||
813 | - return $msg->warn($Object); | ||
814 | - case self::ERROR: | ||
815 | - return $msg->error($Object); | ||
816 | - case self::TRACE: | ||
817 | - return $msg->trace($Object); | ||
818 | - case self::EXCEPTION: | ||
819 | - return $this->plugin('engine')->handleException($Object, $msg); | ||
820 | - case self::TABLE: | ||
821 | - if (isset($Object[0]) && !is_string($Object[0]) && $Label) { | ||
822 | - $Object = array($Label, $Object); | ||
823 | - } | ||
824 | - return $msg->table($Object[0], array_slice($Object[1],1), $Object[1][0]); | ||
825 | - case self::GROUP_START: | ||
826 | - $insightGroupStack[] = $msg->group(md5($Label))->open(); | ||
827 | - return $msg->log($Label); | ||
828 | - case self::GROUP_END: | ||
829 | - if(count($insightGroupStack)==0) { | ||
830 | - throw new Error('Too many groupEnd() as opposed to group() calls!'); | ||
831 | - } | ||
832 | - $group = array_pop($insightGroupStack); | ||
833 | - return $group->close(); | ||
834 | - default: | ||
835 | - return $msg->log($Object); | ||
836 | - } | ||
837 | - } | ||
838 | - | ||
839 | - if (!$this->detectClientExtension()) { | ||
840 | - return false; | ||
841 | - } | ||
842 | - | ||
843 | - $meta = array(); | ||
844 | - $skipFinalObjectEncode = false; | ||
845 | - | ||
846 | - if ($Object instanceof Exception) { | ||
847 | - | ||
848 | - $meta['file'] = $this->_escapeTraceFile($Object->getFile()); | ||
849 | - $meta['line'] = $Object->getLine(); | ||
850 | - | ||
851 | - $trace = $Object->getTrace(); | ||
852 | - if ($Object instanceof ErrorException | ||
853 | - && isset($trace[0]['function']) | ||
854 | - && $trace[0]['function']=='errorHandler' | ||
855 | - && isset($trace[0]['class']) | ||
856 | - && $trace[0]['class']=='FirePHP') { | ||
857 | - | ||
858 | - $severity = false; | ||
859 | - switch($Object->getSeverity()) { | ||
860 | - case E_WARNING: $severity = 'E_WARNING'; break; | ||
861 | - case E_NOTICE: $severity = 'E_NOTICE'; break; | ||
862 | - case E_USER_ERROR: $severity = 'E_USER_ERROR'; break; | ||
863 | - case E_USER_WARNING: $severity = 'E_USER_WARNING'; break; | ||
864 | - case E_USER_NOTICE: $severity = 'E_USER_NOTICE'; break; | ||
865 | - case E_STRICT: $severity = 'E_STRICT'; break; | ||
866 | - case E_RECOVERABLE_ERROR: $severity = 'E_RECOVERABLE_ERROR'; break; | ||
867 | - case E_DEPRECATED: $severity = 'E_DEPRECATED'; break; | ||
868 | - case E_USER_DEPRECATED: $severity = 'E_USER_DEPRECATED'; break; | ||
869 | - } | ||
870 | - | ||
871 | - $Object = array('Class'=>get_class($Object), | ||
872 | - 'Message'=>$severity.': '.$Object->getMessage(), | ||
873 | - 'File'=>$this->_escapeTraceFile($Object->getFile()), | ||
874 | - 'Line'=>$Object->getLine(), | ||
875 | - 'Type'=>'trigger', | ||
876 | - 'Trace'=>$this->_escapeTrace(array_splice($trace,2))); | ||
877 | - $skipFinalObjectEncode = true; | ||
878 | - } else { | ||
879 | - $Object = array('Class'=>get_class($Object), | ||
880 | - 'Message'=>$Object->getMessage(), | ||
881 | - 'File'=>$this->_escapeTraceFile($Object->getFile()), | ||
882 | - 'Line'=>$Object->getLine(), | ||
883 | - 'Type'=>'throw', | ||
884 | - 'Trace'=>$this->_escapeTrace($trace)); | ||
885 | - $skipFinalObjectEncode = true; | ||
886 | - } | ||
887 | - $Type = self::EXCEPTION; | ||
888 | - | ||
889 | - } else | ||
890 | - if ($Type==self::TRACE) { | ||
891 | - | ||
892 | - $trace = debug_backtrace(); | ||
893 | - if (!$trace) return false; | ||
894 | - for( $i=0 ; $i<sizeof($trace) ; $i++ ) { | ||
895 | - | ||
896 | - if (isset($trace[$i]['class']) | ||
897 | - && isset($trace[$i]['file']) | ||
898 | - && ($trace[$i]['class']=='FirePHP' | ||
899 | - || $trace[$i]['class']=='FB') | ||
900 | - && (substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php' | ||
901 | - || substr($this->_standardizePath($trace[$i]['file']),-29,29)=='FirePHPCore/FirePHP.class.php')) { | ||
902 | - /* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */ | ||
903 | - } else | ||
904 | - if (isset($trace[$i]['class']) | ||
905 | - && isset($trace[$i+1]['file']) | ||
906 | - && $trace[$i]['class']=='FirePHP' | ||
907 | - && substr($this->_standardizePath($trace[$i+1]['file']),-18,18)=='FirePHPCore/fb.php') { | ||
908 | - /* Skip fb() */ | ||
909 | - } else | ||
910 | - if ($trace[$i]['function']=='fb' | ||
911 | - || $trace[$i]['function']=='trace' | ||
912 | - || $trace[$i]['function']=='send') { | ||
913 | - | ||
914 | - $Object = array('Class'=>isset($trace[$i]['class'])?$trace[$i]['class']:'', | ||
915 | - 'Type'=>isset($trace[$i]['type'])?$trace[$i]['type']:'', | ||
916 | - 'Function'=>isset($trace[$i]['function'])?$trace[$i]['function']:'', | ||
917 | - 'Message'=>$trace[$i]['args'][0], | ||
918 | - 'File'=>isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):'', | ||
919 | - 'Line'=>isset($trace[$i]['line'])?$trace[$i]['line']:'', | ||
920 | - 'Args'=>isset($trace[$i]['args'])?$this->encodeObject($trace[$i]['args']):'', | ||
921 | - 'Trace'=>$this->_escapeTrace(array_splice($trace,$i+1))); | ||
922 | - | ||
923 | - $skipFinalObjectEncode = true; | ||
924 | - $meta['file'] = isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):''; | ||
925 | - $meta['line'] = isset($trace[$i]['line'])?$trace[$i]['line']:''; | ||
926 | - break; | ||
927 | - } | ||
928 | - } | ||
929 | - | ||
930 | - } else | ||
931 | - if ($Type==self::TABLE) { | ||
932 | - | ||
933 | - if (isset($Object[0]) && is_string($Object[0])) { | ||
934 | - $Object[1] = $this->encodeTable($Object[1]); | ||
935 | - } else { | ||
936 | - $Object = $this->encodeTable($Object); | ||
937 | - } | ||
938 | - | ||
939 | - $skipFinalObjectEncode = true; | ||
940 | - | ||
941 | - } else | ||
942 | - if ($Type==self::GROUP_START) { | ||
943 | - | ||
944 | - if (!$Label) { | ||
945 | - throw $this->newException('You must specify a label for the group!'); | ||
946 | - } | ||
947 | - | ||
948 | - } else { | ||
949 | - if ($Type===null) { | ||
950 | - $Type = self::LOG; | ||
951 | - } | ||
952 | - } | ||
953 | - | ||
954 | - if ($this->options['includeLineNumbers']) { | ||
955 | - if (!isset($meta['file']) || !isset($meta['line'])) { | ||
956 | - | ||
957 | - $trace = debug_backtrace(); | ||
958 | - for( $i=0 ; $trace && $i<sizeof($trace) ; $i++ ) { | ||
959 | - | ||
960 | - if (isset($trace[$i]['class']) | ||
961 | - && isset($trace[$i]['file']) | ||
962 | - && ($trace[$i]['class']=='FirePHP' | ||
963 | - || $trace[$i]['class']=='FB') | ||
964 | - && (substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php' | ||
965 | - || substr($this->_standardizePath($trace[$i]['file']),-29,29)=='FirePHPCore/FirePHP.class.php')) { | ||
966 | - /* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */ | ||
967 | - } else | ||
968 | - if (isset($trace[$i]['class']) | ||
969 | - && isset($trace[$i+1]['file']) | ||
970 | - && $trace[$i]['class']=='FirePHP' | ||
971 | - && substr($this->_standardizePath($trace[$i+1]['file']),-18,18)=='FirePHPCore/fb.php') { | ||
972 | - /* Skip fb() */ | ||
973 | - } else | ||
974 | - if (isset($trace[$i]['file']) | ||
975 | - && substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php') { | ||
976 | - /* Skip FB::fb() */ | ||
977 | - } else { | ||
978 | - $meta['file'] = isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):''; | ||
979 | - $meta['line'] = isset($trace[$i]['line'])?$trace[$i]['line']:''; | ||
980 | - break; | ||
981 | - } | ||
982 | - } | ||
983 | - } | ||
984 | - } else { | ||
985 | - unset($meta['file']); | ||
986 | - unset($meta['line']); | ||
987 | - } | ||
988 | - | ||
989 | - $this->setHeader('X-Wf-Protocol-1','http://meta.wildfirehq.org/Protocol/JsonStream/0.2'); | ||
990 | - $this->setHeader('X-Wf-1-Plugin-1','http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/'.self::VERSION); | ||
991 | - | ||
992 | - $structure_index = 1; | ||
993 | - if ($Type==self::DUMP) { | ||
994 | - $structure_index = 2; | ||
995 | - $this->setHeader('X-Wf-1-Structure-2','http://meta.firephp.org/Wildfire/Structure/FirePHP/Dump/0.1'); | ||
996 | - } else { | ||
997 | - $this->setHeader('X-Wf-1-Structure-1','http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1'); | ||
998 | - } | ||
999 | - | ||
1000 | - if ($Type==self::DUMP) { | ||
1001 | - $msg = '{"'.$Label.'":'.$this->jsonEncode($Object, $skipFinalObjectEncode).'}'; | ||
1002 | - } else { | ||
1003 | - $msg_meta = $Options; | ||
1004 | - $msg_meta['Type'] = $Type; | ||
1005 | - if ($Label!==null) { | ||
1006 | - $msg_meta['Label'] = $Label; | ||
1007 | - } | ||
1008 | - if (isset($meta['file']) && !isset($msg_meta['File'])) { | ||
1009 | - $msg_meta['File'] = $meta['file']; | ||
1010 | - } | ||
1011 | - if (isset($meta['line']) && !isset($msg_meta['Line'])) { | ||
1012 | - $msg_meta['Line'] = $meta['line']; | ||
1013 | - } | ||
1014 | - $msg = '['.$this->jsonEncode($msg_meta).','.$this->jsonEncode($Object, $skipFinalObjectEncode).']'; | ||
1015 | - } | ||
1016 | - | ||
1017 | - $parts = explode("\n",chunk_split($msg, 5000, "\n")); | ||
1018 | - | ||
1019 | - for( $i=0 ; $i<count($parts) ; $i++) { | ||
1020 | - | ||
1021 | - $part = $parts[$i]; | ||
1022 | - if ($part) { | ||
1023 | - | ||
1024 | - if (count($parts)>2) { | ||
1025 | - // Message needs to be split into multiple parts | ||
1026 | - $this->setHeader('X-Wf-1-'.$structure_index.'-'.'1-'.$this->messageIndex, | ||
1027 | - (($i==0)?strlen($msg):'') | ||
1028 | - . '|' . $part . '|' | ||
1029 | - . (($i<count($parts)-2)?'\\':'')); | ||
1030 | - } else { | ||
1031 | - $this->setHeader('X-Wf-1-'.$structure_index.'-'.'1-'.$this->messageIndex, | ||
1032 | - strlen($part) . '|' . $part . '|'); | ||
1033 | - } | ||
1034 | - | ||
1035 | - $this->messageIndex++; | ||
1036 | - | ||
1037 | - if ($this->messageIndex > 99999) { | ||
1038 | - throw $this->newException('Maximum number (99,999) of messages reached!'); | ||
1039 | - } | ||
1040 | - } | ||
1041 | - } | ||
1042 | - | ||
1043 | - $this->setHeader('X-Wf-1-Index',$this->messageIndex-1); | ||
1044 | - | ||
1045 | - return true; | ||
1046 | - } | ||
1047 | - | ||
1048 | - /** | ||
1049 | - * Standardizes path for windows systems. | ||
1050 | - * | ||
1051 | - * @param string $Path | ||
1052 | - * @return string | ||
1053 | - */ | ||
1054 | - protected function _standardizePath($Path) | ||
1055 | - { | ||
1056 | - return preg_replace('/\\\\+/','/',$Path); | ||
1057 | - } | ||
1058 | - | ||
1059 | - /** | ||
1060 | - * Escape trace path for windows systems | ||
1061 | - * | ||
1062 | - * @param array $Trace | ||
1063 | - * @return array | ||
1064 | - */ | ||
1065 | - protected function _escapeTrace($Trace) | ||
1066 | - { | ||
1067 | - if (!$Trace) return $Trace; | ||
1068 | - for( $i=0 ; $i<sizeof($Trace) ; $i++ ) { | ||
1069 | - if (isset($Trace[$i]['file'])) { | ||
1070 | - $Trace[$i]['file'] = $this->_escapeTraceFile($Trace[$i]['file']); | ||
1071 | - } | ||
1072 | - if (isset($Trace[$i]['args'])) { | ||
1073 | - $Trace[$i]['args'] = $this->encodeObject($Trace[$i]['args']); | ||
1074 | - } | ||
1075 | - } | ||
1076 | - return $Trace; | ||
1077 | - } | ||
1078 | - | ||
1079 | - /** | ||
1080 | - * Escape file information of trace for windows systems | ||
1081 | - * | ||
1082 | - * @param string $File | ||
1083 | - * @return string | ||
1084 | - */ | ||
1085 | - protected function _escapeTraceFile($File) | ||
1086 | - { | ||
1087 | - /* Check if we have a windows filepath */ | ||
1088 | - if (strpos($File,'\\')) { | ||
1089 | - /* First strip down to single \ */ | ||
1090 | - | ||
1091 | - $file = preg_replace('/\\\\+/','\\',$File); | ||
1092 | - | ||
1093 | - return $file; | ||
1094 | - } | ||
1095 | - return $File; | ||
1096 | - } | ||
1097 | - | ||
1098 | - /** | ||
1099 | - * Check if headers have already been sent | ||
1100 | - * | ||
1101 | - * @param string $Filename | ||
1102 | - * @param integer $Linenum | ||
1103 | - */ | ||
1104 | - protected function headersSent(&$Filename, &$Linenum) | ||
1105 | - { | ||
1106 | - return headers_sent($Filename, $Linenum); | ||
1107 | - } | ||
1108 | - | ||
1109 | - /** | ||
1110 | - * Send header | ||
1111 | - * | ||
1112 | - * @param string $Name | ||
1113 | - * @param string $Value | ||
1114 | - */ | ||
1115 | - protected function setHeader($Name, $Value) | ||
1116 | - { | ||
1117 | - return header($Name.': '.$Value); | ||
1118 | - } | ||
1119 | - | ||
1120 | - /** | ||
1121 | - * Get user agent | ||
1122 | - * | ||
1123 | - * @return string|false | ||
1124 | - */ | ||
1125 | - protected function getUserAgent() | ||
1126 | - { | ||
1127 | - if (!isset($_SERVER['HTTP_USER_AGENT'])) return false; | ||
1128 | - return $_SERVER['HTTP_USER_AGENT']; | ||
1129 | - } | ||
1130 | - | ||
1131 | - /** | ||
1132 | - * Get all request headers | ||
1133 | - * | ||
1134 | - * @return array | ||
1135 | - */ | ||
1136 | - public static function getAllRequestHeaders() { | ||
1137 | - static $_cached_headers = false; | ||
1138 | - if($_cached_headers!==false) { | ||
1139 | - return $_cached_headers; | ||
1140 | - } | ||
1141 | - $headers = array(); | ||
1142 | - if(function_exists('getallheaders')) { | ||
1143 | - foreach( getallheaders() as $name => $value ) { | ||
1144 | - $headers[strtolower($name)] = $value; | ||
1145 | - } | ||
1146 | - } else { | ||
1147 | - foreach($_SERVER as $name => $value) { | ||
1148 | - if(substr($name, 0, 5) == 'HTTP_') { | ||
1149 | - $headers[strtolower(str_replace(' ', '-', str_replace('_', ' ', substr($name, 5))))] = $value; | ||
1150 | - } | ||
1151 | - } | ||
1152 | - } | ||
1153 | - return $_cached_headers = $headers; | ||
1154 | - } | ||
1155 | - | ||
1156 | - /** | ||
1157 | - * Get a request header | ||
1158 | - * | ||
1159 | - * @return string|false | ||
1160 | - */ | ||
1161 | - protected function getRequestHeader($Name) | ||
1162 | - { | ||
1163 | - $headers = self::getAllRequestHeaders(); | ||
1164 | - if (isset($headers[strtolower($Name)])) { | ||
1165 | - return $headers[strtolower($Name)]; | ||
1166 | - } | ||
1167 | - return false; | ||
1168 | - } | ||
1169 | - | ||
1170 | - /** | ||
1171 | - * Returns a new exception | ||
1172 | - * | ||
1173 | - * @param string $Message | ||
1174 | - * @return Exception | ||
1175 | - */ | ||
1176 | - protected function newException($Message) | ||
1177 | - { | ||
1178 | - return new Exception($Message); | ||
1179 | - } | ||
1180 | - | ||
1181 | - /** | ||
1182 | - * Encode an object into a JSON string | ||
1183 | - * | ||
1184 | - * Uses PHP's jeson_encode() if available | ||
1185 | - * | ||
1186 | - * @param object $Object The object to be encoded | ||
1187 | - * @return string The JSON string | ||
1188 | - */ | ||
1189 | - public function jsonEncode($Object, $skipObjectEncode = false) | ||
1190 | - { | ||
1191 | - if (!$skipObjectEncode) { | ||
1192 | - $Object = $this->encodeObject($Object); | ||
1193 | - } | ||
1194 | - | ||
1195 | - if (function_exists('json_encode') | ||
1196 | - && $this->options['useNativeJsonEncode']!=false) { | ||
1197 | - | ||
1198 | - return json_encode($Object); | ||
1199 | - } else { | ||
1200 | - return $this->json_encode($Object); | ||
1201 | - } | ||
1202 | - } | ||
1203 | - | ||
1204 | - /** | ||
1205 | - * Encodes a table by encoding each row and column with encodeObject() | ||
1206 | - * | ||
1207 | - * @param array $Table The table to be encoded | ||
1208 | - * @return array | ||
1209 | - */ | ||
1210 | - protected function encodeTable($Table) | ||
1211 | - { | ||
1212 | - | ||
1213 | - if (!$Table) return $Table; | ||
1214 | - | ||
1215 | - $new_table = array(); | ||
1216 | - foreach($Table as $row) { | ||
1217 | - | ||
1218 | - if (is_array($row)) { | ||
1219 | - $new_row = array(); | ||
1220 | - | ||
1221 | - foreach($row as $item) { | ||
1222 | - $new_row[] = $this->encodeObject($item); | ||
1223 | - } | ||
1224 | - | ||
1225 | - $new_table[] = $new_row; | ||
1226 | - } | ||
1227 | - } | ||
1228 | - | ||
1229 | - return $new_table; | ||
1230 | - } | ||
1231 | - | ||
1232 | - /** | ||
1233 | - * Encodes an object including members with | ||
1234 | - * protected and private visibility | ||
1235 | - * | ||
1236 | - * @param Object $Object The object to be encoded | ||
1237 | - * @param int $Depth The current traversal depth | ||
1238 | - * @return array All members of the object | ||
1239 | - */ | ||
1240 | - protected function encodeObject($Object, $ObjectDepth = 1, $ArrayDepth = 1, $MaxDepth = 1) | ||
1241 | - { | ||
1242 | - if ($MaxDepth > $this->options['maxDepth']) { | ||
1243 | - return '** Max Depth ('.$this->options['maxDepth'].') **'; | ||
1244 | - } | ||
1245 | - | ||
1246 | - $return = array(); | ||
1247 | - | ||
1248 | - if (is_resource($Object)) { | ||
1249 | - | ||
1250 | - return '** '.(string)$Object.' **'; | ||
1251 | - | ||
1252 | - } else | ||
1253 | - if (is_object($Object)) { | ||
1254 | - | ||
1255 | - if ($ObjectDepth > $this->options['maxObjectDepth']) { | ||
1256 | - return '** Max Object Depth ('.$this->options['maxObjectDepth'].') **'; | ||
1257 | - } | ||
1258 | - | ||
1259 | - foreach ($this->objectStack as $refVal) { | ||
1260 | - if ($refVal === $Object) { | ||
1261 | - return '** Recursion ('.get_class($Object).') **'; | ||
1262 | - } | ||
1263 | - } | ||
1264 | - array_push($this->objectStack, $Object); | ||
1265 | - | ||
1266 | - $return['__className'] = $class = get_class($Object); | ||
1267 | - $class_lower = strtolower($class); | ||
1268 | - | ||
1269 | - $reflectionClass = new ReflectionClass($class); | ||
1270 | - $properties = array(); | ||
1271 | - foreach( $reflectionClass->getProperties() as $property) { | ||
1272 | - $properties[$property->getName()] = $property; | ||
1273 | - } | ||
1274 | - | ||
1275 | - $members = (array)$Object; | ||
1276 | - | ||
1277 | - foreach( $properties as $plain_name => $property ) { | ||
1278 | - | ||
1279 | - $name = $raw_name = $plain_name; | ||
1280 | - if ($property->isStatic()) { | ||
1281 | - $name = 'static:'.$name; | ||
1282 | - } | ||
1283 | - if ($property->isPublic()) { | ||
1284 | - $name = 'public:'.$name; | ||
1285 | - } else | ||
1286 | - if ($property->isPrivate()) { | ||
1287 | - $name = 'private:'.$name; | ||
1288 | - $raw_name = "\0".$class."\0".$raw_name; | ||
1289 | - } else | ||
1290 | - if ($property->isProtected()) { | ||
1291 | - $name = 'protected:'.$name; | ||
1292 | - $raw_name = "\0".'*'."\0".$raw_name; | ||
1293 | - } | ||
1294 | - | ||
1295 | - if (!(isset($this->objectFilters[$class_lower]) | ||
1296 | - && is_array($this->objectFilters[$class_lower]) | ||
1297 | - && in_array($plain_name,$this->objectFilters[$class_lower]))) { | ||
1298 | - | ||
1299 | - if (array_key_exists($raw_name,$members) | ||
1300 | - && !$property->isStatic()) { | ||
1301 | - | ||
1302 | - $return[$name] = $this->encodeObject($members[$raw_name], $ObjectDepth + 1, 1, $MaxDepth + 1); | ||
1303 | - | ||
1304 | - } else { | ||
1305 | - if (method_exists($property,'setAccessible')) { | ||
1306 | - $property->setAccessible(true); | ||
1307 | - $return[$name] = $this->encodeObject($property->getValue($Object), $ObjectDepth + 1, 1, $MaxDepth + 1); | ||
1308 | - } else | ||
1309 | - if ($property->isPublic()) { | ||
1310 | - $return[$name] = $this->encodeObject($property->getValue($Object), $ObjectDepth + 1, 1, $MaxDepth + 1); | ||
1311 | - } else { | ||
1312 | - $return[$name] = '** Need PHP 5.3 to get value **'; | ||
1313 | - } | ||
1314 | - } | ||
1315 | - } else { | ||
1316 | - $return[$name] = '** Excluded by Filter **'; | ||
1317 | - } | ||
1318 | - } | ||
1319 | - | ||
1320 | - // Include all members that are not defined in the class | ||
1321 | - // but exist in the object | ||
1322 | - foreach( $members as $raw_name => $value ) { | ||
1323 | - | ||
1324 | - $name = $raw_name; | ||
1325 | - | ||
1326 | - if ($name{0} == "\0") { | ||
1327 | - $parts = explode("\0", $name); | ||
1328 | - $name = $parts[2]; | ||
1329 | - } | ||
1330 | - | ||
1331 | - $plain_name = $name; | ||
1332 | - | ||
1333 | - if (!isset($properties[$name])) { | ||
1334 | - $name = 'undeclared:'.$name; | ||
1335 | - | ||
1336 | - if (!(isset($this->objectFilters[$class_lower]) | ||
1337 | - && is_array($this->objectFilters[$class_lower]) | ||
1338 | - && in_array($plain_name,$this->objectFilters[$class_lower]))) { | ||
1339 | - | ||
1340 | - $return[$name] = $this->encodeObject($value, $ObjectDepth + 1, 1, $MaxDepth + 1); | ||
1341 | - } else { | ||
1342 | - $return[$name] = '** Excluded by Filter **'; | ||
1343 | - } | ||
1344 | - } | ||
1345 | - } | ||
1346 | - | ||
1347 | - array_pop($this->objectStack); | ||
1348 | - | ||
1349 | - } elseif (is_array($Object)) { | ||
1350 | - | ||
1351 | - if ($ArrayDepth > $this->options['maxArrayDepth']) { | ||
1352 | - return '** Max Array Depth ('.$this->options['maxArrayDepth'].') **'; | ||
1353 | - } | ||
1354 | - | ||
1355 | - foreach ($Object as $key => $val) { | ||
1356 | - | ||
1357 | - // Encoding the $GLOBALS PHP array causes an infinite loop | ||
1358 | - // if the recursion is not reset here as it contains | ||
1359 | - // a reference to itself. This is the only way I have come up | ||
1360 | - // with to stop infinite recursion in this case. | ||
1361 | - if ($key=='GLOBALS' | ||
1362 | - && is_array($val) | ||
1363 | - && array_key_exists('GLOBALS',$val)) { | ||
1364 | - $val['GLOBALS'] = '** Recursion (GLOBALS) **'; | ||
1365 | - } | ||
1366 | - | ||
1367 | - $return[$key] = $this->encodeObject($val, 1, $ArrayDepth + 1, $MaxDepth + 1); | ||
1368 | - } | ||
1369 | - } else { | ||
1370 | - if (self::is_utf8($Object)) { | ||
1371 | - return $Object; | ||
1372 | - } else { | ||
1373 | - return utf8_encode($Object); | ||
1374 | - } | ||
1375 | - } | ||
1376 | - return $return; | ||
1377 | - } | ||
1378 | - | ||
1379 | - /** | ||
1380 | - * Returns true if $string is valid UTF-8 and false otherwise. | ||
1381 | - * | ||
1382 | - * @param mixed $str String to be tested | ||
1383 | - * @return boolean | ||
1384 | - */ | ||
1385 | - protected static function is_utf8($str) | ||
1386 | - { | ||
1387 | - if(function_exists('mb_detect_encoding')) { | ||
1388 | - return (mb_detect_encoding($str) == 'UTF-8'); | ||
1389 | - } | ||
1390 | - $c=0; $b=0; | ||
1391 | - $bits=0; | ||
1392 | - $len=strlen($str); | ||
1393 | - for($i=0; $i<$len; $i++){ | ||
1394 | - $c=ord($str[$i]); | ||
1395 | - if ($c > 128){ | ||
1396 | - if (($c >= 254)) return false; | ||
1397 | - elseif ($c >= 252) $bits=6; | ||
1398 | - elseif ($c >= 248) $bits=5; | ||
1399 | - elseif ($c >= 240) $bits=4; | ||
1400 | - elseif ($c >= 224) $bits=3; | ||
1401 | - elseif ($c >= 192) $bits=2; | ||
1402 | - else return false; | ||
1403 | - if (($i+$bits) > $len) return false; | ||
1404 | - while($bits > 1){ | ||
1405 | - $i++; | ||
1406 | - $b=ord($str[$i]); | ||
1407 | - if ($b < 128 || $b > 191) return false; | ||
1408 | - $bits--; | ||
1409 | - } | ||
1410 | - } | ||
1411 | - } | ||
1412 | - return true; | ||
1413 | - } | ||
1414 | - | ||
1415 | - /** | ||
1416 | - * Converts to and from JSON format. | ||
1417 | - * | ||
1418 | - * JSON (JavaScript Object Notation) is a lightweight data-interchange | ||
1419 | - * format. It is easy for humans to read and write. It is easy for machines | ||
1420 | - * to parse and generate. It is based on a subset of the JavaScript | ||
1421 | - * Programming Language, Standard ECMA-262 3rd Edition - December 1999. | ||
1422 | - * This feature can also be found in Python. JSON is a text format that is | ||
1423 | - * completely language independent but uses conventions that are familiar | ||
1424 | - * to programmers of the C-family of languages, including C, C++, C#, Java, | ||
1425 | - * JavaScript, Perl, TCL, and many others. These properties make JSON an | ||
1426 | - * ideal data-interchange language. | ||
1427 | - * | ||
1428 | - * This package provides a simple encoder and decoder for JSON notation. It | ||
1429 | - * is intended for use with client-side Javascript applications that make | ||
1430 | - * use of HTTPRequest to perform server communication functions - data can | ||
1431 | - * be encoded into JSON notation for use in a client-side javascript, or | ||
1432 | - * decoded from incoming Javascript requests. JSON format is native to | ||
1433 | - * Javascript, and can be directly eval()'ed with no further parsing | ||
1434 | - * overhead | ||
1435 | - * | ||
1436 | - * All strings should be in ASCII or UTF-8 format! | ||
1437 | - * | ||
1438 | - * LICENSE: Redistribution and use in source and binary forms, with or | ||
1439 | - * without modification, are permitted provided that the following | ||
1440 | - * conditions are met: Redistributions of source code must retain the | ||
1441 | - * above copyright notice, this list of conditions and the following | ||
1442 | - * disclaimer. Redistributions in binary form must reproduce the above | ||
1443 | - * copyright notice, this list of conditions and the following disclaimer | ||
1444 | - * in the documentation and/or other materials provided with the | ||
1445 | - * distribution. | ||
1446 | - * | ||
1447 | - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
1448 | - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
1449 | - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | ||
1450 | - * NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
1451 | - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
1452 | - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | ||
1453 | - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
1454 | - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | ||
1455 | - * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE | ||
1456 | - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | ||
1457 | - * DAMAGE. | ||
1458 | - * | ||
1459 | - * @category | ||
1460 | - * @package Services_JSON | ||
1461 | - * @author Michal Migurski <mike-json@teczno.com> | ||
1462 | - * @author Matt Knapp <mdknapp[at]gmail[dot]com> | ||
1463 | - * @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com> | ||
1464 | - * @author Christoph Dorn <christoph@christophdorn.com> | ||
1465 | - * @copyright 2005 Michal Migurski | ||
1466 | - * @version CVS: $Id: FirePHP.class.php 232 2011-06-01 12:55:32Z elena $ | ||
1467 | - * @license http://www.opensource.org/licenses/bsd-license.php | ||
1468 | - * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198 | ||
1469 | - */ | ||
1470 | - | ||
1471 | - | ||
1472 | - /** | ||
1473 | - * Keep a list of objects as we descend into the array so we can detect recursion. | ||
1474 | - */ | ||
1475 | - private $json_objectStack = array(); | ||
1476 | - | ||
1477 | - | ||
1478 | - /** | ||
1479 | - * convert a string from one UTF-8 char to one UTF-16 char | ||
1480 | - * | ||
1481 | - * Normally should be handled by mb_convert_encoding, but | ||
1482 | - * provides a slower PHP-only method for installations | ||
1483 | - * that lack the multibye string extension. | ||
1484 | - * | ||
1485 | - * @param string $utf8 UTF-8 character | ||
1486 | - * @return string UTF-16 character | ||
1487 | - * @access private | ||
1488 | - */ | ||
1489 | - private function json_utf82utf16($utf8) | ||
1490 | - { | ||
1491 | - // oh please oh please oh please oh please oh please | ||
1492 | - if (function_exists('mb_convert_encoding')) { | ||
1493 | - return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8'); | ||
1494 | - } | ||
1495 | - | ||
1496 | - switch(strlen($utf8)) { | ||
1497 | - case 1: | ||
1498 | - // this case should never be reached, because we are in ASCII range | ||
1499 | - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 | ||
1500 | - return $utf8; | ||
1501 | - | ||
1502 | - case 2: | ||
1503 | - // return a UTF-16 character from a 2-byte UTF-8 char | ||
1504 | - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 | ||
1505 | - return chr(0x07 & (ord($utf8{0}) >> 2)) | ||
1506 | - . chr((0xC0 & (ord($utf8{0}) << 6)) | ||
1507 | - | (0x3F & ord($utf8{1}))); | ||
1508 | - | ||
1509 | - case 3: | ||
1510 | - // return a UTF-16 character from a 3-byte UTF-8 char | ||
1511 | - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 | ||
1512 | - return chr((0xF0 & (ord($utf8{0}) << 4)) | ||
1513 | - | (0x0F & (ord($utf8{1}) >> 2))) | ||
1514 | - . chr((0xC0 & (ord($utf8{1}) << 6)) | ||
1515 | - | (0x7F & ord($utf8{2}))); | ||
1516 | - } | ||
1517 | - | ||
1518 | - // ignoring UTF-32 for now, sorry | ||
1519 | - return ''; | ||
1520 | - } | ||
1521 | - | ||
1522 | - /** | ||
1523 | - * encodes an arbitrary variable into JSON format | ||
1524 | - * | ||
1525 | - * @param mixed $var any number, boolean, string, array, or object to be encoded. | ||
1526 | - * see argument 1 to Services_JSON() above for array-parsing behavior. | ||
1527 | - * if var is a strng, note that encode() always expects it | ||
1528 | - * to be in ASCII or UTF-8 format! | ||
1529 | - * | ||
1530 | - * @return mixed JSON string representation of input var or an error if a problem occurs | ||
1531 | - * @access public | ||
1532 | - */ | ||
1533 | - private function json_encode($var) | ||
1534 | - { | ||
1535 | - | ||
1536 | - if (is_object($var)) { | ||
1537 | - if (in_array($var,$this->json_objectStack)) { | ||
1538 | - return '"** Recursion **"'; | ||
1539 | - } | ||
1540 | - } | ||
1541 | - | ||
1542 | - switch (gettype($var)) { | ||
1543 | - case 'boolean': | ||
1544 | - return $var ? 'true' : 'false'; | ||
1545 | - | ||
1546 | - case 'NULL': | ||
1547 | - return 'null'; | ||
1548 | - | ||
1549 | - case 'integer': | ||
1550 | - return (int) $var; | ||
1551 | - | ||
1552 | - case 'double': | ||
1553 | - case 'float': | ||
1554 | - return (float) $var; | ||
1555 | - | ||
1556 | - case 'string': | ||
1557 | - // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT | ||
1558 | - $ascii = ''; | ||
1559 | - $strlen_var = strlen($var); | ||
1560 | - | ||
1561 | - /* | ||
1562 | - * Iterate over every character in the string, | ||
1563 | - * escaping with a slash or encoding to UTF-8 where necessary | ||
1564 | - */ | ||
1565 | - for ($c = 0; $c < $strlen_var; ++$c) { | ||
1566 | - | ||
1567 | - $ord_var_c = ord($var{$c}); | ||
1568 | - | ||
1569 | - switch (true) { | ||
1570 | - case $ord_var_c == 0x08: | ||
1571 | - $ascii .= '\b'; | ||
1572 | - break; | ||
1573 | - case $ord_var_c == 0x09: | ||
1574 | - $ascii .= '\t'; | ||
1575 | - break; | ||
1576 | - case $ord_var_c == 0x0A: | ||
1577 | - $ascii .= '\n'; | ||
1578 | - break; | ||
1579 | - case $ord_var_c == 0x0C: | ||
1580 | - $ascii .= '\f'; | ||
1581 | - break; | ||
1582 | - case $ord_var_c == 0x0D: | ||
1583 | - $ascii .= '\r'; | ||
1584 | - break; | ||
1585 | - | ||
1586 | - case $ord_var_c == 0x22: | ||
1587 | - case $ord_var_c == 0x2F: | ||
1588 | - case $ord_var_c == 0x5C: | ||
1589 | - // double quote, slash, slosh | ||
1590 | - $ascii .= '\\'.$var{$c}; | ||
1591 | - break; | ||
1592 | - | ||
1593 | - case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)): | ||
1594 | - // characters U-00000000 - U-0000007F (same as ASCII) | ||
1595 | - $ascii .= $var{$c}; | ||
1596 | - break; | ||
1597 | - | ||
1598 | - case (($ord_var_c & 0xE0) == 0xC0): | ||
1599 | - // characters U-00000080 - U-000007FF, mask 110XXXXX | ||
1600 | - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 | ||
1601 | - $char = pack('C*', $ord_var_c, ord($var{$c + 1})); | ||
1602 | - $c += 1; | ||
1603 | - $utf16 = $this->json_utf82utf16($char); | ||
1604 | - $ascii .= sprintf('\u%04s', bin2hex($utf16)); | ||
1605 | - break; | ||
1606 | - | ||
1607 | - case (($ord_var_c & 0xF0) == 0xE0): | ||
1608 | - // characters U-00000800 - U-0000FFFF, mask 1110XXXX | ||
1609 | - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 | ||
1610 | - $char = pack('C*', $ord_var_c, | ||
1611 | - ord($var{$c + 1}), | ||
1612 | - ord($var{$c + 2})); | ||
1613 | - $c += 2; | ||
1614 | - $utf16 = $this->json_utf82utf16($char); | ||
1615 | - $ascii .= sprintf('\u%04s', bin2hex($utf16)); | ||
1616 | - break; | ||
1617 | - | ||
1618 | - case (($ord_var_c & 0xF8) == 0xF0): | ||
1619 | - // characters U-00010000 - U-001FFFFF, mask 11110XXX | ||
1620 | - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 | ||
1621 | - $char = pack('C*', $ord_var_c, | ||
1622 | - ord($var{$c + 1}), | ||
1623 | - ord($var{$c + 2}), | ||
1624 | - ord($var{$c + 3})); | ||
1625 | - $c += 3; | ||
1626 | - $utf16 = $this->json_utf82utf16($char); | ||
1627 | - $ascii .= sprintf('\u%04s', bin2hex($utf16)); | ||
1628 | - break; | ||
1629 | - | ||
1630 | - case (($ord_var_c & 0xFC) == 0xF8): | ||
1631 | - // characters U-00200000 - U-03FFFFFF, mask 111110XX | ||
1632 | - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 | ||
1633 | - $char = pack('C*', $ord_var_c, | ||
1634 | - ord($var{$c + 1}), | ||
1635 | - ord($var{$c + 2}), | ||
1636 | - ord($var{$c + 3}), | ||
1637 | - ord($var{$c + 4})); | ||
1638 | - $c += 4; | ||
1639 | - $utf16 = $this->json_utf82utf16($char); | ||
1640 | - $ascii .= sprintf('\u%04s', bin2hex($utf16)); | ||
1641 | - break; | ||
1642 | - | ||
1643 | - case (($ord_var_c & 0xFE) == 0xFC): | ||
1644 | - // characters U-04000000 - U-7FFFFFFF, mask 1111110X | ||
1645 | - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 | ||
1646 | - $char = pack('C*', $ord_var_c, | ||
1647 | - ord($var{$c + 1}), | ||
1648 | - ord($var{$c + 2}), | ||
1649 | - ord($var{$c + 3}), | ||
1650 | - ord($var{$c + 4}), | ||
1651 | - ord($var{$c + 5})); | ||
1652 | - $c += 5; | ||
1653 | - $utf16 = $this->json_utf82utf16($char); | ||
1654 | - $ascii .= sprintf('\u%04s', bin2hex($utf16)); | ||
1655 | - break; | ||
1656 | - } | ||
1657 | - } | ||
1658 | - | ||
1659 | - return '"'.$ascii.'"'; | ||
1660 | - | ||
1661 | - case 'array': | ||
1662 | - /* | ||
1663 | - * As per JSON spec if any array key is not an integer | ||
1664 | - * we must treat the the whole array as an object. We | ||
1665 | - * also try to catch a sparsely populated associative | ||
1666 | - * array with numeric keys here because some JS engines | ||
1667 | - * will create an array with empty indexes up to | ||
1668 | - * max_index which can cause memory issues and because | ||
1669 | - * the keys, which may be relevant, will be remapped | ||
1670 | - * otherwise. | ||
1671 | - * | ||
1672 | - * As per the ECMA and JSON specification an object may | ||
1673 | - * have any string as a property. Unfortunately due to | ||
1674 | - * a hole in the ECMA specification if the key is a | ||
1675 | - * ECMA reserved word or starts with a digit the | ||
1676 | - * parameter is only accessible using ECMAScript's | ||
1677 | - * bracket notation. | ||
1678 | - */ | ||
1679 | - | ||
1680 | - // treat as a JSON object | ||
1681 | - if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) { | ||
1682 | - | ||
1683 | - $this->json_objectStack[] = $var; | ||
1684 | - | ||
1685 | - $properties = array_map(array($this, 'json_name_value'), | ||
1686 | - array_keys($var), | ||
1687 | - array_values($var)); | ||
1688 | - | ||
1689 | - array_pop($this->json_objectStack); | ||
1690 | - | ||
1691 | - foreach($properties as $property) { | ||
1692 | - if ($property instanceof Exception) { | ||
1693 | - return $property; | ||
1694 | - } | ||
1695 | - } | ||
1696 | - | ||
1697 | - return '{' . join(',', $properties) . '}'; | ||
1698 | - } | ||
1699 | - | ||
1700 | - $this->json_objectStack[] = $var; | ||
1701 | - | ||
1702 | - // treat it like a regular array | ||
1703 | - $elements = array_map(array($this, 'json_encode'), $var); | ||
1704 | - | ||
1705 | - array_pop($this->json_objectStack); | ||
1706 | - | ||
1707 | - foreach($elements as $element) { | ||
1708 | - if ($element instanceof Exception) { | ||
1709 | - return $element; | ||
1710 | - } | ||
1711 | - } | ||
1712 | - | ||
1713 | - return '[' . join(',', $elements) . ']'; | ||
1714 | - | ||
1715 | - case 'object': | ||
1716 | - $vars = self::encodeObject($var); | ||
1717 | - | ||
1718 | - $this->json_objectStack[] = $var; | ||
1719 | - | ||
1720 | - $properties = array_map(array($this, 'json_name_value'), | ||
1721 | - array_keys($vars), | ||
1722 | - array_values($vars)); | ||
1723 | - | ||
1724 | - array_pop($this->json_objectStack); | ||
1725 | - | ||
1726 | - foreach($properties as $property) { | ||
1727 | - if ($property instanceof Exception) { | ||
1728 | - return $property; | ||
1729 | - } | ||
1730 | - } | ||
1731 | - | ||
1732 | - return '{' . join(',', $properties) . '}'; | ||
1733 | - | ||
1734 | - default: | ||
1735 | - return null; | ||
1736 | - } | ||
1737 | - } | ||
1738 | - | ||
1739 | - /** | ||
1740 | - * array-walking function for use in generating JSON-formatted name-value pairs | ||
1741 | - * | ||
1742 | - * @param string $name name of key to use | ||
1743 | - * @param mixed $value reference to an array element to be encoded | ||
1744 | - * | ||
1745 | - * @return string JSON-formatted name-value pair, like '"name":value' | ||
1746 | - * @access private | ||
1747 | - */ | ||
1748 | - private function json_name_value($name, $value) | ||
1749 | - { | ||
1750 | - // Encoding the $GLOBALS PHP array causes an infinite loop | ||
1751 | - // if the recursion is not reset here as it contains | ||
1752 | - // a reference to itself. This is the only way I have come up | ||
1753 | - // with to stop infinite recursion in this case. | ||
1754 | - if ($name=='GLOBALS' | ||
1755 | - && is_array($value) | ||
1756 | - && array_key_exists('GLOBALS',$value)) { | ||
1757 | - $value['GLOBALS'] = '** Recursion **'; | ||
1758 | - } | ||
1759 | - | ||
1760 | - $encoded_value = $this->json_encode($value); | ||
1761 | - | ||
1762 | - if ($encoded_value instanceof Exception) { | ||
1763 | - return $encoded_value; | ||
1764 | - } | ||
1765 | - | ||
1766 | - return $this->json_encode(strval($name)) . ':' . $encoded_value; | ||
1767 | - } | ||
1768 | - | ||
1769 | - /** | ||
1770 | - * @deprecated | ||
1771 | - */ | ||
1772 | - public function setProcessorUrl($URL) | ||
1773 | - { | ||
1774 | - trigger_error("The FirePHP::setProcessorUrl() method is no longer supported", E_USER_DEPRECATED); | ||
1775 | - } | ||
1776 | - | ||
1777 | - /** | ||
1778 | - * @deprecated | ||
1779 | - */ | ||
1780 | - public function setRendererUrl($URL) | ||
1781 | - { | ||
1782 | - trigger_error("The FirePHP::setRendererUrl() method is no longer supported", E_USER_DEPRECATED); | ||
1783 | - } | ||
1784 | -} |
php/firephp/LICENSE deleted
@@ -1,29 +0,0 @@ | @@ -1,29 +0,0 @@ | ||
1 | -Software License Agreement (New BSD License) | ||
2 | - | ||
3 | -Copyright (c) 2006-2009, Christoph Dorn | ||
4 | -All rights reserved. | ||
5 | - | ||
6 | -Redistribution and use in source and binary forms, with or without modification, | ||
7 | -are permitted provided that the following conditions are met: | ||
8 | - | ||
9 | - * Redistributions of source code must retain the above copyright notice, | ||
10 | - this list of conditions and the following disclaimer. | ||
11 | - | ||
12 | - * Redistributions in binary form must reproduce the above copyright notice, | ||
13 | - this list of conditions and the following disclaimer in the documentation | ||
14 | - and/or other materials provided with the distribution. | ||
15 | - | ||
16 | - * Neither the name of Christoph Dorn nor the names of its | ||
17 | - contributors may be used to endorse or promote products derived from this | ||
18 | - software without specific prior written permission. | ||
19 | - | ||
20 | -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
21 | -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
22 | -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
23 | -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
24 | -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
25 | -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
26 | -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
27 | -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
28 | -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
29 | -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
php/firephp/fb.php deleted
@@ -1,276 +0,0 @@ | @@ -1,276 +0,0 @@ | ||
1 | -<?php | ||
2 | - | ||
3 | -/* ***** BEGIN LICENSE BLOCK ***** | ||
4 | - * | ||
5 | - * This file is part of FirePHP (http://www.firephp.org/). | ||
6 | - * | ||
7 | - * Software License Agreement (New BSD License) | ||
8 | - * | ||
9 | - * Copyright (c) 2006-2010, Christoph Dorn | ||
10 | - * All rights reserved. | ||
11 | - * | ||
12 | - * Redistribution and use in source and binary forms, with or without modification, | ||
13 | - * are permitted provided that the following conditions are met: | ||
14 | - * | ||
15 | - * * Redistributions of source code must retain the above copyright notice, | ||
16 | - * this list of conditions and the following disclaimer. | ||
17 | - * | ||
18 | - * * Redistributions in binary form must reproduce the above copyright notice, | ||
19 | - * this list of conditions and the following disclaimer in the documentation | ||
20 | - * and/or other materials provided with the distribution. | ||
21 | - * | ||
22 | - * * Neither the name of Christoph Dorn nor the names of its | ||
23 | - * contributors may be used to endorse or promote products derived from this | ||
24 | - * software without specific prior written permission. | ||
25 | - * | ||
26 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
27 | - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
28 | - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
29 | - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
30 | - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
31 | - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
32 | - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
33 | - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
34 | - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
35 | - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
36 | - * | ||
37 | - * ***** END LICENSE BLOCK ***** | ||
38 | - * | ||
39 | - * @copyright Copyright (C) 2007-2009 Christoph Dorn | ||
40 | - * @author Christoph Dorn <christoph@christophdorn.com> | ||
41 | - * @license http://www.opensource.org/licenses/bsd-license.php | ||
42 | - * @package FirePHPCore | ||
43 | - */ | ||
44 | - | ||
45 | -if(!class_exists('FirePHP')) { | ||
46 | - require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'FirePHP.class.php'; | ||
47 | -} | ||
48 | - | ||
49 | -/** | ||
50 | - * Sends the given data to the FirePHP Firefox Extension. | ||
51 | - * The data can be displayed in the Firebug Console or in the | ||
52 | - * "Server" request tab. | ||
53 | - * | ||
54 | - * @see http://www.firephp.org/Wiki/Reference/Fb | ||
55 | - * @param mixed $Object | ||
56 | - * @return true | ||
57 | - * @throws Exception | ||
58 | - */ | ||
59 | -function fb() | ||
60 | -{ | ||
61 | - $instance = FirePHP::getInstance(true); | ||
62 | - | ||
63 | - $args = func_get_args(); | ||
64 | - return call_user_func_array(array($instance,'fb'),$args); | ||
65 | -} | ||
66 | - | ||
67 | - | ||
68 | -class FB | ||
69 | -{ | ||
70 | - /** | ||
71 | - * Enable and disable logging to Firebug | ||
72 | - * | ||
73 | - * @see FirePHP->setEnabled() | ||
74 | - * @param boolean $Enabled TRUE to enable, FALSE to disable | ||
75 | - * @return void | ||
76 | - */ | ||
77 | - public static function setEnabled($Enabled) | ||
78 | - { | ||
79 | - $instance = FirePHP::getInstance(true); | ||
80 | - $instance->setEnabled($Enabled); | ||
81 | - } | ||
82 | - | ||
83 | - /** | ||
84 | - * Check if logging is enabled | ||
85 | - * | ||
86 | - * @see FirePHP->getEnabled() | ||
87 | - * @return boolean TRUE if enabled | ||
88 | - */ | ||
89 | - public static function getEnabled() | ||
90 | - { | ||
91 | - $instance = FirePHP::getInstance(true); | ||
92 | - return $instance->getEnabled(); | ||
93 | - } | ||
94 | - | ||
95 | - /** | ||
96 | - * Specify a filter to be used when encoding an object | ||
97 | - * | ||
98 | - * Filters are used to exclude object members. | ||
99 | - * | ||
100 | - * @see FirePHP->setObjectFilter() | ||
101 | - * @param string $Class The class name of the object | ||
102 | - * @param array $Filter An array or members to exclude | ||
103 | - * @return void | ||
104 | - */ | ||
105 | - public static function setObjectFilter($Class, $Filter) | ||
106 | - { | ||
107 | - $instance = FirePHP::getInstance(true); | ||
108 | - $instance->setObjectFilter($Class, $Filter); | ||
109 | - } | ||
110 | - | ||
111 | - /** | ||
112 | - * Set some options for the library | ||
113 | - * | ||
114 | - * @see FirePHP->setOptions() | ||
115 | - * @param array $Options The options to be set | ||
116 | - * @return void | ||
117 | - */ | ||
118 | - public static function setOptions($Options) | ||
119 | - { | ||
120 | - $instance = FirePHP::getInstance(true); | ||
121 | - $instance->setOptions($Options); | ||
122 | - } | ||
123 | - | ||
124 | - /** | ||
125 | - * Get options for the library | ||
126 | - * | ||
127 | - * @see FirePHP->getOptions() | ||
128 | - * @return array The options | ||
129 | - */ | ||
130 | - public static function getOptions() | ||
131 | - { | ||
132 | - $instance = FirePHP::getInstance(true); | ||
133 | - return $instance->getOptions(); | ||
134 | - } | ||
135 | - | ||
136 | - /** | ||
137 | - * Log object to firebug | ||
138 | - * | ||
139 | - * @see http://www.firephp.org/Wiki/Reference/Fb | ||
140 | - * @param mixed $Object | ||
141 | - * @return true | ||
142 | - * @throws Exception | ||
143 | - */ | ||
144 | - public static function send() | ||
145 | - { | ||
146 | - $instance = FirePHP::getInstance(true); | ||
147 | - $args = func_get_args(); | ||
148 | - return call_user_func_array(array($instance,'fb'),$args); | ||
149 | - } | ||
150 | - | ||
151 | - /** | ||
152 | - * Start a group for following messages | ||
153 | - * | ||
154 | - * Options: | ||
155 | - * Collapsed: [true|false] | ||
156 | - * Color: [#RRGGBB|ColorName] | ||
157 | - * | ||
158 | - * @param string $Name | ||
159 | - * @param array $Options OPTIONAL Instructions on how to log the group | ||
160 | - * @return true | ||
161 | - */ | ||
162 | - public static function group($Name, $Options=null) | ||
163 | - { | ||
164 | - $instance = FirePHP::getInstance(true); | ||
165 | - return $instance->group($Name, $Options); | ||
166 | - } | ||
167 | - | ||
168 | - /** | ||
169 | - * Ends a group you have started before | ||
170 | - * | ||
171 | - * @return true | ||
172 | - * @throws Exception | ||
173 | - */ | ||
174 | - public static function groupEnd() | ||
175 | - { | ||
176 | - return self::send(null, null, FirePHP::GROUP_END); | ||
177 | - } | ||
178 | - | ||
179 | - /** | ||
180 | - * Log object with label to firebug console | ||
181 | - * | ||
182 | - * @see FirePHP::LOG | ||
183 | - * @param mixes $Object | ||
184 | - * @param string $Label | ||
185 | - * @return true | ||
186 | - * @throws Exception | ||
187 | - */ | ||
188 | - public static function log($Object, $Label=null) | ||
189 | - { | ||
190 | - return self::send($Object, $Label, FirePHP::LOG); | ||
191 | - } | ||
192 | - | ||
193 | - /** | ||
194 | - * Log object with label to firebug console | ||
195 | - * | ||
196 | - * @see FirePHP::INFO | ||
197 | - * @param mixes $Object | ||
198 | - * @param string $Label | ||
199 | - * @return true | ||
200 | - * @throws Exception | ||
201 | - */ | ||
202 | - public static function info($Object, $Label=null) | ||
203 | - { | ||
204 | - return self::send($Object, $Label, FirePHP::INFO); | ||
205 | - } | ||
206 | - | ||
207 | - /** | ||
208 | - * Log object with label to firebug console | ||
209 | - * | ||
210 | - * @see FirePHP::WARN | ||
211 | - * @param mixes $Object | ||
212 | - * @param string $Label | ||
213 | - * @return true | ||
214 | - * @throws Exception | ||
215 | - */ | ||
216 | - public static function warn($Object, $Label=null) | ||
217 | - { | ||
218 | - return self::send($Object, $Label, FirePHP::WARN); | ||
219 | - } | ||
220 | - | ||
221 | - /** | ||
222 | - * Log object with label to firebug console | ||
223 | - * | ||
224 | - * @see FirePHP::ERROR | ||
225 | - * @param mixes $Object | ||
226 | - * @param string $Label | ||
227 | - * @return true | ||
228 | - * @throws Exception | ||
229 | - */ | ||
230 | - public static function error($Object, $Label=null) | ||
231 | - { | ||
232 | - return self::send($Object, $Label, FirePHP::ERROR); | ||
233 | - } | ||
234 | - | ||
235 | - /** | ||
236 | - * Dumps key and variable to firebug server panel | ||
237 | - * | ||
238 | - * @see FirePHP::DUMP | ||
239 | - * @param string $Key | ||
240 | - * @param mixed $Variable | ||
241 | - * @return true | ||
242 | - * @throws Exception | ||
243 | - */ | ||
244 | - public static function dump($Key, $Variable) | ||
245 | - { | ||
246 | - return self::send($Variable, $Key, FirePHP::DUMP); | ||
247 | - } | ||
248 | - | ||
249 | - /** | ||
250 | - * Log a trace in the firebug console | ||
251 | - * | ||
252 | - * @see FirePHP::TRACE | ||
253 | - * @param string $Label | ||
254 | - * @return true | ||
255 | - * @throws Exception | ||
256 | - */ | ||
257 | - public static function trace($Label) | ||
258 | - { | ||
259 | - return self::send($Label, FirePHP::TRACE); | ||
260 | - } | ||
261 | - | ||
262 | - /** | ||
263 | - * Log a table in the firebug console | ||
264 | - * | ||
265 | - * @see FirePHP::TABLE | ||
266 | - * @param string $Label | ||
267 | - * @param string $Table | ||
268 | - * @return true | ||
269 | - * @throws Exception | ||
270 | - */ | ||
271 | - public static function table($Label, $Table) | ||
272 | - { | ||
273 | - return self::send($Table, $Label, FirePHP::TABLE); | ||
274 | - } | ||
275 | - | ||
276 | -} |
php/makeMultiMission.php deleted
@@ -1,186 +0,0 @@ | @@ -1,186 +0,0 @@ | ||
1 | -<?php | ||
2 | -/** @file makeMultiMission | ||
3 | -* @version $Id: makeMultiMission.php 2321 2014-04-26 12:36:18Z elena $ | ||
4 | -* @brief StandAlone executable launched in BASE_PATH/php to create LOCALLY | ||
5 | -* @brief DD_MISSION.xml and MISSION.xml from templates | ||
6 | -* @brief and LocalParamsList.xml and LocalParams.xml | ||
7 | -* @brief it is analog of AmdaUpdate.php INSTALL | ||
8 | -*/ | ||
9 | - require_once "config.php"; | ||
10 | - | ||
11 | - $missionsDom = new DomDocument("1.0"); | ||
12 | - $missionsDom->load(missionXml); | ||
13 | - $locBases = $missionsDom->getElementsByTagName("MissionID"); | ||
14 | - | ||
15 | - foreach ($locBases as $locbase) { | ||
16 | - $multi = $locbase->getAttribute("missions"); | ||
17 | - $nameArr = explode(";",$multi); | ||
18 | - | ||
19 | - $templatename = LocalDataTemplate."DD_".$locbase->nodeValue.".template"; | ||
20 | - $paramtemplate = LocalDataTemplate.$locbase->nodeValue.".template"; | ||
21 | - if (count($nameArr) > 1 && | ||
22 | - (file_exists($templatename) && file_exists($paramtemplate))) { | ||
23 | - | ||
24 | - $suffix = array(); | ||
25 | - foreach ($nameArr as $item) { | ||
26 | - $temp = explode("-",$item); | ||
27 | - if (count($temp) > 1) { | ||
28 | - $suffix[] = $temp[1]; | ||
29 | - } | ||
30 | - else { | ||
31 | - $suffix[] = substr($item,-1); | ||
32 | - } | ||
33 | - } | ||
34 | - | ||
35 | - $template = new DomDocument("1.0"); | ||
36 | - $status = $template->load($templatename); | ||
37 | - | ||
38 | - $paramdom = new DomDocument("1.0"); | ||
39 | - $status = $paramdom->load($paramtemplate); | ||
40 | - | ||
41 | - | ||
42 | -// Create DD_Mission.xml | ||
43 | - $locbasename = LocalData."DD_".$locbase->nodeValue.".xml"; | ||
44 | - $locbasedom = new DomDocument("1.0"); | ||
45 | - $root = $locbasedom->importNode($template->documentElement); | ||
46 | - $amda = $locbasedom->importNode($template->getElementsByTagName("dataCenter")->item(0)); | ||
47 | - $missionMain = $locbasedom->importNode($template->getElementsByTagName("mission")->item(0)); | ||
48 | - | ||
49 | - $mission = $locbasedom->importNode($template->getElementsByTagName("mission")->item(0), true); | ||
50 | - | ||
51 | - $targets = $mission->getElementsByTagName("target"); | ||
52 | - $targetNames = array(); | ||
53 | - foreach ($targets as $target) | ||
54 | - if ($target->parentNode->tagName == 'mission') | ||
55 | - $targetNames[] = $target->nodeValue; | ||
56 | - | ||
57 | - $observatory = $mission->getElementsByTagName("observatory")->item(0); | ||
58 | - $instruments = $observatory->getElementsByTagName("instrument"); | ||
59 | -// create param descriptor Mission.xml | ||
60 | - $parambasename = LocalDataParam.$locbase->nodeValue.".xml"; | ||
61 | - $parambasedom = new DomDocument("1.0"); | ||
62 | - $paramroot = $parambasedom->importNode($paramdom->documentElement); | ||
63 | - | ||
64 | - $instrumentNon = array(); | ||
65 | - foreach ($instruments as $instrument) { | ||
66 | - | ||
67 | - if ($instrument->hasAttribute("absent")) { | ||
68 | - $absent = $instrument->getAttribute("absent"); | ||
69 | - $absentArray = explode(";",$absent); | ||
70 | - $tempArr = array(); | ||
71 | - | ||
72 | - if (count($absentArray) > 1) { | ||
73 | - for ($i = 0; $i < count($suffix); $i++) $tempArr[$i] = false; | ||
74 | - for ($j = 0; $j < count($absentArray); $j++) { | ||
75 | - $temp = array_search($absentArray[$j], $suffix, true); | ||
76 | - $tempArr[$temp] = true; | ||
77 | - } | ||
78 | - | ||
79 | - } | ||
80 | - else { | ||
81 | - for ($i = 0; $i < count($suffix); $i++) { | ||
82 | - $tempArr[$i] = $absent == $suffix[$i]; | ||
83 | - } | ||
84 | - } | ||
85 | - | ||
86 | - $instrumentNon[$instrument->getAttribute("name")] = $tempArr; | ||
87 | - } | ||
88 | - } | ||
89 | - | ||
90 | - foreach ($targetNames as $targetName) { | ||
91 | - $missionMain->appendChild($locbasedom->createElement("target",$targetName)); | ||
92 | - } | ||
93 | - | ||
94 | - for ($index = 0; $index < count($suffix); $index++) { | ||
95 | - | ||
96 | - $missionArr[$index] = $observatory->cloneNode(); | ||
97 | - | ||
98 | - $missionArr[$index]->setAttribute("name", str_replace("XXX", $suffix[$index], $missionArr[$index]->getAttribute("name"))); | ||
99 | - $missionArr[$index]->setAttribute("xml:id", str_replace("XXX", $suffix[$index], $missionArr[$index]->getAttribute("name"))); | ||
100 | - $instruments = $observatory->getElementsByTagName("instrument"); | ||
101 | - | ||
102 | - foreach ($instruments as $instrumentReal){ | ||
103 | - if (!$instrumentNon[$instrumentReal->getAttribute("name")] || !$instrumentNon[$instrumentReal->getAttribute("name")][$index]) { | ||
104 | - $instrument = $instrumentReal->cloneNode(true); | ||
105 | - $instrument->setAttribute("desc",str_replace("XXX", $suffix[$index], $instrument->getAttribute("desc"))); | ||
106 | - $instrument->setAttribute("xml:id",str_replace("XXX", $suffix[$index], $instrument->getAttribute("xml:id"))); | ||
107 | - $tags = array("dataset", "parameter", "component"); | ||
108 | - | ||
109 | - foreach ($tags as $tag) { | ||
110 | - $all = $instrument->getElementsByTagName($tag); | ||
111 | - foreach ($all as $one) { | ||
112 | - if ($tag == 'parameter') { | ||
113 | - $id = $one->getAttribute("xml:id"); | ||
114 | - // create param tag in param XML descriptor | ||
115 | - $param = $paramdom->getElementById($id); | ||
116 | - if ($param){ | ||
117 | - $paramAdd = $parambasedom->importNode($param, true); | ||
118 | - $paramAdd->setAttribute("xml:id",str_replace("XXX", strtolower($suffix[$index]), $id)); | ||
119 | - $paramAdd->setAttribute("vi",str_replace("XXX", strtolower($suffix[$index]), $paramAdd->getAttribute("vi"))); | ||
120 | - $yTitle = $paramAdd->getElementsByTagName("YTITLE"); | ||
121 | - if ($yTitle->length > 0) { | ||
122 | - $value = $yTitle->item(0)->nodeValue; | ||
123 | - $yTitle->item(0)->nodeValue = str_replace("XXX", $suffix[$index], $value); | ||
124 | - } | ||
125 | - $paramroot->appendChild($paramAdd); | ||
126 | - } | ||
127 | - } | ||
128 | - $one->setAttribute("xml:id",str_replace("XXX", strtolower($suffix[$index]), $one->getAttribute("xml:id"))); | ||
129 | - if ($tag == 'dataset' && $one->hasAttribute("vi")) | ||
130 | - $one->setAttribute("vi",str_replace("XXX", strtolower($suffix[$index]), $one->getAttribute("vi"))); | ||
131 | - } | ||
132 | - } | ||
133 | - $missionArr[$index]->appendChild($instrument); | ||
134 | - } | ||
135 | - } | ||
136 | - | ||
137 | - $missionMain->appendChild($missionArr[$index]); | ||
138 | - } | ||
139 | - | ||
140 | - $amda->appendChild($missionMain); | ||
141 | - $root->appendChild($amda); | ||
142 | - $locbasedom->appendChild($root); | ||
143 | - $locbasedom->save($locbasename); | ||
144 | - | ||
145 | - $parambasedom->appendChild($paramroot); | ||
146 | - $parambasedom->save($parambasename); | ||
147 | - } | ||
148 | - } | ||
149 | - | ||
150 | -// temporary here | ||
151 | - $paramsDom = new DomDocument("1.0"); | ||
152 | - $paramsDom->formatOutput = true; | ||
153 | - $paramsDom->preserveWhiteSpace = false; | ||
154 | - $paramsRoot = $paramsDom->createElement('LOCAL'); | ||
155 | - $paramsDom->appendChild($paramsRoot); | ||
156 | - | ||
157 | - $listDom = new DomDocument("1.0"); | ||
158 | - $listDom->formatOutput = true; | ||
159 | - $listDom->preserveWhiteSpace = false; | ||
160 | - $listRoot = $listDom->createElement('LOCAL'); | ||
161 | - $listDom->appendChild($listRoot); | ||
162 | - | ||
163 | - $dom = new DomDocument("1.0"); | ||
164 | - foreach ($locBases as $locbase) | ||
165 | - { | ||
166 | - $ddparamfilename = $locbase->nodeValue.".xml"; | ||
167 | - | ||
168 | - $status = $dom->load(LocalDataParam.$ddparamfilename); | ||
169 | - $params = $dom->getElementsByTagName('PARAM'); | ||
170 | - // if ($locbase->nodeValue == 'SW_Mars') printf($status.PHP_EOL); | ||
171 | - foreach ($params as $param) | ||
172 | - { | ||
173 | - $node = $paramsDom->importNode($param,TRUE); | ||
174 | - $paramsRoot->appendChild($node); | ||
175 | - $id = $param->getAttribute('xml:id'); | ||
176 | - // if ($locbase->nodeValue == 'SW_Mars') printf($id.PHP_EOL); | ||
177 | - $node = $listDom->createElement('PARAM',$id); | ||
178 | - $listRoot->appendChild($node); | ||
179 | - | ||
180 | - } | ||
181 | - } | ||
182 | - | ||
183 | - $paramsDom->save(paramXml); | ||
184 | - $listDom->save(paramListXml); | ||
185 | - | ||
186 | -?> |
php/old_amda/ParamBuilder.php deleted
@@ -1,526 +0,0 @@ | @@ -1,526 +0,0 @@ | ||
1 | -<?php | ||
2 | -/** @class ParamBuilder | ||
3 | -* @version $Id: ParamBuilder.php 2918 2015-05-19 13:12:09Z elena $ | ||
4 | -* @brief | ||
5 | -* | ||
6 | -*/ | ||
7 | -class ParamBuilder { | ||
8 | - | ||
9 | - private $TargetDir, $PRODIR, $PredefinedDir; | ||
10 | - public $file; | ||
11 | - public $components; | ||
12 | - | ||
13 | - function __construct(){ | ||
14 | - $this->TargetDir = './'; | ||
15 | -// new amda | ||
16 | - $this->PRODIR = TEMPLATES; | ||
17 | - $this->PredefinedDir = PREDEFINED; | ||
18 | - } | ||
19 | - | ||
20 | - protected function param2dd($paramID){ | ||
21 | - $pairs = array(":" => "_"); | ||
22 | - return strtr($paramID, $pairs); | ||
23 | - } | ||
24 | - protected function param2ddPoint($paramID){ | ||
25 | - $pairs = array(":" => "_", "." => "_"); | ||
26 | - return strtr($paramID, $pairs); | ||
27 | - } | ||
28 | - public function makeNewChain($chain, $vars){ | ||
29 | - | ||
30 | -// cleanup components array !!! | ||
31 | - | ||
32 | - $this->components = array(); | ||
33 | - rsort($vars); | ||
34 | - | ||
35 | - for ($i = 0; $i < count($vars); $i++){ | ||
36 | - $start = 0; | ||
37 | - | ||
38 | - while (($pos = strpos($chain, $vars[$i], $start)) !== false) { | ||
39 | - | ||
40 | - $moreLong = false; | ||
41 | - | ||
42 | - if ($i > 0) { | ||
43 | - for ($k = 0; $k < $i; $k++) { | ||
44 | - if (substr($vars[$k],0,strlen($vars[$i])) === $vars[$i]) { | ||
45 | - if (strpos($chain, $vars[$k], $pos) !== false) { | ||
46 | - $moreLong = true; | ||
47 | - $start = $pos+strlen($vars[$k]); | ||
48 | - $break; | ||
49 | - } | ||
50 | - } | ||
51 | - } | ||
52 | - } | ||
53 | - | ||
54 | - if (!$moreLong) { | ||
55 | - | ||
56 | - if (($open = strpos($chain,$vars[$i]."(",$start)) === false) { | ||
57 | - $chain = substr_replace($chain,$vars[$i]."(num)", $pos, strlen($vars[$i])); | ||
58 | - $this->components[] = $vars[$i]."(*)"; | ||
59 | - $start = $pos+strlen($vars[$i]); | ||
60 | - } | ||
61 | - else { | ||
62 | - $close = strpos($chain, ",num)", $open); | ||
63 | - if ($close !== false && ($close-$open) < (strlen($vars[$i])+5)) { | ||
64 | - $start = $open+strlen($vars[$i]); | ||
65 | - } | ||
66 | - else { | ||
67 | - $close = strpos($chain,")",$open); | ||
68 | - $vector_pos = strpos($chain,":",$open); | ||
69 | - if ($vector_pos === false || $vector_pos > $close) { | ||
70 | - $chain = substr_replace($chain,",num)",$close,1); | ||
71 | - $this->components[] = substr($chain,$open,$close-$open).",*)"; | ||
72 | - } | ||
73 | - else { | ||
74 | - $comp = substr($chain, $vector_pos+3, 1); | ||
75 | - $this->components[] = substr($chain,$open,strlen($vars[$i]))."(".$comp.",*)"; | ||
76 | - $chain = substr_replace($chain,",num),".$comp, $close-2, 3); | ||
77 | - } | ||
78 | - $start = $open+strlen($vars[$i]); | ||
79 | - } | ||
80 | - } | ||
81 | - } | ||
82 | - } | ||
83 | - } | ||
84 | - | ||
85 | - $this->components = array_unique($this->components); | ||
86 | - | ||
87 | - return $chain; | ||
88 | - } | ||
89 | - | ||
90 | - | ||
91 | - | ||
92 | - public function makeParamCalcul($chain, $vars, $name) { | ||
93 | - | ||
94 | - | ||
95 | - foreach ($vars as &$var) $var = $this->param2dd($var); | ||
96 | - $chain = $this->param2dd($chain); | ||
97 | - | ||
98 | - $newChain = $this->makeNewChain($chain, $vars); | ||
99 | - | ||
100 | - $function_name = $name == "" ? "paramcalcul" : strtolower($name)."_calcul"; | ||
101 | - $fillValue = $name == "" ? "3" : "!Values.F_NAN"; | ||
102 | - | ||
103 | - $pro = fopen($this->TargetDir.$function_name.".pro", "w"); | ||
104 | - fwrite($pro,"function ".$function_name.",".join(",",$vars).PHP_EOL); | ||
105 | - fwrite($pro,"common InternalCommon, FinalTime, num".PHP_EOL); | ||
106 | - fwrite($pro,"OutPut = REPLICATE(".$fillValue.", N_Elements(FinalTime))".PHP_EOL); | ||
107 | - fwrite($pro,"num = -1L\n"); | ||
108 | -/* | ||
109 | -* !!!! array_unique($this->components) -> keeps unset empty values!!! | ||
110 | -*/ | ||
111 | - | ||
112 | - foreach ($this->components as $comp) { | ||
113 | - fwrite($pro," num_ = where(finite(".$comp."), Index)\n"); | ||
114 | - fwrite($pro," if (Index eq 0) then return, OutPut\n"); | ||
115 | - fwrite($pro," if (num[0] eq -1L) then num = num_ $\n else begin\n numTemp = -1L\n k = -1L\n j0 = 0L\n"); | ||
116 | - fwrite($pro," for i = 0L, n_elements(num) - 1 do begin\n for j = j0, n_elements(num_) - 1 do begin\n"); | ||
117 | - fwrite($pro," if (num[i] eq num_[j]) then begin\n k++\n if (k eq 0) then numTemp = num[i] $\n else numTemp = [numTemp, num[i]]\n"); | ||
118 | - fwrite($pro," j0 = j+1\n break\n endif\n endfor\n endfor\n"); | ||
119 | - fwrite($pro," if (j0 gt 0) then num = numTemp else return, OutPut\n endelse \n"); | ||
120 | - } | ||
121 | - // printf, LUN, 'On_error,2' | ||
122 | - fwrite($pro,"OutPut[num] = ".$newChain.PHP_EOL); | ||
123 | - fwrite($pro,"return, OutPut".PHP_EOL); | ||
124 | - fwrite($pro,"end".PHP_EOL); | ||
125 | - fclose($pro); | ||
126 | - } | ||
127 | - | ||
128 | -/* | ||
129 | -* | ||
130 | -* Make all staff for local params from templates & descriptor XML | ||
131 | -* | ||
132 | -*/ | ||
133 | - public function paramLocalBuild($id) { | ||
134 | -/* | ||
135 | -* Get Param Info | ||
136 | -*/ | ||
137 | - | ||
138 | - $infoMgr = new ParamsInfoMgr(); | ||
139 | - $infos = $infoMgr->GetParamInfo($id); | ||
140 | - | ||
141 | - if (!$infos['success']) | ||
142 | - { | ||
143 | - die($infos['message']); | ||
144 | - } | ||
145 | - | ||
146 | - | ||
147 | - $name = $infos['codeinfos']['name']; | ||
148 | - $vi = $infos['codeinfos']['vi']; | ||
149 | - $size = $infos['codeinfos']['size']; | ||
150 | - $tensor = $infos['codeinfos']['tensor']; | ||
151 | - if ($tensor == '') | ||
152 | - $tensor = -1; | ||
153 | - $value_type = $infos['codeinfos']['valuetype']; | ||
154 | - $fill_value = $infos['codeinfos']['fillvalue']; | ||
155 | - if ($fill_value == "NaN") | ||
156 | - $fill_value = "!Values.F_NAN"; | ||
157 | - $units = $infos['codeinfos']['units']; | ||
158 | - $sampling = $infos['codeinfos']['minsampling']; | ||
159 | - $maxSampling = $infos['codeinfos']['maxsampling']; | ||
160 | - $frame = $infos['codeinfos']['frame']; | ||
161 | - $legend = $infos['codeinfos']['legend']; | ||
162 | - $title = $infos['codeinfos']['title']; | ||
163 | - $plottype = $infos['codeinfos']['plottype']; | ||
164 | - $mission = $infos['codeinfos']['mission']; | ||
165 | - $energychannel = $infos['codeinfos']['energychannel']; | ||
166 | - if ($energychannel == '') | ||
167 | - $energychannel = 'Energy'; | ||
168 | - | ||
169 | - $ytitle = $units != NULL ? $title.",!C".$units : $title; | ||
170 | - $conversion = $infos['codeinfos']['conversion']; | ||
171 | - $process = $infos['codeinfos']['process']; | ||
172 | - | ||
173 | -/* | ||
174 | -* Make init | ||
175 | -*/ | ||
176 | - | ||
177 | - if (file_exists($this->PredefinedDir.$id."_init.pro")) { | ||
178 | - copy($this->PredefinedDir.$id."_init.pro", $this->TargetDir.$id."_init.pro"); | ||
179 | - } | ||
180 | - else { | ||
181 | - $newfile = fopen($this->TargetDir.$id."_init.pro","w"); | ||
182 | - $pairs = array("LOCALPARAM" => $id,"LOCALTENSOR"=>$tensor,"LOCALSIZE"=>$size,"LOCALYTITLE"=>"'".$ytitle."'","LOCALPROCESS"=>"'".$process."'", | ||
183 | - "LOCALFRAME"=>"'".$frame."'","LOCALMISSION"=>"'".$mission."'","LOCALPLOTTYPE"=>"'".$plottype."'", "LOCALLEGEND"=>"'".$legend."'"); | ||
184 | - $lines = file($this->PRODIR."localparam_init.pro"); | ||
185 | - for ($i = 0; $i < count($lines); $i++) { | ||
186 | - $newline = strtr($lines[$i],$pairs); | ||
187 | - fwrite($newfile,$newline); | ||
188 | - } | ||
189 | - fclose($newfile); | ||
190 | - | ||
191 | - if ($size > 1) { | ||
192 | - $comp = array("/X", "/Y", "/Z"); | ||
193 | -// VECTOR | ||
194 | - if ($size <= 3) { | ||
195 | - $comp = array("/X", "/Y", "/Z"); | ||
196 | - for ($i = 0; $i < $size; $i++) { | ||
197 | - $newfile = fopen($id."_".$i."_init.pro", "w"); | ||
198 | - fwrite($newfile,"pro ".$id."_".$i."_init, FRAME=frame,LOG=log,LIN=lin,COLOR=color,PSYM=psym,AY1TITLE=aytitle, _EXTRA=e".PHP_EOL); | ||
199 | - fwrite($newfile,"cmd = '".$id."_init, ".$comp[$i]."'".PHP_EOL); | ||
200 | - fwrite($newfile, "if KEYWORD_SET(COLOR) then cmd += ',COLOR=color'".PHP_EOL); | ||
201 | - fwrite($newfile, "if KEYWORD_SET(FRAME) then cmd += ',FRAME=frame'".PHP_EOL); | ||
202 | - fwrite($newfile, "if KEYWORD_SET(PSYM) then cmd += ',PSYM=psym'".PHP_EOL); | ||
203 | - fwrite($newfile, "if KEYWORD_SET(LOG) then cmd += ',/LOG'".PHP_EOL); | ||
204 | - fwrite($newfile, "if KEYWORD_SET(LIN) then cmd += ',/LIN'".PHP_EOL); | ||
205 | - fwrite($newfile, "if KEYWORD_SET(AY1TITLE) then cmd += ',AY1TITLE=ay1title'".PHP_EOL); | ||
206 | - fwrite($newfile,"R = execute(cmd)".PHP_EOL); | ||
207 | - fwrite($newfile,"return".PHP_EOL); | ||
208 | - fwrite($newfile,"end".PHP_EOL); | ||
209 | - fclose($newfile); | ||
210 | - } | ||
211 | - } | ||
212 | - elseif ($plottype == "STACK") { | ||
213 | - for ($i = 0; $i < $size; $i++) { | ||
214 | - $newfile = fopen($id."_".$i."_init.pro", "w"); | ||
215 | - fwrite($newfile,"pro ".$id."_".$i."_init, LOG=log,LIN=lin,COLOR=color,PSYM=psym,AY1TITLE=aytitle, _EXTRA=e".PHP_EOL); | ||
216 | - fwrite($newfile,"cmd = '".$id."_init, CHANNEL=".($i+1)."'".PHP_EOL); | ||
217 | - fwrite($newfile, "if KEYWORD_SET(COLOR) then cmd += ',COLOR=color'".PHP_EOL); | ||
218 | - fwrite($newfile, "if KEYWORD_SET(PSYM) then cmd += ',PSYM=psym'".PHP_EOL); | ||
219 | - fwrite($newfile, "if KEYWORD_SET(LOG) then cmd += ',/LOG'".PHP_EOL); | ||
220 | - fwrite($newfile, "if KEYWORD_SET(LIN) then cmd += ',/LIN'".PHP_EOL); | ||
221 | - fwrite($newfile, "if KEYWORD_SET(AY1TITLE) then cmd += ',AY1TITLE=ay1title'".PHP_EOL); | ||
222 | - fwrite($newfile,"R = execute(cmd)".PHP_EOL); | ||
223 | - fwrite($newfile,"return".PHP_EOL); | ||
224 | - fwrite($newfile,"end".PHP_EOL); | ||
225 | - fclose($newfile); | ||
226 | - } | ||
227 | - | ||
228 | - } | ||
229 | -// TENSOR; diagonal elements | ||
230 | - elseif ($size == 9 && $tensor == 2) { | ||
231 | - $sizeR = array(0, 4, 8); | ||
232 | - for ($i = 0; $i < 3; $i++) { | ||
233 | - $newfile = fopen($id."_".$sizeR[$i]."_init.pro", "w"); | ||
234 | - fwrite($newfile,"pro ".$id."_".$sizeR[$i]."_init, LOG=log,LIN=lin,COLOR=color,PSYM=psym,AY1TITLE=aytitle, _EXTRA=e".PHP_EOL); | ||
235 | - fwrite($newfile,"cmd = '".$id."_init, ".$comp[$i].PHP_EOL); | ||
236 | - fwrite($newfile, "if KEYWORD_SET(COLOR) then cmd += ',COLOR=color'".PHP_EOL); | ||
237 | - fwrite($newfile, "if KEYWORD_SET(PSYM) then cmd += ',PSYM=psym'".PHP_EOL); | ||
238 | - fwrite($newfile, "if KEYWORD_SET(LOG) then cmd += ',/LOG'".PHP_EOL); | ||
239 | - fwrite($newfile, "if KEYWORD_SET(LIN) then cmd += ',/LIN'".PHP_EOL); | ||
240 | - fwrite($newfile, "if KEYWORD_SET(AY1TITLE) then cmd += ',AY1TITLE=ay1title'".PHP_EOL); | ||
241 | - fwrite($newfile,"R = execute(cmd)".PHP_EOL); | ||
242 | - fwrite($newfile,"return".PHP_EOL); | ||
243 | - fwrite($newfile,"end".PHP_EOL); | ||
244 | - fclose($newfile); | ||
245 | - } | ||
246 | - } | ||
247 | - } | ||
248 | - } | ||
249 | -/* | ||
250 | -* Make com | ||
251 | -*/ | ||
252 | - if (file_exists($this->PredefinedDir.$id."_com.pro")) { | ||
253 | - copy($this->PredefinedDir.$id."_com.pro", $this->TargetDir.$id."_com.pro"); | ||
254 | - } | ||
255 | - else { | ||
256 | - $newfile = fopen($this->TargetDir.$id."_com.pro","w"); | ||
257 | - $pairs = array("LOCALPARAM" => $id,"LOCALSIZE"=>$size,"LOCALSAMPLING"=>$sampling, "LOCALMAXSAMPLING"=>$maxSampling,"LOCALFILLVALUE"=>$fill_value, | ||
258 | - "LOCALPLOTTYPE"=>"'".$plottype."'","LOCALVI"=>"'".$vi."'","LOCALENERGYCHANNEL"=>"'".$energychannel."'", | ||
259 | - "LOCALCONVERSION" => "'".$conversion."'"); | ||
260 | - | ||
261 | - $lines = file($this->PRODIR."localparam_com.pro"); | ||
262 | - for ($i = 0; $i < count($lines); $i++) { | ||
263 | - $newline = strtr($lines[$i],$pairs); | ||
264 | - fwrite($newfile,$newline); | ||
265 | - } | ||
266 | - fclose($newfile); | ||
267 | - } | ||
268 | -/* | ||
269 | -* Make get | ||
270 | -*/ | ||
271 | - if (file_exists($this->PredefinedDir."get".$id.".pro")) { | ||
272 | - copy($this->PredefinedDir."get".$id.".pro", $this->TargetDir."get".$id.".pro"); | ||
273 | - } | ||
274 | - else { | ||
275 | - $newfile = fopen($this->TargetDir."get".$id.".pro","w"); | ||
276 | - $pairs = array("LOCALPARAM" => $id,"LOCALSIZE"=>$size,"LOCALPARAMNAME"=>"'".$this->param2ddPoint($name)."'", | ||
277 | - "LOCALVI"=>"'".$vi."'", "LOCALDATATYPE" => "'".$value_type."'", "LOCALCONVERSION" => "'".$conversion."'"); | ||
278 | - $lines = file($this->PRODIR."getlocalparam.pro"); | ||
279 | - for ($i = 0; $i < count($lines); $i++) { | ||
280 | - $newline = strtr($lines[$i],$pairs); | ||
281 | - fwrite($newfile,$newline); | ||
282 | - } | ||
283 | - fclose($newfile); | ||
284 | - } | ||
285 | -/* | ||
286 | -* Make parameter | ||
287 | -*/ | ||
288 | - if (file_exists($this->PredefinedDir.$id."_.pro")) { | ||
289 | - copy($this->PredefinedDir.$id."_.pro", $this->TargetDir.$id."_.pro"); | ||
290 | - } | ||
291 | - else { | ||
292 | - $newfile = fopen($this->TargetDir.$id."_.pro","w"); | ||
293 | - $pairs = array("LOCALPARAM" => $id,"LOCALSIZE"=>$size, "LOCALSAMPLING"=>$sampling, "LOCALPARAMNAME"=>"'".$this->param2ddPoint($name)."'", | ||
294 | - "LOCALVI"=>"'".$vi."'", "LOCALDATATYPE" => "'".$value_type."'","LOCALFILLVALUE"=>$fill_value,"LOCALPROCESS"=>"'".$process."'", | ||
295 | - "LOCALCONVERSION" => "'".$conversion."'"); | ||
296 | - | ||
297 | - $lines = file($this->PRODIR."localparam_.pro"); | ||
298 | - | ||
299 | - for ($i = 0; $i < count($lines); $i++) { | ||
300 | - $newline = strtr($lines[$i],$pairs); | ||
301 | - fwrite($newfile,$newline); | ||
302 | - } | ||
303 | - fclose($newfile); | ||
304 | - } | ||
305 | -} | ||
306 | - | ||
307 | -/* | ||
308 | -* Make WS parameter | ||
309 | -*/ | ||
310 | - public function makeWsParamPlot($ws_object) { | ||
311 | - | ||
312 | - | ||
313 | -/* | ||
314 | -* Make init | ||
315 | -*/ | ||
316 | - | ||
317 | - $infoMgr = new ParamsInfoMgr(); | ||
318 | - $infos = $infoMgr->GetParamInfo($ws_object); | ||
319 | - | ||
320 | - $Ytitle = $ws_object; | ||
321 | - | ||
322 | - if ($infos['success']) { | ||
323 | - | ||
324 | - if ($infos['infos']['ytitle'] != 'undefined') | ||
325 | - $Ytitle = $infos['infos']['ytitle']; | ||
326 | - | ||
327 | - if ($infos['infos']['units'] != 'undefined') | ||
328 | - $Ytitle .= ','.$infos['infos']['units']; | ||
329 | - | ||
330 | - } | ||
331 | - | ||
332 | - $pairs = array("WS" => $ws_object, "TTT" => $Ytitle); | ||
333 | - | ||
334 | - $newfile = fopen($this->TargetDir.$ws_object."_init.pro","w"); | ||
335 | - | ||
336 | - $lines = file($this->PRODIR."ws_init.pro"); | ||
337 | - for ($i = 0; $i < count($lines); $i++) { | ||
338 | - $newline = strtr($lines[$i],$pairs); | ||
339 | - fwrite($newfile,$newline); | ||
340 | - } | ||
341 | - fclose($newfile); | ||
342 | - | ||
343 | -/* | ||
344 | -* Make Common | ||
345 | -*/ | ||
346 | - $newfile = fopen($this->TargetDir.$ws_object."_com.pro","w"); | ||
347 | - | ||
348 | - $lines = file($this->PRODIR."ws_com.pro"); | ||
349 | - for ($i = 0; $i < count($lines); $i++) { | ||
350 | - $newline = strtr($lines[$i],$pairs); | ||
351 | - fwrite($newfile,$newline); | ||
352 | - } | ||
353 | - fclose($newfile); | ||
354 | - | ||
355 | -/* | ||
356 | -* Make Get | ||
357 | -*/ | ||
358 | - $newfile = fopen($this->TargetDir."get".$ws_object.".pro","w"); | ||
359 | - | ||
360 | - $lines = file($this->PRODIR."getws.pro"); | ||
361 | - for ($i = 0; $i < count($lines); $i++) { | ||
362 | - $newline = strtr($lines[$i],$pairs); | ||
363 | - fwrite($newfile,$newline); | ||
364 | - } | ||
365 | - fclose($newfile); | ||
366 | - | ||
367 | - | ||
368 | -/* | ||
369 | -* Make parameter | ||
370 | -*/ | ||
371 | - | ||
372 | - $newfile = fopen($this->TargetDir.$ws_object."_.pro","w"); | ||
373 | - $lines = file($this->PRODIR."ws_.pro"); | ||
374 | - | ||
375 | - for ($i = 0; $i < count($lines); $i++) { | ||
376 | - $newline = strtr($lines[$i],$pairs); | ||
377 | - fwrite($newfile,$newline); | ||
378 | - } | ||
379 | - fclose($newfile); | ||
380 | - | ||
381 | - } | ||
382 | -/* | ||
383 | -* Make WSD parameter | ||
384 | -*/ | ||
385 | - | ||
386 | - public function makeWsdParam($wsd) { | ||
387 | - | ||
388 | - copy (OLD_CLASSPATH."getViStart.php",$this->TargetDir."getViStart.php"); | ||
389 | - copy (OLD_CLASSPATH."getViStop.php",$this->TargetDir."getViStop.php"); | ||
390 | - copy (OLD_CLASSPATH."setViStart.php",$this->TargetDir."setViStart.php"); | ||
391 | - copy (OLD_CLASSPATH."setViStop.php",$this->TargetDir."setViStop.php"); | ||
392 | - copy (OLD_CLASSPATH."getFileNames.php",$this->TargetDir."getFileNames.php"); | ||
393 | - copy (OLD_CLASSPATH."getVotVar.php",$this->TargetDir."getVotVar.php"); | ||
394 | - copy (OLD_CLASSPATH."moreData.php",$this->TargetDir."moreData.php"); | ||
395 | - | ||
396 | -//TODO do we need wsd_..xml??? | ||
397 | -// $param_xml = USERWSDIR.$wsd.".xml"; | ||
398 | - $param_xml = getenv('USER_WS_PATH').$wsd.".xml"; | ||
399 | - $param_dom = new DomDocument("1.0"); | ||
400 | - $param_dom -> load($param_xml); | ||
401 | -/* | ||
402 | -* Get Param Info | ||
403 | -*/ | ||
404 | - if (strncmp($wsd, "simu_", 5) == 0) { | ||
405 | - $paramType = 'simu'; | ||
406 | - $isMoreData = 1; | ||
407 | - $theParam = $param_dom->getElementsByTagName("mysimudata")->item(0); | ||
408 | - } | ||
409 | - elseif (strncmp($wsd, "wsr_", 4) == 0) { | ||
410 | - $paramType = 'wsr'; | ||
411 | - $isMoreData = 1; | ||
412 | - $theParam = $param_dom->getElementsByTagName("mywsrdata")->item(0); | ||
413 | - } | ||
414 | - else { | ||
415 | - $paramType = 'wsd'; | ||
416 | - $isMoreData = 0; | ||
417 | - $theParam = $param_dom->getElementsByTagName("mydata")->item(0); | ||
418 | - } | ||
419 | - | ||
420 | - if ($paramType == 'wsr' || $paramType == 'simu') | ||
421 | - $alias = strtolower($theParam->getElementsByTagName("name")->item(0)->nodeValue); | ||
422 | - else | ||
423 | - $alias = "wsd_".strtolower($theParam->getElementsByTagName("name")->item(0)->nodeValue); | ||
424 | - | ||
425 | - | ||
426 | - $name = $theParam->getElementsByTagName("realvar")->item(0)->nodeValue; | ||
427 | - $size = $theParam->getElementsByTagName("size")->item(0)->nodeValue; | ||
428 | - $format = $theParam->getElementsByTagName("format")->item(0)->nodeValue; | ||
429 | - $vi = $theParam->getElementsByTagName("vi")->item(0)->nodeValue; | ||
430 | - $plottypeArr = $theParam->getElementsByTagName("plottype"); | ||
431 | - $plot_type = $plottypeArr->length > 0 ? $plottypeArr->item(0)->nodeValue : 'undefined'; | ||
432 | - | ||
433 | - switch ($size) { | ||
434 | - case "3" : $tensor = 1; break; | ||
435 | - case "1" : $tensor = 0; break; | ||
436 | - default : $tensor = 2; | ||
437 | - } | ||
438 | - | ||
439 | - $value_type = $theParam->getElementsByTagName("type")->item(0)->nodeValue; | ||
440 | - $fill_value = $theParam->getElementsByTagName("fillvalue")->item(0)->nodeValue; | ||
441 | - if (!$fill_value) $fill_value = -1.e+31; | ||
442 | - if ($fill_value == "NaN") $fill_value = "!Values.F_NAN"; | ||
443 | - $units = $theParam->getElementsByTagName("units")->item(0)->nodeValue; | ||
444 | - if (!$units) $units = ""; | ||
445 | - $sampling = $theParam->getElementsByTagName("minsampling")->item(0)->nodeValue; | ||
446 | - $maxSampling = $sampling; | ||
447 | - if ($theParam->getElementsByTagName("maxsampling")->item(0)->nodeValue != $sampling) | ||
448 | - $maxSampling =$theParam->getElementsByTagName("maxsampling")->item(0)->nodeValue; | ||
449 | - | ||
450 | - $legend = $theParam->getElementsByTagName("legend")->item(0)->nodeValue; | ||
451 | - if (!$legend) $legend = " X; Y; Z"; | ||
452 | - $ytitle = $theParam->getElementsByTagName("ytitle")->item(0)->nodeValue; | ||
453 | -/* | ||
454 | -* Make init | ||
455 | -*/ | ||
456 | - | ||
457 | - $newfile = fopen($this->TargetDir.$alias."_init.pro","w"); | ||
458 | - $pairs = array("WSDPARAM" => $alias,"WSDTENSOR"=>$tensor,"WSDUNITS"=>"'".$units."'","WSDPLOTTYPE"=>"'".$plot_type."'","WSDSIZE"=>$size,"WSDYTITLE"=>"'".$ytitle."'", "WSDLEGEND"=>"'".$legend."'"); | ||
459 | - $lines = file($this->PRODIR."wsd_init.pro"); | ||
460 | - for ($i = 0; $i < count($lines); $i++) { | ||
461 | - $newline = strtr($lines[$i],$pairs); | ||
462 | - fwrite($newfile,$newline); | ||
463 | - } | ||
464 | - fclose($newfile); | ||
465 | - | ||
466 | - if ($size > 1) { | ||
467 | - $comp = array("/X", "/Y", "/Z"); | ||
468 | - for ($i = 0; $i < $size; $i++) { | ||
469 | - $newfile = fopen($alias."_".$i."_init.pro", "w"); | ||
470 | - fwrite($newfile,"pro ".$alias."_".$i."_init \n"); | ||
471 | - fwrite($newfile,"cmd = '".$alias."_init, ".$comp[$i]."'\n"); | ||
472 | - fwrite($newfile,"R = execute(cmd) \n"); | ||
473 | - fwrite($newfile,"return \n"); | ||
474 | - fwrite($newfile,"end \n"); | ||
475 | - fclose($newfile); | ||
476 | - } | ||
477 | - } | ||
478 | - | ||
479 | -/* | ||
480 | -* Make com | ||
481 | -*/ | ||
482 | - | ||
483 | - $newfile = fopen($this->TargetDir.$alias."_com.pro","w"); | ||
484 | - $pairs = array("WSDPARAM" => $alias,"WSDSIZE"=>$size,"WSDSAMPLING"=>$sampling,"WSDMAXSAMPLING"=>$maxSampling, "WSDFILLVALUE"=>$fill_value); | ||
485 | - $lines = file($this->PRODIR."wsd_com.pro"); | ||
486 | - for ($i = 0; $i < count($lines); $i++) { | ||
487 | - $newline = strtr($lines[$i],$pairs); | ||
488 | - fwrite($newfile,$newline); | ||
489 | - } | ||
490 | - fclose($newfile); | ||
491 | - | ||
492 | -/* | ||
493 | -* Make get | ||
494 | -*/ | ||
495 | - | ||
496 | - $newfile = fopen($this->TargetDir."get".$alias.".pro","w"); | ||
497 | - $pairs = array("WSDPARAM" => $alias,"WSDSIZE"=>$size,"WSDPARAMNAME"=>"'".$name."'", | ||
498 | - "WSDDATATYPE" => "'".$value_type."'","WSDFORMAT" => "'".$format."'", | ||
499 | - "WSDVI" => "'".$vi."'", "WSDMOREDATA" => $isMoreData,"WSDPLOTTYPE"=>"'".$plot_type."'"); | ||
500 | - $lines = file($this->PRODIR."getwsd.pro"); | ||
501 | - for ($i = 0; $i < count($lines); $i++) { | ||
502 | - $newline = strtr($lines[$i],$pairs); | ||
503 | - fwrite($newfile,$newline); | ||
504 | - } | ||
505 | - fclose($newfile); | ||
506 | -/* | ||
507 | -* Make parameter | ||
508 | -*/ | ||
509 | - | ||
510 | - $newfile = fopen($this->TargetDir.$alias."_.pro","w"); | ||
511 | - $pairs = array("WSDPARAM" => $alias,"WSDSIZE"=>$size,"WSDSAMPLING"=>$sampling, "WSDPARAMNAME"=>"'".$name."'", | ||
512 | - "WSDDATATYPE" => "'".$value_type."'","WSDFORMAT" => "'".$format."'","WSDFILLVALUE"=>$fill_value, "WSDVI" => "'".$vi."'"); | ||
513 | - | ||
514 | - $lines = file($this->PRODIR."wsd_.pro"); | ||
515 | - | ||
516 | - for ($i = 0; $i < count($lines); $i++) { | ||
517 | - $newline = strtr($lines[$i],$pairs); | ||
518 | - fwrite($newfile,$newline); | ||
519 | - } | ||
520 | - fclose($newfile); | ||
521 | -} | ||
522 | - | ||
523 | - | ||
524 | -} | ||
525 | - | ||
526 | -?> | ||
527 | \ No newline at end of file | 0 | \ No newline at end of file |
php/old_amda/Parser.php deleted
@@ -1,265 +0,0 @@ | @@ -1,265 +0,0 @@ | ||
1 | -<?php | ||
2 | -/** @class Parser | ||
3 | -* @version $Id: Parser.php 2938 2015-06-05 16:23:33Z elena $ | ||
4 | -* @brief | ||
5 | -* | ||
6 | -*/ | ||
7 | -class Parser { | ||
8 | - | ||
9 | - public $wsXML, $constantsXML, $functionsXML, $aliasesXML; | ||
10 | - public $dom; | ||
11 | - public $idl_pairs = array(">" => " GT ", "<" => " LT ", "&" => " AND ", "|" => " OR ", "=" => " EQ "); | ||
12 | - | ||
13 | - public $file; | ||
14 | - | ||
15 | - function __construct(){ | ||
16 | - $this->wsXML = USERWSDIR."WsParams.xml"; | ||
17 | - $this->functionsXML = Functions."functions.xml"; | ||
18 | - $this->constantsXML = Functions."constants.xml"; | ||
19 | - $this->aliasesXML = USERWSDIR."Alias.xml"; | ||
20 | - $this->dom = new DomDocument("1.0"); | ||
21 | - | ||
22 | - } | ||
23 | - | ||
24 | -/* | ||
25 | -* Replace Constants, Aliases and WS params by their real values | ||
26 | -*/ | ||
27 | - public function replaceAll($chain){ | ||
28 | - | ||
29 | - $newChain = $this->replaceWsParams($chain); | ||
30 | - $newNewChain = $this->replaceAliases($newChain); | ||
31 | - $newNewNewChain = $this->replaceConstants($newNewChain); | ||
32 | - | ||
33 | - return $newNewNewChain; | ||
34 | - } | ||
35 | - | ||
36 | -/* | ||
37 | -* Replace Constants, Aliases and WS params by their real values | ||
38 | -*/ | ||
39 | - public function replaceAllButWS($chain){ | ||
40 | - | ||
41 | - $newChain = $this->replaceAliases($chain); | ||
42 | - $newNewChain = $this->replaceConstants($newChain); | ||
43 | - | ||
44 | - return $newNewChain; | ||
45 | - } | ||
46 | -/* | ||
47 | -* Return array of Variables | ||
48 | -*/ | ||
49 | - | ||
50 | - public function getVars($chain){ | ||
51 | - | ||
52 | - $arr = $this->delimitIt($chain); | ||
53 | - | ||
54 | - $arr = $this->selectVariables($arr); | ||
55 | - $arr = $this->deSelectFunctions($arr); | ||
56 | - | ||
57 | - return $arr; | ||
58 | - } | ||
59 | - | ||
60 | -/* | ||
61 | -* | ||
62 | -*/ | ||
63 | - public function convert2Idl($chain) { | ||
64 | - | ||
65 | - return (strtr($chain,$this->idl_pairs)); | ||
66 | - | ||
67 | - } | ||
68 | - | ||
69 | - public function getFunctionsNames() { | ||
70 | - | ||
71 | - $this->dom->load($this->functionsXML); | ||
72 | - $functions_ = $this->dom->getElementsByTagName("function"); | ||
73 | - | ||
74 | - for ($i = 0; $i < $functions_->length; $i++) { | ||
75 | - $tempArr = explode('(', $functions_->item($i)->getAttribute("name")); | ||
76 | - $functions[$i] = $tempArr[0]; | ||
77 | - } | ||
78 | - | ||
79 | - return $functions; | ||
80 | - } | ||
81 | - | ||
82 | - public function deSelectFunctions($arr) { | ||
83 | - | ||
84 | - $functions = $this->getFunctionsNames(); | ||
85 | - | ||
86 | - $arr = array_values($arr); | ||
87 | - | ||
88 | - $N_arr = count($arr); | ||
89 | - for ($i = 0; $i < $N_arr; $i++) | ||
90 | - foreach($functions as $the_function) | ||
91 | - if (strcasecmp(trim($the_function),trim($arr[$i])) == 0) { | ||
92 | - unset($arr[$i]); | ||
93 | - continue 2; | ||
94 | - } | ||
95 | - | ||
96 | - return array_values($arr); | ||
97 | - } | ||
98 | - | ||
99 | - public function replaceAliases($chain) { | ||
100 | - | ||
101 | - if ($this->isThereAlias($chain)) { | ||
102 | - | ||
103 | - $this->dom->load($this->aliasesXML); | ||
104 | - $aliases_ = $this->dom->getElementsByTagName("alias"); | ||
105 | - | ||
106 | - if ($aliases_->length > 0 ) { | ||
107 | - for ($i = 0; $i < $aliases_->length; $i++) { | ||
108 | - $aliases["#".$aliases_->item($i)->getAttribute("name")] = "(".$aliases_->item($i)->nodeValue.")"; | ||
109 | - | ||
110 | - } | ||
111 | - | ||
112 | - $chainReplaced = strtr($chain, $aliases); | ||
113 | - | ||
114 | - return $chainReplaced; | ||
115 | - } | ||
116 | - } | ||
117 | - return $chain; | ||
118 | - } | ||
119 | - | ||
120 | - | ||
121 | - public function replaceConstants($chain) { | ||
122 | - | ||
123 | - if ($this->isThereConstant($chain)) { | ||
124 | - | ||
125 | - $this->dom->load($this->constantsXML); | ||
126 | - $constants_ = $this->dom->getElementsByTagName("constant"); | ||
127 | - | ||
128 | - for ($i = 0; $i < $constants_->length; $i++) { | ||
129 | - | ||
130 | - $constants["@".$constants_->item($i)->getAttribute("name")] = "(".$constants_->item($i)->nodeValue.")"; | ||
131 | - | ||
132 | - } | ||
133 | - | ||
134 | - $chainReplaced = strtr($chain, $constants); | ||
135 | - | ||
136 | - return $chainReplaced; | ||
137 | - } | ||
138 | - return $chain; | ||
139 | - } | ||
140 | - | ||
141 | - public function replaceWsParams($chain) { | ||
142 | - | ||
143 | - if ($this->isThereWs($chain)) { | ||
144 | - $this->dom->load($this->wsXML); | ||
145 | - $wspar = $this->dom->getElementsByTagName("param"); | ||
146 | - | ||
147 | - if ($wspar->length > 0) { | ||
148 | - for ($i = 0; $i < $wspar->length; $i++) { | ||
149 | -//Changes: low 'ws' and attributes | ||
150 | - $wsName = "ws_".$wspar->item($i)->getAttribute('name'); | ||
151 | - $wsChain = $wspar->item($i)->getAttribute("buildchain"); | ||
152 | - $wsParams[$wsName]= $wsChain; | ||
153 | - } | ||
154 | - $chainReplaced = strtr($chain, $wsParams); | ||
155 | - return $chainReplaced; | ||
156 | - } | ||
157 | - } | ||
158 | - return $chain; | ||
159 | - } | ||
160 | - | ||
161 | - public function substrAliasWs($chain, $aliasName, $paramName) { | ||
162 | - | ||
163 | - $aliasName="#".$aliasName; | ||
164 | - $pos = strpos($chain, $aliasName); | ||
165 | - while ( $pos !== FALSE ) { | ||
166 | - $pos = $pos+strlen($aliasName); | ||
167 | - if (preg_match('/[-+*,^<>&|=\/\[\]\(\)]/', $chain[$pos]) || $chain[$pos] === '') { | ||
168 | - $chain = substr_replace($chain, $paramName,$pos-strlen($aliasName),strlen($aliasName)); | ||
169 | - } | ||
170 | - $pos = strpos($chain, $aliasName, $pos); | ||
171 | - } | ||
172 | - | ||
173 | - return $chain; | ||
174 | - } | ||
175 | - | ||
176 | - public function substrParamWs($chain, $paramName, $aliasName) { | ||
177 | - | ||
178 | - $aliasName="#".$aliasName; | ||
179 | - $pos = strpos($chain, $paramName); | ||
180 | - while ( $pos !== FALSE ) { | ||
181 | - $pos = $pos+strlen($paramName); | ||
182 | - if (preg_match('/[-+*,^<>&|=\/\[\]\(\)]/', $chain[$pos]) || $chain[$pos] === '') { | ||
183 | - $chain = substr_replace($chain, $aliasName,$pos-strlen($paramName),strlen($paramName)); | ||
184 | - } | ||
185 | - $pos = strpos($chain, $paramName, $pos); | ||
186 | - } | ||
187 | - | ||
188 | - return $chain; | ||
189 | - } | ||
190 | - | ||
191 | - public function modifyParamWs($chain, $oldAliasName, $newAliasName) { | ||
192 | - | ||
193 | - $oldAliasName="#".$oldAliasName; | ||
194 | - $newAliasName="#".$newAliasName; | ||
195 | - $pos = strpos($chain, $oldAliasName); | ||
196 | - while ( $pos !== FALSE ) { | ||
197 | - $pos = $pos+strlen($oldAliasName); | ||
198 | - if (preg_match('/[-+*,^<>&|=\/\[\]\(\)]/', $chain[$pos]) || $chain[$pos] === '') { | ||
199 | - $chain = substr_replace($chain, $newAliasName,$pos-strlen($oldAliasName),strlen($oldAliasName)); | ||
200 | - } | ||
201 | - $pos = strpos($chain, $oldAliasName, $pos); | ||
202 | - } | ||
203 | - | ||
204 | - return $chain; | ||
205 | - } | ||
206 | - | ||
207 | - | ||
208 | - public function delimitIt($chain) { | ||
209 | - | ||
210 | - $delimiter = '[]+,/*()^<>&|=[-]+'; | ||
211 | - $array = split($delimiter,$chain); | ||
212 | - if (trim(end($array)) == "") array_pop($array); | ||
213 | - | ||
214 | - return $array; | ||
215 | - } | ||
216 | - | ||
217 | - | ||
218 | - public function selectVariables($arr) { | ||
219 | - | ||
220 | - $N_arr = count($arr); | ||
221 | - for ($i = 0; $i < $N_arr; $i++) { | ||
222 | - $arr[$i] = trim($arr[$i]); | ||
223 | - if (!$this->isVariable($arr[$i])) | ||
224 | - unset($arr[$i]); | ||
225 | - } | ||
226 | - | ||
227 | - return array_unique(array_values($arr)); | ||
228 | - } | ||
229 | - | ||
230 | - | ||
231 | - public function isNumber($value) { | ||
232 | - | ||
233 | - return preg_match('/^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/', $value); | ||
234 | - } | ||
235 | - | ||
236 | - public function isVariable($value) { | ||
237 | - | ||
238 | - return preg_match('/^[a-zA-Z]/', $value); | ||
239 | - } | ||
240 | - | ||
241 | - public function isConstant($value) { | ||
242 | - | ||
243 | - return preg_match('/^@/', $value); | ||
244 | - } | ||
245 | - | ||
246 | - public function isAlias($value) { | ||
247 | - | ||
248 | - return preg_match('/^#/', $value); | ||
249 | - } | ||
250 | - | ||
251 | - public function isThereConstant($value) { | ||
252 | - | ||
253 | - return preg_match('/@/', $value); | ||
254 | - } | ||
255 | - | ||
256 | - public function isThereWS($value) { | ||
257 | - | ||
258 | - return preg_match('/ws_/', $value); | ||
259 | - } | ||
260 | - | ||
261 | - public function isThereAlias($value) { | ||
262 | - | ||
263 | - return preg_match('/#/', $value); | ||
264 | - } | ||
265 | -} | ||
266 | \ No newline at end of file | 0 | \ No newline at end of file |
php/old_amda/paramBuild.php deleted
@@ -1,88 +0,0 @@ | @@ -1,88 +0,0 @@ | ||
1 | -<?php | ||
2 | - | ||
3 | -/** @file paramBuild.php | ||
4 | -* @brief parameter generator from templates and parameter name | ||
5 | -* @version $Id: $ | ||
6 | -* @date Tue Sep 11 14:04:55 CEST 2007 | ||
7 | -*/ | ||
8 | - | ||
9 | -/* | ||
10 | -* To exclude crazy stuff from parameter name | ||
11 | -*/ | ||
12 | - | ||
13 | - function param2dd($paramID) | ||
14 | - { | ||
15 | - $pairs = array("-" => "_", "%" => "_","\\" => "_","$" => "_",":" => "_","+" =>" _","-" => "_","#" => "_","@" => "_", "." => "_",">" => "_", "<" => "_"); | ||
16 | - return strtr($paramID, $pairs); | ||
17 | - } | ||
18 | - | ||
19 | -/* | ||
20 | -* Object -> Stuff for DD Graph | ||
21 | -*/ | ||
22 | - function paramBuild($paramID) | ||
23 | - { | ||
24 | - | ||
25 | - $TargetDir = "./"; // WHERE CREATE??? | ||
26 | - $PRODIR = TEMPLATES; | ||
27 | - $LIBDIR = PREDEFINED; // predefined ext params | ||
28 | - | ||
29 | - $ddParamID = param2dd($paramID); | ||
30 | - $paramFunc = strtolower($ddParamID); | ||
31 | - | ||
32 | - $SED = "sed 's/NEWPARAM/".$paramID."/g' ".$PRODIR."newparam_init.pro | sed 's/DDPARAM/".$ddParamID."/g' > ".$TargetDir.$paramFunc."_init.pro"; | ||
33 | - system($SED); | ||
34 | - | ||
35 | - $SED = "sed 's/NEWPARAM/".$paramID."/g' ".$PRODIR."newparam_com.pro | sed 's/DDPARAM/".$ddParamID."/g' > ".$TargetDir.$paramFunc."_com.pro"; | ||
36 | - system($SED); | ||
37 | - | ||
38 | - $SED = "sed 's/DDPARAM/".$ddParamID."/g' ".$PRODIR."getnewparam.pro > ".$TargetDir."get".$paramFunc.".pro"; | ||
39 | - system($SED); | ||
40 | - | ||
41 | -/* | ||
42 | -* Add predefined functions if exists | ||
43 | -*/ | ||
44 | - foreach (glob($LIBDIR."*".$paramFunc."*.pro") as $filename) | ||
45 | - copy($filename, str_replace($LIBDIR, $TargetDir, $filename)); | ||
46 | - | ||
47 | - } | ||
48 | - | ||
49 | -/* | ||
50 | -* components | ||
51 | -*/ | ||
52 | - function paramBuildComp($paramID, $comp) | ||
53 | - { | ||
54 | - $TargetDir = "./"; // WHERE CREATE??? | ||
55 | - $PRODIR = TEMPLATES; | ||
56 | - $ddParamID = param2dd($paramID); | ||
57 | - $paramFunc = strtolower($ddParamID).'_'.$comp; | ||
58 | - | ||
59 | - $SED = "sed 's/DDPARAM/".$ddParamID."/g' ".$PRODIR."newparam_XXX_init.pro | sed 's/XXX/".$comp."/g' > ".$TargetDir.$paramFunc."_init.pro"; | ||
60 | - system($SED); | ||
61 | - | ||
62 | - } | ||
63 | -/* | ||
64 | -* Real Parameter | ||
65 | -*/ | ||
66 | - | ||
67 | - function paramBuild_($paramID) | ||
68 | - { | ||
69 | - | ||
70 | - | ||
71 | - $TargetDir = "./"; // WHERE CREATE??? | ||
72 | - $PRODIR = TEMPLATES; | ||
73 | - $LIBDIR = PREDEFINED; // predefined ext params | ||
74 | - | ||
75 | - $ddParamID = param2dd($paramID); | ||
76 | - $paramFunc = strtolower($ddParamID); | ||
77 | - | ||
78 | -/* | ||
79 | -* Add predefined functions if exists | ||
80 | -*/ | ||
81 | - if (file_exists($LIBDIR.$paramFunc."_.pro")) copy($LIBDIR.$paramFunc."_.pro",$TargetDir.$paramFunc."_.pro"); | ||
82 | - else | ||
83 | - { | ||
84 | - $SED = "sed 's/NEWPARAM/".$paramID."/g' ".$PRODIR."newparam_.pro | sed 's/DDPARAM/".$ddParamID."/g' > ".$TargetDir.$paramFunc."_.pro"; | ||
85 | - system($SED); | ||
86 | - } | ||
87 | - } | ||
88 | -?> |