/**
  * @Flow\Around("method(TYPO3\Neos\Routing\FrontendNodeRoutePartHandler->convertRequestPathToNode())")
  *
  * @param \TYPO3\FLOW\AOP\JoinPointInterface $joinPoint the join point
  *
  * @return mixed
  */
 public function aroundConvertRequestPathToNodeAspect($joinPoint)
 {
     if ($this->nodeNotFoundService->isEnabled()) {
         /** @var NodeInterface $node */
         $requestPath = $joinPoint->getMethodArgument('requestPath');
         try {
             return $joinPoint->getAdviceChain()->proceed($joinPoint);
         } catch (InvalidRequestPathException $e) {
             $defaultUriSegment = $this->nodeNotFoundService->getDefaultUriSegment();
             $requestPath = $defaultUriSegment . $this->nodeNotFoundService->get404NodeUriForDimensionUriSegment($defaultUriSegment);
             $joinPoint->setMethodArgument("requestPath", $requestPath);
             return $joinPoint->getAdviceChain()->proceed($joinPoint);
         } catch (NoSuchDimensionValueException $e) {
             $defaultUriSegment = $this->nodeNotFoundService->getDefaultUriSegment();
             $requestPath = $defaultUriSegment . $this->nodeNotFoundService->get404NodeUriForDimensionUriSegment($defaultUriSegment);
             $joinPoint->setMethodArgument("requestPath", $requestPath);
             return $joinPoint->getAdviceChain()->proceed($joinPoint);
         } catch (NoSuchNodeException $e) {
             $dimensionUriSegment = strstr($requestPath, "/", true);
             if (count($this->contentDimensionPresetSource->getAllPresets()) > 0) {
                 $requestPath = $dimensionUriSegment . "/" . $this->nodeNotFoundService->get404NodeUriForDimensionUriSegment($dimensionUriSegment);
             } else {
                 $requestPath = $this->nodeNotFoundService->get404NodeUriForDimensionUriSegment('');
             }
             $joinPoint->setMethodArgument("requestPath", $requestPath);
             return $joinPoint->getAdviceChain()->proceed($joinPoint);
         }
     } else {
         // execute the original code
         return $joinPoint->getAdviceChain()->proceed($joinPoint);
     }
 }
 /**
  * @param string $searchWord
  * @param Site $selectedSite
  * @return void
  */
 public function searchForNodeAction($searchWord, Site $selectedSite = NULL)
 {
     $documentNodeTypes = $this->nodeTypeManager->getSubNodeTypes('TYPO3.Neos:Document');
     $shortcutNodeType = $this->nodeTypeManager->getNodeType('TYPO3.Neos:Shortcut');
     $nodeTypes = array_diff($documentNodeTypes, array($shortcutNodeType));
     $sites = array();
     $activeSites = $this->siteRepository->findOnline();
     foreach ($selectedSite ? array($selectedSite) : $activeSites as $site) {
         /** @var Site $site */
         $contextProperties = array('workspaceName' => 'live', 'currentSite' => $site);
         $contentDimensionPresets = $this->contentDimensionPresetSource->getAllPresets();
         if (count($contentDimensionPresets) > 0) {
             $mergedContentDimensions = array();
             foreach ($contentDimensionPresets as $contentDimensionIdentifier => $contentDimension) {
                 $mergedContentDimensions[$contentDimensionIdentifier] = array($contentDimension['default']);
                 foreach ($contentDimension['presets'] as $contentDimensionPreset) {
                     $mergedContentDimensions[$contentDimensionIdentifier] = array_merge($mergedContentDimensions[$contentDimensionIdentifier], $contentDimensionPreset['values']);
                 }
                 $mergedContentDimensions[$contentDimensionIdentifier] = array_values(array_unique($mergedContentDimensions[$contentDimensionIdentifier]));
             }
             $contextProperties['dimensions'] = $mergedContentDimensions;
         }
         /** @var ContentContext $liveContext */
         $liveContext = $this->contextFactory->create($contextProperties);
         $firstActiveDomain = $site->getFirstActiveDomain();
         $nodes = $this->nodeSearchService->findByProperties($searchWord, $nodeTypes, $liveContext, $liveContext->getCurrentSiteNode());
         if (count($nodes) > 0) {
             $sites[$site->getNodeName()] = array('site' => $site, 'domain' => $firstActiveDomain ? $firstActiveDomain->getHostPattern() : $this->request->getHttpRequest()->getUri()->getHost(), 'nodes' => $nodes);
         }
     }
     $this->view->assignMultiple(array('searchWord' => $searchWord, 'protocol' => $this->request->getHttpRequest()->getUri()->getScheme(), 'selectedSite' => $selectedSite, 'sites' => $sites, 'activeSites' => $activeSites));
 }
 /**
  * @param string $path
  * @return string
  * @throws \Exception
  */
 public function render($path = NULL)
 {
     if ($path === NULL) {
         $path = '404';
     }
     /** @var RequestHandler $activeRequestHandler */
     $activeRequestHandler = $this->bootstrap->getActiveRequestHandler();
     $parentHttpRequest = $activeRequestHandler->getHttpRequest();
     $requestPath = $parentHttpRequest->getUri()->getPath();
     $language = explode('/', ltrim($requestPath, '/'))[0];
     if ($language === 'neos') {
         throw new \Exception('NotFoundViewHelper can not be used for neos-routes.', 1435648210);
     }
     $language = $this->localeDetector->detectLocaleFromLocaleTag($language)->getLanguage();
     if ($this->contentDimensionPresetSource->findPresetByUriSegment('language', $language) === NULL) {
         $language = '';
     }
     if ($language !== '') {
         $language .= '/';
     }
     $request = Request::create(new Uri(rtrim($parentHttpRequest->getBaseUri(), '/') . '/' . $language . $path));
     $matchingRoute = $this->router->route($request);
     if (!$matchingRoute) {
         throw new \Exception(sprintf('Uri with path "%s" could not be found.', rtrim($parentHttpRequest->getBaseUri(), '/') . '/' . $language . $path), 1426446160);
     }
     $response = new Response();
     $objectManager = $this->bootstrap->getObjectManager();
     $baseComponentChain = $objectManager->get('TYPO3\\Flow\\Http\\Component\\ComponentChain');
     $componentContext = new ComponentContext($request, $response);
     $baseComponentChain->handle($componentContext);
     return $response->getContent();
 }
 /**
  * @param ReceiverGroup $receiverGroup
  */
 public function generate(ReceiverGroup $receiverGroup)
 {
     Files::createDirectoryRecursively($this->receiverGroupCache);
     $presets = $this->contentDimensionPresetSource->getAllPresets();
     $languages = array_keys($presets['language']['presets']);
     if (count($languages) == 0) {
         $this->processReceiverGroup($receiverGroup);
     } else {
         foreach ($languages as $language) {
             $this->processReceiverGroup($receiverGroup, $language);
         }
     }
 }
 /**
  * Find a URI segment in the content dimension presets for the given "language" dimension values
  *
  * This will do a reverse lookup from actual dimension values to a preset and fall back to the default preset if none
  * can be found.
  *
  * @param array $dimensionsValues An array of dimensions and their values, indexed by dimension name
  * @param boolean $currentNodeIsSiteNode If the current node is actually the site node
  * @return string
  * @throws \Exception
  */
 protected function getUriSegmentForDimensions(array $dimensionsValues, $currentNodeIsSiteNode)
 {
     $uriSegment = '';
     $allDimensionPresetsAreDefault = TRUE;
     foreach ($this->contentDimensionPresetSource->getAllPresets() as $dimensionName => $dimensionPresets) {
         $preset = NULL;
         if (isset($dimensionsValues[$dimensionName])) {
             $preset = $this->contentDimensionPresetSource->findPresetByDimensionValues($dimensionName, $dimensionsValues[$dimensionName]);
         }
         $defaultPreset = $this->contentDimensionPresetSource->getDefaultPreset($dimensionName);
         if ($preset === NULL) {
             $preset = $defaultPreset;
         }
         if ($preset !== $defaultPreset) {
             $allDimensionPresetsAreDefault = FALSE;
         }
         if (!isset($preset['uriSegment'])) {
             throw new \Exception(sprintf('No "uriSegment" configured for content dimension preset "%s" for dimension "%s". Please check the content dimension configuration in Settings.yaml', $preset['identifier'], $dimensionName), 1395824520);
         }
         $uriSegment .= $preset['uriSegment'] . '_';
     }
     if ($allDimensionPresetsAreDefault && $currentNodeIsSiteNode) {
         return '/';
     } else {
         return ltrim(trim($uriSegment, '_') . '/', '/');
     }
 }
Ejemplo n.º 6
0
 /**
  * @param array $dimensions Dimension values indexed by dimension name
  * @return array Allowed preset names for the given dimension combination indexed by dimension name
  */
 public function allowedPresetsByName(array $dimensions)
 {
     $allowedPresets = array();
     $preselectedDimensionPresets = array();
     foreach ($dimensions as $dimensionName => $dimensionValues) {
         $preset = $this->contentDimensionsPresetSource->findPresetByDimensionValues($dimensionName, $dimensionValues);
         if ($preset !== null) {
             $preselectedDimensionPresets[$dimensionName] = $preset['identifier'];
         }
     }
     foreach ($preselectedDimensionPresets as $dimensionName => $presetName) {
         $presets = $this->contentDimensionsPresetSource->getAllowedDimensionPresetsAccordingToPreselection($dimensionName, $preselectedDimensionPresets);
         $allowedPresets[$dimensionName] = array_keys($presets[$dimensionName]['presets']);
     }
     return $allowedPresets;
 }
 /**
  * @return array
  * @todo will went into TYPO3CR
  */
 protected function calculateDimensionCombinations()
 {
     $dimensionPresets = $this->contentDimensionPresetSource->getAllPresets();
     $dimensionValueCountByDimension = array();
     $possibleCombinationCount = 1;
     $combinations = array();
     foreach ($dimensionPresets as $dimensionName => $dimensionPreset) {
         if (isset($dimensionPreset['presets']) && !empty($dimensionPreset['presets'])) {
             $dimensionValueCountByDimension[$dimensionName] = count($dimensionPreset['presets']);
             $possibleCombinationCount = $possibleCombinationCount * $dimensionValueCountByDimension[$dimensionName];
         }
     }
     foreach ($dimensionPresets as $dimensionName => $dimensionPreset) {
         for ($i = 0; $i < $possibleCombinationCount; $i++) {
             if (!isset($combinations[$i]) || !is_array($combinations[$i])) {
                 $combinations[$i] = array();
             }
             $currentDimensionCurrentPreset = current($dimensionPresets[$dimensionName]['presets']);
             $combinations[$i][$dimensionName] = $currentDimensionCurrentPreset['values'];
             if (!next($dimensionPresets[$dimensionName]['presets'])) {
                 reset($dimensionPresets[$dimensionName]['presets']);
             }
         }
     }
     return $combinations;
 }
 /**
  * Returns only presets of the dimension specified by $dimensionName. But even though only one dimension is returned,
  * the output follows the structure as described in ContentDimensionPresetSourceInterface::getAllPresets().
  *
  * It is possible to pass a selection of presets as a filter. In that case, $chosenDimensionPresets must be an array
  * of one or more dimension names (key) and preset names (value). The returned list will then only contain dimension
  * presets which are allowed in combination with the given presets.
  *
  * Example: Given that $chosenDimensionPresets = array('country' => 'US') and that a second dimension "language"
  * exists and $dimensionName is "language. This method will now display a list of dimension presets for the dimension
  * "language" which are allowed in combination with the country "US".
  *
  * @param string $dimensionName Name of the dimension to return presets for
  * @param array $chosenDimensionPresets An optional array of dimension names and a single preset per dimension
  * @return void
  */
 public function showAction($dimensionName, $chosenDimensionPresets = array())
 {
     if ($chosenDimensionPresets === array()) {
         $contentDimensionsAndPresets = $this->contentDimensionPresetSource->getAllPresets();
         if (!isset($contentDimensionsAndPresets[$dimensionName])) {
             $this->throwStatus(404, sprintf('The dimension %s does not exist.', $dimensionName));
         }
         $contentDimensionsAndPresets = array($dimensionName => $contentDimensionsAndPresets[$dimensionName]);
     } else {
         $contentDimensionsAndPresets = $this->contentDimensionPresetSource->getAllowedDimensionPresetsAccordingToPreselection($dimensionName, $chosenDimensionPresets);
     }
     if ($this->view instanceof JsonView) {
         $this->view->assign('value', $contentDimensionsAndPresets);
     } else {
         $this->view->assign('dimensionName', $dimensionName);
         $this->view->assign('contentDimensionsPresets', $contentDimensionsAndPresets);
     }
 }
Ejemplo n.º 9
0
 public function findNumberOfRecipientsForGroup($identifier)
 {
     if (!$identifier) {
         return array();
     }
     $receiverGroup = $this->receiverGroupRepository->findByIdentifier($identifier);
     /* @var $receiverGroup ReceiverGroup */
     if (!$receiverGroup) {
         return array();
     }
     $presets = $this->contentDimensionPresetSource->getAllPresets();
     $result = array();
     if (!isset($presets['language']['presets'])) {
         $result['all'] = $receiverGroup->getNumberOfReceivers(NULL);
     } else {
         foreach ($presets['language']['presets'] as $languageKey => $languageConfiguration) {
             $result[$languageKey] = $receiverGroup->getNumberOfReceivers($languageKey);
         }
     }
     return $result;
 }
 /**
  * @param ReceiverGroup $receiverGroup
  */
 public function previewReceiverGroupAction(ReceiverGroup $receiverGroup)
 {
     $presets = $this->contentDimensionPresetSource->getAllPresets();
     $languages = array_keys($presets['language']['presets']);
     $exampleDataPerLanguage = array();
     foreach ($languages as $language) {
         $file = fopen($receiverGroup->getCacheFileName($language), 'r');
         $contents = fgets($file);
         fclose($file);
         $exampleDataPerLanguage[$language] = array('numberOfReceivers' => $receiverGroup->getNumberOfReceivers($language), 'singleLine' => json_decode($contents, TRUE));
     }
     $this->view->assign('exampleDataPerLanguage', $exampleDataPerLanguage);
     $this->view->assign('receiverGroup', $receiverGroup);
 }
 /**
  * @param NodeInterface $node
  * @param string $previewEmail
  */
 public function indexAction(NodeInterface $node, $previewEmail = NULL)
 {
     $this->newsletterRenderingView->setControllerContext($this->getControllerContext());
     $this->newsletterRenderingView->setOption('enableContentCache', FALSE);
     $this->newsletterRenderingView->assign('value', $node);
     $this->newsletterRenderingView->assign('editPreviewMode', 'finalNewsletterRendering');
     $presets = $this->contentDimensionPresetSource->getAllPresets();
     if (!isset($presets['language']['presets'])) {
         $this->sendNewsletter($node, $previewEmail);
     } else {
         foreach ($presets['language']['presets'] as $languageKey => $languageConfiguration) {
             $this->sendNewsletter($node, $previewEmail, $languageKey, $languageConfiguration);
         }
     }
     return json_encode(array('success' => TRUE));
 }
 /**
  * Get Related Nodes for an asset
  *
  * @param AssetInterface $asset
  * @return void
  */
 public function relatedNodesAction(AssetInterface $asset)
 {
     $userWorkspace = $this->userService->getPersonalWorkspace();
     $usageReferences = $this->assetService->getUsageReferences($asset);
     $relatedNodes = [];
     /** @var AssetUsageInNodeProperties $usage */
     foreach ($usageReferences as $usage) {
         $documentNodeIdentifier = $usage->getDocumentNode() instanceof NodeInterface ? $usage->getDocumentNode()->getIdentifier() : null;
         $relatedNodes[$usage->getSite()->getNodeName()]['site'] = $usage->getSite();
         $relatedNodes[$usage->getSite()->getNodeName()]['documentNodes'][$documentNodeIdentifier]['node'] = $usage->getDocumentNode();
         $relatedNodes[$usage->getSite()->getNodeName()]['documentNodes'][$documentNodeIdentifier]['nodes'][] = ['node' => $usage->getNode(), 'nodeData' => $usage->getNode()->getNodeData(), 'contextDocumentNode' => $usage->getDocumentNode(), 'accessible' => $usage->isAccessible()];
     }
     $this->view->assignMultiple(['asset' => $asset, 'relatedNodes' => $relatedNodes, 'contentDimensions' => $this->contentDimensionPresetSource->getAllPresets(), 'userWorkspace' => $userWorkspace]);
 }
 /**
  * Get Related Nodes for an asset
  *
  * @param Asset $asset
  * @return void
  */
 public function relatedNodesAction(Asset $asset)
 {
     $userWorkspace = $this->userService->getPersonalWorkspace();
     $relatedNodes = [];
     foreach ($this->getRelatedNodes($asset) as $relatedNodeData) {
         $accessible = $this->domainUserService->currentUserCanReadWorkspace($relatedNodeData->getWorkspace());
         if ($accessible) {
             $context = $this->createContextMatchingNodeData($relatedNodeData);
         } else {
             $context = $this->createContentContext($userWorkspace->getName());
         }
         $site = $context->getCurrentSite();
         $node = $this->nodeFactory->createFromNodeData($relatedNodeData, $context);
         $flowQuery = new FlowQuery([$node]);
         /** @var Node $documentNode */
         $documentNode = $flowQuery->closest('[instanceof TYPO3.Neos:Document]')->get(0);
         $documentNodeIdentifier = $documentNode instanceof NodeInterface ? $documentNode->getIdentifier() : null;
         $relatedNodes[$site->getNodeName()]['site'] = $site;
         $relatedNodes[$site->getNodeName()]['documentNodes'][$documentNodeIdentifier]['node'] = $documentNode;
         $relatedNodes[$site->getNodeName()]['documentNodes'][$documentNodeIdentifier]['nodes'][] = ['node' => $node, 'nodeData' => $relatedNodeData, 'contextDocumentNode' => $documentNode, 'accessible' => $accessible];
     }
     $this->view->assignMultiple(['asset' => $asset, 'relatedNodes' => $relatedNodes, 'contentDimensions' => $this->contentDimensionPresetSource->getAllPresets(), 'userWorkspace' => $userWorkspace]);
 }
 /**
  * @param Workspace $workspace
  * @return void
  */
 public function showAction(Workspace $workspace)
 {
     $this->view->assignMultiple(['selectedWorkspace' => $workspace, 'selectedWorkspaceLabel' => $workspace->getTitle() ?: $workspace->getName(), 'baseWorkspaceName' => $workspace->getBaseWorkspace()->getName(), 'baseWorkspaceLabel' => $workspace->getBaseWorkspace()->getTitle() ?: $workspace->getBaseWorkspace()->getName(), 'canPublishToBaseWorkspace' => $this->userService->currentUserCanPublishToWorkspace($workspace->getBaseWorkspace()), 'siteChanges' => $this->computeSiteChanges($workspace), 'contentDimensions' => $this->contentDimensionPresetSource->getAllPresets()]);
 }
 private function findPreset($needle)
 {
     return $this->contentDimensionPresetSource->findPresetByUriSegment('language', $needle);
 }