Files
jongryangje/app/Views/home/_dashboard_gov_portal_sidebar.php
taekyoungc 794d34635b feat: 기본정보관리 사이드바 소메뉴에 아이콘 추가
- 이름 키워드 기반 Font Awesome 아이콘 매핑(서버 렌더 + JS 재구성 양쪽 반영)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-13 12:27:13 +09:00

87 lines
3.7 KiB
PHP

<?php
declare(strict_types=1);
/** @var list<array> $govNavItems */
/** @var int $govActiveParentIdx */
/** @var string $govActiveChildHref */
$activeParent = $govNavItems[$govActiveParentIdx] ?? $govNavItems[0] ?? null;
$sidebarTitle = $activeParent['name'] ?? 'MY MENU';
$activeChildHref = strtolower(ltrim((string) ($govActiveChildHref ?? ''), '/'));
// 기본정보관리 소메뉴에 어울리는 아이콘(Font Awesome solid) 매핑 — 이름 키워드 기준(구체적인 것 먼저)
$showSidebarIcons = (str_replace(' ', '', (string) $sidebarTitle) === '기본정보관리');
$sidebarIconFor = static function (string $name): string {
$rules = [
'바코드' => 'fa-barcode', // 지정판매소 바코드 출력
'조회' => 'fa-magnifying-glass', // 지정 판매소 조회
'신규' => 'fa-chart-column', // 지정 판매소 신규/취소 현황
'현황' => 'fa-chart-column',
'판매소' => 'fa-store', // 지정 판매소 관리
'대행소' => 'fa-handshake',
'담당자' => 'fa-user-tie',
'업체' => 'fa-building',
'무료' => 'fa-gift',
'포장' => 'fa-box',
'단가' => 'fa-won-sign',
'코드' => 'fa-list-ol',
'비밀번호' => 'fa-key',
'설정' => 'fa-gear',
];
foreach ($rules as $kw => $icon) {
if (mb_stripos($name, $kw) !== false) {
return $icon;
}
}
if (stripos($name, 'password') !== false) {
return 'fa-key';
}
return 'fa-angle-right';
};
?>
<aside class="sidebar">
<div class="my-menu-hd" id="portalSidebarTitle"><?= esc($sidebarTitle) ?></div>
<ul class="my-menu-list" id="portalSidebarList">
<?php if ($activeParent !== null): ?>
<?php if (! empty($activeParent['hasChildren'])): ?>
<?php foreach ($activeParent['children'] as $ci => $child): ?>
<?php
$childHref = strtolower(ltrim((string) ($child['href'] ?? ''), '/'));
$isChildActive = $activeChildHref !== ''
? ($childHref === $activeChildHref)
: ($ci === 0);
?>
<li>
<?php if ($child['href'] !== ''): ?>
<a href="<?= esc($child['url']) ?>" class="<?= $isChildActive ? 'active' : '' ?>">
<?php if ($showSidebarIcons): ?><i class="fa-solid <?= esc($sidebarIconFor((string) $child['name']), 'attr') ?>" style="width:1.15em;margin-right:.45em;opacity:.85;"></i><?php endif; ?><?= esc($child['name']) ?>
</a>
<?php else: ?>
<span class="menu-sub" style="opacity:.65;cursor:default;">
<?php if ($showSidebarIcons): ?><i class="fa-solid <?= esc($sidebarIconFor((string) $child['name']), 'attr') ?>" style="width:1.15em;margin-right:.45em;opacity:.85;"></i><?php endif; ?><?= esc($child['name']) ?>
</span>
<?php endif; ?>
</li>
<?php endforeach; ?>
<?php elseif ($activeParent['href'] !== ''): ?>
<li>
<a href="<?= esc($activeParent['url']) ?>" class="active">
<?= esc($activeParent['name']) ?>
</a>
</li>
<?php endif; ?>
<?php endif; ?>
</ul>
<div class="sidebar-blocks">
<div class="sb-teal">
<i class="fa-solid fa-mobile-screen"></i>
모바일 앱(예정)<br/>지정판매소 판매·스캔 연동
</div>
<div class="sb-gray">
<i class="fa-solid fa-repeat"></i> 통합 전환<br/>
<a href="<?= base_url('admin/select-local-government') ?>" style="color:#fff;text-decoration:underline;">지자체 선택</a>
</div>
<div class="sb-links">
<a href="<?= base_url('bag/manual') ?>">사용자 매뉴얼</a>
</div>
</div>
</aside>