'', 'type' => '', 'mission' => '', 'units' => '','time_resolution' => '', 'fillval' => '', 'coordinate_system' => '', 'label' => ''); function __construct() { $this->myParamsInfoMgr = new ParamsInfoMgr(); $this->xmlName = orbitesXml; if (file_exists($this->xmlName)) unlink($this->xmlName); $this->contentDom = new DomDocument("1.0"); $this->contentDom->preserveWhiteSpace = false; $this->contentDom->formatOutput = true; $this->createDom(); $this->xp = new domxpath($this->contentDom); } protected function createDom() { $rootElement = $this->contentDom->createElement('orbitesList'); $this->contentDom->appendChild($rootElement); $this->contentDom->save($this->xmlName); } /* * Add Orbites in Orbites.xml */ protected function addOrbites($obj) { $objList = $this->contentDom->documentElement; $newObj = $this->contentDom->createElement($this->objTagName); $newObj->setAttribute('xml:id',$this->id); $obj_arr = (array)$obj; foreach ($obj_arr as $key => $value) { if ($key != 'xml:id') $newObj->setAttribute($key, $value); } $objList -> appendChild($newObj); $this->contentDom->save($this->xmlName); } /***************************************************************** * PUBLIC FUNCTIONS *****************************************************************/ public function createOrbites() { $parametresXml = new DomDocument(); if (file_exists(paramXml)) { $parametresXml -> load(paramXml); $xpath = new DOMXpath($parametresXml); $parametres = $xpath->query("//PARAM[@type='orbit']"); if (!is_null($parametres)) { foreach ($parametres as $parametre) { $paramInfo = $this->myParamsInfoMgr->GetDDInfoFromParameterID($parametre->getAttribute('xml:id')); $mission = $paramInfo['submission']['id']; if ($mission == '') $mission = $paramInfo['mission_id']; echo $parametre->getAttribute('xml:id')." was generated....".$mission.PHP_EOL; if ($mission != '') { $obj = (object)array( "param" => $parametre->getAttribute('xml:id'), "name" => $parametre->getAttribute('name'), "type" => $parametre->getAttribute('type'), "mission" => strtoupper($mission), "units" => $parametre->getElementsByTagName('UNITS')->item(0)->nodeValue, "time_resolution" => $parametre->getElementsByTagName('TIME_RESOLUTION')->item(0)->nodeValue, "fillval" => $parametre->getElementsByTagName('FILLVAL')->item(0)->nodeValue, "coordinate_system" => $parametre->getElementsByTagName('COORDINATE_SYSTEM')->item(0)->nodeValue, "label" => $parametre->getElementsByTagName('LABEL_I')->item(0)->nodeValue ); $this->id = $obj->param; $this -> addOrbites($obj); } } } else { return array('success' => false, 'message' => "Local param file is empty"); } } else { echo "Local param file doesn't exist ".paramXml.PHP_EOL; return array('success' => false, 'message' => "Local param file doesn't exist"); } } public function createOrbitesInfoFiles($locBases){ $domTargets = new DomDocument(); if (!$domTargets->load(targetsSimu)) { $msg = "Cannot load file ".targetsSimu.PHP_EOL; if (!$this->updateOnly) error_log($msg,1,email); continue; } $targets = $domTargets->getElementsByTagName('target'); foreach ($targets as $target) { $help = "

".$target->nodeValue."

"; $fileName = HELPPATH."simu/simu".$target->nodeValue; file_put_contents($fileName, $help); } return true; } }