/**
  *
  * Returns an array representation of a PHPCR node
  *
  * @param string $name
  * @param \PHPCR\NodeInterface $node
  *
  * @return array
  */
 private function nodeToArray($name, $node)
 {
     $has_children = $node->hasNodes();
     return array('data' => $name, 'attr' => array('id' => $node->getPath(), 'url_safe_id' => substr($node->getPath(), 1), 'rel' => 'node'), 'state' => $has_children ? 'closed' : null);
 }
Esempio n. 2
0
 /**
  * Recursively output node and all its children into the file in the
  * document view format
  *
  * @param NodeInterface              $node       the node to output
  * @param NamespaceRegistryInterface $ns         The namespace registry to export namespaces too
  * @param resource                   $stream     the resource to write data out to
  * @param boolean                    $skipBinary A boolean governing whether binary properties
  *      are to be serialized.
  * @param boolean $noRecurse A boolean governing whether the subgraph at
  *      absPath is to be recursed.
  * @param boolean $root 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}>");
     }
 }
 public function testHasNodesTrue()
 {
     $this->assertTrue($this->node->hasNodes());
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  */
 public function hasNodes()
 {
     return $this->node->hasNodes();
 }
 public function formatNodeName(NodeInterface $node)
 {
     return sprintf('%s%s', $node->getName(), $node->hasNodes() ? '/' : '');
 }