Ejemplo n.º 1
0
 private function openTagHandler($xmlParser, $tagName, $attributes)
 {
     if ($this->firstOpening) {
         $this->firstOpening = false;
         $positionOfFirstTag = xml_get_current_byte_index($xmlParser);
         $this->firstTagOffset = strpos($this->source, "<{$tagName}") - $positionOfFirstTag;
         //Position the namespace:
         $matches = null;
         foreach ($attributes as $attrName => $attrValue) {
             if (preg_match('/figdice/', $attrValue) && preg_match('/xmlns:(.+)/', $attrName, $matches)) {
                 $this->figNamespace = $matches[1] . ':';
                 break;
             }
         }
     }
     $lineNumber = xml_get_current_line_number($xmlParser);
     if ($this->parentViewElement) {
         $view =& $this->parentViewElement->view;
     } else {
         $view =& $this;
     }
     if ($tagName == $this->figNamespace . TagFigAttr::TAGNAME) {
         $newElement = new TagFigAttr($view, $tagName, $lineNumber);
     } else {
         $newElement = new ViewElementTag($view, $tagName, $lineNumber);
     }
     $newElement->setCurrentFile($this->file);
     $newElement->setAttributes($attributes);
     if ($this->rootNode === null && $this->parentViewElement) {
         $this->rootNode =& $this->parentViewElement;
         $this->stack[] =& $this->parentViewElement;
     }
     if ($this->rootNode) {
         /** @var ViewElementTag $parentElement */
         $parentElement =& $this->stack[count($this->stack) - 1];
         $newElement->parent =& $parentElement;
         //Since the new element has a parent, then the parent is not autoclose.
         $newElement->parent->autoclose = false;
         $parentElement->appendChild($newElement);
     } else {
         //If there no root node yet, then this new element is actually
         //the root element for the view.
         $this->rootNode =& $newElement;
     }
     $this->stack[] =& $newElement;
 }
Ejemplo n.º 2
0
 private function openTagHandler($xmlParser, $tagName, $attributes)
 {
     if ($this->firstOpening) {
         $this->firstOpening = false;
         //Position the namespace:
         $matches = null;
         foreach ($attributes as $attrName => $attrValue) {
             if (preg_match('/figdice/', $attrValue) && preg_match('/xmlns:(.+)/', $attrName, $matches)) {
                 $this->figNamespace = $matches[1] . ':';
                 break;
             }
         }
         // Remove the fig xmlns directive from the list of attributes of the opening root tag
         // (as it should not be rendered)
         unset($attributes['xmlns:' . substr($this->figNamespace, 0, strlen($this->figNamespace) - 1)]);
     }
     $lineNumber = xml_get_current_line_number($xmlParser);
     if ($this->parentViewElement) {
         $view =& $this->parentViewElement->view;
     } else {
         $view =& $this;
     }
     if ($tagName == $this->figNamespace . TagFigAttr::TAGNAME) {
         $newElement = new TagFigAttr($view, $tagName, $lineNumber);
     } else {
         $newElement = new ViewElementTag($view, $tagName, $lineNumber);
     }
     $newElement->setCurrentFile($this->file);
     $newElement->setAttributes($attributes);
     if ($this->rootNode === null && $this->parentViewElement) {
         $this->rootNode =& $this->parentViewElement;
         $this->stack[] =& $this->parentViewElement;
     }
     if ($this->rootNode) {
         /** @var ViewElementTag $parentElement */
         $parentElement =& $this->stack[count($this->stack) - 1];
         $newElement->parent =& $parentElement;
         //Since the new element has a parent, then the parent is not autoclose.
         $newElement->parent->autoclose = false;
         $parentElement->appendChild($newElement);
     } else {
         //If there no root node yet, then this new element is actually
         //the root element for the view.
         $this->rootNode =& $newElement;
     }
     $this->stack[] =& $newElement;
 }