Ejemplo n.º 1
0
 /**
  * Retrieve layer objects
  * 
  * @return array
  */
 public function retriveLayerObjects()
 {
     $classes = [];
     foreach ($this->engine->query('//dia:diagram/dia:layer') as $layer) {
         if ($layer->nodeName == 'dia:layer') {
             foreach ($layer->childNodes as $elementObject) {
                 if ($elementObject->nodeName == 'dia:object') {
                     foreach ($elementObject->childNodes as $childNodesAttributes) {
                         if ($childNodesAttributes->nodeName == 'dia:attribute' && $childNodesAttributes->attributes->getNamedItem("name")->nodeValue == 'name') {
                             $name = str_replace(['#'], [''], $childNodesAttributes->childNodes->item(1)->nodeValue);
                             $classes[$name] = $elementObject;
                         }
                     }
                 }
             }
         }
     }
     return $classes;
 }
Ejemplo n.º 2
0
 public function testReadmeExampleCreate1()
 {
     $engine = new FabricationEngine();
     $hi = $engine->create('div', '', array('id' => 'hello-world'), array(array('name' => 'u', 'value' => 'Hello', 'attributes' => array('id' => 'hello'), 'children' => array()), array('name' => 'strong', 'attributes' => array('id' => 'world'), 'children' => array(array('name' => 'i', 'value' => 'W'), array('name' => 'i', 'value' => 'o'), array('name' => 'i', 'value' => 'r'), array('name' => 'i', 'value' => 'l'), array('name' => 'i', 'value' => 'd')))));
     $this->assertEquals('div', $hi->nodeName);
     $this->assertEquals('HelloWorld', $hi->nodeValue);
     $this->assertEquals('id', $hi->attributes->getNamedItem('id')->nodeName);
     $this->assertEquals('hello-world', $hi->attributes->getNamedItem('id')->nodeValue);
     $engine->appendChild($hi);
     $this->assertEquals('<strong id="world"><i>W</i><i>o</i><i>r</i><i>l</i><i>d</i></strong>', $engine->saveHTML('//div[@id="hello-world"]/strong[@id="world"]'));
 }