Commit dd4ddfe0 by Kartik Visweswaran

Simplify inline script code

Simplify the rendering of the inline script (using direct markup), eliminating need for using PHP variable to store value using HEREDOC.
parent f9befd58
...@@ -5,29 +5,25 @@ use yii\helpers\Json; ...@@ -5,29 +5,25 @@ use yii\helpers\Json;
/* @var $this \yii\base\View */ /* @var $this \yii\base\View */
/* @var $url string */ /* @var $url string */
/* @var $enforceRedirect boolean */ /* @var $enforceRedirect boolean */
$redirectJavaScript = <<<EOL
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;
}
}
EOL;
$redirectJavaScript .= 'popupWindowRedirect(' . Json::encode($url) . ', ' . Json::encode($enforceRedirect) . ');';
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<?= Html::script($redirectJavaScript) ?> <script>
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;
}
}
popupWindowRedirect(<?= Json::encode($url) ?>, <?= Json::encode($enforceRedirect) ?>);
</script>
</head> </head>
<body> <body>
<h2 id="title" style="display:none;">Redirecting back to the &quot;<?= Yii::$app->name ?>&quot;...</h2> <h2 id="title" style="display:none;">Redirecting back to the &quot;<?= Yii::$app->name ?>&quot;...</h2>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment