mirror of
https://github.com/silverstripe/silverstripe-iframe
synced 2024-10-22 11:05:51 +02:00
de7a66b12a
This needs to extend from PageController to pick up site templating, styleing etc.
30 lines
792 B
PHP
30 lines
792 B
PHP
<?php
|
|
|
|
namespace SilverStripe\IFrame;
|
|
|
|
use PageController;
|
|
use SilverStripe\Control\Director;
|
|
use SilverStripe\View\Requirements;
|
|
|
|
class IFramePageController extends PageController
|
|
{
|
|
protected function init()
|
|
{
|
|
parent::init();
|
|
$currentProtocol = Director::protocol();
|
|
$desiredProtocol = $this->ForceProtocol;
|
|
if ($desiredProtocol && $currentProtocol !== $desiredProtocol) {
|
|
$enforcedLocation = preg_replace(
|
|
"#^${currentProtocol}#",
|
|
$desiredProtocol,
|
|
$this->AbsoluteLink()
|
|
);
|
|
return $this->redirect($enforcedLocation);
|
|
}
|
|
|
|
if ($this->IFrameURL) {
|
|
Requirements::javascript('silverstripe/iframe: javascript/iframe_page.js');
|
|
}
|
|
}
|
|
}
|