Exemplo n.º 1
0
 /**
  * @param string $sourceFile
  * @param string $resultFile
  * @dataProvider convertDataProvider
  */
 public function testConvert($sourceFile, $resultFile)
 {
     $dom = new \DOMDocument();
     $dom->loadXML(file_get_contents(__DIR__ . "/../_files/converter/dom/{$sourceFile}"));
     $resultFile = (include __DIR__ . "/../_files/converter/dom/{$resultFile}");
     $converterDom = new Dom();
     $this->assertEquals($resultFile, $converterDom->convert($dom));
 }
Exemplo n.º 2
0
 /**
  * Cria a tag evt????
  *
  * @param  string $id
  * @param  string $indRetificacao
  * @param  int    $tpAmb
  * @param  string $nrRecibo
  * @return Dom
  */
 public function tagEvento($id, $indRetificacao, $tpAmb, $nrRecibo = '')
 {
     $id = "ID" . str_pad($id, 18, '0', STR_PAD_LEFT);
     $identificador = 'tag raiz ';
     $this->evt = $this->dom->createElement($this->signTag);
     //importante a identificação "Id" deve estar grafada assim
     $this->evt->setAttribute("id", $id);
     $ide = $this->dom->createElement("ideEvento");
     $this->dom->addChild($ide, "indRetificacao", $indRetificacao, false, $identificador . "Indicador de retificação");
     if ($indRetificacao > 1) {
         $this->dom->addChild($ide, "nrRecibo", $nrRecibo, true, $identificador . "Numero do recibo quando for retificador");
     }
     $this->dom->addChild($ide, "tpAmb", $tpAmb, true, $identificador . "tipo de ambiente");
     $this->dom->addChild($ide, "aplicEmi", $this->objConfig->aplicEmi, true, $identificador . "Aplicativo de emissão do evento");
     $this->dom->addChild($ide, "verAplic", $this->objConfig->verAplic, true, $identificador . "Versão do aplicativo de emissão do evento");
     $this->dom->appChild($this->evt, $ide);
     return $this->evt;
 }
Exemplo n.º 3
0
 public function get_nav($menu = '', $partial_path = null)
 {
     if (\Event::listeners("menu.render.navigation: {$menu}")) {
         $result = \Event::until("menu.render.navigation: {$menu}");
         if (!is_null($result)) {
             if ($result instanceof \DOMDocument) {
                 return $result->saveHTML();
             } elseif (is_string($result)) {
                 return $result;
             } elseif (is_array($result)) {
                 return Dom::arrayToDOMDocument($result)->saveHTML();
             } else {
                 throw new \Exception("Menu event response is invalid. Supported responses are: [DOMDocument], [String], [Array]");
             }
         }
     }
     $navigation_group = \Navigation\Model\Group::with(array('links' => function ($query) {
         $query->order_by('order', 'asc');
     }))->where('slug', '=', $menu)->first();
     // This navigation group is available?
     if (isset($navigation_group) and !empty($navigation_group)) {
         $items = $navigation_group->get_links();
         if (\Event::listeners("menu.merge.navigation: {$menu}", array($items))) {
             $result = \Event::until("menu.merge.navigation: {$menu}", array($items));
             $items = array_merge_recursive($items, $result);
             sort($items);
         }
         if (\Event::listeners("menu.make.navigation: {$menu}", array($items))) {
             $items = \Event::until("menu.make.navigation: {$menu}", array($items));
         }
         if (\Event::listeners("menu.make.navigation", array($items))) {
             $items = \Event::until("menu.make.navigation", array($items));
         }
         return $this->make($items, '', $partial_path);
     } else {
         return 'ERROR: The navigation group [' . $menu . '] does not exist.';
     }
 }
Exemplo n.º 4
0
 public function testFindI()
 {
     Dom::load('tests/files/horrible.html');
     $this->assertEquals('[ Досие бр:12928 ]', Dom::find('i')[0]->innerHtml);
 }
 // get depth
 $depth = $item->data('depth') + $startDepth;
 // create item html
 $menuItem = Dom::fragment(View::factory('menu/item/base', array('item' => $item, 'alias' => $alias, 'depth' => $depth))->render());
 // calulate depth difference
 $depthDiff = $depth - $currentDepth;
 // update current depth
 $currentDepth = $depth;
 // lookup or create the correct parent to add the item to
 if ($depthDiff > 0) {
     if (isset($nodeBranch)) {
         // use nodebranch as template
         $newParent = clone $nodeBranch;
     } else {
         // create ul node
         $newParent = Dom::node('ul');
     }
     // append class
     $newParent->attribute('class', 'menuLevel' . $depth, TRUE);
     // add it to the last created item
     $parent->last_child()->append($newParent);
     // set the newly created element as the new parent element
     $parent = $newParent;
     // add this parent to the stack
     $stack[] = $parent;
 } elseif ($depthDiff == 0) {
     // do nothing
 } elseif ($depthDiff < 0) {
     // traverse back thought the tree to set a new parent
     for ($j = 0; $j > $depthDiff; $j--) {
         array_pop($stack);
Exemplo n.º 6
0
function str_get_dom($str, $lowercase = true)
{
    $dom = new Dom();
    $dom->load($str, $lowercase);
    return $dom;
}
 private function findUrlsInHtml($url, $html)
 {
     if (!$html) {
         return;
     }
     $dom = new Dom();
     $dom->load($html);
     $elems = $dom->find('html');
     foreach ($elems as $i) {
         $this->findUrlsInNode($url, $i);
     }
 }
<?php

echo View::factory('menu/base', array('nodeRoot' => Dom::node('ul')->attribute('class', 'main'), 'nodeBranch' => Dom::node('ul'), 'data' => $data, 'alias' => $alias, 'startDepth' => $startDepth))->render();
Exemplo n.º 9
0
 /**
  * Prepare the set description for the collection / set, if any.
  *
  * @see OaiPmhRepository_Metadata_OaiDc::appendMetadata()
  *
  * @param Dom $set
  * @param Collection $collection
  * @return Dom
  */
 protected function _addSetDescription($set, $collection)
 {
     // Prepare the list of Dublin Core element texts, except the first title.
     $elementTexts = array();
     // List of the Dublin Core terms, needed to removed qualified ones.
     $dcTerms = array('title' => 'Title', 'creator' => 'Creator', 'subject' => 'Subject', 'description' => 'Description', 'publisher' => 'Publisher', 'contributor' => 'Contributor', 'date' => 'Date', 'type' => 'Type', 'format' => 'Format', 'identifier' => 'Identifier', 'source' => 'Source', 'language' => 'Language', 'relation' => 'Relation', 'coverage' => 'Coverage', 'rights' => 'Rights');
     foreach ($dcTerms as $name => $elementName) {
         $elTexts = $collection->getElementTexts('Dublin Core', $elementName);
         // Remove the first title.
         if ($elementName == 'Title' && isset($elTexts[0])) {
             unset($elTexts[0]);
         }
         if ($elTexts) {
             $elementTexts[$name] = $elTexts;
         }
     }
     if (empty($elementTexts)) {
         return $set;
     }
     $setDescription = $this->document->createElement('setDescription');
     $set->appendChild($setDescription);
     $oai_dc = $this->document->createElementNS(OaiPmhRepository_Metadata_OaiDc::METADATA_NAMESPACE, 'oai_dc:dc');
     $setDescription->appendChild($oai_dc);
     $oai_dc->setAttribute('xmlns:dc', OaiPmhRepository_Metadata_OaiDc::DC_NAMESPACE_URI);
     $oai_dc->declareSchemaLocation(OaiPmhRepository_Metadata_OaiDc::METADATA_NAMESPACE, OaiPmhRepository_Metadata_OaiDc::METADATA_SCHEMA);
     foreach ($elementTexts as $name => $elTexts) {
         foreach ($elTexts as $elementText) {
             $oai_dc->appendNewElement('dc:' . $name, $elementText->text);
         }
     }
 }