# HAYAN_CS 게시판 확장 계획서

## 📋 현재 구조 분석

### 현재 파일 구조

#### 리스트 페이지 (총 6개)
- **고객용 (3종)**:
  - `list.skin.php` → normal 모드 (일반 리스트)
  - `list_StandForm.skin.php` → standby 모드 (대기자 리스트)
  - `list_acceptance.php` → acceptance 모드 (합격자 리스트)
  
- **관리자용 (3종)**:
  - `list_manage.php` → normal 모드 (관리자 리스트)
  - (standby 모드 관리자용 - 현재 list_manage.php에서 분기 처리)
  - (acceptance 모드 관리자용 - 현재 list_manage.php에서 분기 처리)

#### 뷰 페이지 (2개)
- **고객용**: `view.skin.php` (그누보드 스킨 파일)
- **관리자용**: `view_detail.php` (팝업 형식)

#### 글쓰기 페이지 (2개)
- **고객용**: `write.skin.php` (그누보드 스킨 파일, 폼 생성기 사용)
- **관리자용**: `write_edit.php` (팝업 형식, 폼 생성기 사용)

### 현재 board_mode 체계
```json
{
  "board_mode": "normal" | "standby" | "acceptance"
}
```

---

## 🎯 확장 목표

### 요구사항
1. **현재 구조 100% 유지** (기존 기능 절대 손상 금지)
2. **새로운 버전 추가 가능**: 갤러리, 공지사항, 온라인학습, 룸소개 등
3. **각 버전별 독립적 페이지**:
   - 리스트: 고객용, 관리자용 각각
   - 뷰: 고객용, 관리자용 각각
   - 글쓰기: 고객용, 관리자용 각각 (때로는 특화 페이지)
4. **글쓰기 폼 확장**: 내용 입력창(wr_content 에디터) 추가 가능
5. **유지보수 편의성**: 새 버전 추가 시 기존 코드 수정 최소화

---

## 🏗️ 확장 구조 설계

### 1단계: board_type 필드 추가

#### form_config.json 구조 확장
```json
{
  "board_type": "cs" | "gallery" | "notice" | "education" | "room",
  "board_mode": "normal" | "standby" | "acceptance",
  "write_config": {
    "use_content_editor": false,
    "content_editor_type": "basic" | "advanced",
    "content_required": false
  },
  "page_config": {
    "list_client": "auto" | "custom",
    "list_admin": "auto" | "custom",
    "view_client": "auto" | "custom",
    "view_admin": "auto" | "custom",
    "write_client": "auto" | "custom",
    "write_admin": "auto" | "custom"
  }
}
```

#### board_type 종류
- `cs`: 현재 신청 게시판 (기본값, 하위 호환성)
- `gallery`: 갤러리
- `notice`: 공지사항
- `education`: 온라인학습
- `room`: 룸소개

---

### 2단계: 파일명 규칙 정의

#### 리스트 페이지
```
[고객용]
list.skin.php              → 기본 (board_type="cs", board_mode="normal")
list_{board_type}.skin.php → 특정 타입 전용
list_{board_mode}.skin.php → 특정 모드 전용 (현재 구조)
list_{board_type}_{board_mode}.skin.php → 타입+모드 조합

[관리자용]
list_manage.php                    → 기본 (board_type="cs", board_mode="normal")
list_manage_{board_type}.php       → 특정 타입 전용
list_manage_{board_mode}.php       → 특정 모드 전용
list_manage_{board_type}_{board_mode}.php → 타입+모드 조합
```

#### 뷰 페이지
```
[고객용]
view.skin.php              → 기본 (board_type="cs")
view_{board_type}.skin.php → 특정 타입 전용

[관리자용]
view_detail.php              → 기본 (board_type="cs")
view_detail_{board_type}.php → 특정 타입 전용
```

#### 글쓰기 페이지
```
[고객용]
write.skin.php              → 기본 (board_type="cs")
write_{board_type}.skin.php → 특정 타입 전용

[관리자용]
write_edit.php              → 기본 (board_type="cs")
write_edit_{board_type}.php → 특정 타입 전용
```

---

### 3단계: 파일 로딩 로직

#### 공통 함수: `hycs_load_page_file()`

**위치**: `mandoo.function.php` 또는 새 파일 `page_loader.php`

```php
function hycs_load_page_file($page_type, $board_skin_path, $form_config) {
    /**
     * $page_type: 'list_client', 'list_admin', 'view_client', 'view_admin', 'write_client', 'write_admin'
     * 
     * 로딩 우선순위:
     * 1. board_type + board_mode 조합 파일
     * 2. board_type 전용 파일
     * 3. board_mode 전용 파일 (기존 방식)
     * 4. 기본 파일
     */
    
    $board_type = isset($form_config['board_type']) ? $form_config['board_type'] : 'cs';
    $board_mode = isset($form_config['board_mode']) ? $form_config['board_mode'] : 'normal';
    
    $file_map = array(
        'list_client' => array(
            'list_{type}_{mode}.skin.php',
            'list_{type}.skin.php',
            'list_{mode}.skin.php',
            'list.skin.php'
        ),
        'list_admin' => array(
            'list_manage_{type}_{mode}.php',
            'list_manage_{type}.php',
            'list_manage_{mode}.php',
            'list_manage.php'
        ),
        // ... 나머지 페이지 타입
    );
    
    $files = $file_map[$page_type];
    foreach ($files as $file_pattern) {
        $file = str_replace(
            array('{type}', '{mode}'),
            array($board_type, $board_mode),
            $file_pattern
        );
        $file_path = $board_skin_path . '/' . $file;
        
        if (file_exists($file_path)) {
            return $file_path;
        }
    }
    
    // 기본 파일도 없으면 에러
    return false;
}
```

---

### 4단계: 기존 파일 수정 (최소화)

#### list.skin.php 수정
```php
// 기존 코드 (130-171 라인)
$board_mode = isset($form_config['board_mode']) ? $form_config['board_mode'] : 'normal';

// ✅ 기존 분기 로직 유지 (100% 호환성)
if ($board_mode === 'standby') {
    include_once $board_skin_path . '/list_StandForm.skin.php';
    return;
}
if ($board_mode === 'acceptance') {
    include_once $board_skin_path . '/list_acceptance.php';
    return;
}

// ✅ 새로운 확장 로직 추가 (기존 코드 아래)
$board_type = isset($form_config['board_type']) ? $form_config['board_type'] : 'cs';

// board_type이 'cs'가 아니면 타입별 파일 체크
if ($board_type !== 'cs') {
    $type_file = $board_skin_path . '/list_' . $board_type . '.skin.php';
    if (file_exists($type_file)) {
        include_once $type_file;
        return;
    }
    
    // 타입+모드 조합 파일 체크
    $type_mode_file = $board_skin_path . '/list_' . $board_type . '_' . $board_mode . '.skin.php';
    if (file_exists($type_mode_file)) {
        include_once $type_mode_file;
        return;
    }
}

// ✅ 기존 normal 모드 코드 계속 실행 (변경 없음)
```

#### view.skin.php 수정
```php
// 파일 상단에 추가 (50 라인 근처)
$board_type = isset($form_config['board_type']) ? $form_config['board_type'] : 'cs';

if ($board_type !== 'cs') {
    $type_file = $board_skin_path . '/view_' . $board_type . '.skin.php';
    if (file_exists($type_file)) {
        include_once $type_file;
        return;
    }
}

// ✅ 기존 코드 계속 실행 (변경 없음)
```

#### write.skin.php 수정
```php
// 파일 상단에 추가 (67 라인 근처)
$board_type = isset($form_config['board_type']) ? $form_config['board_type'] : 'cs';

if ($board_type !== 'cs') {
    $type_file = $board_skin_path . '/write_' . $board_type . '.skin.php';
    if (file_exists($type_file)) {
        include_once $type_file;
        return;
    }
}

// ✅ 내용 입력창 추가 로직 (기존 코드 아래)
$write_config = isset($form_config['write_config']) ? $form_config['write_config'] : array();
$use_content_editor = isset($write_config['use_content_editor']) && $write_config['use_content_editor'];
$content_editor_type = isset($write_config['content_editor_type']) ? $write_config['content_editor_type'] : 'basic';
$content_required = isset($write_config['content_required']) ? $write_config['content_required'] : false;

// ✅ 기존 코드 계속 실행
```

---

### 5단계: 새 버전 추가 예시 (갤러리)

#### form_config_gallery.json
```json
{
  "board_type": "gallery",
  "board_mode": "normal",
  "write_config": {
    "use_content_editor": true,
    "content_editor_type": "basic",
    "content_required": false
  }
}
```

#### list_gallery.skin.php (고객용 갤러리 리스트)
```php
<?php
// list.skin.php를 복사하여 시작
// 갤러리 전용 수정:
// - 이미지 썸네일 표시
// - 그리드 레이아웃
// - 라이트박스 기능
```

#### list_manage_gallery.php (관리자용 갤러리 리스트)
```php
<?php
// list_manage.php를 복사하여 시작
// 갤러리 관리 전용 수정:
// - 이미지 일괄 업로드
// - 드래그 앤 드롭 순서 변경
```

#### view_gallery.skin.php (고객용 갤러리 뷰)
```php
<?php
// view.skin.php를 복사하여 시작
// 갤러리 전용 수정:
// - 이미지 슬라이더
// - 이미지 확대 기능
```

#### write_gallery.skin.php (고객용 갤러리 글쓰기)
```php
<?php
// write.skin.php를 복사하여 시작
// 갤러리 전용 수정:
// - 다중 이미지 업로드
// - 내용 입력창 추가 (wr_content 에디터)
// - 이미지 미리보기
```

---

### 6단계: 관리자 설정 화면 확장

#### hycs_form_config.php 수정
```php
// board_type 선택 필드 추가
// 기존 board_mode 필드 아래
```

**설정 화면 UI**:
```
┌─────────────────────────────────┐
│ 게시판 타입: [cs ▼]            │
│  - cs (신청)                    │
│  - gallery (갤러리)             │
│  - notice (공지사항)            │
│  - education (온라인학습)       │
│  - room (룸소개)                │
├─────────────────────────────────┤
│ 게시판 모드: [normal ▼]        │
│  - normal (일반)                │
│  - standby (대기자)             │
│  - acceptance (합격자)          │
├─────────────────────────────────┤
│ 글쓰기 설정                     │
│  ☑ 내용 입력창 사용             │
│  에디터 타입: [basic ▼]        │
│  ☐ 내용 필수 입력               │
└─────────────────────────────────┘
```

---

## 📁 최종 파일 구조 (예시)

```
hayan_cs/
├── [공통 파일]
│   ├── mandoo.function.php
│   ├── standby.helper.php
│   ├── hycs_excel_helper.php
│   └── page_loader.php (신규)
│
├── [리스트 - 고객용]
│   ├── list.skin.php (기본, normal 모드)
│   ├── list_StandForm.skin.php (standby 모드)
│   ├── list_acceptance.php (acceptance 모드)
│   ├── list_gallery.skin.php (신규)
│   ├── list_notice.skin.php (신규)
│   └── ...
│
├── [리스트 - 관리자용]
│   ├── list_manage.php (기본, normal 모드)
│   ├── list_manage_gallery.php (신규)
│   ├── list_manage_notice.php (신규)
│   └── ...
│
├── [뷰 - 고객용]
│   ├── view.skin.php (기본)
│   ├── view_gallery.skin.php (신규)
│   ├── view_notice.skin.php (신규)
│   └── ...
│
├── [뷰 - 관리자용]
│   ├── view_detail.php (기본)
│   ├── view_detail_gallery.php (신규)
│   ├── view_detail_notice.php (신규)
│   └── ...
│
├── [글쓰기 - 고객용]
│   ├── write.skin.php (기본)
│   ├── write_gallery.skin.php (신규)
│   ├── write_notice.skin.php (신규)
│   └── ...
│
├── [글쓰기 - 관리자용]
│   ├── write_edit.php (기본)
│   ├── write_edit_gallery.php (신규)
│   ├── write_edit_notice.php (신규)
│   └── ...
│
└── [설정 파일]
    ├── form_config.json (기본)
    ├── form_config_{bo_table}.json
    ├── form_config_gallery.json (신규)
    └── ...
```

---

## ✅ 구현 체크리스트

### Phase 1: 기본 구조 확장
- [ ] `form_config.json`에 `board_type` 필드 추가 (기본값: "cs")
- [ ] `form_config.json`에 `write_config` 필드 추가
- [ ] `mandoo.function.php`에 `hycs_load_page_file()` 함수 추가
- [ ] `list.skin.php`에 타입별 분기 로직 추가 (기존 코드 유지)
- [ ] `view.skin.php`에 타입별 분기 로직 추가
- [ ] `write.skin.php`에 타입별 분기 로직 추가

### Phase 2: 내용 입력창 기능
- [ ] `write.skin.php`에 내용 에디터 추가 로직
- [ ] 기본 에디터 (textarea) 구현
- [ ] 고급 에디터 (그누보드 에디터 연동) 옵션
- [ ] `write_update.skin.php`에 내용 저장 로직

### Phase 3: 관리자 설정 UI
- [ ] `hycs_form_config.php`에 board_type 선택 필드 추가
- [ ] `hycs_form_config.php`에 글쓰기 설정 UI 추가
- [ ] `hycs_form_config_save.php`에 설정 저장 로직 추가

### Phase 4: 새 버전 추가 (갤러리 예시)
- [ ] `form_config_gallery.json` 생성
- [ ] `list_gallery.skin.php` 생성
- [ ] `list_manage_gallery.php` 생성
- [ ] `view_gallery.skin.php` 생성
- [ ] `view_detail_gallery.php` 생성
- [ ] `write_gallery.skin.php` 생성
- [ ] `write_edit_gallery.php` 생성

### Phase 5: 테스트
- [ ] 기존 cs 게시판 정상 동작 확인
- [ ] 새 갤러리 게시판 정상 동작 확인
- [ ] 하위 호환성 확인 (기존 설정 파일 정상 로드)

---

## 🛡️ 안전장치

### 1. 하위 호환성 보장
- `board_type`이 없으면 기본값 "cs" 사용
- 기존 `board_mode` 분기 로직 유지
- 기존 파일들이 우선 로드되도록 우선순위 설정

### 2. 에러 처리
- 파일이 없으면 기본 파일로 폴백
- 잘못된 설정값은 기본값으로 처리
- 디버그 모드 옵션 제공

### 3. 백업
- 기존 파일 수정 전 백업 필수
- 설정 파일 백업 권장

---

## 📝 마이그레이션 가이드

### 기존 게시판 설정 업데이트 (선택사항)
```json
// 기존 form_config_{bo_table}.json
{
  "board_mode": "normal"
}

// 업데이트 (선택사항, 안 해도 됨)
{
  "board_type": "cs",  // 명시적 추가
  "board_mode": "normal"
}
```

**참고**: `board_type`이 없어도 기본값 "cs"로 동작하므로 업데이트 필수 아님.

---

## 🎓 개발 가이드

### 새 버전 추가하기
1. `form_config_{bo_table}.json`에 `board_type` 설정
2. 필요한 파일만 복사하여 수정:
   - 리스트: `list.skin.php` → `list_{type}.skin.php`
   - 관리자 리스트: `list_manage.php` → `list_manage_{type}.php`
   - 뷰: `view.skin.php` → `view_{type}.skin.php`
   - 관리자 뷰: `view_detail.php` → `view_detail_{type}.php`
   - 글쓰기: `write.skin.php` → `write_{type}.skin.php`
   - 관리자 글쓰기: `write_edit.php` → `write_edit_{type}.php`
3. 타입별 필요 기능만 수정
4. 테스트

---

## ⚠️ 주의사항

1. **기존 파일 절대 수정 금지** (기능 추가만 허용)
2. **새 파일은 기존 파일을 복사하여 시작**
3. **공통 함수는 `mandoo.function.php`에 추가**
4. **설정 파일은 게시판별 독립 보관**
5. **버전 관리 필수** (Git 권장)

---

## 📞 문제 해결

### Q: 기존 게시판이 작동하지 않아요
A: `board_type`이 없으면 기본값 "cs"를 사용하도록 설계되었습니다. 
   기존 분기 로직(`board_mode` 체크)을 먼저 실행하므로 문제없습니다.

### Q: 새 버전 파일을 만들었는데 로드가 안 돼요
A: 파일명 규칙을 확인하세요. 
   `list_{board_type}.skin.php` 형식이어야 합니다.

### Q: 내용 입력창이 표시되지 않아요
A: `form_config.json`의 `write_config.use_content_editor`가 `true`인지 확인하세요.

---

**작성일**: 2025-01-XX
**버전**: 1.0
**작성자**: AI Assistant


