2017-04-25 01:47:34 +12:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\IFrame;
|
|
|
|
|
2019-03-01 12:01:09 +13:00
|
|
|
use PageController;
|
2017-04-25 01:47:34 +12:00
|
|
|
use SilverStripe\Control\Director;
|
|
|
|
use SilverStripe\View\Requirements;
|
|
|
|
|
2019-03-01 12:01:09 +13:00
|
|
|
class IFramePageController extends PageController
|
2017-04-25 01:47:34 +12:00
|
|
|
{
|
|
|
|
protected function init()
|
|
|
|
{
|
|
|
|
parent::init();
|
2017-11-22 17:11:34 +13:00
|
|
|
$currentProtocol = Director::protocol();
|
|
|
|
$desiredProtocol = $this->ForceProtocol;
|
|
|
|
if ($desiredProtocol && $currentProtocol !== $desiredProtocol) {
|
|
|
|
$enforcedLocation = preg_replace(
|
|
|
|
"#^${currentProtocol}#",
|
|
|
|
$desiredProtocol,
|
|
|
|
$this->AbsoluteLink()
|
|
|
|
);
|
|
|
|
return $this->redirect($enforcedLocation);
|
2017-04-25 01:47:34 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->IFrameURL) {
|
2017-11-22 17:11:34 +13:00
|
|
|
Requirements::javascript('silverstripe/iframe: javascript/iframe_page.js');
|
2017-04-25 01:47:34 +12:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|