mirror of
https://github.com/wilr/silverstripe-googlesitemaps.git
synced 2024-10-22 11:05:48 +02:00
BUGFIX: More fixes to googlesitemaps from simon_w
This commit is contained in:
parent
d01188afff
commit
758715c205
@ -50,8 +50,10 @@ class GoogleSitemap extends Controller {
|
|||||||
// The one field that isn't easy to deal with in the template is
|
// The one field that isn't easy to deal with in the template is
|
||||||
// Change frequency, so we set that here.
|
// Change frequency, so we set that here.
|
||||||
$properties = $page->toMap();
|
$properties = $page->toMap();
|
||||||
$created = new SSDatetime($properties['Created']);
|
$created = new SSDatetime();
|
||||||
$now = new SSDatetime(date('Y-m-d H:i:s'));
|
$created->value = $properties['Created'];
|
||||||
|
$now = new SSDatetime();
|
||||||
|
$now->value = date('Y-m-d H:i:s');
|
||||||
$versions = $properties['Version'];
|
$versions = $properties['Version'];
|
||||||
$timediff = $now->format('U') - $created->format('U');
|
$timediff = $now->format('U') - $created->format('U');
|
||||||
|
|
||||||
@ -62,13 +64,13 @@ class GoogleSitemap extends Controller {
|
|||||||
|
|
||||||
if($period > 60*60*24*365) { // > 1 year
|
if($period > 60*60*24*365) { // > 1 year
|
||||||
$page->ChangeFreq='yearly';
|
$page->ChangeFreq='yearly';
|
||||||
} else if($period > 60*60*24*30) { // > ~1 month
|
} elseif($period > 60*60*24*30) { // > ~1 month
|
||||||
$page->ChangeFreq='monthly';
|
$page->ChangeFreq='monthly';
|
||||||
} else if($period > 60*60*24*7) { // > 1 week
|
} elseif($period > 60*60*24*7) { // > 1 week
|
||||||
$page->ChangeFreq='weekly';
|
$page->ChangeFreq='weekly';
|
||||||
} else if($period > 60*60*24) { // > 1 day
|
} elseif($period > 60*60*24) { // > 1 day
|
||||||
$page->ChangeFreq='daily';
|
$page->ChangeFreq='daily';
|
||||||
} else if($period > 60*60) { // > 1 hour
|
} elseif($period > 60*60) { // > 1 hour
|
||||||
$page->ChangeFreq='hourly';
|
$page->ChangeFreq='hourly';
|
||||||
} else { // < 1 hour
|
} else { // < 1 hour
|
||||||
$page->ChangeFreq='always';
|
$page->ChangeFreq='always';
|
||||||
@ -219,7 +221,7 @@ class GoogleSitemapDecorator extends SiteTreeDecorator {
|
|||||||
$parentStack = $this->owner->parentStack();
|
$parentStack = $this->owner->parentStack();
|
||||||
$numParents = is_array($parentStack) ? count($parentStack) - 1: 0;
|
$numParents = is_array($parentStack) ? count($parentStack) - 1: 0;
|
||||||
return max(0.1, 1.0 - ($numParents / 10));
|
return max(0.1, 1.0 - ($numParents / 10));
|
||||||
} else if($this->owner->getField('Priority') == -1) {
|
} elseif($this->owner->getField('Priority') == -1) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return $this->owner->getField('Priority');
|
return $this->owner->getField('Priority');
|
||||||
|
Loading…
Reference in New Issue
Block a user