first commit 2

This commit is contained in:
hmw1001
2026-06-11 18:47:38 +09:00
parent c768729ce6
commit 6f534e33a6
11095 changed files with 1595758 additions and 0 deletions
@@ -0,0 +1,239 @@
<?php
if (!defined('_GNUBOARD_')) exit;
/**
* rb.board.core.coverage :: write.skin.php
* 💡 [최종 수정] 그누보드 표준 방식을 준수하는 에디터 전환 기능
*/
// 💡 [추가] 메인 노출 관련 로직
$main_view_max = null;
// 게시판 여분필드(bo_1 ~ bo_10) 중 제목이 'main_view_max'인 필드의 값을 가져옵니다.
for ($i = 1; $i <= 10; $i++) {
if (isset($board['bo_'.$i.'_subj']) && $board['bo_'.$i.'_subj'] == 'main_view_max') {
$main_view_max = $board['bo_'.$i];
break;
}
}
$main_display_count = 0;
$main_display_titles = '';
// main_view_max가 숫자이거나, 비어있거나, null일 때만 유효한 것으로 간주
$is_main_view_max_valid = ($main_view_max === null || $main_view_max === '' || is_numeric($main_view_max));
if ($is_main_view_max_valid && is_numeric($main_view_max) && $main_view_max !== '') {
$sql = "SELECT wr_subject FROM {$g5['write_prefix']}{$bo_table} WHERE wr_8 = 'Y'";
if ($w == 'u') {
// 수정 모드에서는 현재 글을 제외하고 카운트
$sql .= " AND wr_id != '{$wr_id}'";
}
$result = sql_query($sql);
$titles = array();
while ($row = sql_fetch_array($result)) {
$titles[] = $row['wr_subject'];
}
$main_display_count = count($titles);
$main_display_titles = implode(', ', $titles);
}
$field_map = array(
'summary' => 'wr_1',
'featured' => 'wr_10',
'main_display' => 'wr_8', // 💡 [추가] 메인 화면 노출 필드 매핑
);
$ebook_link_field = 'wr_link1';
$cfg_write = isset($board_config['write']) ? $board_config['write'] : array();
?>
<div id="coverage-board" class="board-write-container">
<form name="fwrite" id="fwrite" action="<?php echo $action_url ?>" onsubmit="return fwrite_submit(this);" method="post" enctype="multipart/form-data" autocomplete="off" novalidate>
<input type="hidden" name="uid" value="<?php echo get_uniqid(); ?>">
<input type="hidden" name="w" value="<?php echo $w ?>">
<input type="hidden" name="bo_table" value="<?php echo $bo_table ?>">
<input type="hidden" name="wr_id" value="<?php echo $wr_id ?>">
<input type="hidden" name="sca" value="<?php echo $sca ?>">
<input type="hidden" name="sfl" value="<?php echo $sfl ?>">
<input type="hidden" name="stx" value="<?php echo $stx ?>">
<input type="hidden" name="spt" value="<?php echo $spt ?>">
<input type="hidden" name="sst" value="<?php echo $sst ?>">
<input type="hidden" name="sod" value="<?php echo $sod ?>">
<input type="hidden" name="page" value="<?php echo $page ?>">
<div class="write-form-group">
<label for="wr_subject" class="form-label">제목<span class="required">*</span></label>
<input type="text" name="wr_subject" value="<?php echo $subject ?>" id="wr_subject" required class="form-control" placeholder="제목을 입력하세요">
</div>
<?php if ($is_category): ?>
<div class="write-form-group">
<label for="ca_name" class="form-label">카테고리<span class="required">*</span></label>
<select name="ca_name" id="ca_name" required class="form-control"><option value="">선택하세요</option><?php echo $category_option ?></select>
</div>
<?php endif; ?>
<?php if (!empty($cfg_write['use_summary'])): ?>
<div class="write-form-group">
<label for="<?php echo $field_map['summary']; ?>" class="form-label"><?php echo $cfg_write['summary_label'] ?: '요약'; ?></label>
<textarea name="<?php echo $field_map['summary']; ?>" id="<?php echo $field_map['summary']; ?>" class="form-control" rows="3" placeholder="<?php echo $cfg_write['summary_placeholder']; ?>"><?php echo $write[$field_map['summary']]; ?></textarea>
</div>
<?php endif; ?>
<div class="write-form-group">
<label for="wr_content" class="form-label">내용<span class="required">*</span></label>
<div class="editor-toggle-buttons">
<button type="button" class="btn btn-sm btn-editor-toggle <?php echo $is_dhtml_editor ? 'active' : ''; ?>" data-editor-type="dhtml">HTML 에디터</button>
<button type="button" class="btn btn-sm btn-editor-toggle <?php echo $is_dhtml_editor ? '' : 'active'; ?>" data-editor-type="text">텍스트 에디터</button>
</div>
<div id="dhtml-editor-area" style="display: <?php echo $is_dhtml_editor ? 'block' : 'none'; ?>;">
<?php if ($is_dhtml_editor) { echo $editor_html; } ?>
</div>
<div id="text-editor-area" style="display: <?php echo $is_dhtml_editor ? 'none' : 'block'; ?>;">
<textarea id="wr_content_text" class="form-control" rows="10"><?php echo $content ?></textarea>
</div>
</div>
<div style="display:none;">
<?php if ($is_html) { ?>
<input type="checkbox" id="html" name="html" value="html2" <?php echo ($html_value) ? "checked" : ""; ?>>
<label for="html">html</label>
<?php } ?>
</div>
<hr class="form-divider">
<?php for ($i=1; $is_file && $i<=$board['bo_upload_count']; $i++):
$file_label = isset($cfg_write['file_labels'][$i]) ? $cfg_write['file_labels'][$i] : '첨부파일 #'.$i;
$file_text = isset($cfg_write['file_texts'][$i]) ? $cfg_write['file_texts'][$i] : '';
?>
<div class="write-form-group file-upload-group">
<label for="bf_file_<?php echo $i ?>" class="form-label"><?php echo $file_label; ?><?php if($i==1) echo '<span class="required">*</span>'; ?></label>
<div class="file-input-wrapper">
<input type="file" name="bf_file[]" id="bf_file_<?php echo $i ?>" title="파일첨부 <?php echo $i ?> : 용량 <?php echo $upload_max_filesize ?> 이하만 업로드 가능" class="form-control" <?php if ($w=='' && $i==1) echo 'required'; ?>>
<?php if ($w == 'u' && isset($file[$i-1]) && !empty($file[$i-1]['file'])): ?>
<span class="file-delete-wrap"><input type="checkbox" id="bf_file_del_<?php echo $i-1 ?>" name="bf_file_del[<?php echo $i-1; ?>]" value="1"><label for="bf_file_del_<?php echo $i-1 ?>"><?php echo $file[$i-1]['source'].'('.$file[$i-1]['size'].')'; ?> 파일 삭제</label></span>
<?php endif; ?>
</div>
<?php if($file_text): ?><p class="form-text"><?php echo $file_text; ?></p><?php endif; ?>
</div>
<?php endfor; ?>
<hr class="form-divider">
<?php if ($is_admin): ?>
<div class="admin-options-group">
<h3 class="form-section-title">관리자 전용 설정</h3>
<div class="admin-option-item">
<label class="form-check-label" for="is_main_display">
<input type="checkbox" name="<?php echo $field_map['main_display']; ?>" value="Y" id="is_main_display" class="admin-option-checkbox" <?php echo isset($write[$field_map['main_display']]) && ($write[$field_map['main_display']] == 'Y') ? 'checked' : ''; ?>>
<span class="option-text">메인 화면 노출 (체크 시 메인 페이지 포트폴리오 영역에 노출됩니다)</span>
</label>
</div>
<!-- <div class="admin-option-item">
<label class="form-check-label" for="is_featured">
<input type="checkbox" name="<?php /*echo $field_map['featured']; */?>" value="Y" id="is_featured" class="admin-option-checkbox" <?php /*echo ($write[$field_map['featured']] == 'Y') ? 'checked' : ''; */?>>
<span class="option-text">이 글을 '지정 최신글'로 설정합니다. (최대 6개)</span>
</label>
<div id="ebook-link-group" style="display: <?php /*echo ($write[$field_map['featured']] == 'Y') ? 'block' : 'none'; */?>; margin-top: 15px;">
<label for="<?php /*echo $ebook_link_field; */?>" class="form-label" style="margin-top:0;">E-book 링크</label>
<input type="url" name="<?php /*echo $ebook_link_field; */?>" value="<?php /*echo $write[$ebook_link_field]; */?>" id="<?php /*echo $ebook_link_field; */?>" class="form-control" placeholder="https://example.com/ebook/123">
<p class="form-text">'지정 최신글'로 설정했을 경우, 클릭 시 이동할 이북 주소를 입력하세요.</p>
</div>
</div>-->
</div>
<?php endif; ?>
<div class="write-form-footer">
<a href="<?php echo get_pretty_url($bo_table); ?>" class="btn btn-secondary">취소</a>
<button type="submit" id="btn_submit" accesskey="s" class="btn btn-primary">작성완료</button>
</div>
</form>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const isFeaturedCheckbox = document.getElementById('is_featured');
const ebookLinkGroup = document.getElementById('ebook-link-group');
if (isFeaturedCheckbox && ebookLinkGroup) {
isFeaturedCheckbox.addEventListener('change', function() {
ebookLinkGroup.style.display = this.checked ? 'block' : 'none';
});
}
const dhtmlEditorArea = document.getElementById('dhtml-editor-area');
const textEditorArea = document.getElementById('text-editor-area');
const editorToggleButtons = document.querySelectorAll('.btn-editor-toggle');
const wrContentTextarea = document.getElementById('wr_content_text');
const htmlCheckbox = document.getElementById('html');
function setEditorMode(isDhtml) {
if (isDhtml) {
dhtmlEditorArea.style.display = 'block';
textEditorArea.style.display = 'none';
if (htmlCheckbox) htmlCheckbox.checked = true;
if (typeof CKEDITOR !== 'undefined' && CKEDITOR.instances.wr_content) {
CKEDITOR.instances.wr_content.setData(wrContentTextarea.value);
}
} else {
dhtmlEditorArea.style.display = 'none';
textEditorArea.style.display = 'block';
if (htmlCheckbox) htmlCheckbox.checked = false;
if (typeof CKEDITOR !== 'undefined' && CKEDITOR.instances.wr_content) {
wrContentTextarea.value = CKEDITOR.instances.wr_content.getData();
}
}
editorToggleButtons.forEach(btn => {
if ((btn.dataset.editorType === 'dhtml' && isDhtml) || (btn.dataset.editorType === 'text' && !isDhtml)) {
btn.classList.add('active');
} else {
btn.classList.remove('active');
}
});
}
setEditorMode(<?php echo $is_dhtml_editor ? 'true' : 'false'; ?>);
editorToggleButtons.forEach(button => {
button.addEventListener('click', function() {
const type = this.dataset.editorType;
setEditorMode(type === 'dhtml');
});
});
});
function fwrite_submit(f) {
const textEditorArea = document.getElementById('text-editor-area');
if (textEditorArea.style.display === 'block') {
f.wr_content.value = document.getElementById('wr_content_text').value;
}
// 💡 [추가] 메인 노출 개수 제한 검사
const mainDisplayCheckbox = document.getElementById('is_main_display');
if (mainDisplayCheckbox && mainDisplayCheckbox.checked) {
const mainViewMax = <?php echo json_encode($main_view_max); ?>;
const isMainViewMaxValid = <?php echo json_encode($is_main_view_max_valid); ?>;
if (!isMainViewMaxValid) {
alert('게시판의 "main_view_max" 여분 필드 설정값이 숫자가 아닙니다. 관리자에게 문의하여 설정을 수정해주세요.');
return false;
}
if (mainViewMax !== null && mainViewMax !== '' && !isNaN(parseInt(mainViewMax))) {
const mainViewMaxInt = parseInt(mainViewMax, 10);
const mainDisplayCount = <?php echo (int)$main_display_count; ?>;
if (mainDisplayCount >= mainViewMaxInt) {
const mainDisplayTitles = <?php echo json_encode($main_display_titles); ?>;
alert('메인 노출 최대 개수(' + mainViewMaxInt + '개)를 초과하여 더 이상 설정할 수 없습니다.\n\n현재 설정된 글:\n' + mainDisplayTitles);
return false;
}
}
}
<?php echo $editor_js; ?>
return true;
}
</script>