redirect.php 1.02 KB
Newer Older
1 2 3 4 5 6 7 8 9
<?php
use yii\helpers\Html;
use yii\helpers\Json;

/* @var $this \yii\base\View */
/* @var $url string */
/* @var $enforceRedirect boolean */

$redirectJavaScript = <<<EOL
Qiang Xue committed
10
function popupWindowRedirect(url, enforceRedirect) {
11
	if (window.opener && !window.opener.closed) {
Qiang Xue committed
12
		if (enforceRedirect === undefined || enforceRedirect) {
13 14
			window.opener.location = url;
		}
15 16
		window.opener.focus();
		window.close();
17 18 19 20 21 22 23 24 25 26 27 28
	} else {
		window.location = url;
	}
}
EOL;

$redirectJavaScript .= 'popupWindowRedirect(' . Json::encode($url) . ', ' . Json::encode($enforceRedirect) . ');';

?>
<!DOCTYPE html>
<html>
<head>
Luciano Baraglia committed
29
	<?= Html::script($redirectJavaScript) ?>
30 31
</head>
<body>
Luciano Baraglia committed
32 33
<h2 id="title" style="display:none;">Redirecting back to the &quot;<?= Yii::$app->name ?>&quot;...</h2>
<h3 id="link"><a href="<?= $url ?>">Click here to return to the &quot;<?= Yii::$app->name ?>&quot;.</a></h3>
34 35 36 37 38
<script type="text/javascript">
	document.getElementById('title').style.display = '';
	document.getElementById('link').style.display = 'none';
</script>
</body>
Qiang Xue committed
39
</html>