351 lines
18 KiB
PHP
351 lines
18 KiB
PHP
<?php
|
|
$sub_menu = '700100';
|
|
include_once('./_common.php');
|
|
|
|
// ==================================================================
|
|
// 삭제 처리 로직
|
|
// ==================================================================
|
|
if (isset($_GET['mode']) && $_GET['mode'] == 'delete') {
|
|
auth_check_menu($auth, $sub_menu, 'd');
|
|
check_admin_token();
|
|
$um_id = isset($_GET['um_id']) ? (int)$_GET['um_id'] : 0;
|
|
if (!$um_id) {
|
|
alert('um_id 값이 없습니다.');
|
|
}
|
|
$sql = "SELECT resource_type FROM {$g5['ui_manager_table']} WHERE um_id = '{$um_id}'";
|
|
$row = sql_fetch($sql);
|
|
if (isset($row['resource_type'])) {
|
|
if ($row['resource_type'] == 'DATA') {
|
|
$sql_delete_lang = "DELETE FROM {$g5['common_lang_table']} WHERE target_table = '{$g5['form_category_table']}' AND target_id IN (SELECT fc_id FROM {$g5['form_category_table']} WHERE um_id = '{$um_id}')";
|
|
sql_query($sql_delete_lang);
|
|
$sql_delete_cat = "DELETE FROM {$g5['form_category_table']} WHERE um_id = '{$um_id}'";
|
|
sql_query($sql_delete_cat);
|
|
}
|
|
$sql_delete_main_lang = "DELETE FROM {$g5['common_lang_table']} WHERE target_table = '{$g5['ui_manager_table']}' AND target_id = '{$um_id}'";
|
|
sql_query($sql_delete_main_lang);
|
|
$sql_delete_main = "DELETE FROM {$g5['ui_manager_table']} WHERE um_id = '{$um_id}'";
|
|
sql_query($sql_delete_main);
|
|
}
|
|
// 삭제 후 현재 페이지와 검색 조건을 유지하도록 $qstr 사용
|
|
goto_url('./ui_manager_list.php?'.$qstr);
|
|
}
|
|
|
|
// ==================================================================
|
|
// 💡 [핵심 수정 1] 폼 제출 처리 로직 (신규 등록)
|
|
// ==================================================================
|
|
// GnuBoard 표준에 따라 'w' 값이 비어있을 때를 신규 등록으로 처리합니다.
|
|
if (empty($w) && $_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']) : '';
|
|
|
|
// 유효성 검사
|
|
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 테이블에 정보 INSERT
|
|
$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 테이블에 정보 INSERT
|
|
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('./ui_manager_list.php');
|
|
}
|
|
// ==================================================================
|
|
|
|
auth_check_menu($auth, $sub_menu, 'r');
|
|
|
|
// 검색 및 페이징 변수 처리
|
|
$sfl = isset($_GET['sfl']) ? trim($_GET['sfl']) : '';
|
|
$stx = isset($_GET['stx']) ? trim($_GET['stx']) : '';
|
|
$page_rows = isset($_GET['page_rows']) && (int)$_GET['page_rows'] > 0 ? (int)$_GET['page_rows'] : 15;
|
|
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
|
|
if ($page < 1) $page = 1;
|
|
|
|
// 페이지당 목록 수($page_rows)를 $qstr에 추가하여 다른 링크에서도 유지되도록 함
|
|
$qstr .= ($qstr ? '&' : '') . 'page_rows=' . urlencode($page_rows);
|
|
|
|
$sql_search = "";
|
|
if ($sfl && $stx) {
|
|
$stx_escaped = sql_real_escape_string($stx);
|
|
$sql_search = " WHERE ";
|
|
|
|
switch ($sfl) {
|
|
case 'screen_code':
|
|
case 'group_code':
|
|
case 'resource_code':
|
|
case 'resource_desc':
|
|
$sql_search .= "A.{$sfl} LIKE '%{$stx_escaped}%'";
|
|
break;
|
|
case 'cl_name':
|
|
$sql_search .= "B.cl_name LIKE '%{$stx_escaped}%'";
|
|
break;
|
|
default: // '전체' 검색
|
|
$sql_search .= " ( A.screen_code LIKE '%{$stx_escaped}%' OR A.group_code LIKE '%{$stx_escaped}%' OR A.resource_code LIKE '%{$stx_escaped}%' OR A.resource_desc LIKE '%{$stx_escaped}%' OR B.cl_name LIKE '%{$stx_escaped}%' ) ";
|
|
break;
|
|
}
|
|
}
|
|
|
|
// 1. 검색 조건에 맞는 모든 리소스를 한 번에 가져옴
|
|
$sql = "SELECT A.*, B.cl_name
|
|
FROM {$g5['ui_manager_table']} AS A
|
|
LEFT JOIN {$g5['common_lang_table']} AS B
|
|
ON (A.um_id = B.target_id AND B.target_table = '{$g5['ui_manager_table']}' AND B.lang_code = 'ko')
|
|
{$sql_search}
|
|
ORDER BY A.screen_code, A.group_code, A.resource_code";
|
|
$result = sql_query($sql);
|
|
|
|
// 2. PHP에서 화면별로 그룹화
|
|
$all_grouped_resources = [];
|
|
$total_resource_count = 0;
|
|
while ($row = sql_fetch_array($result)) {
|
|
$all_grouped_resources[$row['screen_code']][] = $row;
|
|
$total_resource_count++;
|
|
}
|
|
|
|
// 3. 그룹화된 결과를 기준으로 페이징 처리
|
|
$total_count = count($all_grouped_resources); // 전체 '화면' 수
|
|
$total_page = ceil($total_count / $page_rows);
|
|
$from_record = ($page - 1) * $page_rows;
|
|
|
|
// 현재 페이지에 해당하는 그룹만 잘라냄
|
|
$paged_groups = array_slice($all_grouped_resources, $from_record, $page_rows, true);
|
|
|
|
$g5['title'] = 'UI 리소스 관리';
|
|
include_once(G5_ADMIN_PATH . '/admin.head.php');
|
|
|
|
add_stylesheet('<link rel="stylesheet" href="' . G5_ADMIN_URL . '/code_manager/css/code_manager.css?ver=1.3">', 0);
|
|
?>
|
|
|
|
<div class="local_desc01 local_desc">
|
|
<p>
|
|
웹사이트의 모든 화면에 사용되는 텍스트(라벨)와 선택 옵션(데이터)을 체계적으로 관리합니다.<br>
|
|
'화면 코드' 별로 그룹화되어 표시되며, 각 그룹을 클릭하여 내용을 확인하거나 수정할 수 있습니다.
|
|
</p>
|
|
</div>
|
|
|
|
<!-- 검색 폼 -->
|
|
<section id="resource_search_form">
|
|
<h2 class="h2_frm">리소스 검색</h2>
|
|
<form name="fsearch" id="fsearch" method="get">
|
|
<div class="search-form-inner">
|
|
<label for="page_rows" class="sound_only">페이지당 개수</label>
|
|
<select name="page_rows" id="page_rows" class="frm_input">
|
|
<option value="15" <?php echo get_selected($page_rows, 15); ?>>15개씩</option>
|
|
<option value="30" <?php echo get_selected($page_rows, 30); ?>>30개씩</option>
|
|
<option value="50" <?php echo get_selected($page_rows, 50); ?>>50개씩</option>
|
|
<option value="100" <?php echo get_selected($page_rows, 100); ?>>100개씩</option>
|
|
</select>
|
|
|
|
<label for="sfl" class="sound_only">검색대상</label>
|
|
<select name="sfl" id="sfl">
|
|
<option value="all" <?php echo get_selected($sfl, 'all'); ?>>전체</option>
|
|
<option value="screen_code" <?php echo get_selected($sfl, 'screen_code'); ?>>화면 코드</option>
|
|
<option value="group_code" <?php echo get_selected($sfl, 'group_code'); ?>>그룹 코드</option>
|
|
<option value="resource_code" <?php echo get_selected($sfl, 'resource_code'); ?>>리소스 코드</option>
|
|
<option value="resource_desc" <?php echo get_selected($sfl, 'resource_desc'); ?>>설명</option>
|
|
<option value="cl_name" <?php echo get_selected($sfl, 'cl_name'); ?>>라벨명</option>
|
|
</select>
|
|
|
|
<label for="stx" class="sound_only">검색어</label>
|
|
<input type="text" name="stx" value="<?php echo get_text($stx) ?>" id="stx" class="frm_input" size="30">
|
|
<input type="submit" value="검색" class="btn_submit">
|
|
</div>
|
|
</form>
|
|
</section>
|
|
|
|
<section id="code_manager">
|
|
<div class="code-manager-header">
|
|
<h2 class="code-manager-title">UI 리소스 목록 (총 <?php echo number_format($total_count); ?>개 화면)</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">
|
|
<!-- 💡 [핵심 수정 2] 신규 등록이므로 w 값을 비워둡니다. -->
|
|
<input type="hidden" name="w" value="">
|
|
<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 id="resource-list-accordion">
|
|
<?php if (count($paged_groups) == 0) : ?>
|
|
<div class="empty_list">표시할 리소스가 없습니다.</div>
|
|
<?php else : ?>
|
|
<?php foreach ($paged_groups as $screen_code => $resources) : ?>
|
|
<div class="accordion-item">
|
|
<div class="accordion-header">
|
|
<span class="screen-title"><i class="fa fa-desktop"></i> 화면: <strong><?php echo get_text($screen_code); ?></strong></span>
|
|
<span class="resource-count"><?php echo count($resources); ?>개 리소스</span>
|
|
<i class="fa fa-chevron-down accordion-icon"></i>
|
|
</div>
|
|
<div class="accordion-content">
|
|
<div class="tbl_head01 tbl_wrap">
|
|
<table>
|
|
<colgroup>
|
|
<col style="width: 15%;">
|
|
<col style="width: 20%;">
|
|
<col style="width: 10%;">
|
|
<col>
|
|
<col style="width: 240px;">
|
|
</colgroup>
|
|
<thead>
|
|
<tr>
|
|
<th scope="col">그룹 코드</th>
|
|
<th scope="col">리소스 코드</th>
|
|
<th scope="col">타입</th>
|
|
<th scope="col">설명</th>
|
|
<th scope="col">관리</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($resources as $res) : ?>
|
|
<tr>
|
|
<td><?php echo get_text($res['group_code']); ?></td>
|
|
<td><?php echo get_text($res['resource_code']); ?></td>
|
|
<td>
|
|
<?php if ($res['resource_type'] == 'LABEL'): ?>
|
|
<span class="res-type-label">라벨</span>
|
|
<?php else: ?>
|
|
<span class="res-type-data">데이터</span>
|
|
<?php endif; ?>
|
|
</td>
|
|
<td class="td_left"><?php echo get_text($res['resource_desc']); ?></td>
|
|
<td class="td_mng td_mng_s">
|
|
<?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="./ui_manager_form.php?w=u&um_id=<?php echo $res['um_id']; ?>&<?php echo $qstr; ?>" class="btn btn_02">수정</a>
|
|
<a href="./lang_manager.php?target_table=<?php echo $g5['ui_manager_table']; ?>&target_id=<?php echo $res['um_id']; ?>" class="btn btn_01">다국어</a>
|
|
<button type="button" class="btn btn_delete btn_delete_resource" data-um_id="<?php echo $res['um_id']; ?>">삭제</button>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<!-- 페이징 링크 출력 -->
|
|
<div class="pagination_wrap">
|
|
<?php
|
|
$paging_url = $_SERVER['SCRIPT_NAME'].'?'.$qstr;
|
|
echo get_paging(G5_IS_MOBILE ? $config['cf_mobile_pages'] : $config['cf_write_pages'], $page, $total_page, $paging_url);
|
|
?>
|
|
</div>
|
|
|
|
</section>
|
|
|
|
<script>
|
|
var g5_admin_token = "<?php echo get_admin_token(); ?>";
|
|
</script>
|
|
<script src="<?php echo G5_ADMIN_URL; ?>/code_manager/js/ui_manager.js?ver=1.3"></script>
|
|
|
|
<?php
|
|
include_once(G5_ADMIN_PATH . '/admin.tail.php');
|