2016-08-16 03:22:58 +02:00
|
|
|
<?php
|
|
|
|
namespace SilverStripe\CMS\Model;
|
|
|
|
|
2016-12-29 22:32:04 +01:00
|
|
|
use PageController;
|
2016-08-16 03:22:58 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Controller for the {@link RedirectorPage}.
|
|
|
|
*/
|
2016-12-29 22:32:04 +01:00
|
|
|
class RedirectorPageController extends PageController
|
2016-08-16 03:22:58 +02:00
|
|
|
{
|
|
|
|
|
2017-01-21 23:35:14 +01:00
|
|
|
protected function init()
|
2016-08-16 03:22:58 +02:00
|
|
|
{
|
|
|
|
parent::init();
|
|
|
|
|
|
|
|
// Check we don't already have a redirect code set
|
|
|
|
/** @var RedirectorPage $page */
|
|
|
|
$page = $this->data();
|
|
|
|
if (!$this->getResponse()->isFinished() && $link = $page->redirectionLink()) {
|
|
|
|
$this->redirect($link, 301);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If we ever get this far, it means that the redirection failed.
|
|
|
|
*/
|
|
|
|
public function Content()
|
|
|
|
{
|
|
|
|
return "<p class=\"message-setupWithoutRedirect\">" .
|
|
|
|
_t('RedirectorPage.HASBEENSETUP', 'A redirector page has been set up without anywhere to redirect to.') .
|
|
|
|
"</p>";
|
|
|
|
}
|
|
|
|
}
|