Наследование: extends DOMElement, implements ArrayAccess, implements Countable, implements IteratorAggregate, implements FluentDOM\Node\ChildNode, implements Node\NonDocumentTypeChildNode, implements FluentDOM\Node\ParentNode, use trait FluentDOM\Node\ChildNode\Implementation, use trait FluentDOM\Node\NonDocumentTypeChildNode\Implementation, use trait FluentDOM\Node\ParentNode\Implementation, use trait Node\QuerySelector\Implementation, use trait FluentDOM\Node\StringCast, use trait FluentDOM\Node\Xpath, use trait FluentDOM\HHVM\Properties
Пример #1
0
 /**
  * Transfer attributes to the node.
  *
  * @param Element $node
  * @param \stdClass $namespaces
  * @param \stdClass $attributes
  */
 private function transferAttributes(Element $node, $namespaces, $attributes)
 {
     foreach ($namespaces as $name => $value) {
         $node->setAttribute($name, $value);
     }
     foreach ($attributes as $name => $value) {
         $node->setAttribute($name, $value);
     }
 }
Пример #2
0
 /**
  * @param Document|Element $parent
  * @param \DOMElement $node
  * @param bool $addNameAttribute
  */
 public function addNode($parent, \DOMElement $node, $addNameAttribute = FALSE)
 {
     switch ($this->getType($node)) {
         case 'object':
             $result = $parent->appendElement('json:object');
             $this->appendChildNodes($result, $node, TRUE);
             break;
         case 'array':
             $result = $parent->appendElement('json:array');
             $this->appendChildNodes($result, $node, FALSE);
             break;
         case 'number':
             $result = $parent->appendElement('json:number', $node->nodeValue);
             break;
         case 'boolean':
             $result = $parent->appendElement('json:boolean', $node->nodeValue);
             break;
         case 'null':
             $result = $parent->appendElement('json:null');
             break;
         default:
             $result = $parent->appendElement('json:string', $node->nodeValue);
             break;
     }
     if ($addNameAttribute) {
         $name = $node->localName;
         if ($node->hasAttributeNS(self::XMLNS_JSONDOM, 'name')) {
             $name = $node->getAttributeNS(self::XMLNS_JSONDOM, 'name');
         }
         $result['name'] = $name;
     }
 }
Пример #3
0
 /**
  * @param Element $parent
  * @param string $name
  * @param string $value
  */
 private function appendField(Element $parent, $name, $value)
 {
     $qname = QualifiedName::normalizeString($name, self::DEFAULT_QNAME);
     $child = $parent->appendElement($qname, $value);
     if ($qname !== $name) {
         $child->setAttributeNS(self::XMLNS, 'json:name', $name);
     }
 }
Пример #4
0
 public function callAction(Element $element)
 {
     $url = Uri::createFromString($element->getAttribute('href'));
     $action = new Action($this, $url, $element);
     $params = explode(':', urldecode($url->getFragment()));
     array_shift($params);
     // slice away the needle
     $actionName = array_shift($params);
     $action->setParameters($params);
     $actions = $this->getLinkActions();
     if (array_key_exists($actionName, $actions)) {
         $config = $actions[$actionName];
         if (is_string($config)) {
             $config = ['call' => $config];
         }
         $action->setConfig($config);
         $action->call();
     }
 }
Пример #5
0
 /**
  * @param Element $parent
  * @return Element
  */
 public function appendTo(Element $parent)
 {
     foreach ($this as $item) {
         $parent->append($item);
     }
     return $parent;
 }
 private function appendValueTo(Element $parent, $token)
 {
     $itemNode = $parent->appendElement(strtolower($token->name));
     if (!empty($token->parameters)) {
         $parametersNode = $this->getWrapperNode($itemNode, $this->_nodeNames['parameters']);
         foreach ($token->parameters as $name => $parameter) {
             $parameterNode = $parametersNode->appendElement(strtolower($name));
             $this->appendValueNode($parameterNode, strtolower(isset($this->_parameters[$name]) ? $this->_parameters[$name] : $this->_nodeNames['default-type']), $parameter);
         }
     }
     if (!empty($token->value)) {
         $tokenType = $token->type ?: (isset($this->_components[$token->name]) ? $this->_components[$token->name] : 'unknown');
         if (is_array($tokenType)) {
             $tokenValues = $this->getValuesAsList($token->value, $tokenType);
             foreach ($tokenValues as $tokenName => $tokenValue) {
                 $this->appendValueNode($itemNode, $tokenName, $tokenValue);
             }
         } else {
             $this->appendValueNode($itemNode, strtolower($tokenType), $token->value);
         }
     }
 }