Exports the given Nodes into the XML structure, contained in <nodes> </nodes> tags.

@param array $nodeDataList The nodes to export
@return void The result is written directly into $this->xmlWriter
189519
protected function exportNodeDataList(array &$nodeDataList)
    {
        $this->xmlWriter->startElement('nodes');
        $this->xmlWriter->writeAttribute('formatVersion', self::SUPPORTED_FORMAT_VERSION);

        $nodesStack = [];
        foreach ($nodeDataList as $nodeData) {
            $this->exportNodeData($nodeData, $nodesStack);
        }

        // Close remaining <node> tags according to the stack:
        while (array_pop($nodesStack)) {
            $this->xmlWriter->endElement();
        }

        $this->xmlWriter->endElement();
    }
298508
protected function childrenAsArray($nodeList)
	{
		$result = array();
		if (! is_object($nodeList))
		{
			return $result;
		}

		if (! ($nodeList instanceof DOMNodeList))
		{
			return $result;
		}

		for ($i = 0; $i < $nodeList->length; $i++)
		{
			$result []= $nodeList->item($i);
		}

		return $result;
	}
564416
static function appendSiblingsNodeIDs( &$nodeList, &$nodeIDList )
    {
        $params = array( 'Depth' => 1,
                         'AsObject' => false );
        foreach ( $nodeList as $node )
        {
            $siblingNodeList = eZContentObjectTreeNode::subTreeByNodeID( $params, $node->attribute( 'parent_node_id' ) );
            if ( count( $siblingNodeList ) > 0 )
            {
                foreach ( array_keys( $siblingNodeList ) as $siblingKey )
                {
                    $nodeIDList[] = $siblingNodeList[$siblingKey]['node_id'];
                }
            }
        }
    }
573889
public function execute(NodeData $nodeData, array $transformationConfigurations)
    {
        $transformationConjunction = $this->buildTransformationConjunction($transformationConfigurations);
        foreach ($transformationConjunction as $transformation) {
            if ($transformation->isTransformable($nodeData)) {
                $transformation->execute($nodeData);
            }
        }
    }
748527
public static function nodelist_to_array( \DOMNodeList $list ) {
		$out = [];

		foreach ( $list as $node ) {
			$out[ \spl_object_hash( $node ) ] = $node;
		}

		return $out;
	}
1200661
public function exportThemeHook($xml, $zipArchive, $themeId)
	{
		$xpath = new \DOMXPath($xml);
		$tlModule = $xpath->query('/tables/table[@name = \'tl_module\']')->item(0);

		if (!$tlModule) {
			return;
		}

		static::reloadConfig();

		foreach ($tlModule->childNodes as $row) {

			if (strtolower($row->nodeName) !== 'row') {
				continue;
			}

			$type = $xpath->query('field[@name = \'type\']', $row)->item(0);
			if (!$type || substr($type->nodeValue, 0, 5) !== 'rsce_') {
				continue;
			}

			$rsceData = $xpath->query('field[@name = \'rsce_data\']', $row)->item(0);
			if (!$rsceData) {
				continue;
			}

			$rsceDataConverted = $this->convertDataForImportExport(
				false,
				$type->nodeValue,
				$rsceData->nodeValue
			);

			if (
				!$rsceDataConverted
				|| strtolower($rsceDataConverted) === 'null'
				|| $rsceDataConverted === '{}'
				|| $rsceDataConverted === '[]'
				|| $rsceDataConverted === $rsceData->nodeValue
			) {
				continue;
			}

			$rsceData->nodeValue = $rsceDataConverted;

		}
	}
622775
public function execute(NodeData $nodeData)
    {
        $dimensions = $nodeData->getDimensions();
        if ($dimensions !== []) {
            $hasChanges = false;
            $newDimensions  = [];
            foreach ($dimensions as $dimension) {
                /** @var NodeDimension $dimension */
                if ($dimension->getName() === $this->oldDimensionName) {
                    $dimension = new NodeDimension($dimension->getNodeData(), $this->newDimensionName, $dimension->getValue());
                    $hasChanges = true;
                } else {
                    $dimension = new NodeDimension($dimension->getNodeData(), $dimension->getName(), $dimension->getValue());
                }
                $newDimensions[] = $dimension;
            }
            if ($hasChanges) {
                $nodeData->setDimensions($newDimensions);
            }
        }
    }
564485
protected function exportSite(Site $site, $nodeTypeFilter)
    {
        /** @var ContentContext $contentContext */
        $contentContext = $this->contextFactory->create([
            'currentSite' => $site,
            'invisibleContentShown' => true,
            'inaccessibleContentShown' => true
        ]);

        $siteNode = $contentContext->getCurrentSiteNode();

        $this->xmlWriter->startElement('site');
        $this->xmlWriter->writeAttribute('name', $site->getName());
        $this->xmlWriter->writeAttribute('state', $site->getState());
        $this->xmlWriter->writeAttribute('siteResourcesPackageKey', $site->getSiteResourcesPackageKey());
        $this->xmlWriter->writeAttribute('siteNodeName', $siteNode->getName());

        $this->nodeExportService->export($siteNode->getPath(), $contentContext->getWorkspaceName(), $this->xmlWriter, false, false, $this->resourcesPath, $nodeTypeFilter);

        $this->xmlWriter->endElement();
    }
281990
public function execute(NodeData $node)
    {
        $node->setProperty($this->propertyName, strip_tags($node->getProperty($this->propertyName)));
    }
363703
protected function _toArray(DOMNodeList $nodes) {
		$array = array();
		foreach ($nodes as $node) {
			if ($node->nodeType != XML_ELEMENT_NODE) {
				continue;
			}
			if ($node->hasAttributes()) { // deep
				if ($node->tagName == 'error') {
					$array = array(
						'id' => $node->getAttribute('id'),
						'code' => $node->getAttribute('code'),
						'auxCode' => $node->getAttribute('auxCode'),
						'message' => $node->nodeValue
					);
				} else {
					// in the case of custom charges, use the id for the key
					if ($node->hasAttribute('code') && $node->getAttribute('code')) {
						$key = $node->getAttribute('code');

						$tmpArr = array();

						if ($node->hasAttribute('id')) {
							$tmpArr = array(
								'id' => $node->getAttribute('id')
							);
						}
						$tmpArr = $tmpArr + array('code'=>$key);

						// charges need to be a nested array since there can be multiple charges with the same charge code
						if ($node->tagName == 'charge') {
							$array[$key][] = $tmpArr;
						} else {
							$array[$key] = $tmpArr;
						}

						unset($tmpArr);

					} else {
						$key = $node->getAttribute('id');
						$array[$key] = array('id' => $node->getAttribute('id'));
					}
					$array[$key] = $array[$key] + $this->_toArray($node->childNodes);
				}
			} else {
				if ($node->tagName == 'errors') {
					$array[$node->tagName][] = $this->_toArray($node->childNodes);
				} else if ($node->childNodes->length > 1) { // sub array
					$array[$node->tagName] = $this->_toArray($node->childNodes);
				} else {
					$array[$node->tagName] = $node->nodeValue;
				}
			}
		}
		return $array;
	}
1214696
public function exportTables ($xml, $objArchive, $objThemeId)
	{

		// Find tables node
		$tables = $xml->getElementsByTagName('tables')[0];
		
		// Add the table (elements)
		$table = $xml->createElement('table');
		$table->setAttribute('name', 'tl_elements');
		$table = $tables->appendChild($table);

		// Load the DCA
		$this->loadDataContainer('tl_elements');

		// Get the order fields
		$objDcaExtractor = \DcaExtractor::getInstance('tl_elements');
		$arrOrder = $objDcaExtractor->getOrderFields();

		// Get all content blocks
		$objContentBlocks = $this->Database->prepare("SELECT * FROM tl_elements WHERE pid=?")
										->execute($objThemeId);

		// Add the rows
		while ($objContentBlocks->next())
		{
			$this->addDataRow($xml, $table, $objContentBlocks->row(), $arrOrder);
		}

		$objContentBlocks->reset();
		
		
		// Add the child table (pattern)
		$table = $xml->createElement('table');
		$table->setAttribute('name', 'tl_pattern');
		$table = $tables->appendChild($table);

		// Load the DCA
		$this->loadDataContainer('tl_pattern');

		// Get the order fields
		$objDcaExtractor = \DcaExtractor::getInstance('tl_pattern');
		$arrOrder = $objDcaExtractor->getOrderFields();

		// Add pattern recursively
		while ($objContentBlocks->next())
		{
			$this->addPatternData($xml, $table, $arrOrder, $objContentBlocks->id);
		}
	}
1039283
public static function generateValidXmlFromArray($array, $nodeBlock = 'nodes', $nodeNames = [])
    {
        if (is_string($nodeNames)) {
            $nodeNames = ['__global' => $nodeNames];
        }
        if (!isset($nodeNames['__global'])) {
            $nodeNames['__global'] = current($nodeNames);
        }
        $xml = '<?xml version="1.0" encoding="UTF-8" ?>';
        $xml .= '<' . $nodeBlock . '>';
        $xml .= self::generateXmlFromArray($array, $nodeNames, $nodeBlock);
        $xml .= '</' . $nodeBlock . '>';

        return $xml;
    }
85550
protected function exportNodes($oids) {
    // Export starts from root oids and iterates over all children.
    // On every call we have to decide what to do:
    // - If there is an iterator stored in the session we are inside a tree and continue iterating (_NODES_PER_CALL nodes)
    //   until the iterator finishes
    // - If the oids array holds one value!=null this is assumed to be an root oid and a new iterator is constructed
    // - If there is no iterator and no oid given, we return

    $session = $this->getSession();
    $persistenceFacade = $this->getPersistenceFacade();
    $message = $this->getMessage();

    // get document definition
    $docFile = $this->getDownloadFile();
    $nodesPerCall = $this->getRequestValue('nodesPerCall');
    $cacheSection = $this->getRequestValue('cacheSection');

    // check for iterator in session
    $iterator = PersistentIterator::load($this->ITERATOR_ID_VAR, $persistenceFacade, $session);
    // no iterator but oid given, start with new root oid
    if ($iterator == null && sizeof($oids) > 0 && $oids[0] != null) {
      $iterator = new PersistentIterator($this->ITERATOR_ID_VAR, $persistenceFacade, $session, $oids[0]);
    }
    // no iterator, no oid, finish
    if ($iterator == null) {
      $this->addWorkPackage($message->getText('Finish'), 1, [null], 'finishExport');
      return;
    }

    // process nodes
    $fileHandle = fopen($docFile, "a");
    $counter = 0;
    while ($iterator->valid() && $counter < $nodesPerCall) {
      // write node
      $this->writeNode($fileHandle, $iterator->current(), $iterator->key()+1);
      $iterator->next();
      $counter++;
    }
    $this->endTags($fileHandle, 0);
    fclose($fileHandle);

    // decide what to do next
    $rootOIDs = $this->cache->get($cacheSection, self::CACHE_KEY_ROOT_OIDS);
    if (!$iterator->valid() && sizeof($rootOIDs) > 0) {
      // if the current iterator is finished, reset the iterator and proceed with the next root oid
      $nextOID = array_shift($rootOIDs);
      // store remaining root oids in the cache
      $this->cache->put($cacheSection, self::CACHE_KEY_ROOT_OIDS, $rootOIDs);
      // delete iterator to start with new root oid
      PersistentIterator::reset($this->ITERATOR_ID_VAR, $session);

      $name = $message->getText('Exporting tree: start with %0%', [$nextOID]);
      $this->addWorkPackage($name, 1, [$nextOID], 'exportNodes');
    }
    elseif ($iterator->valid()) {
      // proceed with current iterator
      $iterator->save();

      $name = $message->getText('Exporting tree: continue with %0%', [$iterator->current()]);
      $this->addWorkPackage($name, 1, [null], 'exportNodes');
    }
    else {
      // finish
      $this->addWorkPackage($message->getText('Finish'), 1, [null], 'finishExport');
    }
  }
1152501
public function saveNode(NodePath $nodePath, array $node)
    {
        $this->data = $this->storeNode($nodePath, $this->data, $node);
    }
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;
    }
1135277
public function execute(NodeData $node)
    {
        $nodeType = $this->nodeTypeManager->getNodeType($this->newType);
        $node->setNodeType($nodeType);
    }
75375
protected function writeArrayItem(\XMLWriter $xmlWriter, array $itemArray, $elementName)
    {
        Validate::isString($elementName, 'elementName');

        foreach ($itemArray as $itemInstance) {
            $xmlWriter->startElementNS(
                'atom',
                $elementName,
                Resources::ATOM_NAMESPACE
            );
            $itemInstance->writeInnerXml($xmlWriter);
            $xmlWriter->endElement();
        }
    }