Loading Classes/Service/SitemapBuilder.php +17 −12 Original line number Original line Diff line number Diff line Loading @@ -4,7 +4,9 @@ namespace Ttree\Neos\Sitemap\Service; use Tackk\Cartographer\ChangeFrequency; use Tackk\Cartographer\ChangeFrequency; use Tackk\Cartographer\Sitemap; use Tackk\Cartographer\Sitemap; use Ttree\Neos\Sitemap\Domain\Model\SitemapDefinition; use Ttree\Neos\Sitemap\Domain\Model\SitemapDefinition; use TYPO3\Eel\EelEvaluatorInterface; use TYPO3\Eel\FlowQuery\FlowQuery; use TYPO3\Eel\FlowQuery\FlowQuery; use TYPO3\Eel\Utility; use TYPO3\Flow\Annotations as Flow; use TYPO3\Flow\Annotations as Flow; use TYPO3\Flow\Http\Request; use TYPO3\Flow\Http\Request; use TYPO3\Flow\Http\Response; use TYPO3\Flow\Http\Response; Loading @@ -13,6 +15,7 @@ use TYPO3\Flow\Mvc\ActionRequest; use TYPO3\Flow\Mvc\Controller\Arguments; use TYPO3\Flow\Mvc\Controller\Arguments; use TYPO3\Flow\Mvc\Controller\ControllerContext; use TYPO3\Flow\Mvc\Controller\ControllerContext; use TYPO3\Flow\Mvc\Routing\UriBuilder; use TYPO3\Flow\Mvc\Routing\UriBuilder; use TYPO3\Flow\Utility\Arrays; use TYPO3\Neos\Domain\Repository\SiteRepository; use TYPO3\Neos\Domain\Repository\SiteRepository; use TYPO3\Neos\Service\LinkingService; use TYPO3\Neos\Service\LinkingService; use TYPO3\TYPO3CR\Domain\Model\NodeInterface; use TYPO3\TYPO3CR\Domain\Model\NodeInterface; Loading Loading @@ -48,6 +51,12 @@ class SitemapBuilder implements SitemapBuilderInterface { */ */ protected $uriBuilder; protected $uriBuilder; /** * @Flow\Inject * @var EelEvaluatorInterface */ protected $eelEvaluator; /** /** * @param SitemapDefinition $definiton * @param SitemapDefinition $definiton * @return string * @return string Loading @@ -60,19 +69,13 @@ class SitemapBuilder implements SitemapBuilderInterface { $context = $this->createContext('live', $definiton->getSiteNodeName()); $context = $this->createContext('live', $definiton->getSiteNodeName()); $controllerContext = $this->createControllerContext($definiton->getBaseUrl()); $controllerContext = $this->createControllerContext($definiton->getBaseUrl()); foreach ($preset['include'] as $nodeType => $nodeTypeStatus) { foreach ($preset['includes'] as $queryLabel => $query) { if ($nodeTypeStatus !== TRUE) { $nodes = Utility::evaluateEelExpression($query, $this->eelEvaluator, array('node' => $context->getRootNode())); continue; } $flowQuery = new FlowQuery(array($context->getRootNode())); /** @var NodeInterface $node */ /** @var NodeInterface $node */ foreach ($flowQuery->find(sprintf('[instanceof %s]', $nodeType)) as $node) { foreach ($nodes as $node) { if ($this->needToSkipNode($preset, $node)) { if ($this->needToSkipNode($preset, $node)) { continue; continue; } } if (trim($node->getProperty('uriPathSegment')) === '') { continue; } $uri = $this->linkingService->createNodeUri($controllerContext, $node, NULL, 'html', TRUE); $uri = $this->linkingService->createNodeUri($controllerContext, $node, NULL, 'html', TRUE); $hash = md5($uri); $hash = md5($uri); if (isset($processedUri[$hash])) { if (isset($processedUri[$hash])) { Loading @@ -93,8 +96,11 @@ class SitemapBuilder implements SitemapBuilderInterface { * @return boolean * @return boolean */ */ protected function needToSkipNode(array $preset, NodeInterface $node) { protected function needToSkipNode(array $preset, NodeInterface $node) { if (isset($preset['skip']) && is_array($preset['skip'])) { if (trim($node->getProperty('uriPathSegment')) === '') { foreach ($preset['skip'] as $nodeType => $nodeTypeStatus) { return TRUE; } $skipNodeTypes = Arrays::getValueByPath($preset, 'skipNodeTypes') ?: []; foreach ($skipNodeTypes as $nodeType => $nodeTypeStatus) { if ($nodeTypeStatus !== TRUE) { if ($nodeTypeStatus !== TRUE) { continue; continue; } } Loading @@ -102,7 +108,6 @@ class SitemapBuilder implements SitemapBuilderInterface { return TRUE; return TRUE; } } } } } return FALSE; return FALSE; } } Loading Configuration/Settings.yaml +4 −4 Original line number Original line Diff line number Diff line Loading @@ -3,10 +3,10 @@ Ttree: Sitemap: Sitemap: presets: presets: default: default: include: type: 'normal' 'TYPO3.Neos.NodeTypes:Page': TRUE includes: skip: 'AllPages': "${q(node).find('[instanceof TYPO3.Neos.NodeTypes:Page]')}" skipNodeTypes: 'TYPO3.Neos:Shortcut': TRUE 'TYPO3.Neos:Shortcut': TRUE type: 'single' queueName: 'Default' queueName: 'Default' path: '%FLOW_PATH_DATA%/Web/sitemap.xml' path: '%FLOW_PATH_DATA%/Web/sitemap.xml' No newline at end of file Loading
Classes/Service/SitemapBuilder.php +17 −12 Original line number Original line Diff line number Diff line Loading @@ -4,7 +4,9 @@ namespace Ttree\Neos\Sitemap\Service; use Tackk\Cartographer\ChangeFrequency; use Tackk\Cartographer\ChangeFrequency; use Tackk\Cartographer\Sitemap; use Tackk\Cartographer\Sitemap; use Ttree\Neos\Sitemap\Domain\Model\SitemapDefinition; use Ttree\Neos\Sitemap\Domain\Model\SitemapDefinition; use TYPO3\Eel\EelEvaluatorInterface; use TYPO3\Eel\FlowQuery\FlowQuery; use TYPO3\Eel\FlowQuery\FlowQuery; use TYPO3\Eel\Utility; use TYPO3\Flow\Annotations as Flow; use TYPO3\Flow\Annotations as Flow; use TYPO3\Flow\Http\Request; use TYPO3\Flow\Http\Request; use TYPO3\Flow\Http\Response; use TYPO3\Flow\Http\Response; Loading @@ -13,6 +15,7 @@ use TYPO3\Flow\Mvc\ActionRequest; use TYPO3\Flow\Mvc\Controller\Arguments; use TYPO3\Flow\Mvc\Controller\Arguments; use TYPO3\Flow\Mvc\Controller\ControllerContext; use TYPO3\Flow\Mvc\Controller\ControllerContext; use TYPO3\Flow\Mvc\Routing\UriBuilder; use TYPO3\Flow\Mvc\Routing\UriBuilder; use TYPO3\Flow\Utility\Arrays; use TYPO3\Neos\Domain\Repository\SiteRepository; use TYPO3\Neos\Domain\Repository\SiteRepository; use TYPO3\Neos\Service\LinkingService; use TYPO3\Neos\Service\LinkingService; use TYPO3\TYPO3CR\Domain\Model\NodeInterface; use TYPO3\TYPO3CR\Domain\Model\NodeInterface; Loading Loading @@ -48,6 +51,12 @@ class SitemapBuilder implements SitemapBuilderInterface { */ */ protected $uriBuilder; protected $uriBuilder; /** * @Flow\Inject * @var EelEvaluatorInterface */ protected $eelEvaluator; /** /** * @param SitemapDefinition $definiton * @param SitemapDefinition $definiton * @return string * @return string Loading @@ -60,19 +69,13 @@ class SitemapBuilder implements SitemapBuilderInterface { $context = $this->createContext('live', $definiton->getSiteNodeName()); $context = $this->createContext('live', $definiton->getSiteNodeName()); $controllerContext = $this->createControllerContext($definiton->getBaseUrl()); $controllerContext = $this->createControllerContext($definiton->getBaseUrl()); foreach ($preset['include'] as $nodeType => $nodeTypeStatus) { foreach ($preset['includes'] as $queryLabel => $query) { if ($nodeTypeStatus !== TRUE) { $nodes = Utility::evaluateEelExpression($query, $this->eelEvaluator, array('node' => $context->getRootNode())); continue; } $flowQuery = new FlowQuery(array($context->getRootNode())); /** @var NodeInterface $node */ /** @var NodeInterface $node */ foreach ($flowQuery->find(sprintf('[instanceof %s]', $nodeType)) as $node) { foreach ($nodes as $node) { if ($this->needToSkipNode($preset, $node)) { if ($this->needToSkipNode($preset, $node)) { continue; continue; } } if (trim($node->getProperty('uriPathSegment')) === '') { continue; } $uri = $this->linkingService->createNodeUri($controllerContext, $node, NULL, 'html', TRUE); $uri = $this->linkingService->createNodeUri($controllerContext, $node, NULL, 'html', TRUE); $hash = md5($uri); $hash = md5($uri); if (isset($processedUri[$hash])) { if (isset($processedUri[$hash])) { Loading @@ -93,8 +96,11 @@ class SitemapBuilder implements SitemapBuilderInterface { * @return boolean * @return boolean */ */ protected function needToSkipNode(array $preset, NodeInterface $node) { protected function needToSkipNode(array $preset, NodeInterface $node) { if (isset($preset['skip']) && is_array($preset['skip'])) { if (trim($node->getProperty('uriPathSegment')) === '') { foreach ($preset['skip'] as $nodeType => $nodeTypeStatus) { return TRUE; } $skipNodeTypes = Arrays::getValueByPath($preset, 'skipNodeTypes') ?: []; foreach ($skipNodeTypes as $nodeType => $nodeTypeStatus) { if ($nodeTypeStatus !== TRUE) { if ($nodeTypeStatus !== TRUE) { continue; continue; } } Loading @@ -102,7 +108,6 @@ class SitemapBuilder implements SitemapBuilderInterface { return TRUE; return TRUE; } } } } } return FALSE; return FALSE; } } Loading
Configuration/Settings.yaml +4 −4 Original line number Original line Diff line number Diff line Loading @@ -3,10 +3,10 @@ Ttree: Sitemap: Sitemap: presets: presets: default: default: include: type: 'normal' 'TYPO3.Neos.NodeTypes:Page': TRUE includes: skip: 'AllPages': "${q(node).find('[instanceof TYPO3.Neos.NodeTypes:Page]')}" skipNodeTypes: 'TYPO3.Neos:Shortcut': TRUE 'TYPO3.Neos:Shortcut': TRUE type: 'single' queueName: 'Default' queueName: 'Default' path: '%FLOW_PATH_DATA%/Web/sitemap.xml' path: '%FLOW_PATH_DATA%/Web/sitemap.xml' No newline at end of file