Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
Ttree.Neos.Sitemap
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ttree
Ttree.Neos.Sitemap
Commits
fc241908
Commit
fc241908
authored
Sep 23, 2015
by
Dominique Feyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[TASK] Use EEL query to select documents
parent
d7b93ccb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
21 deletions
+26
-21
Classes/Service/SitemapBuilder.php
Classes/Service/SitemapBuilder.php
+22
-17
Configuration/Settings.yaml
Configuration/Settings.yaml
+4
-4
No files found.
Classes/Service/SitemapBuilder.php
View file @
fc241908
...
...
@@ -4,7 +4,9 @@ namespace Ttree\Neos\Sitemap\Service;
use
Tackk\Cartographer\ChangeFrequency
;
use
Tackk\Cartographer\Sitemap
;
use
Ttree\Neos\Sitemap\Domain\Model\SitemapDefinition
;
use
TYPO3\Eel\EelEvaluatorInterface
;
use
TYPO3\Eel\FlowQuery\FlowQuery
;
use
TYPO3\Eel\Utility
;
use
TYPO3\Flow\Annotations
as
Flow
;
use
TYPO3\Flow\Http\Request
;
use
TYPO3\Flow\Http\Response
;
...
...
@@ -13,6 +15,7 @@ use TYPO3\Flow\Mvc\ActionRequest;
use
TYPO3\Flow\Mvc\Controller\Arguments
;
use
TYPO3\Flow\Mvc\Controller\ControllerContext
;
use
TYPO3\Flow\Mvc\Routing\UriBuilder
;
use
TYPO3\Flow\Utility\Arrays
;
use
TYPO3\Neos\Domain\Repository\SiteRepository
;
use
TYPO3\Neos\Service\LinkingService
;
use
TYPO3\TYPO3CR\Domain\Model\NodeInterface
;
...
...
@@ -48,6 +51,12 @@ class SitemapBuilder implements SitemapBuilderInterface {
*/
protected
$uriBuilder
;
/**
* @Flow\Inject
* @var EelEvaluatorInterface
*/
protected
$eelEvaluator
;
/**
* @param SitemapDefinition $definiton
* @return string
...
...
@@ -60,19 +69,13 @@ class SitemapBuilder implements SitemapBuilderInterface {
$context
=
$this
->
createContext
(
'live'
,
$definiton
->
getSiteNodeName
());
$controllerContext
=
$this
->
createControllerContext
(
$definiton
->
getBaseUrl
());
foreach
(
$preset
[
'include'
]
as
$nodeType
=>
$nodeTypeStatus
)
{
if
(
$nodeTypeStatus
!==
TRUE
)
{
continue
;
}
$flowQuery
=
new
FlowQuery
(
array
(
$context
->
getRootNode
()));
foreach
(
$preset
[
'includes'
]
as
$queryLabel
=>
$query
)
{
$nodes
=
Utility
::
evaluateEelExpression
(
$query
,
$this
->
eelEvaluator
,
array
(
'node'
=>
$context
->
getRootNode
()));
/** @var NodeInterface $node */
foreach
(
$
flowQuery
->
find
(
sprintf
(
'[instanceof %s]'
,
$nodeType
))
as
$node
)
{
foreach
(
$
nodes
as
$node
)
{
if
(
$this
->
needToSkipNode
(
$preset
,
$node
))
{
continue
;
}
if
(
trim
(
$node
->
getProperty
(
'uriPathSegment'
))
===
''
)
{
continue
;
}
$uri
=
$this
->
linkingService
->
createNodeUri
(
$controllerContext
,
$node
,
NULL
,
'html'
,
TRUE
);
$hash
=
md5
(
$uri
);
if
(
isset
(
$processedUri
[
$hash
]))
{
...
...
@@ -93,14 +96,16 @@ class SitemapBuilder implements SitemapBuilderInterface {
* @return boolean
*/
protected
function
needToSkipNode
(
array
$preset
,
NodeInterface
$node
)
{
if
(
isset
(
$preset
[
'skip'
])
&&
is_array
(
$preset
[
'skip'
]))
{
foreach
(
$preset
[
'skip'
]
as
$nodeType
=>
$nodeTypeStatus
)
{
if
(
$nodeTypeStatus
!==
TRUE
)
{
continue
;
}
if
(
$node
->
getNodeType
()
->
isOfType
(
$nodeType
)
===
TRUE
)
{
return
TRUE
;
}
if
(
trim
(
$node
->
getProperty
(
'uriPathSegment'
))
===
''
)
{
return
TRUE
;
}
$skipNodeTypes
=
Arrays
::
getValueByPath
(
$preset
,
'skipNodeTypes'
)
?:
[];
foreach
(
$skipNodeTypes
as
$nodeType
=>
$nodeTypeStatus
)
{
if
(
$nodeTypeStatus
!==
TRUE
)
{
continue
;
}
if
(
$node
->
getNodeType
()
->
isOfType
(
$nodeType
)
===
TRUE
)
{
return
TRUE
;
}
}
return
FALSE
;
...
...
Configuration/Settings.yaml
View file @
fc241908
...
...
@@ -3,10 +3,10 @@ Ttree:
Sitemap
:
presets
:
default
:
include
:
'
TYPO3.Neos.NodeTypes:Page'
:
TRUE
skip
:
type
:
'
normal'
includes
:
'
AllPages'
:
"
${q(node).find('[instanceof
TYPO3.Neos.NodeTypes:Page]')}"
skipNodeTypes
:
'
TYPO3.Neos:Shortcut'
:
TRUE
type
:
'
single'
queueName
:
'
Default'
path
:
'
%FLOW_PATH_DATA%/Web/sitemap.xml'
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment