Blame view

update_amda/mvTemplates.php 2.01 KB
4c77b9b1   Elena.Budnik   final update
1
2
3
<?php

     $NEWMETA = getenv('NEWMETA');
4c77b9b1   Elena.Budnik   final update
4
     $AMDAINTERNALDIR = getenv('AMDAINTERNALDIR');
99ae8744   Benjamin Renard   Use config variab...
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
     $PARAMTEMPLATEDIR = getenv('ParamTemplate');

     if (empty($NEWMETA)) {
         echo "[ERROR] check if NEWMETA env varibale is defined".PHP_EOL;
         exit(1);
     }

     if (empty($AMDAINTERNALDIR)) {
         echo "[ERROR] check if AMDAINTERNALDIR env varibale is defined".PHP_EOL;
         exit(1);
     }

     if (empty($PARAMTEMPLATEDIR)) {
         echo "[ERROR] check if PARAMTEMPLATEDIR env varibale is defined".PHP_EOL;
         exit(1);
     }
4c77b9b1   Elena.Budnik   final update
21
22
23
24
25
     
     $templateXml = new DomDocument("1.0");
     $templateXml->load($AMDAINTERNALDIR."/ParamTemplateList.xml");
     $paramTemplates =  $templateXml->getElementsByTagName('paramTemplate');
     
99ae8744   Benjamin Renard   Use config variab...
26
27
     if (!is_dir($PARAMTEMPLATEDIR)) 
		mkdir("$PARAMTEMPLATEDIR");
4c77b9b1   Elena.Budnik   final update
28
29
30
31
32
33
34
35
     
     foreach ($paramTemplates as $template) {    
       $paramId = $template->getAttribute('paramId');
       $fileName = $template->getAttribute('fileName');
       // for spase-list params
       if (file_exists("$NEWMETA/final/$paramId.xml")) {
		echo "Template  ".$paramId.PHP_EOL;
		$from = "$NEWMETA/final/$paramId.xml";
99ae8744   Benjamin Renard   Use config variab...
36
		$to = "$PARAMTEMPLATEDIR/$fileName.xml";	
4c77b9b1   Elena.Budnik   final update
37
38
39
40
41
42
43
44
		
	  	copy($from, $to);
		unlink("$NEWMETA/final/$paramId.xml");
	}
	//  for internal params
	if (file_exists("$AMDAINTERNALDIR/INTERNAL_PARAM_DEF/$paramId.xml")) {
		echo "Template  ".$paramId.PHP_EOL;
		$from = "$AMDAINTERNALDIR/INTERNAL_PARAM_DEF/$paramId.xml";
99ae8744   Benjamin Renard   Use config variab...
45
		$to = "$PARAMTEMPLATEDIR/$fileName.xml";	
4c77b9b1   Elena.Budnik   final update
46
47
	  	copy($from,$to);					
	}
9dbe0268   Benjamin Renard   Add predefined te...
48
49
50
51
52
53
54
55
56
57
58
59
60
	// for predefined params
	$predefinedNodes = $template->getElementsByTagName('predefined');
	if ($predefinedNodes->length > 0) {
		$paramPredefinedNodes = $predefinedNodes->item(0)->getElementsByTagName('param');
		if ($paramPredefinedNodes->length > 0) {
			if (file_exists("$AMDAINTERNALDIR/PARAM_DEF/$paramId.xml")) {
				echo "Template  ".$paramId.PHP_EOL;
				$from = "$AMDAINTERNALDIR/PARAM_DEF/$paramId.xml";
				$to = "$PARAMTEMPLATEDIR/$fileName.xml";
				copy($from,$to);
			}
		}
	}
4c77b9b1   Elena.Budnik   final update
61
     }     
99ae8744   Benjamin Renard   Use config variab...
62
?>