file = $file; $zip = new ZipArchive; $res = $zip->open($this->file); $properties = array(); if ($res !== TRUE) throw new Exception('Impossible d\'ouvrir le ZIP, code:' . $res); for( $i = 0; $i < $zip->numFiles; $i++ ){ $stat = $zip->statIndex($i); if(substr($stat['name'], -3) == '.fz') $this->xml = new SimpleXMLElement($zip->getFromName($stat['name'])); if(substr($stat['name'], -4) == '.ino') $this->ino = $zip->getFromName($stat['name']); $this->files[$stat['name']] = $zip->getFromName($stat['name']); } $zip->close(); $this->parse(); } private function parse(){ $this->minY = 0; $this->minX = 0; foreach($this->xml->instances->instance as $instance){ $part = array(); $part['sigle'] = (string) $instance->title; $attributes = $instance->attributes(); $part['id'] = (string) $attributes->moduleIdRef; $part['properties'] = array(); foreach($instance->property as $property){ $attribute = $property->attributes(); $part['properties'][(string)$attribute['name']] = (string)$attribute['value']; } $part['type'] = 'component'; if(isset($instance->views->breadboardView->geometry)){ $geometry = $instance->views->breadboardView->geometry->attributes(); $part['geometry'] = array( 'x' => array(), 'z' => 0, 'y' => array() ); if(isset($instance->views->breadboardView->geometry->transform)){ $part['geometry']['r'] = $instance->views->breadboardView->geometry->transform; $this->comment = json_encode($instance->views->breadboardView->geometry->transform->attributes()); } if(isset($geometry['wireFlags'])) $part['type'] = 'wire'; foreach ($geometry as $key => $value) { if(substr($key, 0,1) == 'x') $part['geometry']['x'][] =(float)$value; if(substr($key, 0,1) == 'y') $part['geometry']['y'][] =(float)$value; } $part['geometry']['z'] =(float)$geometry['z']; if($this->minY>$part['geometry']['y'][0])$this->minY = $part['geometry']['y'][0]; if($this->minX>$part['geometry']['x'][0])$this->minX = $part['geometry']['x'][0]; if( $part['type']== 'wire'){ $wireAttributes = $instance->views->breadboardView->wireExtras->attributes(); $part['color'] = (string)$wireAttributes['color']; } } $part['component'] = $this->getComponent($attributes->path); $this->parts[] = $part; } $this->minY = abs($this->minY); $this->minX = abs($this->minX); $this->comment = '