Skip to content

Commit

Permalink
MINOR redirector link tracking is more intelligent (from r96461) (fro…
Browse files Browse the repository at this point in the history
…m r98139)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102611 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information
chillu committed Apr 13, 2010
1 parent 9b650a4 commit 864a15d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions core/model/SiteTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -1435,11 +1435,20 @@ function onAfterDelete() {
} else {
$virtualPages = DataObject::get('VirtualPage', "SiteTree$suffix.ID = SiteTree$suffix.ID AND CopyContentFromID = {$this->ID}");
}
if(class_exists('Subsite')) {
$redirectorPages = Subsite::get_from_all_subsites('RedirectorPage', "SiteTree$suffix.ID = SiteTree$suffix.ID AND LinkToID = {$this->ID}");
} else {
$redirectorPages = DataObject::get('RedirectorPage', "SiteTree$suffix.ID = SiteTree$suffix.ID AND LinkToID = {$this->ID}");
}

if($virtualPages) foreach($virtualPages as $page) {
// $page->write() calls syncLinkTracking, which does all the hard work for us.
$page->write();
}
if($redirectorPages) foreach($redirectorPages as $page) {
// $page->write() calls syncLinkTracking, which does all the hard work for us.
$page->write();
}

parent::onAfterDelete();
}
Expand Down Expand Up @@ -2022,6 +2031,18 @@ function doUnpublish() {
}
if ($virtualPages) foreach($virtualPages as $vp) $vp->doUnpublish();

$suffix = Versioned::current_stage() == 'Live' ? '_Live' : '';
if(class_exists('Subsite')) {
$redirectorPages = Subsite::get_from_all_subsites('RedirectorPage', "SiteTree$suffix.ID = SiteTree$suffix.ID AND LinkToID = {$this->ID}");
} else {
$redirectorPages = DataObject::get('RedirectorPage', "SiteTree$suffix.ID = SiteTree$suffix.ID AND LinkToID = {$this->ID}");
}

if($redirectorPages) foreach($redirectorPages as $page) {
// $page->write() calls syncLinkTracking, which does all the hard work for us.
$page->write();
}

$this->extend('onAfterUnpublish');
}

Expand Down

0 comments on commit 864a15d

Please sign in to comment.