yii2-netdisk/views/layouts/main.php

130 lines
4.8 KiB
PHP
Raw Normal View History

2013-05-24 22:14:49 +08:00
<?php
//USER LAYOUT
/** @var yii\web\View $this */
2024-02-09 14:14:45 +08:00
/** @var string $content */
use app\assets\AppAsset;
2021-05-19 20:01:06 +08:00
use app\widgets\Alert;
use yii\bootstrap5\Breadcrumbs;
use yii\bootstrap5\Html;
use yii\bootstrap5\Nav;
use yii\bootstrap5\NavBar;
use yii\web\View;
2013-05-24 22:14:49 +08:00
2013-11-12 12:24:07 +08:00
AppAsset::register($this);
$this->registerCsrfMetaTags();
$this->registerMetaTag(['charset' => Yii::$app->charset], 'charset');
$this->registerMetaTag(['name' => 'viewport', 'content' => 'width=device-width, initial-scale=1, shrink-to-fit=no']);
$this->registerMetaTag(['name' => 'description', 'content' => $this->params['meta_description'] ?? '']);
$this->registerMetaTag(['name' => 'keywords', 'content' => $this->params['meta_keywords'] ?? '']);
$this->registerLinkTag(['rel' => 'icon', 'type' => 'image/x-icon', 'href' => Yii::getAlias('@web/favicon.ico')]);
$darkMode = Yii::$app->user->isGuest ? 0 : Yii::$app->user->identity->dark_mode;
2013-05-24 22:14:49 +08:00
?>
2013-11-28 05:19:43 +08:00
<?php $this->beginPage() ?>
2013-05-24 22:14:49 +08:00
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>" class="h-100" <?= $darkMode === 1 ? 'data-bs-theme="dark"' : '' ?> >
2013-05-24 22:14:49 +08:00
<head>
<title><?= Html::encode($this->title) . ' | ' . Yii::$app->name ?></title>
2014-03-16 12:46:16 +08:00
<?php $this->head() ?>
<?php
if ($_ENV['CLARITY_ENABLED'] === 'true') {
$clarityId = $_ENV['CLARITY_ID'];
echo <<<EOL
<script type="text/javascript">
(function(c,l,a,r,i,t,y){
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", "$clarityId");
</script>
EOL;
}
if ($_ENV['GA_ENABLED'] === 'true') {
$gaId = $_ENV['GA_ID'];
echo <<<EOL
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=$gaId"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '$gaId');
</script>
EOL;
}
?>
2013-05-24 22:14:49 +08:00
</head>
2021-05-19 20:01:06 +08:00
<body class="d-flex flex-column h-100">
2013-11-28 05:19:43 +08:00
<?php $this->beginBody() ?>
<header id="header">
<?php
NavBar::begin([
2024-02-15 11:08:46 +08:00
'brandLabel' => Yii::$app->name,
'brandUrl' => Yii::$app->homeUrl,
'options' => ['class' => 'navbar-expand-md navbar-dark bg-dark fixed-top']
]);
echo Nav::widget([
2021-05-19 20:01:06 +08:00
'options' => ['class' => 'navbar-nav'],
'items' => [
2024-04-19 18:22:39 +08:00
['label' => '仪表盘', 'url' => ['/site/index']],
['label' => '我的文件', 'url' => ['/home/index']],
['label' => '文件保险箱', 'url' => ['/vault/index']],
2024-02-16 15:13:29 +08:00
['label' => '分享管理', 'url' => ['/share/index']],
['label' => '文件收集', 'url' => ['/collection/index']],
2024-04-16 16:46:56 +08:00
['label' => '工单支持', 'url' => ['/tickets/index']],
['label' => '个人设置', 'url' => ['/user/info']],
Yii::$app->user->isGuest
2024-02-09 14:14:45 +08:00
? ['label' => '登录', 'url' => ['/user/login']]
: '<li class="nav-item">'
2024-02-09 14:14:45 +08:00
. Html::beginForm(['/user/logout'])
. Html::submitButton(
'登出账户 (' . Yii::$app->user->identity->username . ')',
2024-02-09 14:14:45 +08:00
['class' => 'nav-link btn btn-link logout']
)
. Html::endForm()
. '</li>'
]
]);
NavBar::end();
?>
2021-05-19 20:01:06 +08:00
</header>
2013-05-24 22:14:49 +08:00
<main id="main" class="flex-shrink-0" role="main">
<div class="container">
<?php if (!empty($this->params['breadcrumbs'])): ?>
<?= Breadcrumbs::widget(['links' => $this->params['breadcrumbs']]) ?>
<?php endif ?>
2017-08-08 18:02:19 +08:00
<?= Alert::widget() ?>
<?= $content ?>
2014-03-16 12:46:16 +08:00
</div>
2021-05-19 20:01:06 +08:00
</main>
<footer id="footer" class="mt-auto py-3">
<div class="container">
<div class="row text-muted">
2024-02-09 14:14:45 +08:00
<div class="col-md-6 text-center text-md-start"><?php echo '&copy; Created & Design by ' . '<a href="https://blog.chenx221.cyou" rel="external">Chenx221</a> | 2024 - ' . date('Y') ?></div>
<div class="col-md-6 text-center text-md-end"><?= Yii::t('yii', 'Powered by {yii}', [
2024-02-16 13:59:54 +08:00
'yii' => '<a href="https://www.yiiframework.com/" rel="external">' . Yii::t('yii',
2024-02-09 14:14:45 +08:00
'Yii Framework') . '</a>',
]) ?></div>
</div>
</div>
</footer>
2013-05-24 22:14:49 +08:00
2013-11-28 05:19:43 +08:00
<?php $this->endBody() ?>
2013-05-24 22:14:49 +08:00
</body>
</html>
<?php
if ($darkMode === 2) {
$this->registerJsFile('@web/js/darkmode_auto.js', ['position' => View::POS_BEGIN]);
} else if ($darkMode === 1) {
$this->registerJsFile('@web/js/darkmode.js', ['position' => View::POS_BEGIN]);
}
?>
2013-11-28 05:19:43 +08:00
<?php $this->endPage() ?>