redirect.php 1.08 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
10 11 12 13 14 15 16 17 18 19 20
function popupWindowRedirect(url, enforceRedirect)
{
    if (window.opener && !window.opener.closed) {
        if (enforceRedirect === undefined || enforceRedirect) {
            window.opener.location = url;
        }
        window.opener.focus();
        window.close();
    } else {
        window.location = url;
    }
21 22 23 24 25 26 27 28 29
}
EOL;

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

?>
<!DOCTYPE html>
<html>
<head>
30
    <?= Html::script($redirectJavaScript) ?>
31 32
</head>
<body>
Luciano Baraglia committed
33 34
<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>
35
<script type="text/javascript">
36 37
    document.getElementById('title').style.display = '';
    document.getElementById('link').style.display = 'none';
38 39
</script>
</body>
Qiang Xue committed
40
</html>