Restores value for a given Item $node.

@param \DOMElement $node

@return \eZ\Publish\Core\FieldType\Page\Parts\Item
321064
protected function restoreItemFromXml(DOMElement $node)
    {
        $item = array('attributes' => array());

        if ($node->hasAttributes()) {
            foreach ($node->attributes as $attr) {
                switch ($attr->name) {
                    case 'action':
                        $item['action'] = $attr->value;
                        break;
                    default:
                        $item['attributes'][$attr->name] = $attr->value;
                }
            }
        }

        foreach ($node->childNodes as $node) {
            if ($node->nodeType !== XML_ELEMENT_NODE) {
                continue;
            }

            switch ($node->nodeName) {
                case 'object_id':
                    $item['contentId'] = $node->nodeValue;
                    break;
                case 'node_id':
                    $item['locationId'] = $node->nodeValue;
                    break;
                case 'priority':
                    $item[$node->nodeName] = $node->nodeValue;
                    break;
                case 'ts_publication':
                    $item['publicationDate'] = $node->nodeValue;
                    break;
                case 'ts_visible':
                    $item['visibilityDate'] = $node->nodeValue;
                    break;
                case 'ts_hidden':
                    $item['hiddenDate'] = $node->nodeValue;
                    break;
                case 'rotation_until':
                    $item['rotationUntilDate'] = $node->nodeValue;
                    break;
                case 'moved_to':
                    $item['movedTo'] = $node->nodeValue;
                    break;
            }
        }

        return new Parts\Item($item);
    }
1270203
public function transform($node)
    {
        $blocksData = $this->transformBlock($node);
        $documentData = array(
            'id' => $node->getNodeId() . '-' . $node->getLanguage(). '-' . $node->getSiteId(),
            'elementId' => $node->getId(),
            'nodeId' => $node->getNodeId(),
            'siteId' => $node->getSiteId(),
            'language' => $node->getLanguage(),
            'name' => $node->getName(),
            'blocks' => $blocksData
        );

        if (!is_null($node->getUpdatedAt())) {
            $documentData['updatedAt'] = $node->getUpdatedAt()->getTimestamp();
        }

        $document = new Document($documentData['id'], $documentData);

        return $document;
    }
1159816
public function trashRestoreNodeAction(Node $node)
    {
        $node->setIsDeleted(false);

        // Если у модуля есть роутинги, тогда нода подключается к папке как роутер.
        $folder = $node->getFolder();
        if ($this->container->has('cms.router_module.'.$node->getModule()) and !$folder->getRouterNodeId()) {
            $folder->setRouterNodeId($node->getId());
        }

        $this->persist($node, true);

        $this->addFlash('success', 'Нода восстановлена.');

        return $this->redirectToRoute('cms_admin_structure_trash');
    }
686809
function copy(DOMNode $node)
    {
        $frame = new Frame($node);
        $frame->set_style(clone $this->_frame->get_original_style());

        return Factory::decorate_frame($frame, $this->_dompdf, $this->_root);
    }
64882
protected function replaceVars(DOMElement $node, array $vars)
	{
		foreach ($this->xpath->query('.//var', $node) as $varNode)
		{
			$varName = $varNode->getAttribute('name');

			if (isset($vars[$varName]))
			{
				$varNode->parentNode->replaceChild(
					$this->dom->createTextNode($vars[$varName]),
					$varNode
				);
			}
		}
	}
286602
protected function getNodeValueByTagName(DOMElement $node, $tagName)
    {
        $results = $node->getElementsByTagName($tagName);
        for ($i = 0; $i < $results->length; $i++) {
            $result = $results->item($i);
            if (!$result->nodeValue) {
                continue;
            }

            return $result->nodeValue;
        }

        return false;
    }
247063
protected function fieldToElementWithAttribute(DOMDocument $doc, string $value, $node_name): DOMElement
    {
        $item = $this->fieldToElement($doc, $value);
        $item->setAttribute($this->column_attr, (string) $node_name);

        return $item;
    }
730999
public function saveHtml($node = null)
    {
        if ($node) {
            return $node->ownerDocument->saveHTML($node);
        } else {
            return $this->_dom->saveHTML($this->_dom);
        }
    }
1145630
public function retriveAttributeType(\DOMElement $element)
    {
        $name = $this->engine->query($element->getNodePath() . '/dia:attribute[@name="type"]/dia:string');
        return $this->cleanString($name->item(0)->nodeValue);
    }
362991
public function appendItem(Node $item) {
    if ($this->getItems()->isEmpty()) {
      $this->append($item);
    }
    else {
      $this->append([
        Token::comma(),
        Token::space(),
        $item,
      ]);
    }
    return $this;
  }
510611
private function transformType(\DOMElement $node): array
    {
        $data = [];

        $childNodes = [];
        foreach ($node->childNodes as $childNode) {
            if ($childNode instanceof \DOMElement) {
                $childNodes[] = $childNode;
            }
        }

        foreach ($childNodes as $childNode) {
            if (0 === $childNode->childNodes->length) {
                $data[$this->getKey($childNode)] = null;

                continue;
            }

            if (1 === $childNode->childNodes->length) {
                $data[$this->getKey($childNode)] = $this->getValue($childNode);

                continue;
            }

            if ('object' === $childNode->nodeName
                && $childNode->hasAttribute('type')
                && !$childNode->hasAttribute('key')
            ) {
                return $this->transformType($childNode);
            }

            $data[$this->getKey($childNode)] = $this->transformType($childNode);
        }

        if ('object' === $node->nodeName && $node->hasAttribute('type')) {
            $data['_type'] = $node->getAttribute('type');
        }

        return $data;
    }
1219436
private function normalizeStyleAttributes(\DOMElement $node)
    {
        $normalizedOriginalStyle = preg_replace_callback(
            '/[A-z\\-]+(?=\\:)/S',
            function (array $m) {
                return strtolower($m[0]);
            },
            $node->getAttribute('style')
        );

        // in order to not overwrite existing style attributes in the HTML, we
        // have to save the original HTML styles
        $nodePath = $node->getNodePath();
        if (!isset($this->styleAttributesForNodes[$nodePath])) {
            $this->styleAttributesForNodes[$nodePath] = $this->parseCssDeclarationsBlock($normalizedOriginalStyle);
            $this->visitedNodes[$nodePath] = $node;
        }

        $node->setAttribute('style', $normalizedOriginalStyle);
    }
1268919
protected function valueOf(DOMNode $node)
	{
		switch ($node->nodeName)
		{
			case 'input':

				switch ($node->getAttribute('type'))
				{
					case 'checkbox':
						return $node->getAttribute('checked') ? $node->getAttribute('value') : false;
						break;

					default:
						return $node->getAttribute('value');
				}

			break;
		}
		return null;
	}
595134
public function addChoice(\DOMElement $node) {
		if($node->nodeName != 'input')
			return;
		$inputValue = $node->getAttribute('value');
		$this->choices[] = $inputValue;
		switch($node->getAttribute('type')) {
			case 'radio':
				if($node->getAttribute('checked') == 'checked')
					$this->value = $inputValue;
				break;
			case 'checkbox':
				if($node->getAttribute('checked') == 'checked')
					$this->value = $inputValue;
				break;
		}
	}
1098406
protected function cloneAndEmpty(DOMElement $element)
    {
        $clone = $element->cloneNode(true);

        $children = [];

        // Collect child nodes first, as we can't iterate and
        // remove from \DOMNodeList directly
        foreach ($clone->childNodes as $node) {
            $children[] = $node;
        }

        foreach ($children as $node) {
            $clone->removeChild($node);
        }

        return $clone;
    }
331414
public static function getElementsByTagName($node, $tagName)
    {
        $ret = array();
        $nodes = $node->getElementsByTagName($tagName);
        foreach ($nodes as $node) {
            if ($node instanceof DOMElement) {
                array_push($ret, $node);
            }
        }
        return $ret;
    }
360088
protected function initializeNode(\DOMElement $node)
    {
        if (!isset($node->tagName)) {
            return;
        }

        $readability = $this->dom->createAttribute('readability');
        // this is our contentScore
        $readability->value = 0;
        $node->setAttributeNode($readability);

        // using strtoupper just in case
        switch (strtoupper($node->tagName)) {
            case 'ARTICLE':
                $readability->value += 15;
                // no break
            case 'DIV':
                $readability->value += 5;
                break;
            case 'PRE':
            case 'CODE':
            case 'TD':
            case 'BLOCKQUOTE':
            case 'FIGURE':
                $readability->value += 3;
                break;
            case 'SECTION':
                // often misused
                // $readability->value += 2;
                break;
            case 'OL':
            case 'UL':
            case 'DL':
            case 'DD':
            case 'DT':
            case 'LI':
                $readability->value -= 2 * round($this->getLinkDensity($node), 0, PHP_ROUND_HALF_UP);
                break;
            case 'ASIDE':
            case 'FOOTER':
            case 'HEADER':
            case 'ADDRESS':
            case 'FORM':
            case 'BUTTON':
            case 'TEXTAREA':
            case 'INPUT':
            case 'NAV':
                $readability->value -= 3;
                break;
            case 'H1':
            case 'H2':
            case 'H3':
            case 'H4':
            case 'H5':
            case 'H6':
            case 'TH':
            case 'HGROUP':
                $readability->value -= 5;
                break;
        }

        $readability->value += $this->getWeight($node);
    }