Jackalope\ImportExport\ImportExport::exportDocumentViewRecursive PHP Method

exportDocumentViewRecursive() private static method

Recursively output node and all its children into the file in the document view format
private static exportDocumentViewRecursive ( PHPCR\NodeInterface $node, PHPCR\NamespaceRegistryInterface $ns, resource $stream, boolean $skipBinary, boolean $noRecurse, boolean $root = false )
$node PHPCR\NodeInterface the node to output
$ns PHPCR\NamespaceRegistryInterface The namespace registry to export namespaces too
$stream resource the resource to write data out to
$skipBinary boolean A boolean governing whether binary properties are to be serialized.
$noRecurse boolean A boolean governing whether the subgraph at absPath is to be recursed.
$root boolean Whether this is the root node of the resulting document, meaning the namespace declarations have to be included in it.
    private static function exportDocumentViewRecursive(NodeInterface $node, NamespaceRegistryInterface $ns, $stream, $skipBinary, $noRecurse, $root = false)
    {
        $nodename = self::escapeXmlName($node->getName());
        fwrite($stream, "<{$nodename}");
        if ($root) {
            self::exportNamespaceDeclarations($ns, $stream);
        }
        foreach ($node->getProperties() as $name => $property) {
            /** @var $property \PHPCR\PropertyInterface */
            if ($property->isMultiple()) {
                // skip multiple properties. jackrabbit does this too. cheap but whatever. use system view for a complete export
                continue;
            }
            if (PropertyType::BINARY === $property->getType()) {
                if ($skipBinary) {
                    continue;
                }
                $value = base64_encode($property->getString());
            } else {
                $value = htmlspecialchars($property->getString());
            }
            fwrite($stream, ' ' . self::escapeXmlName($name) . '="' . $value . '"');
        }
        if ($noRecurse || !$node->hasNodes()) {
            fwrite($stream, '/>');
        } else {
            fwrite($stream, '>');
            foreach ($node as $child) {
                if (!($child->getDepth() === 1 && NodeHelper::isSystemItem($child))) {
                    self::exportDocumentViewRecursive($child, $ns, $stream, $skipBinary, $noRecurse);
                }
            }
            fwrite($stream, "</{$nodename}>");
        }
    }