Пример #1
0
 public function isActive(NodeInterface $siteNode)
 {
     if ($siteModel = $this->siteRepository->findOneByNodeName($siteNode->getName())) {
         return $siteModel->isOnline();
     }
     throw new \RuntimeException('Could not find a site for the given site node', 1473366137);
 }
 private function renderNode(NodeInterface $node, ControllerContext $controllerContext)
 {
     $nodeInfo = ['contextPath' => $node->getContextPath(), 'name' => $node->getName(), 'identifier' => $node->getIdentifier(), 'nodeType' => $node->getNodeType()->getName(), 'properties' => $this->buildNodeProperties($node), 'label' => $node->getLabel(), 'isAutoCreated' => $node->isAutoCreated(), 'children' => []];
     if ($node->getNodeType()->isOfType('TYPO3.Neos:Document')) {
         $nodeInfo['uri'] = $this->uri($node, $controllerContext);
     }
     foreach ($node->getChildNodes() as $childNode) {
         /* @var NodeInterface $childNode */
         $nodeInfo['children'][] = ['contextPath' => $childNode->getContextPath(), 'nodeType' => $childNode->getNodeType()->getName()];
     }
     return $nodeInfo;
 }
 /**
  * Sets the best possible uriPathSegment for the given Node.
  * Will use an already set uriPathSegment or alternatively the node name as base,
  * then checks if the uriPathSegment already exists on the same level and appends a counter until a unique path segment was found.
  *
  * @param NodeInterface $node
  * @return void
  */
 public static function setUniqueUriPathSegment(NodeInterface $node)
 {
     if ($node->getNodeType()->isOfType('TYPO3.Neos:Document')) {
         $q = new FlowQuery(array($node));
         $q = $q->context(array('invisibleContentShown' => true, 'removedContentShown' => true, 'inaccessibleContentShown' => true));
         $possibleUriPathSegment = $initialUriPathSegment = !$node->hasProperty('uriPathSegment') ? $node->getName() : $node->getProperty('uriPathSegment');
         $i = 1;
         while ($q->siblings('[instanceof TYPO3.Neos:Document][uriPathSegment="' . $possibleUriPathSegment . '"]')->count() > 0) {
             $possibleUriPathSegment = $initialUriPathSegment . '-' . $i++;
         }
         $node->setProperty('uriPathSegment', $possibleUriPathSegment);
     }
 }
 /**
  * Generates a URI path segment for a given node taking it's language dimension into account
  *
  * @param NodeInterface $node Optional node to determine language dimension
  * @param string $text Optional text
  * @return string
  */
 public function generateUriPathSegment(NodeInterface $node = null, $text = null)
 {
     if ($node) {
         $text = $text ?: $node->getLabel() ?: $node->getName();
         $dimensions = $node->getContext()->getDimensions();
         if (array_key_exists('language', $dimensions) && $dimensions['language'] !== array()) {
             $locale = new Locale($dimensions['language'][0]);
             $language = $locale->getLanguage();
         }
     } elseif (strlen($text) === 0) {
         throw new Exception('Given text was empty.', 1457591815);
     }
     $text = $this->transliterationService->transliterate($text, isset($language) ? $language : null);
     return Transliterator::urlize($text);
 }
 /**
  * Move $node before, into or after $targetNode
  *
  * @param NodeInterface $node
  * @param NodeInterface $targetNode
  * @param string $position where the node should be added (allowed: before, into, after)
  * @return NodeInterface The same node given as first argument
  * @throws NodeException
  */
 public function move(NodeInterface $node, NodeInterface $targetNode, $position)
 {
     if (!in_array($position, array('before', 'into', 'after'), true)) {
         throw new NodeException('The position should be one of the following: "before", "into", "after".', 1296132542);
     }
     $designatedParentNode = $this->getDesignatedParentNode($targetNode, $position);
     // If we stay inside the same parent we basically just reorder, no rename needed or wanted.
     if ($designatedParentNode !== $node->getParent()) {
         $designatedNodePath = NodePaths::addNodePathSegment($designatedParentNode->getPath(), $node->getName());
         if ($this->nodeService->nodePathAvailableForNode($designatedNodePath, $node) === false) {
             $nodeName = $this->nodeService->generateUniqueNodeName($designatedParentNode->getPath(), $node->getName());
             if ($nodeName !== $node->getName()) {
                 // FIXME: This can be removed if $node->move* supports additionally changing the name of the node.
                 $node->setName($nodeName);
             }
         }
     }
     switch ($position) {
         case 'before':
             $node->moveBefore($targetNode);
             break;
         case 'into':
             $node->moveInto($targetNode);
             break;
         case 'after':
             $node->moveAfter($targetNode);
     }
     return $node;
 }
Пример #6
0
 /**
  * Returns TRUE if the given node is of the node type this filter expects.
  *
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node
  * @return boolean
  */
 public function matches(\TYPO3\TYPO3CR\Domain\Model\NodeInterface $node)
 {
     return $node->getName() === $this->nodeName;
 }
 /**
  * Collects metadata attributes used to allow editing of the node in the Neos backend.
  *
  * @param array $attributes
  * @param NodeInterface $node
  * @return array
  */
 protected function addGenericEditingMetadata(array $attributes, NodeInterface $node)
 {
     $attributes['typeof'] = 'typo3:' . $node->getNodeType()->getName();
     $attributes['about'] = $node->getContextPath();
     $attributes['data-node-_identifier'] = $node->getIdentifier();
     $attributes['data-node-__workspace-name'] = $node->getWorkspace()->getName();
     $attributes['data-node-__label'] = $node->getLabel();
     if ($node->getNodeType()->isOfType('TYPO3.Neos:ContentCollection')) {
         $attributes['rel'] = 'typo3:content-collection';
     }
     // these properties are needed together with the current NodeType to evaluate Node Type Constraints
     // TODO: this can probably be greatly cleaned up once we do not use CreateJS or VIE anymore.
     if ($node->getParent()) {
         $attributes['data-node-__parent-node-type'] = $node->getParent()->getNodeType()->getName();
     }
     if ($node->isAutoCreated()) {
         $attributes['data-node-_name'] = $node->getName();
         $attributes['data-node-_is-autocreated'] = 'true';
     }
     if ($node->getParent() && $node->getParent()->isAutoCreated()) {
         $attributes['data-node-_parent-is-autocreated'] = 'true';
         // we shall only add these properties if the parent is actually auto-created; as the Node-Type-Switcher in the UI relies on that.
         $attributes['data-node-__parent-node-name'] = $node->getParent()->getName();
         $attributes['data-node-__grandparent-node-type'] = $node->getParent()->getParent()->getNodeType()->getName();
     }
     return $attributes;
 }
 /**
  * Traverses through the tree starting at the given root node and sets the uriPathSegment property derived from
  * the node label.
  *
  * @param NodeInterface $node The node where the traversal starts
  * @param boolean $dryRun
  * @return void
  */
 protected function generateUriPathSegmentsForNode(NodeInterface $node, $dryRun)
 {
     if ((string) $node->getProperty('uriPathSegment') === '') {
         $name = $node->getLabel() ?: $node->getName();
         $uriPathSegment = Utility::renderValidNodeName($name);
         if ($dryRun === FALSE) {
             $node->setProperty('uriPathSegment', $uriPathSegment);
             $this->output->outputLine('Added missing URI path segment for "%s" (%s) => %s', array($node->getPath(), $name, $uriPathSegment));
         } else {
             $this->output->outputLine('Found missing URI path segment for "%s" (%s) => %s', array($node->getPath(), $name, $uriPathSegment));
         }
     }
     foreach ($node->getChildNodes('TYPO3.Neos:Document') as $childNode) {
         $this->generateUriPathSegmentsForNode($childNode, $dryRun);
     }
 }
 /**
  * @param NodeInterface $node
  * @param boolean $expand
  * @param array $children
  * @param boolean $hasChildNodes
  * @param boolean $matched
  * @return array
  */
 public function collectTreeNodeData(NodeInterface $node, $expand = TRUE, array $children = array(), $hasChildNodes = FALSE, $matched = FALSE)
 {
     $isTimedPage = FALSE;
     $now = new \DateTime();
     $now = $now->getTimestamp();
     $hiddenBeforeDateTime = $node->getHiddenBeforeDateTime();
     $hiddenAfterDateTime = $node->getHiddenAfterDateTime();
     if ($hiddenBeforeDateTime !== NULL && $hiddenBeforeDateTime->getTimestamp() > $now) {
         $isTimedPage = TRUE;
     }
     if ($hiddenAfterDateTime !== NULL) {
         $isTimedPage = TRUE;
     }
     $classes = array();
     if ($isTimedPage === TRUE && $node->isHidden() === FALSE) {
         array_push($classes, 'neos-timedVisibility');
     }
     if ($node->isHidden() === TRUE) {
         array_push($classes, 'neos-hidden');
     }
     if ($node->isHiddenInIndex() === TRUE) {
         array_push($classes, 'neos-hiddenInIndex');
     }
     if ($matched) {
         array_push($classes, 'neos-matched');
     }
     $uriBuilder = $this->controllerContext->getUriBuilder();
     $nodeType = $node->getNodeType();
     $nodeTypeConfiguration = $nodeType->getFullConfiguration();
     if ($node->getNodeType()->isOfType('TYPO3.Neos:Document')) {
         $uriForNode = $uriBuilder->reset()->setFormat('html')->setCreateAbsoluteUri(TRUE)->uriFor('show', array('node' => $node), 'Frontend\\Node', 'TYPO3.Neos');
     } else {
         $uriForNode = '#';
     }
     $label = $node->getLabel();
     $nodeTypeLabel = $node->getNodeType()->getLabel();
     $treeNode = array('key' => $node->getContextPath(), 'title' => $label, 'fullTitle' => $node->getProperty('title'), 'nodeTypeLabel' => $nodeTypeLabel, 'tooltip' => '', 'href' => $uriForNode, 'isFolder' => $hasChildNodes, 'isLazy' => $hasChildNodes && !$expand, 'nodeType' => $nodeType->getName(), 'isAutoCreated' => $node->isAutoCreated(), 'expand' => $expand, 'addClass' => implode(' ', $classes), 'name' => $node->getName(), 'iconClass' => isset($nodeTypeConfiguration['ui']) && isset($nodeTypeConfiguration['ui']['icon']) ? $nodeTypeConfiguration['ui']['icon'] : '', 'isHidden' => $node->isHidden());
     if ($hasChildNodes) {
         $treeNode['children'] = $children;
     }
     return $treeNode;
 }
Пример #10
0
 /**
  * Returns TRUE if the given node does not yet have the new name.
  *
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node
  * @return boolean
  */
 public function isTransformable(\TYPO3\TYPO3CR\Domain\Model\NodeInterface $node)
 {
     return $node->getName() !== $this->newName;
 }
Пример #11
0
 /**
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node
  * @param boolean $expand
  * @param array $children
  * @param string $contentTypeFilter
  * @return array
  */
 public function collectTreeNodeData(\TYPO3\TYPO3CR\Domain\Model\NodeInterface $node, $expand = TRUE, array $children = array())
 {
     $contentType = $node->getContentType()->getName();
     $classes = array(strtolower(str_replace(array('.', ':'), array('_', '-'), $contentType)));
     if ($node->isHidden() === TRUE) {
         array_push($classes, 'hidden');
     }
     if ($node->isHiddenInIndex() === TRUE) {
         array_push($classes, 'hiddenInIndex');
     }
     $uriBuilder = $this->controllerContext->getUriBuilder();
     $hasChildNodes = $children !== array() ? TRUE : FALSE;
     $contentType = $node->getContentType()->getName();
     $treeNode = array('key' => $node->getContextPath(), 'title' => $node->getContentType() === 'TYPO3.Phoenix.ContentTypes:Page' ? $node->getProperty('title') : $node->getLabel(), 'href' => $uriBuilder->reset()->setFormat('html')->setCreateAbsoluteUri(TRUE)->uriFor('show', array('node' => $node), 'Frontend\\Node', 'TYPO3.TYPO3', ''), 'isFolder' => $hasChildNodes, 'isLazy' => $hasChildNodes && !$expand, 'contentType' => $contentType, 'expand' => $expand, 'addClass' => implode(' ', $classes), 'name' => $node->getName());
     if ($hasChildNodes) {
         $treeNode['children'] = $children;
     }
     return $treeNode;
 }