From 4a438b99da5ded006edce23c875f4dcbc1004e81 Mon Sep 17 00:00:00 2001 From: elena <ebudnik@irap.omp.eu> Date: Fri, 24 Jul 2015 12:33:33 +0200 Subject: [PATCH] catalog draft --- php/classes/CatalogCacheMgr.php | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------- php/classes/CatalogMgr.php | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------- php/classes/TimeTableMgr.php | 246 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------- 3 files changed, 263 insertions(+), 225 deletions(-) diff --git a/php/classes/CatalogCacheMgr.php b/php/classes/CatalogCacheMgr.php index 000d41c..765d441 100644 --- a/php/classes/CatalogCacheMgr.php +++ b/php/classes/CatalogCacheMgr.php @@ -10,7 +10,8 @@ class CatIntervalCacheObject extends IntervalCacheObject // for catalog private $params = array(); - public function toArray() { + public function toArray() + { $result = array( "cacheId" => $this->id, "start" => $this->getStartToISO(), @@ -30,26 +31,28 @@ class CatIntervalCacheObject extends IntervalCacheObject } // for catalog - public function setParams($params) { - $this->params = $params; - + public function setParams($params) + { + $this->params = $params; } - public function getParams() { + public function getParams() + { return $this->params; } - public function writeBin($handle, $paramsNumber, $paramsSizes) { + public function writeBin($handle, $paramsNumber, $paramsSizes) + { fwrite($handle,pack('L6',$this->id,$this->index,$this->start,$this->stop,$this->isNew,$this->isModified)); for ($i = 0; $i < $paramsNumber; $i++) { $paramString = $this->params[$i]; $paramArray = explode(',',$this->params[$i]); for ($j = 0; $j < $paramsSizes[$i]; $j++) fwrite($handle,pack('d', $paramArray[$j])); - } - + } } - public function loadBin($handle, $paramsNumber, $paramsSizes) { + public function loadBin($handle, $paramsNumber, $paramsSizes) + { $array = unpack('L6int',fread($handle,6*4)); $this->id = $array['int1']; $this->index = $array['int2']; @@ -69,7 +72,8 @@ class CatIntervalCacheObject extends IntervalCacheObject } - public function dump() { + public function dump() + { echo " => Interval : id = ".$this->id.", index = ".$this->index.", start = ".$this->start.", stop = ".$this->stop.", isNew = ".$this->isNew.", isModified = ".$this->isModified.PHP_EOL; } } @@ -79,36 +83,40 @@ class CatalogCacheObject extends TimeTableCacheObject private $paramsNumber; private $paramsSizes = array(); - public function addInterval($startIso, $stopIso, $params, $isNew = false, $index = -1) { - $interval = new CatIntervalCacheObject($this->lastId, count($this->intervals)); - ++$this->lastId; - $interval->setStartFromISO($startIso); - $interval->setStopFromISO($stopIso); - // for catalog - $interval->setParams($params); + public function addInterval($startIso, $stopIso, $params, $isNew = false, $index = -1) + { + $interval = new CatIntervalCacheObject($this->lastId, count($this->intervals)); + ++$this->lastId; + $interval->setStartFromISO($startIso); + $interval->setStopFromISO($stopIso); + // for catalog + $interval->setParams($params); - $interval->setIsNew($isNew); - array_push($this->intervals, $interval); - if ($index < 0) - array_push($this->indexes, count($this->intervals) - 1); - else - array_splice($this->indexes, $index, 0, array(count($this->intervals) - 1)); - if ($isNew) - $this->isModified = true; - - return $interval; + $interval->setIsNew($isNew); + array_push($this->intervals, $interval); + if ($index < 0) + array_push($this->indexes, count($this->intervals) - 1); + else + array_splice($this->indexes, $index, 0, array(count($this->intervals) - 1)); + if ($isNew) + $this->isModified = true; + + return $interval; } - public function setParamsNumber($number){ + public function setParamsNumber($number) + { $this->paramsNumber = $number; } - public function setParamsSizes($params){ - for ($i = 0; $i < $this->paramsNumber; $i++) - $this->paramsSizes[$i] = $params[$i]['size']; + public function setParamsSizes($params) + { + for ($i = 0; $i < $this->paramsNumber; $i++) + $this->paramsSizes[$i] = $params[$i]['size']; } - public function writeBin($handle) { + public function writeBin($handle) + { //Magic key ("TTC") fwrite($handle,pack('C3',ord('T'),ord('T'),ord('C'))); @@ -206,7 +214,7 @@ class CatalogCacheObject extends TimeTableCacheObject $interval->loadBin($handle, $this->paramsNumber, $this->paramsSizes); array_push($this->intervals, $interval); } - + //Indexes $res = unpack('Ldata',fread($handle,4)); $nbIndexes = $res['data']; @@ -218,7 +226,6 @@ class CatalogCacheObject extends TimeTableCacheObject return true; } - } class CatalogCacheMgr extends TimeTableCacheMgr @@ -273,11 +280,12 @@ class CatalogCacheMgr extends TimeTableCacheMgr 'status' => $this->cache->getStatus(), 'parameters' => $paramHeaders); } - public function initFromTT($id, $typeTT) { + public function initFromTT($id, $typeTT) + { //Create new cache - $this->cache = new CatalogeCacheObject(); + $this->cache = new CatalogCacheObject(); - //Load intervals from TT file and add to cache + //Load intervals from catalog file and add to cache $intervals_res = $this->ttMgr->loadIntervalsFromTT($id,$typeTT); if (!$intervals_res['success']) @@ -286,21 +294,26 @@ class CatalogCacheMgr extends TimeTableCacheMgr foreach ($intervals_res['intervals'] as $interval) { //Add interval - $this->cache->addInterval($interval['start'], $interval['stop']); + $this->cache->addInterval($interval['start'], $interval['stop'], $interval['paramTable']); } + $paramHeaders = $intervals_res['parameters']; + + $this->cache->setParamsNumber(count($paramHeaders)); + $this->cache->setParamsSizes($paramHeaders); unset($intervals_res); //Update cache $this->cache->updateIndexes(); //Save cache file - return array('success' => $this->saveToFile(), 'token' => $this->cache->getToken(), 'status' => $this->cache->getStatus()); + return array('success' => $this->saveToFile(), 'token' => $this->cache->getToken(), + 'status' => $this->cache->getStatus(),'parameters' => $paramHeaders); } - protected function loadFromFile() { - + protected function loadFromFile() + { if (!file_exists($this->getCacheFilePath())) return false; $this->cache = new CatalogCacheObject(); @@ -313,15 +326,16 @@ class CatalogCacheMgr extends TimeTableCacheMgr $result = true; } fclose($handle); - return $result; + return $result; } - protected function getCacheFilePath() { + protected function getCacheFilePath() + { return USERTTDIR.(self::$cache_file); } - public function saveInTT($id, $action, $token) { - + public function saveInTT($id, $action, $token) + { if (!$this->loadFromFile()) return array('success' => false, 'message' => 'Cannot load cache file'); @@ -334,11 +348,8 @@ class CatalogCacheMgr extends TimeTableCacheMgr $intervals = $this->cache->getIntervalsArray(NULL,NULL,true); $this->cache->reset(); - - return $this->ttMgr->saveIntervals($id, $intervals, $action); - } - - + return $this->ttMgr->saveIntervals($id, $intervals, $action); + } } ?> \ No newline at end of file diff --git a/php/classes/CatalogMgr.php b/php/classes/CatalogMgr.php index e865a40..3f9d533 100644 --- a/php/classes/CatalogMgr.php +++ b/php/classes/CatalogMgr.php @@ -100,10 +100,8 @@ class CatalogMgr extends TimeTableMgr { $attributesToReturn['parameters'] = $paramsArray; } else - return array('error' => 'No information on parameters in result file'); - - - } + return array('error' => 'No information on parameters in result file'); + } return $attributesToReturn; } @@ -111,7 +109,6 @@ class CatalogMgr extends TimeTableMgr { public function loadIntervalsFromTT($id, $typeTT, $start = NULL, $limit = NULL) { - if ($typeTT == 'sharedcatalog') { $pathid = SHAREDPATH.'TT/'.$id; } @@ -120,43 +117,71 @@ class CatalogMgr extends TimeTableMgr { } //load intervals from TT id - if (!file_exists($pathid.'.xml')) - return array('success' => false, 'message' => "Cannot find Catalog file ".$id); + if (!file_exists($pathid.'.xml')) + return array('success' => false, 'message' => "Cannot find Catalog file ".$id); $this->objectDom->load($pathid.'.xml'); - if (!($objToGet = $this->objectDom->getElementById($id))) - return array('success' => false, 'message' => NO_SUCH_ID." ".$id); + if (!($objToGet = $this->objectDom->getElementById($id))) + return array('success' => false, 'message' => NO_SUCH_ID." ".$id); $xpath = new DOMXPath($this->objectDom); $intervals = $xpath->query('//intervals'); $result = array(); - if (!isset($start) || !isset($limit)) - { - foreach ($intervals as $interval) - { - $startTime = $interval->getElementsByTagName('start')->item(0)->nodeValue; - $stopTime = $interval->getElementsByTagName('stop')->item(0)->nodeValue; - array_push($result, array('start' => $startTime, 'stop' => $stopTime)); - } - } - else + if (!isset($start) || !isset($limit)) + { + foreach ($intervals as $interval) + { + $startTime = $interval->getElementsByTagName('start')->item(0)->nodeValue; + $stopTime = $interval->getElementsByTagName('stop')->item(0)->nodeValue; + // for catalog + $paramNodes = $interval->getElementsByTagName('param'); + $params = array(); + if ($paramNodes->length > 0) + foreach ( $paramNodes as $paramNode ) $params[] = $paramNode->nodeValue; + + array_push($result, array('start' => $startTime, 'stop' => $stopTime,'paramTable' => $params)); + + } + } + else { - for ($i = 0; $i < $limit; ++$i) - { + for ($i = 0; $i < $limit; ++$i) + { if ($start+$i >= $intervals->length) break; - $startTime = $intervals->item($start+$i)->getElementsByTagName('start')->item(0)->nodeValue; - $stopTime = $intervals->item($start+$i)->getElementsByTagName('stop')->item(0)->nodeValue; - array_push($result, array('start' => $startTime, 'stop' => $stopTime)); - } - } - - return array( + $startTime = $intervals->item($start+$i)->getElementsByTagName('start')->item(0)->nodeValue; + $stopTime = $intervals->item($start+$i)->getElementsByTagName('stop')->item(0)->nodeValue; + // for catalog + $paramNodes = $intervals->item($start+$i)->getElementsByTagName('param'); + $params = array(); + if ($paramNodes->length > 0) + foreach ( $paramNodes as $paramNode ) $params[] = $paramNode->nodeValue; + + array_push($result, array('start' => $startTime, 'stop' => $stopTime,'paramTable' => $params)); + } + } + // for catalog : params header + $paramsNodes = $xpath->query('//parametres/param'); + $paramsArray = array(); + + if ($paramsNodes->length > 0) + { + foreach ($paramsNodes as $paramNode) + { + $oneParam = array(); + foreach ($paramNode->attributes as $attr) + $oneParam[$attr->nodeName] = $attr->nodeValue; + $paramsArray[] = $oneParam; + } + } + + return array( 'totalCount' => $intervals->length, 'intervals' => $result, + 'parameters' => $paramsArray, 'start' => isset($start) ? $start : 0, 'limit' => isset($limit) ? $limit : 0, 'success' => true @@ -167,34 +192,36 @@ class CatalogMgr extends TimeTableMgr { /* * catalog header */ - protected function setParamDescription($params) { - - $paramsElement = $this->objectDom->createElement('parametres'); - foreach ($params as $param) { - $paramElement = $this->objectDom->createElement('param'); - $attrArray = (array)$param; - foreach ($attrArray as $key => $value) - $paramElement->setAttribute($key, $value); - $paramsElement->appendChild($paramElement); - } - - return $paramsElement; - } - - protected function createIntervalElement($interval) { - $newInterval = $this->objectDom->createElement('intervals'); - $newInterval->appendChild($this->objectDom->createElement('start',$interval['start'])); - $newInterval->appendChild($this->objectDom->createElement('stop',$interval['stop'])); - foreach ($interval as $key =>$value) { - if (substr($key,0,5) == 'param') - $newInterval->appendChild($this->objectDom->createElement('param', $value)); - + protected function setParamDescription($params) + { + $paramsElement = $this->objectDom->createElement('parametres'); + foreach ($params as $param) + { + $paramElement = $this->objectDom->createElement('param'); + $attrArray = (array)$param; + foreach ($attrArray as $key => $value) + $paramElement->setAttribute($key, $value); + $paramsElement->appendChild($paramElement); + } + + return $paramsElement; } + + protected function createIntervalElement($interval) + { + $newInterval = $this->objectDom->createElement('intervals'); + $newInterval->appendChild($this->objectDom->createElement('start',$interval['start'])); + $newInterval->appendChild($this->objectDom->createElement('stop',$interval['stop'])); + foreach ($interval as $key =>$value) { + if (substr($key,0,5) == 'param') + $newInterval->appendChild($this->objectDom->createElement('param', $value)); + + } return $newInterval; } - public function createObject($p, $folder){ - + public function createObject($p, $folder) + { if ($p -> leaf) { $result = $this->createParameter($p, $folder); diff --git a/php/classes/TimeTableMgr.php b/php/classes/TimeTableMgr.php index 0f32209..b9fc8ab 100644 --- a/php/classes/TimeTableMgr.php +++ b/php/classes/TimeTableMgr.php @@ -7,23 +7,23 @@ * */ -function timeFormat($myString) { - if (format == "Y z H i s") { - $tt = getdate(strtotime($myString)); - return sprintf("%04d",$tt["year"])." " - .sprintf("%03d",$tt["yday"]+1)." " - .sprintf("%02d",$tt["hours"])." " - .sprintf("%02d",$tt["minutes"])." " - .sprintf("%02d",$tt["seconds"]); - } - return date(format,strtotime($myString)); - - } - -class TimeTableMgr extends AmdaObjectMgr { - +function timeFormat($myString) +{ + if (format == "Y z H i s") { + $tt = getdate(strtotime($myString)); + return sprintf("%04d",$tt["year"])." " + .sprintf("%03d",$tt["yday"]+1)." " + .sprintf("%02d",$tt["hours"])." " + .sprintf("%02d",$tt["minutes"])." " + .sprintf("%02d",$tt["seconds"]); + } + return date(format,strtotime($myString)); +} - function __construct($user) { +class TimeTableMgr extends AmdaObjectMgr +{ + function __construct($user) + { parent::__construct('Tt.xml'); $this->contentRootId = 'timeTable-treeRootNode'; $this->contentRootTag = 'timetabList'; @@ -38,7 +38,6 @@ class TimeTableMgr extends AmdaObjectMgr { } } - protected function createDom() { $types = array('timetab' => 'timeTable', 'catalog' => 'catalog'); @@ -51,14 +50,15 @@ class TimeTableMgr extends AmdaObjectMgr { $typeElement->setAttribute('xml:id', $contentId); $rootElement->appendChild($typeElement); } - $this->contentDom->appendChild($rootElement); + $this->contentDom->appendChild($rootElement); $this->contentDom->save($this->xmlName); } /* - * rename Time Table in id.xml - */ - protected function renameInResource($name, $id) { + * rename Time Table in id.xml + */ + protected function renameInResource($name, $id) + { if (!file_exists(USERTTDIR.$id.'.xml')) return false; $this->objectDom -> load(USERTTDIR.$id.'.xml'); @@ -69,13 +69,14 @@ class TimeTableMgr extends AmdaObjectMgr { return true; } - protected function deleteParameter($id){ + protected function deleteParameter($id) + { if (file_exists(USERTTDIR.$id.'.xml')) unlink(USERTTDIR.$id.'.xml'); } /* - * Check if difference is name and info only - */ + * Check if difference is name and info only + */ protected function renameOnly($p) { //if (!($p->intervals)) return true; return false; @@ -90,7 +91,8 @@ class TimeTableMgr extends AmdaObjectMgr { /* * Create Time Table */ - protected function createParameter($p, $folder){ + protected function createParameter($p, $folder) + { if ($this -> objectExistsByName($p->name)) { $p -> id = $this -> getObjectIdByName($p->name); $this -> deleteObject($p); @@ -137,119 +139,117 @@ class TimeTableMgr extends AmdaObjectMgr { $obj->intervals = $p->nbIntervals; $this -> addToContent($obj, $folder); return array('id' => $this->id,'created' => $this->created,'info' =>$obj->intervals.' intervals' ); - } - protected function call_intersection($fst, $snd) { - $inf = ( $fst[0] > $snd[0] ) ? $fst[0] : $snd[0]; - $sup = ( $fst[1] < $snd[1] ) ? $fst[1] : $snd[1]; - if ( $inf >= $sup ) { $inter[] = array(0,0); } - else {$inter[] = array($inf,$sup); } - return $inter; - } + protected function call_intersection($fst, $snd) + { + $inf = ( $fst[0] > $snd[0] ) ? $fst[0] : $snd[0]; + $sup = ( $fst[1] < $snd[1] ) ? $fst[1] : $snd[1]; + if ( $inf >= $sup ) { $inter[] = array(0,0); } + else {$inter[] = array($inf,$sup); } + return $inter; + } /* * For TT download : file format in text */ - protected function xsl2text($file,$format) { - define("format", $format); - $xslt = new XSLTProcessor(); + protected function xsl2text($file,$format) + { + define("format", $format); + $xslt = new XSLTProcessor(); - // add PHP functions to XSLT functions - $xslt -> registerPHPFunctions(); - - // Load Time table - $xml = new domDocument("1.0"); - $xml->load($file); - - // Load XSL file - $xsl = new domDocument("1.0"); - if ($format == "Y-m-dTH:i:s") $xslName = "xml2iso.xsl"; - else $xslName = "xml2all.xsl"; - $xsl->load(XMLPATH.$xslName); - - // Import XSL and write output file in text format - $xslt -> importStylesheet($xsl); - $filename = $xml->getElementsByTagName('name')->item(0)->nodeValue.".txt"; - $output=fopen(USERWORKINGDIR.$filename, "w"); - fwrite($output, trim($xslt -> transformToDoc($xml)->firstChild->wholeText)); - fclose($output); + // add PHP functions to XSLT functions + $xslt -> registerPHPFunctions(); + + // Load Time table + $xml = new domDocument("1.0"); + $xml->load($file); + + // Load XSL file + $xsl = new domDocument("1.0"); + if ($format == "Y-m-dTH:i:s") $xslName = "xml2iso.xsl"; + else $xslName = "xml2all.xsl"; + $xsl->load(XMLPATH.$xslName); + + // Import XSL and write output file in text format + $xslt -> importStylesheet($xsl); + $filename = $xml->getElementsByTagName('name')->item(0)->nodeValue.".txt"; + $output=fopen(USERWORKINGDIR.$filename, "w"); + fwrite($output, trim($xslt -> transformToDoc($xml)->firstChild->wholeText)); + fclose($output); return USERWORKINGDIR.$filename; } /* - * For TT download : file format in vot + * For TT download : file format in vot */ - public function xsl2vot($file,$format) { + public function xsl2vot($file,$format) + { $xslt = new XSLTProcessor(); - // Load Time table - $xml = new domDocument("1.0"); - $xml->load($file); - - // Load XSL file - $xsl = new domDocument("1.0"); - $xsl->load(XMLPATH.'xml2vot.xsl'); - - // Import XSL and write output file in vot format - $xslt -> importStylesheet($xsl); - $vot = new domDocument("1.0"); - $vot -> loadXML($xslt -> transformToXML($xml)); - $filename = $xml->getElementsByTagName('name')->item(0)->nodeValue.".xml"; - $vot -> save(USERWORKINGDIR.$filename); - - return USERWORKINGDIR.$filename; + // Load Time table + $xml = new domDocument("1.0"); + $xml->load($file); + + // Load XSL file + $xsl = new domDocument("1.0"); + $xsl->load(XMLPATH.'xml2vot.xsl'); + + // Import XSL and write output file in vot format + $xslt -> importStylesheet($xsl); + $vot = new domDocument("1.0"); + $vot -> loadXML($xslt -> transformToXML($xml)); + $filename = $xml->getElementsByTagName('name')->item(0)->nodeValue.".xml"; + $vot -> save(USERWORKINGDIR.$filename); + + return USERWORKINGDIR.$filename; } /* * Uploaded text file => convert to array */ - protected function text2amda($tmp_file, $onlyDescription = false) { - - - $suffix = explode('.', basename($tmp_file)); - - $lines = file($tmp_file,FILE_SKIP_EMPTY_LINES); - - $description="Uploaded Time Table".PHP_EOL; - - foreach ($lines as $line){ - if ($line[0] == '#') $description=$description."\n".substr($line,1,-1); - else { - $date = explode(' ',$line); - if (!strtotime(trim($date[0]))) { - $description=$description."\n".$line; - continue; - } -// check if it is ISO format - if (!isset($isIso)) $isIso = preg_match('/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/', trim($date[0])); - if (!$isIso) { + protected function text2amda($tmp_file, $onlyDescription = false) + { + $suffix = explode('.', basename($tmp_file)); + $lines = file($tmp_file,FILE_SKIP_EMPTY_LINES); + $description="Uploaded Time Table".PHP_EOL; + + foreach ($lines as $line){ + if ($line[0] == '#') $description=$description."\n".substr($line,1,-1); + else { + $date = explode(' ',$line); + if (!strtotime(trim($date[0]))) { + $description=$description."\n".$line; + continue; + } + // check if it is ISO format + if (!isset($isIso)) $isIso = preg_match('/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/', trim($date[0])); + if (!$isIso) { $tempT = strtotime(trim($date[0])); $startDate = date('Y-m-d',$tempT)."T".date('H:i:s',$tempT); $tempT = strtotime(trim($date[1])); $stopDate = date('Y-m-d',$tempT)."T".date('H:i:s',$tempT); -//TODO convert time into non standard formats - // $startDate = DateTime::createFromFormat($timeFormat, trim($date[0]); - // $start = $startDate->format('Y-m-d')."T".$startDate->format('H:i:s'); - // $stopDate = DateTime::createFromFormat($timeFormat, trim($date[1]); - // $stop = $stopDate->format('Y-m-d')."T".$stopDate->format('H:i:s'); - if (!$onlyDescription) - $attributesToReturn['intervals'][] = array('start' => $startDate, 'stop' => $stopDate); - } - else { - if (!$onlyDescription) + //TODO convert time into non standard formats + // $startDate = DateTime::createFromFormat($timeFormat, trim($date[0]); + // $start = $startDate->format('Y-m-d')."T".$startDate->format('H:i:s'); + // $stopDate = DateTime::createFromFormat($timeFormat, trim($date[1]); + // $stop = $stopDate->format('Y-m-d')."T".$stopDate->format('H:i:s'); + if (!$onlyDescription) + $attributesToReturn['intervals'][] = array('start' => $startDate, 'stop' => $stopDate); + } + else { + if (!$onlyDescription) $attributesToReturn['intervals'][] = array('start' => trim($date[0]), 'stop' => trim($date[1])); } } } - $attributesToReturn['description'] = $description; - $attributesToReturn['name'] = basename($tmp_file, '.'.$suffix[1]); - $attributesToReturn['created'] = date('Y-m-d')."T".date('H:i:s'); + $attributesToReturn['description'] = $description; + $attributesToReturn['name'] = basename($tmp_file, '.'.$suffix[1]); + $attributesToReturn['created'] = date('Y-m-d')."T".date('H:i:s'); return $attributesToReturn; - } @@ -288,7 +288,7 @@ class TimeTableMgr extends AmdaObjectMgr { function getObject($id, $nodeType) { - if ($nodeType == 'sharedtimeTable') { + if (substr($nodeType,0,6) == 'shared') { $pathid = SHAREDPATH.'TT/'.$id; } else { @@ -303,20 +303,20 @@ class TimeTableMgr extends AmdaObjectMgr { $nbInt = 0; foreach($attributes as $attribute) - if($attribute->nodeType == XML_ELEMENT_NODE){ - /*if ($attribute->tagName == 'intervals') { - $start = $attribute -> getElementsByTagName('start')->item(0) -> nodeValue; - $stop = $attribute -> getElementsByTagName('stop')->item(0) -> nodeValue; - $attributesToReturn['intervals'][] = array('start' => $start, 'stop' => $stop); - } - else - $attributesToReturn[$attribute->tagName] = $attribute->nodeValue;*/ - //BRE - load all except intervals - Intervals will be loaded later with 'loadIntervalsFromTT' function - if ($attribute->tagName != 'intervals') - $attributesToReturn[$attribute->tagName] = $attribute->nodeValue; - else - $nbInt++; - } + if($attribute->nodeType == XML_ELEMENT_NODE){ + /*if ($attribute->tagName == 'intervals') { + $start = $attribute -> getElementsByTagName('start')->item(0) -> nodeValue; + $stop = $attribute -> getElementsByTagName('stop')->item(0) -> nodeValue; + $attributesToReturn['intervals'][] = array('start' => $start, 'stop' => $stop); + } + else + $attributesToReturn[$attribute->tagName] = $attribute->nodeValue;*/ + //BRE - load all except intervals - Intervals will be loaded later with 'loadIntervalsFromTT' function + if ($attribute->tagName != 'intervals') + $attributesToReturn[$attribute->tagName] = $attribute->nodeValue; + else + $nbInt++; + } $attributesToReturn['nbIntervals'] = $nbInt; @@ -769,7 +769,7 @@ class TimeTableMgr extends AmdaObjectMgr { $transform = "xsl2".$obj->fileformat; $format = $obj->timeformat; -// shared or my + // shared or my for ($i=0; $i < count($obj->list); $i++) { -- libgit2 0.21.2