Create a new trans-unit node.

@param \DOMDocument $dom
@param int $id
@param string $key
@param string $value
@return \DOMElement
496552
protected function createTranslationNode(\DOMDocument $dom, $id, $key, $value)
    {
        $translationNode = $dom->createElement('trans-unit');
        $translationNode->appendChild(new \DOMAttr('id', $id));
        
        /**
         * @see http://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html#approved
         */
        if ($value != '') {
            $translationNode->appendChild(new \DOMAttr('approved', 'yes'));
        }

        $source = $dom->createElement('source');
        $source->appendChild($dom->createCDATASection($key));
        $translationNode->appendChild($source);

        $target = $dom->createElement('target');
        $target->appendChild($dom->createCDATASection($value));
        $translationNode->appendChild($target);

        return $translationNode;
    }
539974
private function createBooleanNode(\DOMDocument $document, bool $value, string $name = null): \DOMNode
    {
        $node = $document->createElement('json:boolean', $value ? 'true' : 'false');

        if (null !== $name) {
            $node->setAttribute('name', $name);
        }

        return $node;
    }
57397
public function add($id, $value, $parent = 'root', array $meta = [ ], array $attributes = [ ])
    {
        $node = new Node($id, $this, $value, $meta, $attributes);

        if (! is_null($parent) and $this->items->has($parent)) {
            $parentNode = $this->items->get($parent);
            $parentNode->addChild($node);
            $node->setMeta('data-parent', $parent);
        }

        $this->items->put($id, $node);

        return $node;
    }
392822
protected function appendValueToElementToSend($value, \DOMElement $element)
    {
        if ($value instanceof Element) {
            $this->appendElementToElementToSend($value, $element);
        } elseif (is_array($value)) {
            $this->appendValuesToElementToSend($value, $element);
        } elseif (!empty($value)) {
            $element->appendChild(self::getDom()->createTextNode($value));
        }

        return $this;
    }
658440
protected function addSequentialNode(DOMElement $element, $value)
    {
        if (empty($element->nodeValue)) {
            $element->nodeValue = htmlspecialchars($value);

            return;
        }

        $child = $element->cloneNode();
        $child->nodeValue = htmlspecialchars($value);
        $element->parentNode->appendChild($child);
    }
866547
public function addNode($parentNode, $name, $value = false)
    {
        // if $parentNode is a string, it is likely to be
        // an XPath expression. If so, it is converted
        // into a DOMElement.
        if (is_string($parentNode)) {
            if ($parentNode == "/") {
                $parentNode = $this->domDocument;
            } else {
                $parentNode = $this->getNode($parentNode);
            }
        }

        if ($parentNode) {
            try {
                $newNode = $this->domDocument->createElement($name);
                if (!is_array($value) && !is_resource($value)) {
                    $newNode->appendChild(
                        $this->domDocument->createTextNode($value)
                    );
                }

                return $parentNode->appendChild($newNode);
            } catch (\DOMException $exception) {
                throw new Dom\Exception("Could not add node named '$name'.");
            }
        } else {
            throw new Dom\Exception("Parent node not found: " . $parentNode);
        }
    }
379016
public function modify($id, $field, $value)
    {
        $map = [
            'id' => $id
        ];
        $data = [
            $field => $value
        ];
        return $this->save($data, $map);
    }
326510
public function buildElement($name = '', $value = '', $namespaceURI = '', $attributes = [])
    {
        return new DOMItem($this->getDOMDocument(), $name, $value, $namespaceURI, $attributes);
    }
381434
public static function make_label( $id, $key, $text = null, $attr = array() ) 
	{
		if ( is_null( $text ) )
		{
			$text = $key;
		}

		$element = HTML::tag( 'label', $text, array_merge( array( 
			'id' => $id, 
			'for' => static::build_id( 'input', $key ) 
		), $attr ));

		if ( !static::$builder_enabled )
		{
			 return $element;
		}

		return Builder::handle( 'form_label', $element );
	}
547950
protected function extendedNodeTabControl(DOMNode $node, $id)
	{
		$parent = $node->parentNode;

		/* Создаём замену для тега tabcontrol */
		$newNode = $this->xml->createElement('ul');
		/* Копируем в него содержимое tabcontrol */
		$childNodes = $this->childrenAsArray($node->childNodes);
		for ($i = 0; $i < count($childNodes); $i++)
		{
			$child = $childNodes[$i];
			$newNode->appendChild($child->cloneNode(true));
		}
		$parent->replaceChild($newNode, $node);

		$tabs = $this->childrenAsArray($newNode->getElementsByTagNameNS(self::NS, 'tab'));
		for ($i = 0; $i < count($tabs); $i++)
		{
			$this->extendedNodeTab($tabs[$i], $id);
		}

		return $newNode;
	}
1289669
public function writeXml(DOMDocument $dom = null)
    {
        if (null === $dom) {
            $imp = new DOMImplementation();
            $dtd  = $imp->createDocumentType(
                static::DOCUMENT_TYPE_QUALIFIED_NAME,
                static::DOCUMENT_TYPE_PUBLIC_ID,
                static::DOCUMENT_TYPE_SYSTEM_ID
            );
            $dom = $imp->createDocument('', '', $dtd);
            $dom->encoding = 'UTF-8';
            $dom->xmlVersion = '1.0';
            $dom->formatOutput = true;
        }

        $descriptor = $dom->createElement('workflow');

        $metaAttributes = $this->getMetaAttributes();
        $metaElementBase = $dom->createElement('meta');
        foreach ($metaAttributes as $metaAttributeName => $metaAttributeValue) {
            $metaAttributeNameEncode = XmlUtil::encode($metaAttributeName);
            $metaAttributeValueEnEncode = XmlUtil::encode($metaAttributeValue);

            $metaElement = clone $metaElementBase;
            $metaElement->setAttribute('name', $metaAttributeNameEncode);
            $metaValueElement = $dom->createTextNode($metaAttributeValueEnEncode);
            $metaElement->appendChild($metaValueElement);

            $descriptor->appendChild($metaElement);
        }

        $registers = $this->getRegisters();
        if ($registers->count() > 0) {
            $registersElement = $dom->createElement('registers');
            foreach ($registers as $register) {
                $registerElement = $register->writeXml($dom);
                $registersElement->appendChild($registerElement);
            }

            $descriptor->appendChild($registersElement);
        }


        $timerFunctions = $this->getTriggerFunctions();
        if (count($timerFunctions) > 0) {
            $timerFunctionsElement = $dom->createElement('trigger-functions');
            $timerFunctionElementBase = $dom->createElement('trigger-function');
            foreach ($timerFunctions as $timerFunctionId => $timerFunction) {
                $timerFunctionElement = clone $timerFunctionElementBase;
                $timerFunctionElement->setAttribute('id', $timerFunctionId);

                $functionElement = $timerFunction->writeXml($dom);

                $timerFunctionElement->appendChild($functionElement);

                $timerFunctionsElement->appendChild($timerFunctionElement);
            }
            $descriptor->appendChild($timerFunctionsElement);
        }


        $globalConditions = $this->getGlobalConditions();
        if (null !== $globalConditions) {
            $globalConditionsElement = $dom->createElement('global-conditions');
            $globalConditionElement = $globalConditions->writeXml($dom);
            $globalConditionsElement->appendChild($globalConditionElement);
            $descriptor->appendChild($globalConditionsElement);
        }


        $initialActionsElement = $dom->createElement('initial-actions');
        $initialActions = $this->getInitialActions();
        foreach ($initialActions as $initialAction) {
            $initialActionElement = $initialAction->writeXml($dom);
            $initialActionsElement->appendChild($initialActionElement);
        }
        $descriptor->appendChild($initialActionsElement);


        $globalActions = $this->getGlobalActions();
        if ($globalActions->count() > 0) {
            $globalActionsElement = $dom->createElement('global-actions');
            foreach ($globalActions as $globalAction) {
                $globalActionElement = $globalAction->writeXml($dom);

                $globalActionsElement->appendChild($globalActionElement);
            }

            $descriptor->appendChild($globalActionsElement);
        }

        $commonActions = $this->getCommonActions();
        if (count($commonActions) > 0) {
            $commonActionsElement = $dom->createElement('common-actions');
            foreach ($commonActions as $commonAction) {
                $commonActionElement = $commonAction->writeXml($dom);
                $commonActionsElement->appendChild($commonActionElement);
            }

            $descriptor->appendChild($commonActionsElement);
        }


        $stepsElement = $dom->createElement('steps');
        $steps = $this->getSteps();
        foreach ($steps as $step) {
            $stepElement = $step->writeXml($dom);
            $stepsElement->appendChild($stepElement);
        }

        $descriptor->appendChild($stepsElement);

        $splits = $this->getSplits();
        if ($splits->count() > 0) {
            $splitsElement = $dom->createElement('splits');
            foreach ($splits as $split) {
                $splitElement = $split->writeXml($dom);
                $splitsElement->appendChild($splitElement);
            }

            $descriptor->appendChild($splitsElement);
        }

        $joins = $this->getJoins();
        if ($joins->count() > 0) {
            $joinsElement = $dom->createElement('joins');
            foreach ($joins as $join) {
                $joinElement = $join->writeXml($dom);
                $joinsElement->appendChild($joinElement);
            }

            $descriptor->appendChild($joinsElement);
        }

        $dom->appendChild($descriptor);
        return $dom;
    }
404742
public function setHeader( $key, $value )
	{
		if( !in_array( $key, $this->headers ) )
			throw new InvalidArgumentException( "Unsupported Header '".$key."'" );
		$children	=& $this->tree->getChildren();
		$head		=& $children[0];
		$node		= new XML_DOM_Node( $key, $value );
		$head->addChild( $node );
	}
968417
public static function setDOMElementAttribute(DOMElement $element, $attribute, $value)
    {
        switch (gettype($value)) {
            case 'boolean':
                $element->setAttribute($attribute, ($value === true) ? 'true' : 'false');
                break;
            
            default:
                $element->setAttribute($attribute, '' . $value);
                break;
        }
    }
585827
public function process(\DOMDocument $xml)
    {
        $xpath = new \DOMXPath($xml);
        $nodes = $xpath->query(
            '/project/file/class/docblock/tag[@name="property"]'
            . '|/project/file/class/docblock/tag[@name="property-read"]'
            . '|/project/file/class/docblock/tag[@name="property-write"]'
        );

        /** @var \DOMElement $node */
        foreach ($nodes as $node) {
            $class = $node->parentNode->parentNode;

            $property = new \DOMElement('property');
            $class->appendChild($property);

            $property->setAttribute('final', 'false');
            $property->setAttribute('static', 'false');
            $property->setAttribute('visibility', 'public');
            $property->setAttribute('line', $node->getAttribute('line'));
            $property->appendChild(
                new \DOMElement('name', $node->getAttribute('variable'))
            );
            $property->appendChild(new \DOMElement('default'));

            $docblock = new \DOMElement('docblock');
            $property->appendChild($docblock);
            $docblock->appendChild(
                new \DOMElement('description', $node->getAttribute('description'))
            );
            $docblock->appendChild(new \DOMElement('long-description'));

            $var_tag = new \DOMElement('tag');
            $docblock->appendChild($var_tag);
            $var_tag->setAttribute('name', 'var');
            $var_tag->setAttribute('description', $node->getAttribute('description'));
            $var_tag->setAttribute('type', $node->getAttribute('type'));
            $var_tag->setAttribute('line', $node->getAttribute('line'));

            $var_tag_type = new \DOMElement('type', $node->getAttribute('type'));
            $var_tag->appendChild($var_tag_type);
            $var_tag_type->setAttribute('by_reference', 'false');

            $magic_tag = new \DOMElement('tag');
            $docblock->appendChild($magic_tag);
            $magic_tag->setAttribute('name', 'magic');
            $magic_tag->setAttribute('line', $node->getAttribute('line'));

            $node->parentNode->removeChild($node);
            $docblock->appendChild($node);
        }

        return $xml;
    }
746352
private static function getOrCreateNode(DOMElement $svg, $tagName, $value)
    {
        $node = $svg->getElementsByTagName($tagName);

        if ($node->length) {
            $node = $node->item(0);
            $node->nodeValue = $value;
            
            return $node;
        }

        $newNode = new DOMElement($tagName, $value);
        $svg->appendChild($newNode);

        return $newNode;
    }
703502
public static function make_input( $id, $key, $value = null, $type = 'text', $attr = array() ) 
	{
		$element = HTML::tag( 'input', array_merge( array( 
			'id' => $id, 
			'name' => $key, 
			'type' => $type 
		), $attr ));

		if ( !is_null( $value ) )
		{
			$element->value( _e( $value ) );
		}

		if ( !static::$builder_enabled )
		{
			 return $element;
		}

		return Builder::handle( 'form_input', $element );
	}
1139674
private function createTextNodeWithTypeAttribute(\DOMDocument $dom, \DOMNode $node, $value, $type = 'int')
    {
        $text = $dom->createTextNode($value);
        $attr = $dom->createAttribute('type');
        $attr->value = $type;

        $node->appendChild($text);
        $node->appendChild($attr);
    }