/**
  * Resolves a shortcut node to the target. The return value can be
  *
  * * a NodeInterface instance if the target is a node or a node:// URI
  * * a string (in case the target is a plain text URI or an asset:// URI)
  * * NULL in case the shortcut cannot be resolved
  *
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node
  * @return NodeInterface|string|NULL
  */
 public function resolveShortcutTarget(NodeInterface $node)
 {
     $infiniteLoopPrevention = 0;
     while ($node->getNodeType()->isOfType('TYPO3.Neos:Shortcut') && $infiniteLoopPrevention < 50) {
         $infiniteLoopPrevention++;
         switch ($node->getProperty('targetMode')) {
             case 'selectedTarget':
                 $target = $node->getProperty('target');
                 if ($this->linkingService->hasSupportedScheme($target)) {
                     $targetObject = $this->linkingService->convertUriToObject($target, $node);
                     if ($targetObject instanceof NodeInterface) {
                         $node = $targetObject;
                     } elseif ($targetObject instanceof AssetInterface) {
                         return $this->linkingService->resolveAssetUri($target);
                     }
                 } else {
                     return $target;
                 }
                 break;
             case 'parentNode':
                 $node = $node->getParent();
                 break;
             case 'firstChildNode':
             default:
                 $childNodes = $node->getChildNodes('TYPO3.Neos:Document');
                 if ($childNodes !== array()) {
                     $node = reset($childNodes);
                 } else {
                     return null;
                 }
         }
     }
     return $node;
 }
Пример #2
0
 /**
  * Increase read counter of the node by one
  *
  * @param NodeInterface $node Node to increase the read counter for
  *
  * @throws BadRequestException
  * @return mixed[]
  */
 public function trackAction(NodeInterface $node)
 {
     // we can only count pages that include the mixin
     if ($node->getNodeType()->isOfType('Futjikato.ReadCounter:CounterMixin')) {
         $node->setProperty('readcounter', $node->getProperty('readcounter') + 1);
         /**
          * Action changes data but is accessible via GET. this issues a error if we do not manually
          * persists the object in the persistence manager
          */
         $this->persistenceManager->persistAll();
         // by default the flow JSON view uses the 'value' variable
         $this->view->assign('value', array('readcounter' => $node->getProperty('readcounter')));
     } else {
         throw new BadRequestException('Node does not contain Futjikato.ReadCounter:CounterMixin.');
     }
 }
Пример #3
0
 /**
  * Fetch thumb url from Vimeo API
  *
  * @param NodeInterface $node
  * @return void
  */
 public function fetchVimeoThumb(NodeInterface $node)
 {
     $fullVideo = $node->getProperty('fullVideo');
     $fullVideoThumb = $node->getProperty('fullVideoThumb');
     if ($fullVideo && !$fullVideoThumb) {
         $url = 'https://vimeo.com/api/oembed.json?url=http%3A//vimeo.com/' . $fullVideo;
         $content = file_get_contents($url);
         $json = json_decode($content, true);
         $node->setProperty('fullVideoThumb', $json['thumbnail_url']);
     } else {
         if (!$fullVideo && $fullVideoThumb) {
             // Clear thumb, if Vimeo video is gone. Useful for reloading thumb.
             $node->setProperty('fullVideoThumb', '');
         }
     }
 }
Пример #4
0
 /**
  * Returns TRUE if the given node has the property and the value is not empty.
  *
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node
  * @return boolean
  */
 public function matches(\TYPO3\TYPO3CR\Domain\Model\NodeInterface $node)
 {
     if ($node->hasProperty($this->propertyName)) {
         $propertyValue = $node->getProperty($this->propertyName);
         return !empty($propertyValue);
     }
     return FALSE;
 }
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation
  * @return mixed|null if the operation is final, the return value
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     $imagePropertyName = $arguments[0];
     if ($this->contextNode->hasProperty($imagePropertyName)) {
         $image = $this->contextNode->getProperty($imagePropertyName);
         if ($image instanceof ImageVariant) {
             $image = $image->getOriginalAsset();
         }
         if ($image instanceof Image) {
             $identifier = $image->getIdentifier();
             $nodeData = $this->metaDataRepository->findOneByAssetIdentifier($identifier, $this->contextNode->getContext()->getWorkspace());
             if ($nodeData instanceof NodeData) {
                 return $this->nodeFactory->createFromNodeData($nodeData, $this->contextNode->getContext());
             }
         }
     }
     return null;
 }
 /**
  * Sets default node property values on the given node.
  *
  * @param NodeInterface $node
  * @return void
  */
 public function setDefaultValues(NodeInterface $node)
 {
     $nodeType = $node->getNodeType();
     foreach ($nodeType->getDefaultValuesForProperties() as $propertyName => $defaultValue) {
         if (trim($node->getProperty($propertyName)) === '') {
             $node->setProperty($propertyName, $defaultValue);
         }
     }
 }
 /**
  * @param NodeInterface $profileNode
  * @return string
  */
 public function getDisplayName(NodeInterface $profileNode)
 {
     $return = '';
     if ($profileNode->getProperty('firstName')) {
         $return .= ucfirst($profileNode->getProperty('firstName'));
     }
     if ($profileNode->getProperty('lastName')) {
         $lastNameParts = explode(' ', $profileNode->getProperty('lastName'));
         $return .= ' ';
         $lastName = ucfirst(end($lastNameParts));
         array_pop($lastNameParts);
         $lastNameParts[] = $lastName;
         foreach ($lastNameParts as $namePart) {
             $return .= $namePart . ' ';
         }
     }
     return $return;
 }
Пример #8
0
 /**
  * Extract comments and deserialize them
  *
  * @param NodeInterface|NodeData $nodeOrNodeData
  * @return array
  */
 protected function extractComments($nodeOrNodeData)
 {
     if ($nodeOrNodeData->hasProperty('comments')) {
         $comments = $nodeOrNodeData->getProperty('comments');
         if (is_string($comments) && strlen($comments) > 0) {
             return json_decode($comments, TRUE);
         }
     }
     return array();
 }
 /**
  * Check if user is already registered for an event.
  *
  * @param NodeInterface $event
  * @param NodeInterface $person
  *
  * @return string
  */
 public function render(NodeInterface $event, NodeInterface $person = null)
 {
     $authenticationProviderName = $this->authenticationManagerInterface->getSecurityContext()->getAccount()->getAuthenticationProviderName();
     if ($authenticationProviderName === 'Typo3BackendProvider') {
         return $this->renderElseChild();
     }
     if ($person === null) {
         $person = $this->profileService->getCurrentPartyProfile();
     }
     $eventAttendees = $event->getProperty('attendees') ? $event->getProperty('attendees') : [];
     $eventAttendeesIdentifiers = [];
     foreach ($eventAttendees as $eventAttendee) {
         /* @var NodeInterface $eventAttendee */
         $eventAttendeesIdentifiers[] = $eventAttendee->getIdentifier();
     }
     if (in_array($person->getIdentifier(), $eventAttendeesIdentifiers, true)) {
         return $this->renderThenChild();
     }
     return $this->renderElseChild();
 }
 /**
  * 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);
     }
 }
Пример #11
0
 /**
  * @param NodeInterface $article
  * @return array
  */
 protected function buildSingleItemJson(NodeInterface $article)
 {
     $contentCollection = $article->getChildNodes('TYPO3.Neos:ContentCollection')[0];
     $articleBody = '';
     if ($contentCollection instanceof NodeInterface) {
         $content = $contentCollection->getChildNodes();
         if (is_array($content) && array_key_exists(0, $content)) {
             foreach ($content as $node) {
                 /** @var NodeInterface $node */
                 if ($node->getNodeType()->getName() === 'TYPO3.Neos.NodeTypes:Text' || $node->getNodeType()->getName() === 'TYPO3.Neos.NodeTypes:TextWithImage') {
                     $articleBody .= $node->getProperty('text');
                 }
             }
         }
     }
     $thumbnailConfiguration = new ThumbnailConfiguration(125, 125, 125, 125, true, true, false);
     $detailConfiguration = new ThumbnailConfiguration(300, 300, 200, 200, true, true, false);
     /** @var Image $image */
     $image = $article->getProperty('headerImage');
     $properties = ['@context' => 'http://schema.org', '@type' => 'Article', '@id' => $article->getIdentifier(), 'id' => $article->getIdentifier(), 'shortIdentifier' => explode('-', $article->getIdentifier())[0], 'title' => $article->getProperty('title'), 'articleBody' => $articleBody, 'publicationDate' => $article->getProperty('publicationDate')->format('D M d Y H:i:s O'), 'teaser' => $article->getProperty('article'), 'listImage' => $this->assetService->getThumbnailUriAndSizeForAsset($image, $thumbnailConfiguration)['src'], 'image' => $this->assetService->getThumbnailUriAndSizeForAsset($image, $detailConfiguration)['src']];
     $this->processProperties($properties);
     return $properties;
 }
 /**
  * Send a new notification that a comment has been created
  *
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $commentNode The comment node
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $postNode The post node
  * @return void
  */
 public function sendNewCommentNotification(NodeInterface $commentNode, NodeInterface $postNode)
 {
     if ($this->settings['notifications']['to']['email'] === '') {
         return;
     }
     if (!class_exists('TYPO3\\SwiftMailer\\Message')) {
         $this->systemLogger->logException(new \TYPO3\Flow\Exception('The package "TYPO3.SwiftMailer" is required to send notifications!', 1359473932));
         return;
     }
     try {
         $mail = new Message();
         $mail->setFrom(array($commentNode->getProperty('emailAddress') => $commentNode->getProperty('author')))->setTo(array($this->settings['notifications']['to']['email'] => $this->settings['notifications']['to']['name']))->setSubject('New comment on blog post "' . $postNode->getProperty('title') . '"' . ($commentNode->getProperty('spam') ? ' (SPAM)' : ''))->setBody($commentNode->getProperty('text'))->send();
     } catch (\Exception $e) {
         $this->systemLogger->logException($e);
     }
 }
Пример #13
0
 /**
  * Generate CSS styles from spacing* properties
  *
  * @param NodeInterface $node
  * @return string
  */
 public function generateCss(NodeInterface $node)
 {
     $css = '';
     foreach (self::PROPERTY_MAPPING as $key => $cssProperty) {
         // Get value, also check for `0` values using strlen()
         if (($value = $node->getProperty($key)) || strlen($value)) {
             // if numeric value is provided, add default unit (e.g. px)
             // but don't add it to zero values
             if ($value && is_numeric($value)) {
                 $value .= self::DEFAULT_UNIT;
             }
             $css .= "{$cssProperty}:{$value};";
         }
     }
     return $css;
 }
 /**
  * Returns the plugin namespace that will be prefixed to plugin parameters in URIs.
  * By default this is <plugin_class_name>
  *
  * @return string
  */
 protected function getPluginNamespace()
 {
     if ($this->getArgumentNamespace() !== NULL) {
         return $this->getArgumentNamespace();
     }
     if ($this->node instanceof NodeInterface) {
         $nodeArgumentNamespace = $this->node->getProperty('argumentNamespace');
         if ($nodeArgumentNamespace !== NULL) {
             return $nodeArgumentNamespace;
         }
         $nodeArgumentNamespace = $this->node->getNodeType()->getName();
         $nodeArgumentNamespace = str_replace(':', '-', $nodeArgumentNamespace);
         $nodeArgumentNamespace = str_replace('.', '_', $nodeArgumentNamespace);
         $nodeArgumentNamespace = strtolower($nodeArgumentNamespace);
         return $nodeArgumentNamespace;
     }
     $argumentNamespace = str_replace(array(':', '.', '\\'), array('_', '_', '_'), $this->getPackage() . '_' . $this->getSubpackage() . '-' . $this->getController());
     $argumentNamespace = strtolower($argumentNamespace);
     return $argumentNamespace;
 }
 /**
  * Returns the rendered content of this plugin
  *
  * @return string The rendered content as a string
  * @throws StopActionException
  */
 public function evaluate()
 {
     $currentContext = $this->tsRuntime->getCurrentContext();
     $this->pluginViewNode = $currentContext['node'];
     /** @var $parentResponse Response */
     $parentResponse = $this->tsRuntime->getControllerContext()->getResponse();
     $pluginResponse = new Response($parentResponse);
     $pluginRequest = $this->buildPluginRequest();
     if ($pluginRequest->getControllerObjectName() === '') {
         $message = 'Master View not selected';
         if ($this->pluginViewNode->getProperty('plugin')) {
             $message = 'Plugin View not selected';
         }
         if ($this->pluginViewNode->getProperty('view')) {
             $message = 'Master View or Plugin View not found';
         }
         return $this->pluginViewNode->getContext()->getWorkspaceName() !== 'live' || $this->objectManager->getContext()->isDevelopment() ? '<p>' . $message . '</p>' : '<!-- ' . $message . '-->';
     }
     $this->dispatcher->dispatch($pluginRequest, $pluginResponse);
     return $pluginResponse->getContent();
 }
 private function sendNewsletter(NodeInterface $node, $previewEmail = NULL, $languageKey = NULL, array $languageConfiguration = NULL)
 {
     // The Receiver Group association is specified in each individual node dimension,
     // but as the user submitted it in a certain Node Dimension, we're using *exactly* this
     // $receiverGroup which the user has submitted.
     /* @var $receiverGroup \Sandstorm\Newsletter\Domain\Model\ReceiverGroup */
     $receiverGroup = $this->receiverGroupRepository->findByIdentifier($node->getProperty('receiverGroup'));
     if ($receiverGroup == NULL) {
         // TODO: log!
         return;
     }
     $context = ['workspaceName' => 'live'];
     if ($languageKey) {
         $context['dimensions'] = array('language' => $languageConfiguration['values']);
         $context['targetDimensions'] = array('language' => reset($languageConfiguration['values']));
     }
     /* @var $nodeInCorrectDimension NodeInterface */
     $nodeInCorrectDimension = (new FlowQuery(array($node)))->context($context)->get(0);
     if ($nodeInCorrectDimension == NULL) {
         // Skip un-existing nodes
         return;
     }
     $this->newsletterRenderingView->assign('value', $nodeInCorrectDimension);
     $html = $this->newsletterRenderingView->render();
     $html = $this->styleInliningService->inlineStyles($html);
     $newsletter = new Newsletter();
     $newsletterIdentifier = $node->getIdentifier();
     if ($languageKey) {
         $newsletterIdentifier .= '_' . $languageKey;
     }
     if ($previewEmail) {
         $newsletterIdentifier .= uniqid('__', true);
     }
     $newsletter->setIdentifier($newsletterIdentifier);
     $newsletter->setHtmlContent($html);
     $newsletter->setSubject($nodeInCorrectDimension->getProperty('subjectTemplate'));
     if ($previewEmail !== NULL) {
         $newsletter->setReceiverEmailTemplate($previewEmail);
         $newsletter->setReceiverGroup($receiverGroup->singlePersonReceiverGroup());
     } else {
         $newsletter->setReceiverEmailTemplate($nodeInCorrectDimension->getProperty('receiverEmailTemplate'));
         $newsletter->setReceiverGroup($receiverGroup);
     }
     $newsletter->setReceiverNameTemplate($nodeInCorrectDimension->getProperty('receiverNameTemplate'));
     $newsletter->setSenderEmailTemplate($nodeInCorrectDimension->getProperty('senderEmailTemplate'));
     $newsletter->setSenderNameTemplate($nodeInCorrectDimension->getProperty('senderNameTemplate'));
     $newsletter->setReplyToEmailTemplate($nodeInCorrectDimension->getProperty('replyToEmailTemplate'));
     $newsletter->setNewsletterLink($this->linkingService->createNodeUri($this->getControllerContext(), $nodeInCorrectDimension, NULL, NULL, TRUE));
     $unsubscribeListIdentifier = null;
     if ($receiverGroup->getUnsubscribeList()) {
         $unsubscribeListIdentifier = $this->persistenceManager->getIdentifierByObject($receiverGroup->getUnsubscribeList());
     }
     $newsletter->setUnsubscribeLink($this->uriBuilder->reset()->setCreateAbsoluteUri(TRUE)->uriFor('unsubscribe', array('unsubscribeList' => $unsubscribeListIdentifier), 'Unsubscribe', 'Sandstorm.Newsletter'));
     $this->newsletterSendingService->sendNewsletter($newsletter, $languageKey);
 }
 /**
  * Renders a request path based on the "uriPathSegment" properties of the nodes leading to the given node.
  *
  * @param NodeInterface $siteNode Top level node, corresponds to the top level of the request path
  * @param NodeInterface $node The node where the generated path should lead to
  * @return string A relative request path
  * @throws Exception\MissingNodePropertyException if the given node doesn't have a "uriPathSegment" property set
  */
 protected function getRequestPathByNode(NodeInterface $siteNode, NodeInterface $node)
 {
     if ($siteNode === $node) {
         return '';
     }
     $requestPathSegments = array();
     while ($siteNode !== $node && $node instanceof NodeInterface) {
         if (!$node->hasProperty('uriPathSegment')) {
             throw new Exception\MissingNodePropertyException(sprintf('Missing "uriPathSegment" property for node "%s". Nodes can be migrated with the "flow node:repair" command.', $node->getPath()), 1415020326);
         }
         $pathSegment = $node->getProperty('uriPathSegment');
         $requestPathSegments[] = $pathSegment;
         $node = $node->getParent();
     }
     return implode('/', array_reverse($requestPathSegments));
 }
Пример #18
0
 /**
  * Renames the configured property to the new name.
  *
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node
  * @return void
  */
 public function execute(\TYPO3\TYPO3CR\Domain\Model\NodeInterface $node)
 {
     $node->setProperty($this->newPropertyName, $node->getProperty($this->oldPropertyName));
     $node->removeProperty($this->oldPropertyName);
 }
Пример #19
0
 /**
  * @param NodeInterface $systemNode
  * @param $identifierPathName
  * @param $identifierPath
  * @return array|null
  */
 protected function resolveIdentifierValues(NodeInterface $systemNode, $identifierPathName, $identifierPath)
 {
     $identifierValues = [$this->formatCacheEntryIdentifier($systemNode->getNodeType()->getConfiguration('systemNode.nodeTypeIdentifier') ?: $systemNode->getNodeType()->getName()), $this->formatCacheEntryIdentifier($identifierPathName)];
     foreach ($identifierPath as $propertyName => $active) {
         $identifierValue = $active ? $this->formatCacheEntryIdentifier($systemNode->getProperty($propertyName)) : null;
         if (!$identifierValue) {
             // Don't save node's identifier if it cannot be completely resolved
             return null;
         }
         $identifierValues[] = $identifierValue;
     }
     return $identifierValues;
 }
 /**
  * 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);
     }
 }
Пример #21
0
 /**
  * @param NodeInterface $event
  * @param NodeInterface $person
  *
  * @throws \Exception
  *
  * @return array
  */
 protected function getEventsAndPersonData(NodeInterface $event, NodeInterface $person)
 {
     if ($event->getNodeType()->getName() !== 'BJD.Events:Event' && $person->getNodeType()->getName() !== 'BuJitsuDo.Authentication:Person') {
         throw new \Exception('Not an event and/or person given', 12389172498.0);
     }
     if (!empty($person->getProperty('events'))) {
         $personEvents = $person->getProperty('events');
     } else {
         $personEvents = [];
     }
     $eventIdentifiers = [];
     if (!empty($event->getProperty('attendees'))) {
         $attendees = $event->getProperty('attendees');
     } else {
         $attendees = [];
     }
     $attendeeIdentifiers = [];
     foreach ($attendees as $attendee) {
         /* @var NodeInterface $attendee */
         $attendeeIdentifiers[] = $attendee->getIdentifier();
     }
     foreach ($personEvents as $personEvent) {
         /* @var NodeInterface $personEvent */
         $eventIdentifiers[] = $personEvent->getIdentifier();
     }
     return ['personEvents' => $personEvents, 'personEventsIdentifiers' => $eventIdentifiers, 'attendees' => $attendees, 'attendeeIdentifiers' => $attendeeIdentifiers];
 }
 /**
  * Strips tags on the value of the property to work on.
  *
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node
  * @return void
  */
 public function execute(\TYPO3\TYPO3CR\Domain\Model\NodeInterface $node)
 {
     $node->setProperty($this->propertyName, strip_tags($node->getProperty($this->propertyName)));
 }
 /**
  * Change the property on the given node.
  *
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node
  * @return void
  */
 public function execute(\TYPO3\TYPO3CR\Domain\Model\NodeInterface $node)
 {
     $currentPropertyValue = $node->getProperty($this->propertyName);
     $newValueWithReplacedCurrentValue = str_replace($this->currentValuePlaceholder, $currentPropertyValue, $this->newValue);
     $node->setProperty($this->propertyName, $newValueWithReplacedCurrentValue);
 }
Пример #24
0
 /**
  * @param NodeInterface $event
  * @return array
  */
 protected function buildSingleItemJson($event)
 {
     $properties = ['@context' => ['ical' => 'http://www.w3.org/2002/12/cal/ical#', 'xsd' => 'http://www.w3.org/2001/XMLSchema#', 'ical:dtstart' => ['@type' => 'xsd:dateTime']], '@id' => $event->getIdentifier(), 'id' => $event->getIdentifier(), 'shortIdentifier' => explode('-', $event->getIdentifier())[0], 'title' => $event->getProperty('title'), 'startDate' => $event->getProperty('start')->format('D M d Y H:i:s O'), 'endDate' => $event->getProperty('end')->format('D M d Y H:i:s O')];
     $this->processProperties($properties);
     return $properties;
 }
 /**
  * Method that can be used in usort() to sort by a property in a node
  *
  * Example
  * <code>
  * usort($events, function(NodeInterface $a, NodeInterface $b) {
  *     return $this->sortNodesByDate($a, $b, 'date', false);
  * });
  * </code>
  *
  * @param NodeInterface $a
  * @param NodeInterface $b
  * @param string $property
  * @param boolean $ascending
  * @return integer
  */
 protected function sortNodesSelection(NodeInterface $a, NodeInterface $b, $property, $ascending = true)
 {
     if ($a->getProperty($property) === $b->getProperty($property)) {
         return 0;
     }
     if ($a->getProperty($property) < $b->getProperty($property)) {
         return $ascending === true ? -1 : 1;
     }
     return $ascending === true ? 1 : -1;
 }
 /**
  * @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;
 }
Пример #27
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;
 }