Files
dnssash/adm/code_manager/code_list.php
T
2026-06-11 18:47:38 +09:00

210 lines
10 KiB
PHP

<?php
$sub_menu = '100900'; // admin.menu100.php 에 정의된 메뉴 코드
include_once('./_common.php');
// ==================================================================
// 💡 [핵심] 폼 제출 처리 로직
// ==================================================================
if (isset($w) && $w == 'u' && $_SERVER['REQUEST_METHOD'] === 'POST') {
auth_check_menu($auth, $sub_menu, 'w');
check_admin_token();
// 입력값 정리
$screen_code = trim($_POST['screen_code']);
$group_code = trim($_POST['group_code']);
$resource_code = trim($_POST['resource_code']);
$resource_type = trim($_POST['resource_type']);
$resource_desc = trim($_POST['resource_desc']);
$cl_name = isset($_POST['cl_name']) ? trim($_POST['cl_name']) : ''; // LABEL 타입일 때만 넘어옴
// 유효성 검사
if (!$screen_code || !$group_code || !$resource_code || !$resource_type) {
alert('필수 항목을 모두 입력해주세요.');
}
if ($resource_type == 'LABEL' && !$cl_name) {
alert('UI 라벨 타입은 한국어 라벨명을 필수로 입력해야 합니다.');
}
// 중복 검사
$sql = "SELECT COUNT(*) as cnt FROM {$g5['ui_manager_table']} WHERE screen_code = '{$screen_code}' AND group_code = '{$group_code}' AND resource_code = '{$resource_code}'";
$row = sql_fetch($sql);
if ($row['cnt']) {
alert('이미 등록된 리소스 코드입니다.');
}
// 1. g5_ui_manager 테이블에 리소스 '설계' 정보 저장
$sql = "INSERT INTO {$g5['ui_manager_table']}
SET screen_code = '{$screen_code}',
group_code = '{$group_code}',
resource_code = '{$resource_code}',
resource_type = '{$resource_type}',
resource_desc = '{$resource_desc}',
is_used = '1',
created_at = '".G5_TIME_YMDHIS."',
created_by = '{$member['mb_id']}',
updated_at = '".G5_TIME_YMDHIS."',
updated_by = '{$member['mb_id']}'";
sql_query($sql);
$um_id = sql_insert_id();
// 2. 리소스 타입이 'LABEL'인 경우, g5_common_lang 테이블에 실제 텍스트 저장
if ($resource_type == 'LABEL' && $cl_name) {
$sql = "INSERT INTO {$g5['common_lang_table']}
SET target_table = '{$g5['ui_manager_table']}',
target_id = '{$um_id}',
lang_code = 'ko',
cl_name = '{$cl_name}',
updated_at = '".G5_TIME_YMDHIS."',
updated_by = '{$member['mb_id']}'";
sql_query($sql);
}
goto_url('./code_list.php');
}
auth_check_menu($auth, $sub_menu, 'r');
// 등록된 리소스 목록 조회
$sql = "SELECT * FROM {$g5['ui_manager_table']} ORDER BY screen_code, group_code, resource_code";
$result = sql_query($sql);
$resource_list = [];
while ($row = sql_fetch_array($result)) {
$resource_list[] = $row;
}
$resource_list_count = count($resource_list);
$g5['title'] = 'UI 리소스 관리';
include_once(G5_ADMIN_PATH . '/admin.head.php');
// 솔루션 전용 CSS/JS 파일을 불러옵니다.
add_stylesheet('<link rel="stylesheet" href="' . G5_ADMIN_URL . '/code_manager/css/code_manager.css">', 0);
?>
<div class="local_desc01 local_desc">
<p>
웹사이트의 모든 화면에 사용되는 텍스트(라벨)와 선택 옵션(데이터)을 체계적으로 관리합니다.
</p>
</div>
<section id="code_manager">
<div class="code-manager-header">
<h2 class="code-manager-title">UI 리소스 목록</h2>
<div class="code-manager-actions">
<button type="button" id="add-resource-btn" class="btn btn_01">
<i class="fa fa-plus" aria-hidden="true"></i> 새 리소스 추가
</button>
</div>
</div>
<!-- 새 리소스 추가 폼 -->
<div id="resource-form-container" style="display: none;">
<form name="fresourceform" id="fresourceform" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post">
<input type="hidden" name="w" value="u">
<input type="hidden" name="token" value="<?php echo get_admin_token(); ?>">
<div class="tbl_frm01 tbl_wrap">
<table>
<caption>UI 리소스 추가 폼</caption>
<colgroup>
<col class="grid_4">
<col>
</colgroup>
<tbody>
<tr>
<th scope="row"><label for="screen_code">화면 코드</label></th>
<td>
<input type="text" name="screen_code" id="screen_code" required class="required frm_input" size="30">
<span class="frm_info">리소스가 사용될 화면의 고유 코드 (예: order_form, member_join)</span>
</td>
</tr>
<tr>
<th scope="row"><label for="group_code">그룹 코드</label></th>
<td>
<input type="text" name="group_code" id="group_code" required class="required frm_input" size="30">
<span class="frm_info">화면 내에서 리소스를 묶어줄 그룹 코드 (예: address_info, common_options)</span>
</td>
</tr>
<tr>
<th scope="row">리소스 타입</th>
<td>
<label><input type="radio" name="resource_type" value="LABEL" checked> UI 라벨 (단일 텍스트)</label>
<label><input type="radio" name="resource_type" value="DATA"> 데이터 (선택 옵션)</label>
</td>
</tr>
<tr class="resource-type-field" id="label-field">
<th scope="row"><label for="cl_name">한국어 라벨명</label></th>
<td>
<input type="text" name="cl_name" id="cl_name" class="frm_input" size="50">
<span class="frm_info">화면에 표시될 실제 텍스트 (예: 집의 유형, 창호 재질)</span>
</td>
</tr>
<tr>
<th scope="row"><label for="resource_code">리소스 코드</label></th>
<td>
<input type="text" name="resource_code" id="resource_code" required class="required frm_input" size="30">
<span class="frm_info">개발자가 이 리소스를 호출할 때 사용할 고유 코드 (예: house_type_label, house_type_data)</span>
</td>
</tr>
<tr>
<th scope="row"><label for="resource_desc">설명</label></th>
<td>
<input type="text" name="resource_desc" id="resource_desc" class="frm_input" size="80">
<span class="frm_info">이 리소스의 용도에 대한 설명 (관리자 참고용)</span>
</td>
</tr>
</tbody>
</table>
</div>
<div class="btn_confirm01 btn_confirm">
<button type="button" id="cancel-resource-btn" class="btn_cancel btn">취소</button>
<input type="submit" value="리소스 등록" class="btn_submit btn" accesskey="s">
</div>
</form>
</div>
<!-- 등록된 리소스 목록 테이블 -->
<div class="tbl_head01 tbl_wrap">
<table>
<caption>UI 리소스 목록</caption>
<thead>
<tr>
<th scope="col">화면 코드</th>
<th scope="col">그룹 코드</th>
<th scope="col">리소스 코드</th>
<th scope="col">타입</th>
<th scope="col">설명</th>
<th scope="col">관리</th>
</tr>
</thead>
<tbody>
<?php if ($resource_list_count > 0) : ?>
<?php foreach ($resource_list as $res) : ?>
<tr>
<td><?php echo get_text($res['screen_code']); ?></td>
<td><?php echo get_text($res['group_code']); ?></td>
<td><?php echo get_text($res['resource_code']); ?></td>
<td><?php echo $res['resource_type']; ?></td>
<td class="td_left"><?php echo get_text($res['resource_desc']); ?></td>
<td class="td_mng">
<?php if ($res['resource_type'] == 'DATA') : ?>
<a href="./category_list.php?um_id=<?php echo $res['um_id']; ?>" class="btn btn_03">옵션 관리</a>
<?php endif; ?>
<a href="./category_list.php?w=u&amp;um_id=<?php echo $res['um_id']; ?>" class="btn btn_02">수정</a>
</td>
</tr>
<?php endforeach; ?>
<?php else : ?>
<tr class="empty_table">
<td colspan="6">등록된 리소스가 없습니다.</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</section>
<script src="<?php echo G5_ADMIN_URL; ?>/code_manager/js/code_manager.js"></script>
<?php
include_once(G5_ADMIN_PATH . '/admin.tail.php');