Commit f740e66b76c308f8e2c09814685b031de784b9d7

Authored by Nathanael Jourdane
1 parent 1f7926b5

Improve the VOTable parser.

.gitignore
... ... @@ -8,7 +8,13 @@ generic_data/newKernelDDBase/
8 8 generic_data/ParamTemplate/
9 9 generic_data/ParamInfo/*.xml
10 10 js/lib/ext/
11   -help/auto
12 11 help/simu
  12 +help/auto
13 13 php/bin
14 14 *~
  15 +logs/*
  16 +
  17 +# Ignore these files to safely work on a configured local project:
  18 +# desktop.php
  19 +# php/my_config.php
  20 +# DD.res
... ...
cron_scripts/get_services.php 0 → 100755
... ... @@ -0,0 +1,42 @@
  1 +<?php
  2 +include(realpath(dirname(__FILE__) . "/../php/config.php"));
  3 +include(BASE_PATH . "/php/classes/EpnTapMgr.php");
  4 +
  5 +$EpnTapMgr = new EpnTapMgr;
  6 +$services = json_decode(file_get_contents(EpnTapDataPath . "/EpnTapServices.json"), TRUE);
  7 +
  8 +$services_content = Array();
  9 +
  10 +foreach($services as $s) {
  11 + $query = "SELECT dataproduct_type as dp_type,
  12 + target_class as t_class,
  13 + target_name as t_name,
  14 + COUNT(granule_uid) as nb_res,
  15 + MIN(time_min) as time_min,
  16 + MAX(time_max) as time_max
  17 + FROM " . $s["schema"] . ".epn_core GROUP BY dp_type, t_class, t_name";
  18 +
  19 + $rows = $EpnTapMgr->request($s["accessurl"], $query);
  20 + if($rows == NULL)
  21 + continue;
  22 +
  23 + foreach ($rows as $r) {
  24 + $r['dp_type'] = $r['dp_type'];
  25 + $r['t_class'] = $r['t_class'];
  26 + $r['t_name'] = $r['t_name'];
  27 +
  28 + if(!isset($services_content[$r['dp_type']]))
  29 + $services_content[$r['dp_type']] = Array();
  30 +
  31 + if(!isset($services_content[$r['dp_type']][$r['t_class']]))
  32 + $services_content[$r['dp_type']][$r['t_class']] = Array();
  33 +
  34 + if(!isset($services_content[$r['dp_type']][$r['t_class']][$r['t_name']]))
  35 + $services_content[$r['dp_type']][$r['t_class']][$r['t_name']] = Array();
  36 +
  37 + $services_content[$r['dp_type']][$r['t_class']][$r['t_name']][$s["schema"]] = [$r['nb_res'], $r['time_min'], $r['time_max']];
  38 + }
  39 +}
  40 +
  41 +fwrite(fopen(EpnTapDataPath . "services.json", "w+"), json_encode($services_content, JSON_PRETTY_PRINT));
  42 +?>
... ...
php/classes/AmdaAction.php
... ... @@ -8,17 +8,17 @@
8 8  
9 9 class AmdaAction {
10 10  
11   - private $xmlFiles = array('localParam' => 'LocalParams.xml', 'remoteParam' => 'RemoteParams.xml',
  11 + private $xmlFiles = array('localParam' => 'LocalParams.xml', 'remoteParam' => 'RemoteParams.xml',
12 12 'remoteSimuParam' => 'RemoteParams.xml', 'derivedParam' => 'WsParams.xml', 'myDataParam' => 'WsParams.xml',
13   - 'timeTable' => 'Tt.xml', 'catalog' => 'Tt.xml', 'alias' => 'Alias.xml',
14   - 'myData' => 'Files.xml',
  13 + 'timeTable' => 'Tt.xml', 'catalog' => 'Tt.xml', 'alias' => 'Alias.xml',
  14 + 'myData' => 'Files.xml',
15 15 'request' => 'Request.xml', 'condition' => 'Request.xml',
16 16 'bkgWorks' => 'jobs.xml');
17 17  
18 18 private $user, $amdaStat;
19 19  
20   - public function __construct()
21   - {
  20 + public function __construct()
  21 + {
22 22 $dd = new UserMgr();
23 23 $this->user = $dd->user;
24 24 if (!defined('NEWKERNEL_DEBUG') || !NEWKERNEL_DEBUG)
... ... @@ -28,38 +28,38 @@ class AmdaAction {
28 28 private function getUrlDirs($url) {
29 29 //TODO replace by ftp php class methods: ftp_nlist() etc
30 30 require_once "simple_html_dom.php";
31   -
32   - $url = html_entity_decode($url);
  31 +
  32 + $url = html_entity_decode($url);
33 33 $trimmed_url = trim($url);
34 34 if (strrpos($trimmed_url, "/") == strlen($trimmed_url) - 1) {
35   - if (file_exists("temp.html")) unlink("temp.html");
  35 + if (file_exists("temp.html")) unlink("temp.html");
36 36 exec("wget -O temp.html ".$url);
37   -
  37 +
38 38 $html = file_get_html('temp.html');
39 39 $dirs = $html->find('a[href]');
40 40 foreach ($dirs as $dir) {
41 41 $name = $dir->innertext; //$dir->href;
42 42 $isLeaf = strrpos($name, "/") !== strlen($name) - 1;
43 43 $childrenToReturn[] = array('text' => $name, 'id' => $trimmed_url.$name,
44   - 'nodeType' => 'url', 'leaf' => $isLeaf);
  44 + 'nodeType' => 'url', 'leaf' => $isLeaf);
45 45 }
46   -
  46 +
47 47 }
48   - return $childrenToReturn;
  48 + return $childrenToReturn;
49 49 }
50   -
  50 +
51 51 /*****************************************************************
52 52 * PUBLIC FUNCTIONS
53   -*****************************************************************/
54   -
  53 +*****************************************************************/
  54 +
55 55 /*
56 56 * $obj = { id: node.id, nodeType: node.nodeType }
57 57 */
58 58 public function getTree($obj) {
59   -
  59 +
60 60 $node = $obj->node;
61   -
62   - // to correct 'restricted' parameters
  61 +
  62 + // to correct 'restricted' parameters
63 63 if (strpos($node, restricted) !== false) {
64 64 $node = str_replace(restricted,"",$node);
65 65 }
... ... @@ -68,9 +68,9 @@ class AmdaAction {
68 68 $remoteBase = false;
69 69 $isRemoteDataSet = false;
70 70  
71   - if ($nodeType == 'url')
  71 + if ($nodeType == 'url')
72 72 {
73   - $url = $node == 'root' ? $obj->baseId : $node;
  73 + $url = $node == 'root' ? $obj->baseId : $node;
74 74 return $this->getUrlDirs($url);
75 75 }
76 76  
... ... @@ -78,63 +78,63 @@ class AmdaAction {
78 78  
79 79 if ($node == 'root' && $remoteBase) $node = $obj->baseId;
80 80  
81   - if ($node == 'root' && !$remoteBase)
82   - {
  81 + if ($node == 'root' && !$remoteBase)
  82 + {
83 83 $json_o = json_decode(file_get_contents(DATAPATH.$nodeType.'.json'));
84   - $childrenToReturn = $json_o->nodes;
85   - }
86   - else
  84 + $childrenToReturn = $json_o->nodes;
  85 + }
  86 + else
87 87 {
88 88 $Dom = new DomDocument("1.0");
89 89  
90   - switch ($nodeType)
  90 + switch ($nodeType)
91 91 {
92 92 case 'sharedtimeTable':
93 93 case 'sharedcatalog':
94 94 $xmlName = SHAREDPATH.'/SharedObjectTree.xml';
95 95 break;
96   - case 'bkgWorks':
  96 + case 'bkgWorks':
97 97 $xmlName = USERJOBDIR.$this->xmlFiles[$nodeType];
98 98 break;
99 99 case 'source':
100   - $xmlName = DATAPATH.'RemoteData/'.$obj->baseId.'/base.xml';
  100 + $xmlName = DATAPATH.'RemoteData/'.$obj->baseId.'/base.xml';
  101 + break;
  102 + case 'destination':
  103 + $xmlName = USERWSDIR.'RemoteParams.xml';
101 104 break;
102   - case 'destination':
103   - $xmlName = USERWSDIR.'RemoteParams.xml';
104   - break;
105 105 default:
106 106 $xmlName = USERWSDIR.$this->xmlFiles[$nodeType];
107 107 }
108 108  
109   - if ($remoteBase)
110   - {
  109 + if ($remoteBase)
  110 + {
111 111 $nodeType = 'remoteParam';
112   - }
113   -
  112 + }
  113 +
114 114 $Dom->load($xmlName);
115   -
116   - if ($node == "myRemoteSimuData-treeRootNode")
  115 +
  116 + if ($node == "myRemoteSimuData-treeRootNode")
117 117 $node = "myRemoteData-treeRootNode";
118   -
  118 +
119 119 $nodeToOpen = $Dom->getElementById($node);
120 120 $children = $nodeToOpen->childNodes;
121 121  
122   - foreach ($children as $child)
  122 + foreach ($children as $child)
123 123 if ($child->nodeType == XML_ELEMENT_NODE) {
124 124 $isLeaf = true;
125   -
  125 +
126 126 if ($child->hasChildNodes())
127   - foreach ($child->childNodes as $grandChild)
  127 + foreach ($child->childNodes as $grandChild)
128 128 if ($grandChild -> nodeType == XML_ELEMENT_NODE) {
129 129 $isLeaf = false;
130 130 break;
131 131 }
132 132 if ($child->tagName == 'folder') $isLeaf = false;
133 133  
134   - //TODO MAKE PROPERLY as function of nodetype !!!!
135   - $info = '';
  134 + //TODO MAKE PROPERLY as function of nodetype !!!!
  135 + $info = '';
136 136 $id = $child->getAttribute('xml:id');
137   - $name = $child->getAttribute('name');
  137 + $name = $child->getAttribute('name');
138 138 $help = $child->getAttribute('att');
139 139 if ($child->hasAttribute('dataStart')) $dataStart = $child->getAttribute('dataStart');
140 140 if ($child->hasAttribute('dataStop')) $dataStop = $child->getAttribute('dataStop');
... ... @@ -145,42 +145,42 @@ class AmdaAction {
145 145 $isSimulation = false;
146 146 $rank = null;
147 147  
148   - switch ($nodeType)
  148 + switch ($nodeType)
149 149 {
150   - case 'bkgWorks':
  150 + case 'bkgWorks':
151 151 $specialNode = true;
152 152 $status = $child->getAttribute('status');
153   - // if ($status == 'done') continue;
  153 + // if ($status == 'done') continue;
154 154 $childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType, 'leaf' => $isLeaf,
155   - 'pid' => $child->getAttribute('pid'), 'status' => $status,
  155 + 'pid' => $child->getAttribute('pid'), 'status' => $status,
156 156 'jobType' => $child->getAttribute('jobType'), 'info' => $child->getAttribute('info'));
157 157 break;
158 158  
159 159 case 'condition':
160 160 $objectMgr = new RequestMgr();
161   - $info = $objectMgr->getObject($id)->expression;
162   - break;
  161 + $info = $objectMgr->getObject($id)->expression;
  162 + break;
163 163  
164 164 case 'request':
165   -
  165 +
166 166 $objectMgr = new RequestMgr();
167   - $objplot = $objectMgr->getObject($id);
168   - for ($i=0; $i < count($objplot->children); $i++) {
  167 + $objplot = $objectMgr->getObject($id);
  168 + for ($i=0; $i < count($objplot->children); $i++) {
169 169 for ($j=0; $j < count($objplot->children[$i]->children); $j++) {
170 170 $info = $info.' '.$objplot->children[$i]->children[$j]->name;
171 171 }
172 172 }
173   -
174   - break;
175 173  
176   - case 'alias':
  174 + break;
  175 +
  176 + case 'alias':
177 177 $info = $id;
178 178 $id = 'alias_'.$id;
179   - if ($isLeaf) $isParameter = true;
  179 + if ($isLeaf) $isParameter = true;
180 180 break;
181 181  
182 182 case 'timeTable':
183   - case 'catalog':
  183 + case 'catalog':
184 184 if ($isLeaf) $info = $child->getAttribute('intervals').' intervals';
185 185 break;
186 186 case 'sharedtimeTable':
... ... @@ -204,31 +204,31 @@ class AmdaAction {
204 204 $specialNode = true;
205 205 $isParameter = false;
206 206 $needsArgs = false;
207   - $isSpectra = false;
  207 + $isSpectra = false;
208 208 $isStack = false;
209 209  
210 210 if ($child->hasAttribute('desc')) {
211   -
  211 +
212 212 $info = $child->getAttribute('desc');
213   -
214   - if ($child->hasAttribute('dataStart') && $child->hasAttribute('dataStop')) {
215   - $info .= "<br/>Time Range: ".$child->getAttribute('dataStart')."-".$child->getAttribute('dataStop');
  213 +
  214 + if ($child->hasAttribute('dataStart') && $child->hasAttribute('dataStop')) {
  215 + $info .= "<br/>Time Range: ".$child->getAttribute('dataStart')."-".$child->getAttribute('dataStop');
216 216 }
217   -
  217 +
218 218 if ($child->getAttribute('dataStart') == 'depending on mission'){
219 219 $info .= "<br/>Time Range: ".$child->getAttribute('dataStart');
220   - }
221   -
  220 + }
  221 +
222 222 if ($child->getAttribute('restriction') > 1) {
223 223 $restricted = $child->getAttribute('restriction');
224 224 $info .= "<br/><b>Time Restriction</b>: -$restricted days";
225 225 }
226 226 }
227   -
228   -
  227 +
  228 +
229 229 if ($child->hasAttribute('units')) $info = $child->getAttribute('units');
230 230  
231   - if ($child->tagName == 'parameter')
  231 + if ($child->tagName == 'parameter')
232 232 {
233 233 $isParameter = true;
234 234 $isScatter = true;
... ... @@ -236,24 +236,24 @@ class AmdaAction {
236 236 if ($child->parentNode->hasAttribute('dataStart'))
237 237 {
238 238 $globalStart = $child->parentNode->getAttribute('dataStart');
239   - $globalStop = $child->parentNode->getAttribute('dataStop');
  239 + $globalStop = $child->parentNode->getAttribute('dataStop');
240 240 }
241 241  
242 242 if ($child->parentNode->getAttribute('restriction') > 1 )
243 243 {
244 244 $timeRestriction = true;
245   -
  245 +
246 246 }
247   -
248   - /*------------------- to show not tested parameters ------*/
249   -
  247 +
  248 + /*------------------- to show not tested parameters ------*/
  249 +
250 250 if ($child->getAttribute('tbd'))
251 251 $info .= "<br/><b>Not tested yet</b>";
252   -
253   - /*------------------- --------------------------------------*/
254   -
  252 +
  253 + /*------------------- --------------------------------------*/
  254 +
255 255 }
256   -
  256 +
257 257  
258 258 $component_info = array();
259 259 if ($child->tagName == 'component')
... ... @@ -264,62 +264,61 @@ class AmdaAction {
264 264 if ($child->parentNode->parentNode->hasAttribute('dataStart'))
265 265 {
266 266 $globalStart = $child->parentNode->parentNode->getAttribute('dataStart');
267   - $globalStop = $child->parentNode->parentNode->getAttribute('dataStop');
268   - }
  267 + $globalStop = $child->parentNode->parentNode->getAttribute('dataStop');
  268 + }
269 269  
270 270 if ($child->parentNode->parentNode->getAttribute('restriction') > 1)
271 271 {
272 272 $timeRestriction = true;
273   -
274   - }
  273 +
  274 + }
275 275  
276 276 if ($child->hasAttribute("index1"))
277 277 $component_info["index1"] = $child->getAttribute('index1');
278 278 if ($child->hasAttribute("index2"))
279 279 $component_info["index2"] = $child->getAttribute('index2');
280   -
  280 +
281 281 $component_info["parentId"] = $child->parentNode->getAttribute('xml:id');
282 282 }
283   -
  283 +
284 284 if ($child->tagName == 'parameter' && $child->hasChildNodes()) $isScatter = false;
285   -
  285 +
286 286 if ($child->tagName == 'parameter' && $child->hasAttribute('display_type')) {
287 287  
288 288 if ($child->getAttribute('display_type') == 'spectrogram') {
289   - $needsArgs = true;
290   - $isSpectra = true;
  289 + $needsArgs = true;
  290 + $isSpectra = true;
291 291 $isScatter = false;
292 292 }
293   - else if ($child->getAttribute('display_type') == 'stackplot') {
  293 + else if ($child->getAttribute('display_type') == 'stackplot') {
294 294 $isStack = true;
295 295 $isScatter = false;
296 296 }
297   - }
298   -
299   - if ($isParameter)
  297 + }
  298 +
  299 + if ($isParameter)
300 300 {
301 301 if ($child->tagName == 'parameter' && $child->childNodes->length == 1)
302   - {
303   - $needsArgs = true;
304   - }
305   - if (substr($id,0,4) == 'bt96' || substr($id,0,6) == 'ba2000'|| substr($id,0,5) == 'bcain' || substr($id,0,7) == 'bmorsch' )
306   - {
  302 + {
  303 + $needsArgs = true;
  304 + }
  305 + if (substr($id,0,4) == 'bt96' || substr($id,0,6) == 'ba2000'|| substr($id,0,5) == 'bcain' || substr($id,0,7) == 'bmorsch' )
  306 + {
307 307 $needsArgs = true;
308 308 }
309   -
310 309  
311 310 $objectMgr = new AliasMgr();
312 311 $alias = $objectMgr->getAlias($id);
313   -
314   - $childrenToReturn[] = array('text' => $name,'alias' => $alias,
  312 +
  313 + $childrenToReturn[] = array('text' => $name,'alias' => $alias,
315 314 'id' => $id,'nodeType' => $nodeType, 'info' => $info, "component_info" => $component_info,
316 315 'globalStart' => $globalStart, 'globalStop' => $globalStop, 'timeRestriction' => $timeRestriction,
317 316 'leaf' => $isLeaf, 'isParameter' => $isParameter, 'isScatter' => $isScatter,
318 317 'isSpectra' => $isSpectra,'isStack' => $isStack, 'needsArgs' => $needsArgs, 'help' => $help, 'notyet' => $not_yet);
319 318 }
320   - else
  319 + else
321 320 {
322   - if ($child->tagName == 'mission')
  321 + if ($child->tagName == 'mission')
323 322 {
324 323 $disable = $child->hasAttribute('restriction');
325 324 $rank = $child->getAttribute('rank');
... ... @@ -328,19 +327,19 @@ class AmdaAction {
328 327 {
329 328 $disable = $child->hasAttribute('restriction');
330 329 }
331   -
  330 +
332 331 if ($disable)
333 332 {
334 333 if ($disable == 1) {
335 334 $info .= "<br/><b>Restricted access</b>";
336 335 }
337   - else {
338   - $disable = false;
  336 + else {
  337 + $disable = false;
339 338 }
340 339 }
341 340  
342   - $childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType, 'info' => $info,
343   - 'leaf' => false, 'help' => $help, 'disable' => $disable, 'rank' => $rank);
  341 + $childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType, 'info' => $info,
  342 + 'leaf' => false, 'help' => $help, 'disable' => $disable, 'rank' => $rank);
344 343 }
345 344 break;
346 345  
... ... @@ -358,26 +357,28 @@ class AmdaAction {
358 357 break;
359 358 }
360 359 }
361   - if ($child->tagName == 'simulationRegion')
  360 + if ($child->tagName == 'simulationRegion')
362 361 {
363 362 $rank = $child->getAttribute('rank');
364 363 }
365 364 case 'remoteParam' :
366   -
  365 +
367 366 if ($child->getAttribute('isSimulation') && $child->tagName == 'dataCenter') {
368 367 $skip = true;
369 368 break;
370 369 }
371 370  
372 371 $isDeletable = $child->hasAttribute('isDeletable');
  372 +
373 373 $specialNode = true;
374   - $isParameter = false;
375   - $isSpectra = false;
376   -
377   - switch ($id)
  374 + $isParameter = false;
  375 + $isSpectra = false;
  376 +
  377 + switch ($id)
  378 +
378 379 {
379   - case 'CDAWEB' :
380   - case 'OMNIWEB' :
  380 + case 'CDAWEB' :
  381 + case 'OMNIWEB' :
381 382 $isLeaf = false;
382 383 break;
383 384 case 'THEMIS' :
... ... @@ -391,64 +392,64 @@ class AmdaAction {
391 392 break;
392 393 default:
393 394 }
394   -
  395 +
395 396 $info = $child->getAttribute('desc');
396 397  
397   -// if ($info && !$isSimulation) {
  398 +// if ($info && !$isSimulation) {
398 399 $info = str_replace(';', "<br/>Time Range: ", $info);
399 400 // }
400 401 if ($child->tagName == 'dataset') {
401   - /*if ($child->hasAttribute('dataStart') && $child->hasAttribute('dataStop'))
402   - $info .= "Time Range: ".$child->getAttribute('dataStart')."-".$child->getAttribute('dataStop')."<br/>"; */
  402 + /*if ($child->hasAttribute('dataStart') && $child->hasAttribute('dataStop'))
  403 + $info .= "Time Range: ".$child->getAttribute('dataStart')."-".$child->getAttribute('dataStop')."<br/>"; */
403 404 // $info .= "Time Range: ".$dataStart"-".$dataStop."<br/>";
404 405 }
405 406 if (($child->tagName == 'parameter') || ($child->tagName == 'component')) {
406 407 $isParameter = true;
407   - $isScatter = true;
  408 + $isScatter = true;
408 409 }
409   -
  410 +
410 411 $needsArgs = $child->hasAttribute('needsArgs');
411 412  
412 413 if (($child->tagName == 'parameter' && $child->hasChildNodes()) || $needsArgs) $isScatter = false;
413   -
  414 +
414 415 if ($remoteBase) {
415   - if ($child->tagName == 'dataset') $isRemoteDataSet = true;
  416 + if ($child->tagName == 'dataset') $isRemoteDataSet = true;
416 417 }
417 418  
418 419 if ($isParameter) {
419   - $disable = $child->parentNode->getAttribute('disabled');
  420 + $disable = $child->parentNode->getAttribute('disabled');
420 421 $objectMgr = new AliasMgr();
421 422 $alias = $objectMgr->getAlias($id);
422 423  
423 424  
424   - if ($child->hasAttribute('display_type')
  425 + if ($child->hasAttribute('display_type')
425 426 && $child->getAttribute('display_type') == 'spectrogram'){
426   - $needsArgs = true;
  427 + $needsArgs = true;
427 428 $isScatter = false;
428 429 $isSpectra = true;
429   - }
  430 + }
430 431  
431   - $childrenToReturn[] = array('text' => $name,'alias' => $alias,
  432 + $childrenToReturn[] = array('text' => $name,'alias' => $alias,
432 433 'id' => $id,'nodeType' => $nodeType, 'info' => $info, 'help' => $help,
433   - 'leaf' => $isLeaf, 'disable' => $disable, 'isParameter' => $isParameter,
  434 + 'leaf' => $isLeaf, 'disable' => $disable, 'isParameter' => $isParameter,
434 435 'isScatter' => $isScatter, 'isSpectra' => $isSpectra, 'needsArgs' => $needsArgs, "component_info" => $component_info);
435 436 }
436   - else {
437   - if ($child->tagName == 'dataCenter')
438   - $restricted = ($child->getAttribute('available') != "1");
  437 + else {
  438 + if ($child->tagName == 'dataCenter')
  439 + $restricted = ($child->getAttribute('available') != "1");
439 440 else
440 441 $restricted = false;
441   -
442   - if ($id == 'CDAWEB' || $id == 'THEMIS'|| $id == 'MAPSKP' || $id == 'VEXGRAZ')
  442 +
  443 + if ($id == 'CDAWEB' || $id == 'THEMIS'|| $id == 'MAPSKP' || $id == 'VEXGRAZ')
443 444 $restricted = FALSE;
444 445 if ($restricted)
445   - $info .= "<br/><b>Open soon !</b>";
446   -
  446 + $info .= "<br/><b>Open soon !</b>";
  447 +
447 448 if ($child->tagName == 'dataset')
448 449 $nonavailable = ($child->getAttribute('disabled'));
449 450 else
450 451 $nonavailable = false;
451   -
  452 +
452 453 if ($nonavailable)
453 454 $info .= "<br/><b>Not available yet</b>";
454 455  
... ... @@ -463,15 +464,17 @@ class AmdaAction {
463 464 $obsolete = false;
464 465  
465 466 $disable = $restricted || $nonavailable || $obsolete;
466   -
  467 +
467 468 $childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType, 'isAddable' => $isAddable,
468   - 'info' => $info, 'leaf' => false, 'isRemoteDataSet' => $isRemoteDataSet, 'disable' => $disable,
469   - 'isSimulation' => $isSimulation, 'rank' => $rank, 'isDeletable' => $isDeletable, 'help' => $help);
  469 + 'info' => $info, 'leaf' => false, 'isRemoteDataSet' => $isRemoteDataSet, 'disable' => $disable,
  470 + 'isSimulation' => $isSimulation, 'rank' => $rank, 'isDeletable' => $isDeletable, 'help' => $help);
  471 +
470 472 }
471   -
  473 +
472 474 break;
473   - case 'myData' :
474   - $info = $child->hasAttribute('info') ? $child->getAttribute('info') : $child->nodeValue;
  475 +
  476 + case 'myData' :
  477 + $info = $child->hasAttribute('info') ? $child->getAttribute('info') : $child->nodeValue;
475 478 break;
476 479  
477 480 case 'myDataParam' :
... ... @@ -484,7 +487,7 @@ class AmdaAction {
484 487 $mask = $child->getAttribute('mask');
485 488 $isSpectra = false;
486 489  
487   -
  490 +
488 491 if ($isLeaf) {
489 492 $isParameter = true;
490 493 $info = "Size: ".$size."<br/>".$child->getAttribute('desc')."<br/> Mask: ".$mask;
... ... @@ -496,24 +499,24 @@ class AmdaAction {
496 499 $globalStop = substr($child->getAttribute('desc'), 20);
497 500 }
498 501  
499   - $childrenToReturn[] = array('text' => $name, 'size' => $size, 'id' => $id,
  502 + $childrenToReturn[] = array('text' => $name, 'size' => $size, 'id' => $id,
500 503 'globalStart' => $globalStart, 'globalStop' => $globalStop,
501   - 'nodeType' => $nodeType, 'info' => $info, 'isScatter' => $isScatter, 'leaf' => $isLeaf,
  504 + 'nodeType' => $nodeType, 'info' => $info, 'isScatter' => $isScatter, 'leaf' => $isLeaf,
502 505 'isParameter' => $isParameter, 'linkedMask' => $mask, 'isSpectra' => $isSpectra);
503 506  
504 507 break;
505   - default:
  508 + default:
506 509 }
507   -
  510 +
508 511 if (!$specialNode && !$skip) {
509   - if ($child->hasAttribute('desc'))
  512 + if ($child->hasAttribute('desc'))
510 513 $info = $child->getAttribute('desc');
511   - $childrenToReturn[] = array('text' => $name, 'id' => $id, 'nodeType' => $nodeType, 'info' => $info,
  514 + $childrenToReturn[] = array('text' => $name, 'id' => $id, 'nodeType' => $nodeType, 'info' => $info,
512 515 'help' => $help, 'leaf' => $isLeaf, 'isParameter' => $isParameter);
513 516 }
514 517 }
515 518 // if $childrenToReturn we have to return []
516   - if ($childrenToReturn == null) {
  519 + if ($childrenToReturn == null) {
517 520 $childrenToReturn = array('nodeType' => $nodeType, 'text' => null);
518 521 }
519 522 }
... ... @@ -521,106 +524,106 @@ class AmdaAction {
521 524 return $childrenToReturn;
522 525 }
523 526  
524   - public function saveTree($obj)
  527 + public function saveTree($obj)
525 528 {
526 529 $paramMgr = new ParamMgr();
527   - return $paramMgr->saveTree($obj);
  530 + return $paramMgr->saveTree($obj);
528 531 }
529 532  
530   - public function doNothing($obj)
531   - {
  533 + public function doNothing($obj)
  534 + {
532 535 return array("res" => 'ok');
533   -
  536 +
534 537 }
535 538  
536   - public function deleteFromTree($obj)
537   - {
  539 + public function deleteFromTree($obj)
  540 + {
538 541 $paramMgr = new ParamMgr();
539 542 return $paramMgr->deleteFromTree($obj);
540   -
  543 +
541 544 }
542 545  
543 546 /*
544 547 * temporary object fromUpload
545   -*/
  548 +*/
546 549 public function getUploadedObject($name, $format, $nodeType)
547   - {
548   - switch ($nodeType)
  550 + {
  551 + switch ($nodeType)
549 552 {
550   - case 'timeTable' :
551   - $objectMgr = new TimeTableMgr();
  553 + case 'timeTable' :
  554 + $objectMgr = new TimeTableMgr();
552 555 break;
553   - case 'myDataParam' :
554   - $objectMgr = new FilesMgr();
  556 + case 'myDataParam' :
  557 + $objectMgr = new FilesMgr();
555 558 break;
556 559 default:
557 560 return array("error" => $nodeType." NOT_IMPLEMENTED_YET");
558 561 }
559 562 return $objectMgr -> getUploadedObject($name, $format, true);
560 563  
561   - }
  564 + }
562 565  
563 566 /*
564   -* fill ascii file into grid
565   -*/
566   - public function getAsciiFile($obj)
567   - {
568   - $objectMgr = new FilesMgr();
  567 +* fill ascii file into grid
  568 +*/
  569 + public function getAsciiFile($obj)
  570 + {
  571 + $objectMgr = new FilesMgr();
569 572 return $objectMgr -> getAsciiFile($obj->fileName);
570 573 }
571   -
572   - public function getMyParamInfo($object)
573   - {
574   - $objectMgr = new FilesMgr();
  574 +
  575 + public function getMyParamInfo($object)
  576 + {
  577 + $objectMgr = new FilesMgr();
575 578 return $objectMgr -> getParamInfo($object);
576   - }
  579 + }
577 580  
578 581 /*
579   -* temporary object from Search
580   -*/
581   - public function getTmpObject($folderId, $name, $nodeType) {
  582 +* temporary object from Search
  583 +*/
  584 + public function getTmpObject($folderId, $name, $nodeType) {
  585 +
582 586  
583   -
584 587 switch ($nodeType) {
585   - case 'timeTable' :
586   - $objectMgr = new TimeTableMgr();
587   - break;
  588 + case 'timeTable' :
  589 + $objectMgr = new TimeTableMgr();
  590 + break;
588 591 case 'catalog' :
589   - $objectMgr = new CatalogMgr();
590   - break;
  592 + $objectMgr = new CatalogMgr();
  593 + break;
591 594 default:
592 595 return array("error" => $nodeType." NOT_IMPLEMENTED_YET");
593 596 }
594 597 return $objectMgr -> getTmpObject($folderId, $name, true);
595 598  
596 599 }
597   -
598 600  
599   - public function getObject($id, $nodeType) {
600   -
  601 +
  602 + public function getObject($id, $nodeType) {
  603 +
601 604 switch ($nodeType) {
602 605 case 'myDataParam':
603   - case 'derivedParam' :
604   - $objectMgr = new DerivedParamMgr($nodeType);
  606 + case 'derivedParam' :
  607 + $objectMgr = new DerivedParamMgr($nodeType);
605 608 break;
606   - case 'timeTable' :
  609 + case 'timeTable' :
607 610 case 'sharedtimeTable' :
608   - $objectMgr = new TimeTableMgr();
609   - break;
  611 + $objectMgr = new TimeTableMgr();
  612 + break;
610 613 case 'catalog' :
611 614 case 'sharedcatalog' :
612   - $objectMgr = new CatalogMgr();
613   - break;
614   - case 'condition' :
  615 + $objectMgr = new CatalogMgr();
  616 + break;
  617 + case 'condition' :
615 618 case 'request' :
616   - $objectMgr = new RequestMgr($nodeType);
617   - break;
  619 + $objectMgr = new RequestMgr($nodeType);
  620 + break;
618 621 case 'bkgWorks' :
619 622 require_once(INTEGRATION_SRC_DIR."RequestManager.php");
620 623 return $this->executeRequest($id, FunctionTypeEnumClass::PROCESSGETINFO);
621 624 break;
622 625 case 'myData' :
623   - $objectMgr = new FilesMgr();
  626 + $objectMgr = new FilesMgr();
624 627 break;
625 628 default:
626 629 return array("error" => $nodeType." NOT_IMPLEMENTED_YET");
... ... @@ -631,28 +634,28 @@ class AmdaAction {
631 634 /*
632 635 * $obj = { id: node.id, leaf: node.leaf, nodeType: node.nodeType }
633 636 */
634   - public function deleteObject($obj) {
635   -
636   - switch ($obj->nodeType) {
637   -
638   - case 'myDataParam' :
639   - case 'derivedParam' :
640   - $objectMgr = new DerivedParamMgr($obj->nodeType);
  637 + public function deleteObject($obj) {
  638 +
  639 + switch ($obj->nodeType) {
  640 +
  641 + case 'myDataParam' :
  642 + case 'derivedParam' :
  643 + $objectMgr = new DerivedParamMgr($obj->nodeType);
641 644 break;
642   - case 'timeTable' :
643   - $objectMgr = new TimeTableMgr();
644   - break;
645   - case 'catalog' :
646   - $objectMgr = new CatalogMgr();
  645 + case 'timeTable' :
  646 + $objectMgr = new TimeTableMgr();
647 647 break;
648   - case 'condition' :
  648 + case 'catalog' :
  649 + $objectMgr = new CatalogMgr();
  650 + break;
  651 + case 'condition' :
649 652 case 'request' :
650   - $objectMgr = new RequestMgr($obj->nodeType);
  653 + $objectMgr = new RequestMgr($obj->nodeType);
651 654 break;
652 655 case 'alias' :
653 656 $objectMgr = new AliasMgr();
654 657 $obj->id = substr($obj->id,strlen('alias_'));
655   - break;
  658 + break;
656 659 case 'bkgWorks' :
657 660 require_once(INTEGRATION_SRC_DIR."RequestManager.php");
658 661 return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSDELETE);
... ... @@ -670,27 +673,27 @@ class AmdaAction {
670 673 /*
671 674 * $obj = { id: node.id, old_name: node.text, name: value, parent : node.parentNode.id, leaf: node.leaf, nodeType: node.nodeType }
672 675 */
673   - public function renameObject($obj) {
674   -
  676 + public function renameObject($obj) {
  677 +
675 678 switch ($obj->nodeType) {
676   -
  679 +
677 680 case 'myDataParam' :
678   - case 'derivedParam' :
679   - $objectMgr = new DerivedParamMgr($obj->nodeType);
  681 + case 'derivedParam' :
  682 + $objectMgr = new DerivedParamMgr($obj->nodeType);
680 683 break;
681   - case 'timeTable' :
682   - $objectMgr = new TimeTableMgr();
  684 + case 'timeTable' :
  685 + $objectMgr = new TimeTableMgr();
683 686 break;
684   - case 'catalog' :
685   - $objectMgr = new CatalogMgr();
686   - break;
687   - case 'condition' :
688   - case 'request' :
689   - $objectMgr = new RequestMgr($obj->nodeType);
  687 + case 'catalog' :
  688 + $objectMgr = new CatalogMgr();
  689 + break;
  690 + case 'condition' :
  691 + case 'request' :
  692 + $objectMgr = new RequestMgr($obj->nodeType);
690 693 break;
691 694 case 'alias' :
692   - $objectMgr = new AliasMgr();
693   - break;
  695 + $objectMgr = new AliasMgr();
  696 + break;
694 697 default:
695 698 return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
696 699 }
... ... @@ -698,33 +701,33 @@ class AmdaAction {
698 701 return $objectMgr -> renameObject($obj);
699 702 }
700 703  
701   -/*
  704 +/*
702 705 * $obj = { name: obj.name, obj.nodeType, obj.leaf (??), OBJ DEPENDENT ATTRIBUTES }
703 706 */
704   - public function createObject($obj, $folder) {
705   -
  707 + public function createObject($obj, $folder) {
  708 +
706 709 switch ($obj->nodeType) {
707 710  
708   - case 'myDataParam' :
  711 + case 'myDataParam' :
709 712 case 'derivedParam' :
710   - if ($obj->nodeType == 'derivedParam' && $this->amdaStat->success)
  713 + if ($obj->nodeType == 'derivedParam' && $this->amdaStat->success)
711 714 $this->amdaStat->addTask('create', $this->user, null);
712 715  
713   - $objectMgr = new DerivedParamMgr($obj->nodeType);
714   - break;
715   - case 'timeTable' :
716   - $objectMgr = new TimeTableMgr();
717   - break;
718   - case 'catalog' :
719   - $objectMgr = new CatalogMgr();
  716 + $objectMgr = new DerivedParamMgr($obj->nodeType);
  717 + break;
  718 + case 'timeTable' :
  719 + $objectMgr = new TimeTableMgr();
  720 + break;
  721 + case 'catalog' :
  722 + $objectMgr = new CatalogMgr();
720 723 break;
721 724 case 'condition' :
722   - case 'request' :
723   - $objectMgr = new RequestMgr($obj->nodeType);
724   - break;
  725 + case 'request' :
  726 + $objectMgr = new RequestMgr($obj->nodeType);
  727 + break;
725 728 case 'alias' :
726   - $objectMgr = new AliasMgr();
727   - break;
  729 + $objectMgr = new AliasMgr();
  730 + break;
728 731 default:
729 732 return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
730 733 }
... ... @@ -732,33 +735,33 @@ class AmdaAction {
732 735 return $objectMgr -> createObject($obj, $folder);
733 736 }
734 737  
735   -/*
  738 +/*
736 739 * $obj = { id:obj.id, name: obj.name, obj.nodeType, obj.leaf (??), OBJ DEPENDENT ATTRIBUTES }
737 740 */
738 741 public function modifyObject($obj) {
739   -
740   - switch ($obj->nodeType) {
741 742  
742   - case 'myDataParam' :
743   - case 'derivedParam' :
744   - $objectMgr = new DerivedParamMgr($obj->nodeType);
  743 + switch ($obj->nodeType) {
  744 +
  745 + case 'myDataParam' :
  746 + case 'derivedParam' :
  747 + $objectMgr = new DerivedParamMgr($obj->nodeType);
  748 + break;
  749 + case 'timeTable' :
  750 + $objectMgr = new TimeTableMgr();
745 751 break;
746   - case 'timeTable' :
747   - $objectMgr = new TimeTableMgr();
  752 + case 'catalog' :
  753 + $objectMgr = new CatalogMgr();
748 754 break;
749   - case 'catalog' :
750   - $objectMgr = new CatalogMgr();
751   - break;
752   - case 'condition' :
  755 + case 'condition' :
753 756 case 'request' :
754   - $objectMgr = new RequestMgr($obj->nodeType);
  757 + $objectMgr = new RequestMgr($obj->nodeType);
755 758 break;
756 759 default:
757 760 return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
758 761 }
759 762  
760 763 return $objectMgr -> modifyObject($obj);
761   - }
  764 + }
762 765 /*
763 766 * {obj.name, obj.nodeType, obj.leaf}
764 767 */
... ... @@ -794,7 +797,7 @@ class AmdaAction {
794 797 public function getJobs()
795 798 {
796 799 require_once(INTEGRATION_SRC_DIR."RequestManager.php");
797   - return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSRUNNINGINFO);
  800 + return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSRUNNINGINFO);
798 801 }
799 802  
800 803  
... ... @@ -808,8 +811,8 @@ class AmdaAction {
808 811 $this->user = NEWKERNEL_DEBUG_USER;
809 812 return array('success' => true);
810 813 }
811   -
812   -
  814 +
  815 +
813 816 if (isset($obj->username) && isset($obj->password) && isset($obj->sessionID))
814 817 {
815 818 //$dd = new WSUserMgr();
... ... @@ -818,11 +821,11 @@ class AmdaAction {
818 821 }
819 822 else
820 823 $dd = new UserMgr();
821   -
822   - //TODO error handling
  824 +
  825 + //TODO error handling
823 826 if (($res = $dd -> ddCheckUser()) != 0)
824 827 {
825   - if ($res == 156)
  828 + if ($res == 156)
826 829 return array('success' => false, 'message' => 'Your AMDA session is expired.<br/> Login please!');
827 830  
828 831 return array('success' => false, 'message' => 'ddLogin error: '.$res);
... ... @@ -840,42 +843,42 @@ class AmdaAction {
840 843 if ($dd->getWsSize() > DISK_QUOTA)
841 844 return array('success' => false, 'message' => 'Please clean up your workspace.<br/>No more space is available');
842 845 }
843   -
  846 +
844 847 $this->user = $dd->user;
845   -
  848 +
846 849 return array('success' => true, 'userHost' => $dd -> getIPclient());
847 850 }
848   -
  851 +
849 852 private function executeRequest($obj, $function)
850 853 {
851 854 $res = $this->checkUser($obj);
852   -
  855 +
853 856 if (!$res['success'])
854 857 return $res;
855   -
  858 +
856 859 $requestManager = new RequestManagerClass();
857   -
  860 +
858 861 try {
859 862 $res = $requestManager->runIHMRequest($this->user, $res['userHost'], $function, $obj);
860 863 } catch (Exception $e) {
861 864 return array('success' => false, 'message' => 'Exception detected : '.$e->getMessage());
862 865 }
863   -
  866 +
864 867 return $res;
865 868 }
866   -
867   -/*
868   -* Main EXECUTE PROCEDURE
  869 +
  870 +/*
  871 +* Main EXECUTE PROCEDURE
869 872 */
870 873 public function execute($node, $obj)
871   - {
  874 + {
872 875 require_once(INTEGRATION_SRC_DIR."RequestManager.php");
873 876 if (isset($obj->action))
874 877 return $this->executeRequest($obj, FunctionTypeEnumClass::ACTION);
875 878 else
876 879 return $this->executeRequest($obj, FunctionTypeEnumClass::PARAMS);
877 880 }
878   -
  881 +
879 882 /*
880 883 * Generate derived parameter compilation
881 884 */
... ... @@ -892,23 +895,23 @@ class AmdaAction {
892 895 {
893 896 require_once(INTEGRATION_SRC_DIR."RequestManager.php");
894 897 $res = $this->checkUser($obj);
895   -
  898 +
896 899 if (!$res['success'])
897 900 return $res;
898   -
  901 +
899 902 IHMConfigClass::setUserName($this->user);
900 903 $libParamPath = IHMConfigClass::getCompilationPath()."lib/".$obj->paramId.".so";
901 904 if (file_exists($libParamPath))
902 905 unlink($libParamPath);
903 906 return array("success" => true);
904 907 }
905   -
  908 +
906 909 /*
907 910 * kill plot process
908 911 */
909   -
  912 +
910 913 public function killPlotRequest()
911   - {
  914 + {
912 915 require_once(INTEGRATION_SRC_DIR."RequestManager.php");
913 916 return $this->executeRequest((object) array('nodeType' => 'killplot'), FunctionTypeEnumClass::PARAMS);
914 917 }
... ... @@ -920,14 +923,14 @@ class AmdaAction {
920 923  
921 924 if ($this->amdaStat->success)
922 925 $this->amdaStat->addTask('ttoper', $this->user, null);
923   -
  926 +
924 927 $objectMgr = new TimeTableMgr();
925 928  
926 929 return $objectMgr -> merge($obj);
927 930  
928 931 }
929 932  
930   -
  933 +
931 934 /*
932 935 * intersect time tables
933 936 */
... ... @@ -941,117 +944,117 @@ class AmdaAction {
941 944  
942 945 return $result;
943 946 }
944   -
  947 +
945 948 public function initTTCache($isCatalog = false, $nparams)
946 949 {
947 950 if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr();
948 951 else $cacheMgr = new CatalogCacheMgr();
949   -
  952 +
950 953 return $cacheMgr->initTTCache($nparams);
951 954 }
952   -
953   -
  955 +
  956 +
954 957 public function initTTCacheFromTT($id, $type)
955 958 {
956 959 if ($type == 'catalog' || $type == 'sharedcatalog') $cacheMgr = new CatalogCacheMgr();
957 960 else $cacheMgr = new TimeTableCacheMgr();
958   -
  961 +
959 962 return $cacheMgr->initFromTT($id, $type);
960 963 }
961   -
  964 +
962 965 public function initForChart($id, $name, $isTmpObject, $type)
963 966 {
964 967 if ($type == 'catalog' || $type == 'sharedcatalog') $objMgr = new CatalogMgr();
965   -
  968 +
966 969 return $objMgr->initForChart($id, $name, $isTmpObject, $type);
967 970 }
968   -
  971 +
969 972 public function initTTCacheFromTmpObject($folderId, $name, $isCatalog = false)
970 973 {
971 974 if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr();
972   -
  975 +
973 976 else $cacheMgr = new CatalogCacheMgr();
974   -
975   -
976   -
  977 +
  978 +
  979 +
977 980 return $cacheMgr->initFromTmpObject($folderId, $name);
978 981 }
979   -
  982 +
980 983 public function initTTCacheFromUploadedFile($name, $format)
981 984 {
982 985 $cacheMgr = new TimeTableCacheMgr();
983 986 return $cacheMgr->initFromUploadedFile($name, $format);
984 987 }
985   -
  988 +
986 989 public function readTTCacheIntervals($o)
987 990 {
988 991 if ($o->typeTT == 'catalog' || $type == 'sharedcatalog') $cacheMgr = new CatalogCacheMgr();
989 992 else $cacheMgr = new TimeTableCacheMgr();
990   -
  993 +
991 994 return $cacheMgr->getIntervals($o->start,$o->limit,$o->sort,$o->filter);
992 995 }
993   -
  996 +
994 997 public function readIntervalsForChart($o)
995 998 {
996 999 if ($o->typeTT == 'catalog' || $type == 'sharedcatalog') $objMgr = new CatalogMgr();
997   -
998   -
  1000 +
  1001 +
999 1002 return $objMgr->getIntervalsForChart($o->id, $o->name, $o->fromPlugin, $o->typeTT);
1000 1003 }
1001   -
  1004 +
1002 1005 public function saveTTCacheIntervalsInTT($o)
1003 1006 {
1004 1007 $cacheMgr = new TimeTableCacheMgr();
1005 1008 return $cacheMgr->saveInTT($o->ttId,$o->action,$o->cacheToken);
1006 1009 }
1007   -
  1010 +
1008 1011 public function addTTCacheInterval($o)
1009 1012 {
1010 1013 if ($o->isCatalog) $cacheMgr = new CatalogCacheMgr();
1011 1014 else $cacheMgr = new TimeTableCacheMgr();
1012   -
  1015 +
1013 1016 return $cacheMgr->addInterval($o->index, $o->start, $o->stop);
1014 1017 }
1015   -
  1018 +
1016 1019 public function removeTTCacheIntervalFromId($id, $isCatalog = false)
1017 1020 {
1018 1021 if ($isCatalog) $cacheMgr = new CatalogCacheMgr();
1019 1022 else $cacheMgr = new TimeTableCacheMgr();
1020   -
  1023 +
1021 1024 return $cacheMgr->removeIntervalFromId($id);
1022 1025 }
1023   -
  1026 +
1024 1027 public function modifyTTCacheInterval($o)
1025 1028 {
1026 1029 if ($o->isCatalog) {
1027   -
  1030 +
1028 1031 $cacheMgr = new CatalogCacheMgr();
1029 1032 return $cacheMgr->modifyIntervalFromId($o);
1030   -
  1033 +
1031 1034 }
1032 1035 else $cacheMgr = new TimeTableCacheMgr();
1033   -
  1036 +
1034 1037 return $cacheMgr->modifyIntervalFromId($o->cacheId, $o->start, $o->stop);
1035 1038 }
1036   -
  1039 +
1037 1040 public function operationTTCacheIntervals($extendTime, $shiftTime)
1038 1041 {
1039 1042 $cacheMgr = new TimeTableCacheMgr();
1040 1043 return $cacheMgr->operationIntervals($extendTime, $shiftTime);
1041 1044 }
1042   -
  1045 +
1043 1046 public function mergeTTCacheIntervals()
1044 1047 {
1045 1048 $cacheMgr = new TimeTableCacheMgr();
1046 1049 return $cacheMgr->mergeIntervals();
1047 1050 }
1048   -
  1051 +
1049 1052 public function getTTCacheStatistics()
1050 1053 {
1051 1054 $cacheMgr = new TimeTableCacheMgr();
1052 1055 return $cacheMgr->getStatistics();
1053 1056 }
1054   -
  1057 +
1055 1058 public function getTTCacheStatus()
1056 1059 {
1057 1060 $cacheMgr = new TimeTableCacheMgr();
... ... @@ -1060,39 +1063,39 @@ class AmdaAction {
1060 1063  
1061 1064 /*
1062 1065 * Send a feedback
1063   - *
  1066 + *
1064 1067 */
1065 1068 public function sendFeedback($feed)
1066 1069 {
1067 1070 $feedMgr = new FeedbackMgr();
1068 1071 return $feedMgr->addFeedback($feed->user, $feed->interface, $feed->subject, $feed->userText, $feed->userAgent, $feed->attach);
1069 1072 }
1070   -
  1073 +
1071 1074 /*
1072 1075 * Save state
1073   - *
  1076 + *
1074 1077 */
1075 1078 public function saveState($datas)
1076 1079 {
1077 1080 $myStateMgr = new StateMgr();
1078 1081 return $myStateMgr->saveState($datas);
1079 1082 }
1080   -
  1083 +
1081 1084 /*
1082 1085 * Load state
1083   - *
1084   - */
  1086 + *
  1087 + */
1085 1088 public function loadState($o)
1086   - {
  1089 + {
1087 1090 $myStateMgr = new StateMgr();
1088 1091 return $myStateMgr->loadState();
1089 1092 }
1090   -
1091   -/*
  1093 +
  1094 +/*
1092 1095 * SAMP
1093 1096 */
1094 1097 public function sendToSAMP($o)
1095   - {
  1098 + {
1096 1099 if ($this->amdaStat->success)
1097 1100 $this->amdaStat->addTask('samp', $this->user, null);
1098 1101  
... ... @@ -1105,7 +1108,7 @@ class AmdaAction {
1105 1108 }
1106 1109 return $res;
1107 1110 }
1108   -
  1111 +
1109 1112 /*
1110 1113 * HST Images
1111 1114 */
... ... @@ -1113,30 +1116,30 @@ class AmdaAction {
1113 1116 {
1114 1117 if ($this->amdaStat->success)
1115 1118 $this->amdaStat->addTask('images', $this->user, null);
1116   -
  1119 +
1117 1120 $myHstMgr = new HstMgr();
1118 1121 $res = $myHstMgr->getImagesUrl($o->startTime, $o->stopTime, $o->planet);
1119 1122 //if ($domRes->length <= 0)
1120 1123 // return array('success' => false, 'message' => 'Cannot find HST Images for this request.');
1121 1124 return array('success' => true, 'result' => $res);
1122 1125 }
1123   -
  1126 +
1124 1127 public function getAPISImagesUrl($o)
1125 1128 {
1126   - if ($this->amdaStat->success)
  1129 + if ($this->amdaStat->success)
1127 1130 $this->amdaStat->addTask('images', $this->user, null);
1128   -
  1131 +
1129 1132 $apisMgr = new APISMgr();
1130 1133 $res = $apisMgr->get($o->target, $o->startTime, $o->stopTime, $o->datasets);
1131 1134  
1132 1135 return $res;
1133   - }
  1136 + }
1134 1137 /*
1135 1138 * Filters
1136 1139 */
1137 1140 public function loadFilterList($o)
1138 1141 {
1139   - $filtersMgr = new FiltersMgr();
  1142 + $filtersMgr = new FiltersMgr();
1140 1143 $res = $filtersMgr->loadList();
1141 1144 return $res;
1142 1145 }
... ... @@ -1150,52 +1153,52 @@ class AmdaAction {
1150 1153 $res = $filtersMgr->loadAll();
1151 1154 return $res;
1152 1155 }
1153   -
  1156 +
1154 1157 public function saveFilter($o)
1155 1158 {
1156   - $filtersMgr = new FiltersMgr();
  1159 + $filtersMgr = new FiltersMgr();
1157 1160 return $filtersMgr->save($o);
1158 1161 }
1159   -
  1162 +
1160 1163 public function createFilter($o)
1161 1164 {
1162   - $filtersMgr = new FiltersMgr();
  1165 + $filtersMgr = new FiltersMgr();
1163 1166 return $filtersMgr->create($o);
1164 1167 }
1165   -
  1168 +
1166 1169 public function destroyFilter($o)
1167 1170 {
1168 1171 $filtersMgr = new FiltersMgr();
1169 1172 $res = $filtersMgr->delete($o);
1170 1173 return;
1171 1174 }
1172   -
  1175 +
1173 1176 public function getCrtFilterId()
1174 1177 {
1175 1178 $filtersMgr = new FiltersMgr();
1176 1179 $res = $filtersMgr->getCrtId();
1177 1180 return $res;
1178 1181 }
1179   -
  1182 +
1180 1183 public function getCrtFilterResult()
1181 1184 {
1182   - $filtersMgr = new FiltersMgr();
  1185 + $filtersMgr = new FiltersMgr();
1183 1186 return $filtersMgr->getCrtResult();
1184 1187 }
1185   -
  1188 +
1186 1189 public function setCrtFilterId($o)
1187 1190 {
1188   - $filtersMgr = new FiltersMgr();
  1191 + $filtersMgr = new FiltersMgr();
1189 1192 return $filtersMgr->setCrtId($o->id);
1190 1193 }
1191   -
  1194 +
1192 1195 public function resetFilter()
1193 1196 {
1194 1197 $filtersMgr = new FiltersMgr();
1195 1198 $res = $filtersMgr->reset();
1196 1199 return $res;
1197 1200 }
1198   -
  1201 +
1199 1202 public function logout($isGuest)
1200 1203 {
1201 1204 if ($isGuest) {
... ... @@ -1204,25 +1207,25 @@ class AmdaAction {
1204 1207 }
1205 1208 else {
1206 1209 $myBaseMgr = new BaseManager();
1207   - $myBaseMgr->delSimuFiles('mysimudata');
1208   - $myBaseMgr->delSimuFiles('mywsrdata');
1209   -
  1210 + $myBaseMgr->delSimuFiles('mysimudata');
  1211 + $myBaseMgr->delSimuFiles('mywsrdata');
  1212 +
1210 1213 $this->cleanUserWS();
1211   - }
  1214 + }
1212 1215 return;
1213   - }
  1216 + }
1214 1217  
1215 1218 public function getInfo($obj)
1216 1219 {
1217   - if (file_exists(HELPPATH.$obj->name))
  1220 + if (file_exists(HELPPATH.$obj->name))
1218 1221 {
1219   - $content = file_get_contents(HELPPATH.$obj->name);
  1222 + $content = file_get_contents(HELPPATH.$obj->name);
1220 1223 return array('success' => true, 'result' => $content);
1221 1224 }
1222 1225 return array('success' => false);
1223   -
1224   - }
1225   -
  1226 +
  1227 + }
  1228 +
1226 1229 public function getUserInfo()
1227 1230 {
1228 1231 $dd = new UserMgr();
... ... @@ -1242,11 +1245,11 @@ class AmdaAction {
1242 1245  
1243 1246 $myBestRunsMgr = new BestRunsMgr();
1244 1247 $res = $myBestRunsMgr->getRun($obj);
1245   -
1246   - return $res;
  1248 +
  1249 + return $res;
1247 1250 }
1248   -
1249   - //$obj = array of IDs
  1251 +
  1252 + //$obj = array of IDs
1250 1253 public function addRun($obj)
1251 1254 {
1252 1255 $myBestRunsMgr = new BestRunsMgr();
... ... @@ -1255,7 +1258,7 @@ class AmdaAction {
1255 1258  
1256 1259 $res = array('success' => true,'addedRuns' => $obj);
1257 1260 return $res;
1258   - }
  1261 + }
1259 1262 //AKKA - New action to clean user WS
1260 1263 public function cleanUserWS()
1261 1264 {
... ... @@ -1265,11 +1268,11 @@ class AmdaAction {
1265 1268  
1266 1269 public function deleteSpecialInfo($name)
1267 1270 {
1268   - if (file_exists(USERDIR.$name))
  1271 + if (file_exists(USERDIR.$name))
1269 1272 unlink(USERDIR.$name);
1270 1273 return array('success' => true);
1271 1274 }
1272   -
  1275 +
1273 1276 public function interactivePlot($obj, $multiPlotState)
1274 1277 {
1275 1278 require_once(INTEGRATION_SRC_DIR."RequestManager.php");
... ... @@ -1279,7 +1282,7 @@ class AmdaAction {
1279 1282 );
1280 1283 return $this->executeRequest($inputobj, FunctionTypeEnumClass::ACTION);
1281 1284 }
1282   -
  1285 +
1283 1286 public function getParamPlotInit($obj)
1284 1287 {
1285 1288 require_once(INTEGRATION_SRC_DIR."RequestManager.php");
... ... @@ -1289,7 +1292,7 @@ class AmdaAction {
1289 1292 );
1290 1293 return $this->executeRequest($inputobj, FunctionTypeEnumClass::PARAMINFO);
1291 1294 }
1292   -
  1295 +
1293 1296 public function getParamInfo($obj)
1294 1297 {
1295 1298 require_once(INTEGRATION_SRC_DIR."RequestManager.php");
... ... @@ -1299,14 +1302,14 @@ class AmdaAction {
1299 1302 );
1300 1303 return $this->executeRequest($inputobj, FunctionTypeEnumClass::PARAMINFO);
1301 1304 }
1302   -
  1305 +
1303 1306 public function getSharedObjectFolders($obj)
1304 1307 {
1305 1308 $mgr = new SharedObjectsMgr();
1306 1309 $folders = $mgr->getFolders($obj->type);
1307 1310 return array('success' => true, 'folders' => $folders);
1308 1311 }
1309   -
  1312 +
1310 1313 public function shareObjects($obj)
1311 1314 {
1312 1315 $mgr = new SharedObjectsMgr();
... ... @@ -1315,19 +1318,19 @@ class AmdaAction {
1315 1318 case 'catalog' :
1316 1319 $src_object_path = USERTTDIR.$obj->object->id.".xml";
1317 1320 break;
1318   -
  1321 +
1319 1322 default:
1320 1323 return array('success' => false, 'message' => 'Unknown object type');
1321 1324 }
1322   -
  1325 +
1323 1326 $result = $mgr->add($obj->type, $obj->name, $obj->folder, $src_object_path, $obj->description, $this->user);
1324 1327 if (!$result['success'])
1325 1328 return $result;
1326   -
  1329 +
1327 1330 $mgr->updateTree();
1328 1331 return $result;
1329 1332 }
1330   -
  1333 +
1331 1334 public function isSharedObjectNameAlreadyUsed($obj)
1332 1335 {
1333 1336 $mgr = new SharedObjectsMgr();
... ... @@ -1340,4 +1343,3 @@ class AmdaAction {
1340 1343 }
1341 1344 }
1342 1345 ?>
1343   -
... ...
php/classes/EpnTapMgr.php
... ... @@ -8,13 +8,13 @@ class EpnTapMgr {
8 8  
9 9 function __construct()
10 10 {
11   - $this->logEpnTap = fopen(USERDATADIR."logEpnTap", "a");
  11 + $this->logEpnTap = fopen(LOG_DIR . "epnTap.log", "a");
12 12 $this->addLog("\n---\n");
13 13 }
14 14  
15 15 function addLog($msg)
16 16 {
17   - fwrite($this->logEpnTap, date("h:i:s A") . $msg . "\n");
  17 + fwrite($this->logEpnTap, date("h:i:s A") . ": " . $msg . "\n");
18 18 }
19 19  
20 20 public function call($function_name, $args) {
... ... @@ -45,8 +45,7 @@ class EpnTapMgr {
45 45 $monthp = $month;
46 46 }
47 47  
48   - # this checks where we are in relation to October 15, 1582, the beginning
49   - # of the Gregorian calendar.
  48 + # this checks where we are in relation to October 15, 1582, the beginning of the Gregorian calendar.
50 49 if (($year < 1582) ||
51 50 ($year == 1582 && $month < 10) ||
52 51 ($year == 1582 && $month == 10 && $day < 15))
... ... @@ -60,53 +59,34 @@ class EpnTapMgr {
60 59 return $j_day;
61 60 }
62 61  
63   - private function getServiceNbResults($table_name, $access_url, $target_name, $dataproduct_type, $time_min, $time_max) {
64   - // $this->addLog("getServiceNbResults(" . $table_name .", ". $access_url .", ". $target_name .", ". $dataproduct_type .", ". $time_min .", ". $time_max . ")");
  62 + public function createFilter($target_name, $dataproduct_type, $time_min, $time_max) {
65 63 $filter = array();
66 64 if($target_name)
67 65 array_push($filter, "target_name = '$target_name'");
68 66 if($dataproduct_type)
69 67 array_push($filter, "dataproduct_type = '$dataproduct_type'");
70 68 if($time_min)
71   - array_push($filter, "time_min >= " . $this->date2JD($time_min));
  69 + array_push($filter, "time_min <= " . $this->date2JD($time_min));
72 70 if($time_max)
73 71 array_push($filter, "time_max >= " . $this->date2JD($time_max));
74 72  
75   - $query = "SELECT COUNT(granule_uid) AS nb_results FROM $table_name.epn_core"
76   - . (count($filter) > 0 ? ' WHERE '.join(' AND ', $filter) : '');
77   -
78   - $this->addLog("query: " . $query);
  73 + return (count($filter) > 0 ? ' WHERE '.join(' AND ', $filter) : '');
  74 + }
79 75  
  76 + public function request($access_url, $query) {
80 77 $votMgr = new VOTableMgr;
81 78 $params = 'FORMAT=votable&LANG=ADQL&REQUEST=doQuery';
82 79 $url = $access_url . '/sync?' . $params . '&QUERY=' . urlencode($query);
83   - $this->addLog("URL: " . $url);
  80 + $this->addLog("Query URL: " . $url);
84 81 $votMgr->load($url);
85   - $res = $votMgr->isValidSchema() ? $votMgr->getStream() : "-";
86   - return $res["nb_results"];
  82 + $result = $votMgr->isValidSchema() ? $votMgr->parseStream() : NULL;
  83 + return $result;
87 84 }
88 85  
89 86 private function getGranules($table_name, $access_url, $target_name, $dataproduct_type, $time_min, $time_max) {
90   - $this->addLog("getGranules(" . $table_name .", ". $access_url .", ". $target_name .", ". $dataproduct_type .", ". $time_min .", ". $time_max . ")");
91   - $filter = array();
92   - if($target_name)
93   - array_push($filter, "target_name = '$target_name'");
94   - if($dataproduct_type)
95   - array_push($filter, "dataproduct_type = '$dataproduct_type'");
96   - if($time_min)
97   - array_push($filter, "time_min >= " . $this->date2JD($time_min));
98   - if($time_max)
99   - array_push($filter, "time_max >= " . $this->date2JD($time_max));
100   -
101   - $query = "SELECT dataproduct_type, target_name, time_min, time_max FROM $table_name.epn_core"
102   - . ($filter.length > 0 ? ' WHERE ' . join(' AND ', $filter) : '');
103   -
104   - $votMgr = new VOTableMgr;
105   - $params = 'FORMAT=votable&LANG=ADQL&REQUEST=doQuery';
106   - $url = $access_url . '/sync?' . $params . '&QUERY=' . urlencode($query);
107   - $votMgr->load($url);
108   - $res = $votMgr->isValidSchema() ? $votMgr->getStream() : "-";
109   - return $res;
  87 + $filter = $this->createFilter($target_name, $dataproduct_type, $time_min, $time_max);
  88 + $query = "SELECT dataproduct_type, target_name, time_min, time_max FROM $table_name.epn_core" . $filter;
  89 + return $this->request($access_url, $query);
110 90 }
111 91 }
112 92 ?>
... ...
php/classes/VOTableMgr.php
... ... @@ -9,20 +9,22 @@ define(&quot;DEBUG_MODE&quot;, TRUE);
9 9  
10 10  
11 11 class VOTableMgr {
12   - private $xml, $xp;
13   - private $log;
14   -
15   - function __construct()
16   - {
17   - if (DEBUG_MODE)
18   - $this->log = fopen(USERDATADIR."logVOTable", "a");
19   - }
  12 + private $xml, $xp;
  13 + private $logVotable; // The log file.
  14 + private $stream; // The stream in the VOTable
  15 + private $c; // Current character position on the stream
  16 +
  17 + function __construct()
  18 + {
  19 + if (DEBUG_MODE)
  20 + $this->logVotable = fopen(LOG_DIR . "VOTable.log", "a");
  21 + }
20 22  
21   - function addLog($msg)
22   - {
23   - if (DEBUG_MODE)
24   - fprintf($this->log, $msg."\n");
25   - }
  23 + function addLog($msg)
  24 + {
  25 + if (DEBUG_MODE)
  26 + fwrite($this->logVotable, date("h:i:s A") . ": " . $msg . "\n");
  27 + }
26 28  
27 29 function load($fileName) {
28 30 $this->addLog("File name" . $fileName);
... ... @@ -35,10 +37,11 @@ class VOTableMgr {
35 37 libxml_set_streams_context($context);
36 38  
37 39 $this->xml = new DomDocument();
38   - if (!$this->xml->load($fileName))
39   - {
40   - $this->xml = false;
41   - return FALSE;
  40 + $res = $this->xml->load($fileName);
  41 +
  42 + if(!$res) {
  43 + $this->addLog("Can not load VOTAble.");
  44 + return false;
42 45 }
43 46  
44 47 $this->checkIDAttribute();
... ... @@ -58,113 +61,125 @@ class VOTableMgr {
58 61 return true;
59 62 }
60 63  
61   - function isValidSchema()
62   - {
63   - if (!$this->xml)
64   - return FALSE;
65   -
66   -
67   - //ToDo - BRE - add validation!!
68   - return TRUE;
69   -
70   - if (DEBUG_MODE)
71   - libxml_use_internal_errors(true);
72   -
73   - $vers = $this->getVersion();
74   -
75   - $this->addLog("VOTable version : ".$vers."\n");
76   -
77   - $result = FALSE;
78   -
79   - switch ($vers)
80   - {
81   - case '1.2' :
82   - $result = $this->xml->schemaValidate(XMLPATH.'VOTable-1.2.xsd');
83   - case '1.0' :
84   - $result = $this->xml->schemaValidate(XMLPATH.'VOTable-1.0.xsd');
85   - default :
86   - $result = $this->xml->schemaValidate(XMLPATH.'VOTable-1.1.xsd');
87   - }
88   -
89   - if (DEBUG_MODE)
90   - {
91   - $errors = libxml_get_errors();
92   -
93   - foreach ($errors as $error)
94   - {
95   - $msg = '';
96   -
97   - switch ($error->level)
98   - {
99   - case LIBXML_ERR_WARNING:
100   - $msg .= ("WARNING ".$error->code.": ");
101   - break;
102   - case LIBXML_ERR_ERROR:
103   - $msg .= ("ERROR ".$error->code.": ");
104   - break;
105   - case LIBXML_ERR_FATAL:
106   - $msg .= ("FATAL ".$error->code.": ");
107   - break;
108   - }
109   - $msg .= ($error->message." - In line : ".$error->line." - Of file : ".$error->file."\n");
110   -
111   - $this->addLog($msg);
112   - }
113   -
114   - libxml_use_internal_errors(false);
115   - }
116   -
117   - return $result;
118   - }
119   -
120   - protected function queryResource()
121   - {
122   - return "//x:RESOURCE";
123   - }
124   -
125   - protected function queryTable()
126   - {
127   - return $this->queryResource()."/x:TABLE";
128   - }
129   -
130   - protected function queryDescription()
131   - {
132   - return $this->queryTable()."/x:DESCRIPTION";
133   - }
134   -
135   - protected function queryFields()
136   - {
137   - return $this->queryTable()."/x:FIELD";
138   - }
139   -
140   - protected function queryField($field_id)
141   - {
142   - return $this->queryFields()."[@ID='".$field_id."']";
143   - }
144   -
145   - protected function queryFieldByName($field_id)
146   - {
147   - return $this->queryFields()."[@name='".$field_id."']";
148   - }
149   - protected function queryFieldDescription($field_id)
150   - {
151   - return $this->queryField($field_id)."/x:DESCRIPTION";
152   - }
153   -
154   - protected function queryData()
155   - {
156   - return $this->queryTable()."/x:DATA";
157   - }
158   -
159   - protected function queryTableData()
160   - {
161   - return $this->queryData()."/x:TABLEDATA";
162   - }
163   -
164   - protected function queryTR()
165   - {
166   - return $this->queryTableData()."/x:TR";
167   - }
  64 + function isValidSchema()
  65 + {
  66 + if (!$this->xml)
  67 + return FALSE;
  68 +
  69 + $infos = $this->xp->query($this->queryResourceInfo());
  70 + foreach($infos as $info) {
  71 + if($info->getAttribute('value') == 'ERROR') {
  72 + $this->addLog("There is an error on the VOTable: " . $info->textContent);
  73 + return FALSE;
  74 + }
  75 + }
  76 +
  77 + //ToDo - BRE - add validation!!
  78 + return TRUE;
  79 +
  80 + if (DEBUG_MODE)
  81 + libxml_use_internal_errors(true);
  82 +
  83 + $vers = $this->getVersion();
  84 +
  85 + $this->addLog("VOTable version : ".$vers."\n");
  86 +
  87 + $result = FALSE;
  88 +
  89 + switch ($vers)
  90 + {
  91 + case '1.2' :
  92 + $result = $this->xml->schemaValidate(XMLPATH.'VOTable-1.2.xsd');
  93 + case '1.0' :
  94 + $result = $this->xml->schemaValidate(XMLPATH.'VOTable-1.0.xsd');
  95 + default :
  96 + $result = $this->xml->schemaValidate(XMLPATH.'VOTable-1.1.xsd');
  97 + }
  98 +
  99 + if (DEBUG_MODE)
  100 + {
  101 + $errors = libxml_get_errors();
  102 +
  103 + foreach ($errors as $error)
  104 + {
  105 + $msg = '';
  106 +
  107 + switch ($error->level)
  108 + {
  109 + case LIBXML_ERR_WARNING:
  110 + $msg .= ("WARNING ".$error->code.": ");
  111 + break;
  112 + case LIBXML_ERR_ERROR:
  113 + $msg .= ("ERROR ".$error->code.": ");
  114 + break;
  115 + case LIBXML_ERR_FATAL:
  116 + $msg .= ("FATAL ".$error->code.": ");
  117 + break;
  118 + }
  119 + $msg .= ($error->message." - In line : ".$error->line." - Of file : ".$error->file."\n");
  120 +
  121 + $this->addLog($msg);
  122 + }
  123 +
  124 + libxml_use_internal_errors(false);
  125 + }
  126 +
  127 + return $result;
  128 + }
  129 +
  130 + protected function queryResource()
  131 + {
  132 + return "//x:RESOURCE";
  133 + }
  134 +
  135 + protected function queryResourceInfo()
  136 + {
  137 + return $this->queryResource()."/x:INFO";
  138 + }
  139 +
  140 + protected function queryTable()
  141 + {
  142 + return $this->queryResource()."/x:TABLE";
  143 + }
  144 +
  145 + protected function queryDescription()
  146 + {
  147 + return $this->queryTable()."/x:DESCRIPTION";
  148 + }
  149 +
  150 + protected function queryFields()
  151 + {
  152 + return $this->queryTable()."/x:FIELD";
  153 + }
  154 +
  155 + protected function queryField($field_id)
  156 + {
  157 + return $this->queryFields()."[@ID='".$field_id."']";
  158 + }
  159 +
  160 + protected function queryFieldByName($field_id)
  161 + {
  162 + return $this->queryFields()."[@name='".$field_id."']";
  163 + }
  164 + protected function queryFieldDescription($field_id)
  165 + {
  166 + return $this->queryField($field_id)."/x:DESCRIPTION";
  167 + }
  168 +
  169 + protected function queryData()
  170 + {
  171 + return $this->queryTable()."/x:DATA";
  172 + }
  173 +
  174 + protected function queryTableData()
  175 + {
  176 + return $this->queryData()."/x:TABLEDATA";
  177 + }
  178 +
  179 + protected function queryTR()
  180 + {
  181 + return $this->queryTableData()."/x:TR";
  182 + }
168 183  
169 184 protected function queryBinaryData() {
170 185 return $this->queryData()."/x:BINARY";
... ... @@ -175,448 +190,532 @@ class VOTableMgr {
175 190 }
176 191  
177 192  
178   - public function getVersion()
179   - {
180   - if (!$this->xml)
181   - return '';
182   - $root = $this->xml->documentElement;
  193 + public function getVersion()
  194 + {
  195 + if (!$this->xml)
  196 + return '';
  197 + $root = $this->xml->documentElement;
183 198  
184   - return $root->getAttribute('version');
185   - }
  199 + return $root->getAttribute('version');
  200 + }
186 201  
187   - public function getDescription()
188   - {
189   - if (!$this->xp)
190   - return '';
  202 + public function getDescription()
  203 + {
  204 + if (!$this->xp)
  205 + return '';
191 206  
192   - $desc = $this->xp->query($this->queryDescription());
  207 + $desc = $this->xp->query($this->queryDescription());
193 208  
194   - if ($desc->length < 1)
195   - return '';
  209 + if ($desc->length < 1)
  210 + return '';
196 211  
197   - return $desc->item(0)->nodeValue;
198   - }
  212 + return $desc->item(0)->nodeValue;
  213 + }
  214 +
  215 + private function get_block_size($data_type) {
  216 + switch($data_type) {
  217 + case 'boolean':
  218 + case 'unsignedByte':
  219 + case 'char':
  220 + $block_size = 1;
  221 + break;
  222 + case 'unicodeChar':
  223 + case 'short':
  224 + $block_size = 2;
  225 + break;
  226 + case 'int':
  227 + case 'float':
  228 + $block_size = 4;
  229 + break;
  230 + case 'long':
  231 + case 'double':
  232 + case 'float_complex':
  233 + $block_size = 8;
  234 + break;
  235 + case 'double_complex':
  236 + $block_size = 8;
  237 + break;
  238 + default:
  239 + $block_size = 0;
  240 + break;
  241 + }
  242 + return $block_size;
  243 + }
  244 +
  245 + private function get_row_size($field_node) {
  246 + $datatype = $field_node->getAttribute("datatype");
  247 + $block_size = $this->get_block_size($datatype);
  248 + if($field_node->getAttribute("arraysize") == NULL) {
  249 + $array_size = $block_size;
  250 + } else if("*" == $field_node->getAttribute("arraysize")) {
  251 + // echo "substr: " . json_encode(substr($this->stream, $this->c, 4)) . "\n";
  252 + $array_size = unpack("Ns", substr($this->stream, $this->c, 4))["s"] * $block_size;
  253 + // echo "array_size: $array_size\n";
  254 + $this->c+=4;
  255 + } else {
  256 + $array_size = (int)($field_node->getAttribute("arraysize")) * $block_size;
  257 + }
  258 + return $array_size;
  259 + }
199 260  
200 261 /** Get the VOTable stream content.*/
201   - // TODO: faire une fonction générique avec le curseur qui se déplace et tout et qui renvoie un dictionnaire
202   - public function getStream() {
203   - $fields = array();
204   - $stream = $this->xp->query($this->queryStream())->item(0)->textContent;
205   - $ar = unpack("C*", base64_decode($stream));
206   - $c = 0; // cursor
207   - foreach ($this->xp->query($this->queryFields()) as $field) {
208   - $datatype = $field->getAttribute("datatype");
209   - $id = $field->getAttribute("ID"); // column name
210   - switch ($datatype) {
211   - case 'char':
212   - $str_length = ($ar[1]<<24) + ($ar[2]<<16) + ($ar[3]<<8) + $ar[4];
213   - $res = "";
214   - for($i=0 ; $i<$str_length ; $i++) {
215   - $res = $res . chr($ar[$i+5]);
216   - }
217   - break;
218   - case 'int':
219   - $res = ($ar[1]<<24) + ($ar[2]<<16) + ($ar[3]<<8) + $ar[4];
220   - break;
221   - case 'double':
222   - $this->addLog("Parsing double");
223   - $res = "Float parsing not implemented yet.";//($ar[1]<<24) + ($ar[2]<<16) + ($ar[3]<<8) + $ar[4];
224   - break;
225   -
226   - default:
227   - break;
  262 + public function parseStream() {
  263 + $data = Array();
  264 + $fields = $this->xp->query($this->queryFields());
  265 + $nb_columns = $fields->length;
  266 + $row = Array();
  267 + $n_value = 0; // index of current value
  268 + $this->c = 0; // initialize cursor position.
  269 + $query_stream = $this->xp->query($this->queryStream())->item(0);
  270 + if($query_stream == NULL)
  271 + return NULL;
  272 + $this->stream = base64_decode($query_stream->textContent);
  273 + // echo "stream: " . json_encode($this->stream) . "\n";
  274 + $stream_len = strlen($this->stream);
  275 + if($stream_len == 0)
  276 + return NULL;
  277 + while($this->c < strlen($this->stream)) {
  278 + $col_id = $n_value % $nb_columns;
  279 + $field_node = $fields[$col_id];
  280 +
  281 + // echo "c=$this->c, n_value=$n_value, nb_columns=$nb_columns, col_id=$col_id, column_name=" . $field_node->getAttribute("ID") . "\n";
  282 +
  283 + if($col_id == 0) {
  284 + $row = Array();
  285 + }
  286 + $row[$field_node->getAttribute("ID")] = $this->process_datablock($field_node);
  287 + if($col_id == $nb_columns-1) {
  288 + array_push($data, $row);
228 289 }
229   - $this->addLog($id . "=" . $res);
230   - $fields[$id] = $res;
  290 + $n_value+=1;
  291 + // echo "Char pos: $this->c\n";
231 292 }
  293 + return $data;
  294 + }
232 295  
233   - return $fields;
234   - // return ($ar[1]<<24) + ($ar[2]<<16) + ($ar[3]<<8) + $ar[4];
  296 + private function process_datablock($field_node) {
  297 + $data_type = $field_node->getAttribute("datatype");
  298 + $row_size = $this->get_row_size($field_node);
  299 + // echo "datatype: " . $field_node->getAttribute("datatype") . "\n";
  300 + // echo "Row size: $row_size\n";
  301 + switch ($data_type) {
  302 + case 'boolean':
  303 + case 'unsignedByte':
  304 + $res = $this->stream[$this->c] == "T" || $this->stream[$this->c] == "t" || $this->stream[$this->c] == "1";
  305 + break;
  306 + case 'char':
  307 + case 'unicodeChar':
  308 + $res = $row_size !=0 ? substr($this->stream, $this->c, $row_size) : NULL;
  309 + break;
  310 + case 'short':
  311 + $res = unpack("ss", substr($this->stream, $this->c, 2))["s"];
  312 + break;
  313 + case 'int':
  314 + $res = unpack("Ns", substr($this->stream, $this->c, 4))["s"];
  315 + break;
  316 + case 'long':
  317 + $res = unpack("Js", substr($this->stream, $this->c, 8))["s"]; // /!\ J -> PHP 5.6 only
  318 + break;
  319 + case 'float':
  320 + $res = unpack("fs", substr($this->stream, $this->c, 4))["s"];
  321 + break;
  322 + case 'double':
  323 + $res = unpack("ds", substr($this->stream, $this->c, 8))["s"];
  324 + break;
  325 + default:
  326 + $res = NULL;
  327 + $this->addLog("Unknown character: $data_type");
  328 + break;
  329 + }
  330 + $this->c+=$row_size;
  331 + // echo $field_node->getAttribute("ID") . "($data_type $row_size) = " . json_encode($res) . "\n";
  332 + return $res;
235 333 }
236 334  
237   - public function getFirstTR()
238   - {
239   - if (!$this->xp)
240   - return NULL;
241 335  
242   - /*$trs = $this->xp->query($this->queryTR());
  336 + public function getFirstTR()
  337 + {
  338 + if (!$this->xp)
  339 + return NULL;
243 340  
244   - if ($trs->length < 1)
245   - return NULL;
  341 + /*$trs = $this->xp->query($this->queryTR());
246 342  
247   - return $trs->item(0);*/
  343 + if ($trs->length < 1)
  344 + return NULL;
248 345  
249   - $tabledatas = $this->xp->query($this->queryTableData());
250   - if ($tabledatas->length < 1)
251   - return NULL;
  346 + return $trs->item(0);*/
252 347  
253   - $tabledata = $tabledatas->item(0);
  348 + $tabledatas = $this->xp->query($this->queryTableData());
  349 + if ($tabledatas->length < 1)
  350 + return NULL;
254 351  
255   - $node = $tabledata->firstChild;
  352 + $tabledata = $tabledatas->item(0);
256 353  
257   - while($node && ($node->nodeType != 1) && ($node->nodeName != "TR"))
258   - $node = $node->nextSibling;
  354 + $node = $tabledata->firstChild;
259 355  
260   - return $node;
261   - }
  356 + while($node && ($node->nodeType != 1) && ($node->nodeName != "TR"))
  357 + $node = $node->nextSibling;
262 358  
263   - public function getNextTR($tr)
264   - {
265   - if (!$this->xp)
266   - return NULL;
  359 + return $node;
  360 + }
  361 +
  362 + public function getNextTR($tr)
  363 + {
  364 + if (!$this->xp)
  365 + return NULL;
267 366  
268   - while($tr->nextSibling && ($tr->nextSibling->nodeType != 1) && ($node->nodeName != "TR"))
269   - $tr = $tr->nextSibling;
  367 + while($tr->nextSibling && ($tr->nextSibling->nodeType != 1) && ($node->nodeName != "TR"))
  368 + $tr = $tr->nextSibling;
270 369 return $tr->nextSibling;
271   - }
  370 + }
272 371  
273   - public function getTDValueByFieldIndex($tr,$field_index)
274   - {
275   - if (!$this->xp)
276   - return NULL;
  372 + public function getTDValueByFieldIndex($tr,$field_index)
  373 + {
  374 + if (!$this->xp)
  375 + return NULL;
277 376  
278   - $tds = $tr->getElementsByTagName("TD");
  377 + $tds = $tr->getElementsByTagName("TD");
279 378  
280   - if (($tds->length < 1) || ($field_index >= $tds->length))
281   - return NULL;
  379 + if (($tds->length < 1) || ($field_index >= $tds->length))
  380 + return NULL;
282 381  
283   - return $tds->item($field_index)->nodeValue;
284   - }
  382 + return $tds->item($field_index)->nodeValue;
  383 + }
285 384  
286   - protected function isTimeField($field)
287   - {
288   - if (!$this->xp)
289   - return FALSE;
  385 + protected function isTimeField($field)
  386 + {
  387 + if (!$this->xp)
  388 + return FALSE;
290 389  
291   - return (($field->getAttribute("ucd") == "time.epoch") && ($field->getAttribute("xtype") == "dateTime"));
292   - }
  390 + return (($field->getAttribute("ucd") == "time.epoch") && ($field->getAttribute("xtype") == "dateTime"));
  391 + }
293 392  
294   - public function getTimeFieldIndex()
295   - {
296   - if (!$this->xp)
297   - return -1;
  393 + public function getTimeFieldIndex()
  394 + {
  395 + if (!$this->xp)
  396 + return -1;
298 397  
299   - $fields = $this->xp->query($this->queryFields());
  398 + $fields = $this->xp->query($this->queryFields());
300 399  
301   - if ($fields->length < 1)
302   - return -1;
  400 + if ($fields->length < 1)
  401 + return -1;
303 402  
304   - for ($i = 0; $i < $fields->length; $i++)
305   - if ($this->isTimeField($fields->item($i)))
306   - return $i;
  403 + for ($i = 0; $i < $fields->length; $i++)
  404 + if ($this->isTimeField($fields->item($i)))
  405 + return $i;
307 406  
308   - return -1;
309   - }
  407 + return -1;
  408 + }
310 409  
311   - protected function getFieldByID($field_id)
312   - {
313   - if (!$this->xp)
314   - return NULL;
  410 + protected function getFieldByID($field_id)
  411 + {
  412 + if (!$this->xp)
  413 + return NULL;
315 414  
316   - $fields = $this->xp->query($this->queryFields());
  415 + $fields = $this->xp->query($this->queryFields());
317 416  
318   - if ($fields->length < 1)
319   - return NULL;
  417 + if ($fields->length < 1)
  418 + return NULL;
320 419  
321   - foreach ($fields as $field)
322   - if ($field->getAttribute("ID") == $field_id)
323   - return $field;
  420 + foreach ($fields as $field)
  421 + if ($field->getAttribute("ID") == $field_id)
  422 + return $field;
324 423  
325   - return NULL;
326   - }
  424 + return NULL;
  425 + }
327 426  
328   - protected function getFieldByName($field_id)
329   - {
330   - if (!$this->xp)
331   - return NULL;
  427 + protected function getFieldByName($field_id)
  428 + {
  429 + if (!$this->xp)
  430 + return NULL;
332 431  
333   - $fields = $this->xp->query($this->queryFieldByName($field_id));
  432 + $fields = $this->xp->query($this->queryFieldByName($field_id));
334 433  
335   - if ($fields->length < 1)
336   - return NULL;
  434 + if ($fields->length < 1)
  435 + return NULL;
337 436  
338   - foreach ($fields as $field)
339   - if ($field->getAttribute("name") == $field_id)
340   - return $field;
  437 + foreach ($fields as $field)
  438 + if ($field->getAttribute("name") == $field_id)
  439 + return $field;
341 440  
342   - return NULL;
343   - }
  441 + return NULL;
  442 + }
344 443  
345   - protected function checkIDAttribute(){
  444 + protected function checkIDAttribute(){
346 445  
347   - $fields = $this->xml->getElementsByTagName('FIELD');
348   - $i = 0;
349   - foreach ($fields as $field){
  446 + $fields = $this->xml->getElementsByTagName('FIELD');
  447 + $i = 0;
  448 + foreach ($fields as $field){
350 449 $i++;
351 450 if (!$field->hasAttribute("ID")){
352   - $field->setAttribute("ID", "col".$i);
353   - }
354   - }
355   - $this->xml->saveXML();
356   -
357   - }
358   -
359   - public function getFieldIndexByID($field_id)
360   - {
361   - if (!$this->xp)
362   - return -1;
363   -
364   - $fields = $this->xp->query($this->queryFields());
365   -
366   - if ($fields->length < 1)
367   - return -1;
368   -
369   - for ($i = 0; $i < $fields->length; $i++)
370   - if ($fields->item($i)->getAttribute("ID") == $field_id)
371   - return $i;
372   -
373   - return -1;
374   - }
375   -
376   - public function getStartStop()
377   - {
378   - if (!$this->xp)
379   - return '0 0';
380   -
381   - $timeIndex = $this->getTimeFieldIndex();
382   - if ($timeIndex < 0)
383   - return '0 0';
384   -
385   - $tr = $this->getFirstTR();
386   -
387   - if (!$tr)
388   - return '0 0';
389   -
390   - $start = $this->getTDValueByFieldIndex($tr,$timeIndex);
391   -
392   - $stop = $start;
393   - while ($tr)
394   - {
395   - $stop = $this->getTDValueByFieldIndex($tr,$timeIndex);
396   - $tr = $this->getNextTR($tr);
397   - }
398   -
399   - if (!$start)
400   - $start = 0;
401   - else
402   - $start = strtotime($start);
403   -
404   - if (!$stop)
405   - $stop = 0;
406   - else
407   - $stop = strtotime($stop);
408   -
409   - return $start." ".$stop;
410   - }
411   -
412   - public function getFieldInfoByID($field_id)
413   - {
414   - if (!$this->xp)
415   - return array("id" => $field_id,
416   - "error" => "No file loaded");
417   -
418   - $field = $this->getFieldByID($field_id);
419   -
420   - if (!$field)
421   - $field = $this->getFieldByName($field_id);
422   -
423   - if (!$field)
424   - return array("id" => $field_id,
425   - "error" => "This field doesn't exist");
426   - return $this->getFieldInfo($field);
427   - }
428   -
429   -
430   - public function getFieldInfo($field)
431   - {
432   - if (!$this->xp)
433   - return array("id" => $field_id,
434   - "error" => "No file loaded");
435   - $description = '';
436   - $desc = $field->getElementsByTagName("DESCRIPTION");
437   - if ($desc->length >= 1)
438   - $description = $desc->item(0)->nodeValue;
439   -
440   - $size = $field->getAttribute("arraysize");
441   - if ($size == '')
442   - $size = 1;
443   - else
444   - $size = intval($size);
445   -
446   - switch ($field->getAttribute("datatype"))
447   - {
448   - case "short" :
449   - $type = "SHORT";
450   - break;
451   - case "int" :
452   - $type = "INTEGER";
453   - break;
454   - case "long" :
455   - case "double" :
456   - $type = "DOUBLE";
457   - break;
458   - default :
459   - $type = "FLOAT";
460   - }
  451 + $field->setAttribute("ID", "col".$i);
  452 + }
  453 + }
  454 + $this->xml->saveXML();
  455 +
  456 + }
  457 +
  458 + public function getFieldIndexByID($field_id)
  459 + {
  460 + if (!$this->xp)
  461 + return -1;
  462 +
  463 + $fields = $this->xp->query($this->queryFields());
  464 +
  465 + if ($fields->length < 1)
  466 + return -1;
  467 +
  468 + for ($i = 0; $i < $fields->length; $i++)
  469 + if ($fields->item($i)->getAttribute("ID") == $field_id)
  470 + return $i;
  471 +
  472 + return -1;
  473 + }
  474 +
  475 + public function getStartStop()
  476 + {
  477 + if (!$this->xp)
  478 + return '0 0';
  479 +
  480 + $timeIndex = $this->getTimeFieldIndex();
  481 + if ($timeIndex < 0)
  482 + return '0 0';
  483 +
  484 + $tr = $this->getFirstTR();
  485 +
  486 + if (!$tr)
  487 + return '0 0';
  488 +
  489 + $start = $this->getTDValueByFieldIndex($tr,$timeIndex);
  490 +
  491 + $stop = $start;
  492 + while ($tr)
  493 + {
  494 + $stop = $this->getTDValueByFieldIndex($tr,$timeIndex);
  495 + $tr = $this->getNextTR($tr);
  496 + }
  497 +
  498 + if (!$start)
  499 + $start = 0;
  500 + else
  501 + $start = strtotime($start);
  502 +
  503 + if (!$stop)
  504 + $stop = 0;
  505 + else
  506 + $stop = strtotime($stop);
  507 +
  508 + return $start." ".$stop;
  509 + }
  510 +
  511 + public function getFieldInfoByID($field_id)
  512 + {
  513 + if (!$this->xp)
  514 + return array("id" => $field_id,
  515 + "error" => "No file loaded");
  516 +
  517 + $field = $this->getFieldByID($field_id);
  518 +
  519 + if (!$field)
  520 + $field = $this->getFieldByName($field_id);
  521 +
  522 + if (!$field)
  523 + return array("id" => $field_id,
  524 + "error" => "This field doesn't exist");
  525 + return $this->getFieldInfo($field);
  526 + }
  527 +
  528 +
  529 + public function getFieldInfo($field)
  530 + {
  531 + if (!$this->xp)
  532 + return array("id" => $field_id,
  533 + "error" => "No file loaded");
  534 + $description = '';
  535 + $desc = $field->getElementsByTagName("DESCRIPTION");
  536 + if ($desc->length >= 1)
  537 + $description = $desc->item(0)->nodeValue;
  538 +
  539 + $size = $field->getAttribute("arraysize");
  540 + if ($size == '')
  541 + $size = 1;
  542 + else
  543 + $size = intval($size);
  544 +
  545 + switch ($field->getAttribute("datatype"))
  546 + {
  547 + case "short" :
  548 + $type = "SHORT";
  549 + break;
  550 + case "int" :
  551 + $type = "INTEGER";
  552 + break;
  553 + case "long" :
  554 + case "double" :
  555 + $type = "DOUBLE";
  556 + break;
  557 + default :
  558 + $type = "FLOAT";
  559 + }
461 560 if (!$field->getAttribute("ID"))
462   - $id = "col".$n;
  561 + $id = "col".$n;
463 562 else $id = $field->getAttribute("ID");
464 563  
465   - return array("id" => $field->getAttribute("ID"),
466   - "type" => $type,
467   - "name" => $field->getAttribute("name"),
468   - "ucd" => $field->getAttribute("ucd"),
469   - "unit" => $field->getAttribute("unit"),
470   - "size" => $size,
471   - "description" => $description
472   - );
473   - }
474   -
475   - public function getFieldsInfo()
476   - {
477   - if (!$this->xp)
478   - return array("error" => "No file loaded");
  564 + return array("id" => $field->getAttribute("ID"),
  565 + "type" => $type,
  566 + "name" => $field->getAttribute("name"),
  567 + "ucd" => $field->getAttribute("ucd"),
  568 + "unit" => $field->getAttribute("unit"),
  569 + "size" => $size,
  570 + "description" => $description
  571 + );
  572 + }
479 573  
480   - $fields_info = array();
  574 + public function getFieldsInfo()
  575 + {
  576 + if (!$this->xp)
  577 + return array("error" => "No file loaded");
481 578  
482   - $fields = $this->xp->query($this->queryFields());
  579 + $fields_info = array();
483 580  
484   - if ($fields->length < 1)
485   - return $fields_info;
  581 + $fields = $this->xp->query($this->queryFields());
486 582  
487   - foreach ($fields as $field)
488   - {
489   - if ($this->isTimeField($field))
490   - continue;
  583 + if ($fields->length < 1)
  584 + return $fields_info;
491 585  
492   - array_push($fields_info,$this->getFieldInfo($field));
493   - }
  586 + foreach ($fields as $field)
  587 + {
  588 + if ($this->isTimeField($field))
  589 + continue;
494 590  
495   - return $fields_info;
496   - }
  591 + array_push($fields_info,$this->getFieldInfo($field));
  592 + }
497 593  
498   - public function getSamplings()
499   - {
500   - if (!$this->xp)
501   - return array("minSampling" => 0,
502   - "maxSampling" => 0);
  594 + return $fields_info;
  595 + }
503 596  
504   - $timeIndex = $this->getTimeFieldIndex();
505   - if ($timeIndex < 0)
506   - return array("minSampling" => 0,
507   - "maxSampling" => 0);
  597 + public function getSamplings()
  598 + {
  599 + if (!$this->xp)
  600 + return array("minSampling" => 0,
  601 + "maxSampling" => 0);
508 602  
509   - $tr = $this->getFirstTR();
  603 + $timeIndex = $this->getTimeFieldIndex();
  604 + if ($timeIndex < 0)
  605 + return array("minSampling" => 0,
  606 + "maxSampling" => 0);
510 607  
511   - if (!$tr)
512   - return array("minSampling" => 0,
513   - "maxSampling" => 0);
  608 + $tr = $this->getFirstTR();
514 609  
515   - $prevTime = 0;
516   - while ($tr)
517   - {
518   - $time = $this->getTDValueByFieldIndex($tr,$timeIndex);
  610 + if (!$tr)
  611 + return array("minSampling" => 0,
  612 + "maxSampling" => 0);
519 613  
520   - if ($time)
521   - {
522   - $time = strtotime($time);
523   - if (($prevTime > 0) && ($time-$prevTime > 0))
524   - $deltaT[$time-$prevTime]++;
525   - $prevTime = $time;
526   - }
  614 + $prevTime = 0;
  615 + while ($tr)
  616 + {
  617 + $time = $this->getTDValueByFieldIndex($tr,$timeIndex);
  618 +
  619 + if ($time)
  620 + {
  621 + $time = strtotime($time);
  622 + if (($prevTime > 0) && ($time-$prevTime > 0))
  623 + $deltaT[$time-$prevTime]++;
  624 + $prevTime = $time;
  625 + }
527 626  
528   - $tr = $this->getNextTR($tr);
529   - }
  627 + $tr = $this->getNextTR($tr);
  628 + }
530 629  
531   - $minSampling = +1.e31;
532   - $maxSampling = 0.0;
  630 + $minSampling = +1.e31;
  631 + $maxSampling = 0.0;
533 632  
534   - foreach ($deltaT as $key => $value)
535   - {
  633 + foreach ($deltaT as $key => $value)
  634 + {
536 635  
537   - if ($value/count($deltaT) < 0.10)
538   - continue;
  636 + if ($value/count($deltaT) < 0.10)
  637 + continue;
539 638  
540   - if ($key < $minSampling) $minSampling = $key;
541   - if ($key > $maxSampling) $maxSampling = $key;
542   - }
  639 + if ($key < $minSampling) $minSampling = $key;
  640 + if ($key > $maxSampling) $maxSampling = $key;
  641 + }
543 642  
544   - return array("minSampling" => $minSampling,
545   - "maxSampling" => $maxSampling);
546   - }
  643 + return array("minSampling" => $minSampling,
  644 + "maxSampling" => $maxSampling);
  645 + }
547 646  
548   - public function args2vector($file, $paramID){
  647 + public function args2vector($file, $paramID){
549 648  
550   - $argsArr = explode('_', $paramID);
  649 + $argsArr = explode('_', $paramID);
551 650  
552   - $dom = new DOMDocument();
553   - $dom->load($file);
554   - $fields = $dom->getElementsByTagName('FIELD');
555   - $table = $dom->getElementsByTagName('TABLE')->item(0);
556   - $i=0;
557   - foreach ($fields as $field){
558   - if ($field->getAttribute('name') == $argsArr[0]){
  651 + $dom = new DOMDocument();
  652 + $dom->load($file);
  653 + $fields = $dom->getElementsByTagName('FIELD');
  654 + $table = $dom->getElementsByTagName('TABLE')->item(0);
  655 + $i=0;
  656 + foreach ($fields as $field){
  657 + if ($field->getAttribute('name') == $argsArr[0]){
559 658 $unit = $field->getAttribute('unit');
560   - $ucd = $field->getAttribute('ucd');
561   - $datatype = $field->getAttribute('datatype');
  659 + $ucd = $field->getAttribute('ucd');
  660 + $datatype = $field->getAttribute('datatype');
562 661 $firstTD = $i;
563   - }
564   - $i++;
565   - }
566   - if ($firstTD > 0){
567   - $table->removeChild($fields->item($firstTD + 2));
568   - $table->removeChild($fields->item($firstTD + 1));
569   - $table->removeChild($fields->item($firstTD));
570   -
571   - $i = 0;
572   - foreach ($fields as $field){
  662 + }
  663 + $i++;
  664 + }
  665 + if ($firstTD > 0){
  666 + $table->removeChild($fields->item($firstTD + 2));
  667 + $table->removeChild($fields->item($firstTD + 1));
  668 + $table->removeChild($fields->item($firstTD));
  669 +
  670 + $i = 0;
  671 + foreach ($fields as $field){
573 672 $i++;
574 673 if (strpos($field->getAttribute('ID'),'col') !== FALSE){
575   - $field->setAttribute('ID', 'col'.$i);
576   - $dom->saveXML();
577   - }
578   - }
579   -
580   - $group = $dom->createElement('GROUP');
581   - $group->appendChild(new DOMAttr('ID', 'info_'.$paramID));
582   - $table->appendChild($group);
583   -
584   - $param = $dom->createElement('PARAM');
585   - $param->appendChild(new DOMAttr('ID', 'components_'.$paramID));
586   - $param->appendChild(new DOMAttr('name', 'components_'.$paramID));
587   - $param->appendChild(new DOMAttr('datatype', 'char'));
588   - $param->appendChild(new DOMAttr('arraysize', '*'));
589   - $param->appendChild(new DOMAttr('value', $argsArr[0].' '.$argsArr[1].' '.$argsArr[2] ));
590   - $group->appendChild($param);
591   -
592   - $new_field = $dom->createElement('FIELD');
593   - $new_field->appendChild(new DOMAttr('ID', $paramID));
594   - $new_field->appendChild(new DOMAttr('name', $paramID));
595   - $new_field->appendChild(new DOMAttr('datatype', $datatype));
596   - $new_field->appendChild(new DOMAttr('arraysize', '3'));
597   - $new_field->appendChild(new DOMAttr('unit', $unit));
598   - $new_field->appendChild(new DOMAttr('ucd', $ucd));
599   - $new_field->appendChild(new DOMAttr('ref', 'info_'.$paramID));
600   - $table->appendChild($new_field);
601   -
602   - $trs = $dom->getElementsByTagName('TR');
603   - foreach($trs as $tr){
604   - $tds = $tr->getElementsByTagName('TD');
605   - $value = trim($tds->item($firstTD)->nodeValue).' '.trim($tds->item($firstTD + 1)->nodeValue).' '.trim($tds->item($firstTD + 2)->nodeValue);
606   - $toRemote = $tds->item($firstTD);
607   - $tr->removeChild($toRemote);
608   - $toRemote = $tds->item($firstTD);
609   - $tr->removeChild($toRemote);
610   - $toRemote = $tds->item($firstTD);
611   - $tr->removeChild($toRemote);
612   -
613   - $td = $dom->createElement('TD', $value);
614   - $tr->appendChild($td);
615   - }
616   -
617   - $dom->save($file);
618   - }
619   - }
  674 + $field->setAttribute('ID', 'col'.$i);
  675 + $dom->saveXML();
  676 + }
  677 + }
  678 +
  679 + $group = $dom->createElement('GROUP');
  680 + $group->appendChild(new DOMAttr('ID', 'info_'.$paramID));
  681 + $table->appendChild($group);
  682 +
  683 + $param = $dom->createElement('PARAM');
  684 + $param->appendChild(new DOMAttr('ID', 'components_'.$paramID));
  685 + $param->appendChild(new DOMAttr('name', 'components_'.$paramID));
  686 + $param->appendChild(new DOMAttr('datatype', 'char'));
  687 + $param->appendChild(new DOMAttr('arraysize', '*'));
  688 + $param->appendChild(new DOMAttr('value', $argsArr[0].' '.$argsArr[1].' '.$argsArr[2] ));
  689 + $group->appendChild($param);
  690 +
  691 + $new_field = $dom->createElement('FIELD');
  692 + $new_field->appendChild(new DOMAttr('ID', $paramID));
  693 + $new_field->appendChild(new DOMAttr('name', $paramID));
  694 + $new_field->appendChild(new DOMAttr('datatype', $datatype));
  695 + $new_field->appendChild(new DOMAttr('arraysize', '3'));
  696 + $new_field->appendChild(new DOMAttr('unit', $unit));
  697 + $new_field->appendChild(new DOMAttr('ucd', $ucd));
  698 + $new_field->appendChild(new DOMAttr('ref', 'info_'.$paramID));
  699 + $table->appendChild($new_field);
  700 +
  701 + $trs = $dom->getElementsByTagName('TR');
  702 + foreach($trs as $tr){
  703 + $tds = $tr->getElementsByTagName('TD');
  704 + $value = trim($tds->item($firstTD)->nodeValue).' '.trim($tds->item($firstTD + 1)->nodeValue).' '.trim($tds->item($firstTD + 2)->nodeValue);
  705 + $toRemote = $tds->item($firstTD);
  706 + $tr->removeChild($toRemote);
  707 + $toRemote = $tds->item($firstTD);
  708 + $tr->removeChild($toRemote);
  709 + $toRemote = $tds->item($firstTD);
  710 + $tr->removeChild($toRemote);
  711 +
  712 + $td = $dom->createElement('TD', $value);
  713 + $tr->appendChild($td);
  714 + }
  715 +
  716 + $dom->save($file);
  717 + }
  718 + }
620 719  
621 720 }
622 721  
... ...