Files
jongryangje/app/Views/components/header_user_tools.php
2026-04-08 00:18:01 +09:00

47 lines
2.3 KiB
PHP

<?php
declare(strict_types=1);
/**
* 상단 헤더 오른쪽: 사용자·역할 · 작업 지자체 · (사이트|관리자) · 로그아웃
*
* @var array{name:string,role_label:string}|null $userNav
* @var string|null $effectiveLgName
* @var bool $showSiteLink 관리자 → 일반 사이트
* @var bool $showAdminLink 사이트 → 관리자 패널
*/
helper('admin');
if (! isset($userNav)) {
$userNav = session_user_nav_display();
}
$showSiteLink = ! empty($showSiteLink);
$showAdminLink = ! empty($showAdminLink);
?>
<div class="flex items-center gap-2 sm:gap-3 shrink-0">
<?php if ($userNav !== null): ?>
<div class="hidden sm:flex flex-col items-end leading-tight max-w-[11rem] border-r border-gray-200 pr-3 mr-1"
title="<?= esc($userNav['name'] . ' · ' . $userNav['role_label']) ?>">
<span class="text-sm font-medium text-gray-800 truncate"><?= esc($userNav['name']) ?></span>
<span class="text-xxs text-gray-500 truncate"><?= esc($userNav['role_label']) ?></span>
</div>
<div class="sm:hidden text-xs text-gray-600 max-w-[6rem] truncate" title="<?= esc($userNav['name'] . ' · ' . $userNav['role_label']) ?>">
<?= esc($userNav['name']) ?>
</div>
<?php endif; ?>
<?php if (! empty($effectiveLgName)): ?>
<span class="text-sm text-gray-600 max-w-[10rem] truncate" title="현재 작업 지자체"><?= esc((string) $effectiveLgName) ?></span>
<?php endif; ?>
<?php if ($showSiteLink): ?>
<a href="<?= base_url('/') ?>" class="text-sm text-gray-600 hover:text-blue-600 whitespace-nowrap px-0.5">사이트</a>
<?php endif; ?>
<?php if ($showAdminLink): ?>
<a href="<?= base_url('admin') ?>" class="text-sm text-gray-600 hover:text-blue-600 whitespace-nowrap px-0.5">관리자</a>
<?php endif; ?>
<a href="<?= base_url('logout') ?>"
class="flex items-center gap-1 text-sm text-gray-500 hover:text-red-600 transition-colors px-1.5 py-1 rounded-md hover:bg-red-50 whitespace-nowrap"
title="로그아웃">
<svg class="h-5 w-5 shrink-0" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24" aria-hidden="true">
<path d="M6 18L18 6M6 6l12 12" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
<span>종료</span>
</a>
</div>