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-25 21:59:25 +01:00
|
|
|
protected function init()
|
|
|
|
{
|
|
|
|
parent::init();
|
2016-08-16 03:22:58 +02:00
|
|
|
|
2017-01-25 21:59:25 +01:00
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
}
|
2016-08-16 03:22:58 +02:00
|
|
|
|
2017-01-25 21:59:25 +01:00
|
|
|
/**
|
|
|
|
* If we ever get this far, it means that the redirection failed.
|
|
|
|
*/
|
|
|
|
public function Content()
|
|
|
|
{
|
|
|
|
return "<p class=\"message-setupWithoutRedirect\">" .
|
2017-04-20 03:15:29 +02:00
|
|
|
_t('SilverStripe\\CMS\\Model\\RedirectorPage.HASBEENSETUP', 'A redirector page has been set up without anywhere to redirect to.') .
|
2017-01-25 21:59:25 +01:00
|
|
|
"</p>";
|
|
|
|
}
|
2016-08-16 03:22:58 +02:00
|
|
|
}
|