Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
simple_sitemap
Commits
27f49f79
Commit
27f49f79
authored
Jan 08, 2016
by
Pawel G
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some code cleaning.
parent
c4f1a83d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
13 deletions
+16
-13
src/LinkGenerators/EntityLinkGenerator.php
src/LinkGenerators/EntityLinkGenerator.php
+16
-12
src/LinkGenerators/EntityTypeLinkGenerators/taxonomy_term.php
...LinkGenerators/EntityTypeLinkGenerators/taxonomy_term.php
+0
-1
No files found.
src/LinkGenerators/EntityLinkGenerator.php
View file @
27f49f79
...
...
@@ -25,22 +25,26 @@ abstract class EntityLinkGenerator {
}
$links
=
$this
->
get_entity_bundle_links
(
$entity_type
,
$bundle
,
$language
);
$lastmod
=
NULL
;
foreach
(
$links
as
$id
=>
&
$link
)
{
switch
(
$entity_type
)
{
case
'node'
:
$lastmod
=
db_query
(
"SELECT changed FROM
{
node_field_data
}
WHERE nid = :nid LIMIT 1"
,
array
(
':nid'
=>
$id
))
->
fetchCol
();
break
;
case
'taxonomy_term'
:
$lastmod
=
db_query
(
"SELECT changed FROM
{
taxonomy_term_field_data
}
WHERE tid = :tid LIMIT 1"
,
array
(
':tid'
=>
$id
))
->
fetchCol
();
break
;
case
'menu'
:
//todo: to be implemented
}
$this
->
entity_links
[]
=
SitemapGenerator
::
add_xml_link_markup
(
$link
,
$bundle_settings
[
'priority'
],
isset
(
$lastmod
[
0
])
?
date_iso8601
(
$lastmod
[
0
])
:
NULL
);
foreach
(
$links
as
$id
=>
$link
)
{
$this
->
entity_links
[]
=
SitemapGenerator
::
add_xml_link_markup
(
$link
,
$bundle_settings
[
'priority'
],
$this
->
get_lastmod
(
$entity_type
,
$id
));
}
}
return
$this
->
entity_links
;
}
private
function
get_lastmod
(
$entity_type
,
$id
)
{
switch
(
$entity_type
)
{
case
'node'
:
$lastmod
=
db_query
(
"SELECT changed FROM
{
node_field_data
}
WHERE nid = :nid LIMIT 1"
,
array
(
':nid'
=>
$id
))
->
fetchCol
();
break
;
case
'taxonomy_term'
:
$lastmod
=
db_query
(
"SELECT changed FROM
{
taxonomy_term_field_data
}
WHERE tid = :tid LIMIT 1"
,
array
(
':tid'
=>
$id
))
->
fetchCol
();
break
;
case
'menu'
:
//todo: to be implemented
}
return
isset
(
$lastmod
[
0
])
?
date_iso8601
(
$lastmod
[
0
])
:
NULL
;
}
abstract
function
get_entity_bundle_links
(
$entity_type
,
$bundle
,
$language
);
}
src/LinkGenerators/EntityTypeLinkGenerators/taxonomy_term.php
View file @
27f49f79
...
...
@@ -20,7 +20,6 @@ class taxonomy_term extends EntityLinkGenerator {
function
get_entity_bundle_links
(
$entity_type
,
$bundle
,
$language
)
{
//todo: check what happens if none existent.
$results
=
db_query
(
"SELECT tid FROM
{
taxonomy_term_field_data
}
WHERE vid = :vid"
,
array
(
':vid'
=>
$bundle
))
->
fetchAllAssoc
(
'tid'
);
...
...
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