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