Blame view

update_amda/preprocessInfo.php 1.2 KB
189c51a1   Elena.Budnik   preprocessInfo
1
2
3
4
5
6
<?php
/**
*
*/
	$id = $argv[1];
	$NEWMETA = getenv('NEWMETA');
99ae8744   Benjamin Renard   Use config variab...
7
8
9
10
11

	if ($NEWMETA == "") {
		echo "[ERROR] check if NEWMETA env varibale is defined".PHP_EOL;
		exit(1);
	}
189c51a1   Elena.Budnik   preprocessInfo
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
			
	$infoXml = new DomDocument("1.0");	 	
	$infoXml->load($NEWMETA."final/$id.xml");
		
	$infoBlock =  $infoXml->getElementsByTagName('info')->item(0);
	$components = $infoBlock->getElementsByTagName('components')->item(0);
	
	if ($components->nodeValue != "") {
	
		echo "COMP ".$components->nodeValue.PHP_EOL;
		$comps = explode(',',$components->nodeValue);
		
		if (count($comps) == 3) { 
			$argsXml = new DomDocument("1.0");
			$root = $argsXml->createElement('paraminfo');
			$root->setAttribute('xml:id',$id);
			$dim = $argsXml->createElement('dimensions');
			$dim->setAttribute('dim_1',3);
			$dim->setAttribute('dim_2',1);
			$root->appendChild($dim);
			$cmps = $argsXml->createElement('components');
			$root->appendChild($cmps);
			for ($i = 0; $i < count($comps); $i++) {			
				$cmp = $argsXml->createElement('component');
				$cmp->setAttribute('index_1',$i);
				$cmp->setAttribute('name',$comps[$i]);
				$cmps->appendChild($cmp);
			}	
			
			$argsXml->appendChild($root);
			$argsXml->save($NEWMETA."ParamInfo/info_$id.xml");
		}
	}   
99ae8744   Benjamin Renard   Use config variab...
45
?>