2016-08-16 03:22:58 +02:00
|
|
|
<?php
|
|
|
|
namespace SilverStripe\CMS\Model;
|
|
|
|
|
2017-06-23 00:59:25 +02:00
|
|
|
use SilverStripe\Control\HTTPRequest;
|
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-06-23 00:59:25 +02:00
|
|
|
private static $allowed_actions = ['index'];
|
2016-08-16 03:22:58 +02:00
|
|
|
|
2017-06-23 00:59:25 +02:00
|
|
|
/**
|
|
|
|
* Check we don't already have a redirect code set
|
|
|
|
*
|
|
|
|
* @param HTTPRequest $request
|
|
|
|
* @return \SilverStripe\Control\HTTPResponse
|
|
|
|
*/
|
|
|
|
public function index(HTTPRequest $request)
|
2017-01-25 21:59:25 +01:00
|
|
|
{
|
|
|
|
/** @var RedirectorPage $page */
|
|
|
|
$page = $this->data();
|
|
|
|
if (!$this->getResponse()->isFinished() && $link = $page->redirectionLink()) {
|
|
|
|
$this->redirect($link, 301);
|
|
|
|
}
|
2017-06-23 00:59:25 +02:00
|
|
|
return parent::handleAction($request, 'handleIndex');
|
2017-01-25 21:59:25 +01:00
|
|
|
}
|
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.
|
|
|
|
*/
|
2017-06-23 00:59:25 +02:00
|
|
|
public function getContent()
|
2017-01-25 21:59:25 +01:00
|
|
|
{
|
|
|
|
return "<p class=\"message-setupWithoutRedirect\">" .
|
2017-06-23 00:59:25 +02:00
|
|
|
_t(__CLASS__ . '.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
|
|
|
}
|