232 lines
12 KiB
PHP
232 lines
12 KiB
PHP
<?php
|
|
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
|
|
|
|
// jQuery UI의 CSS와 JS를 불러와 달력(Datepicker) 기능을 사용합니다.
|
|
add_stylesheet('<link rel="stylesheet" href="//code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">', 0);
|
|
add_javascript('<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>', 0);
|
|
|
|
// 이 스킨의 전용 스타일시트를 불러옵니다.
|
|
$style_ver = file_exists($board_skin_path . '/style.css') ? filemtime($board_skin_path . '/style.css') : G5_CSS_VER;
|
|
add_stylesheet('<link rel="stylesheet" href="' . $board_skin_url . '/style.css?ver=' . $style_ver . '">', 0);
|
|
|
|
// 이 스킨의 전용 자바스크립트 파일을 불러옵니다.
|
|
$write_js_path = $board_skin_path . '/js/write.js';
|
|
$write_js_ver = file_exists($write_js_path) ? filemtime($write_js_path) : G5_JS_VER;
|
|
add_javascript('<script src="' . $board_skin_url . '/js/write.js?ver=' . $write_js_ver . '"></script>', 0);
|
|
|
|
// 💡 [추가] 메인 노출 관련 로직
|
|
$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 !== '') {
|
|
// wr_10 != '1' 인 글 (숨김 처리되지 않은 글)을 카운트
|
|
$sql = "SELECT wr_subject FROM {$g5['write_prefix']}{$bo_table} WHERE (wr_10 != '1' OR wr_10 IS NULL)";
|
|
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);
|
|
}
|
|
?>
|
|
|
|
<div id="bo_w">
|
|
<form name="fwrite" id="fwrite" action="<?php echo $action_url ?>" onsubmit="return fwrite_submit(this);"
|
|
method="post" enctype="multipart/form-data" autocomplete="off">
|
|
<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 ?>">
|
|
<?php
|
|
// 스마트에디터를 사용하기 위해 html1로 고정
|
|
$option_hidden = '<input type="hidden" name="html" value="1">';
|
|
echo $option_hidden;
|
|
?>
|
|
|
|
<div class="write_div">
|
|
<label for="wr_subject" class="frm_label">제목</label>
|
|
<input type="text" name="wr_subject" value="<?php echo $subject ?>" id="wr_subject" required
|
|
class="frm_input" size="50" maxlength="255" placeholder="메인 화면에 노출될 제목을 입력하세요.">
|
|
</div>
|
|
|
|
<div class="write_div">
|
|
<label class="frm_label">노출 설정</label>
|
|
<div class="option_group">
|
|
<label>
|
|
<input type="radio" name="wr_9"
|
|
value="IMMEDIATE" <?php if ($w == '' || (isset($write['wr_9']) && $write['wr_9'] != 'RESERVED')) echo 'checked'; ?>>
|
|
<span class="custom-radio"></span> 즉시 노출
|
|
</label>
|
|
<label>
|
|
<input type="radio" name="wr_9"
|
|
value="RESERVED" <?php if ($w == 'u' && isset($write['wr_9']) && $write['wr_9'] == 'RESERVED') echo 'checked'; ?>>
|
|
<span class="custom-radio"></span> 예약 노출
|
|
</label>
|
|
<!-- 💡 [수정] 숨김 설정을 체크박스로 변경 -->
|
|
<label style="margin-left: 20px;">
|
|
<input type="hidden" name="wr_10" value="0">
|
|
<input type="checkbox" name="wr_10" id="wr_10" value="1" <?php echo (isset($write['wr_10']) && $write['wr_10'] == '1') ? 'checked' : ''; ?>>
|
|
<span class="custom-checkbox"></span> 숨김 (노출 안 함)
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="reservation_fields" class="write_div"
|
|
style="display: <?php echo ($w == 'u' && isset($write['wr_9']) && $write['wr_9'] == 'RESERVED') ? 'block' : 'none'; ?>;">
|
|
<div class="date_picker_group">
|
|
<div class="date_item">
|
|
<label for="wr_2" class="frm_label"><?php echo $board['bo_2_subj'] ?: '시작일' ?></label>
|
|
<input type="text" name="wr_2" value="<?php echo $wr_2 ?>" id="wr_2" class="frm_input datepicker"
|
|
maxlength="10" placeholder="YYYY-MM-DD">
|
|
</div>
|
|
<span class="date_divider">~</span>
|
|
<div class="date_item">
|
|
<label for="wr_3" class="frm_label"><?php echo $board['bo_3_subj'] ?: '종료일' ?></label>
|
|
<input type="text" name="wr_3" value="<?php echo $wr_3 ?>" id="wr_3" class="frm_input datepicker"
|
|
maxlength="10" placeholder="YYYY-MM-DD">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 💡 [추가] 링크 입력 필드 -->
|
|
<div class="write_div">
|
|
<label for="wr_link1" class="frm_label">링크 #1</label>
|
|
<input type="text" name="wr_link1" value="<?php echo isset($write['wr_link1']) ? get_text($write['wr_link1']) : ''; ?>" id="wr_link1" class="frm_input" size="50" placeholder="http://...">
|
|
<span class="text-muted font-12">링크를 입력하면 '자세히 보기' 클릭 시 해당 URL로 이동합니다. (입력하지 않으면 이미지 팝업)</span>
|
|
</div>
|
|
|
|
<div class="write_div">
|
|
<label for="wr_1" class="form-label">요약 내용</label>
|
|
<textarea name="wr_1" id="wr_1" class="form-control" rows="3" placeholder="목록에 표시될 뉴스의 핵심 요약 내용을 입력하세요."><?php echo isset($write['wr_1']) ? get_text($write['wr_1']) : ''; ?></textarea>
|
|
</div>
|
|
|
|
<div class="write_div">
|
|
<label for="wr_content" class="frm_label">상세 내용</label>
|
|
<?php echo $editor_html; // 스마트에디터 출력 ?>
|
|
</div>
|
|
|
|
<?php // 💡 [Accessibility Improvement] Use <fieldset> and <legend> for the file upload group. ?>
|
|
<fieldset class="write_div">
|
|
<legend class="frm_label">이미지 또는 동영상 (최대 <?php echo $board['bo_upload_count']; ?>개, 각 10MB 이하)</legend>
|
|
<div class="file_upload_grid">
|
|
<?php
|
|
for ($i = 0; $i < $board['bo_upload_count']; $i++) {
|
|
$file_label_id = 'bf_file_' . $i;
|
|
$is_existing_file = ($w == 'u' && isset($file[$i]['file']) && $file[$i]['file']);
|
|
$preview_class = '';
|
|
$preview_style = '';
|
|
$preview_text_style = '';
|
|
|
|
if ($is_existing_file) {
|
|
$file_url = $file[$i]['path'] . '/' . $file[$i]['file'];
|
|
$file_ext = strtolower(pathinfo($file_url, PATHINFO_EXTENSION));
|
|
|
|
if (in_array($file_ext, ['mp4', 'mov', 'webm'])) {
|
|
$preview_class = 'is-video';
|
|
} else {
|
|
$preview_style = "background-image: url('{$file_url}');";
|
|
}
|
|
$preview_text_style = 'display:none;';
|
|
}
|
|
?>
|
|
<div class="file_preview_wrapper">
|
|
<div class="file_preview <?php echo $preview_class; ?>" id="preview_<?php echo $i; ?>"
|
|
style="<?php echo $preview_style; ?>">
|
|
<span class="preview_text" style="<?php echo $preview_text_style; ?>">클릭하여 파일 업로드</span>
|
|
</div>
|
|
|
|
<?php if ($is_existing_file) { ?>
|
|
<div class="preview_info">
|
|
<span class="current_file_name" title="<?php echo $file[$i]['source'] ?>">
|
|
<?php echo $file[$i]['source'] ?>
|
|
</span>
|
|
<span class="file_del">
|
|
<input type="checkbox" id="bf_file_del_<?php echo $i ?>"
|
|
name="bf_file_del[<?php echo $i ?>]" value="1">
|
|
<label for="bf_file_del_<?php echo $i ?>">삭제</label>
|
|
</span>
|
|
</div>
|
|
<?php } ?>
|
|
|
|
<input type="file" name="bf_file[]" id="<?php echo $file_label_id; ?>" style="display:none;"
|
|
accept="image/*, video/mp4, video/mov, video/webm">
|
|
</div>
|
|
<?php } ?>
|
|
</div>
|
|
</fieldset>
|
|
|
|
<div class="btn_confirm">
|
|
<a href="<?php echo get_pretty_url($bo_table); ?>" class="btn btn_cancel">취소</a>
|
|
<input type="submit" value="작성완료" id="btn_submit" accesskey="s" class="btn btn_submit">
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<script>
|
|
function fwrite_submit(f) {
|
|
<?php echo $editor_js; // 에디터 사용시 자바스크립트 부분 ?>
|
|
|
|
// 💡 [추가] 메인 노출 개수 제한 검사
|
|
const isHiddenCheckbox = document.getElementById('wr_10');
|
|
// 숨김 체크박스가 체크되어 있지 않으면 '노출' 상태임
|
|
if (isHiddenCheckbox && !isHiddenCheckbox.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 + '\n\n"숨김 (노출 안 함)"을 체크하거나 기존 글을 숨김 처리해주세요.');
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
// 예약 노출 선택 시 날짜 입력 유효성 검사
|
|
if (document.querySelector('input[name="wr_9"]:checked').value === 'RESERVED') {
|
|
if (f.wr_2.value === '' || f.wr_3.value === '') {
|
|
alert('예약 시작일과 종료일을 모두 선택해주세요.');
|
|
return false;
|
|
}
|
|
if (f.wr_2.value > f.wr_3.value) {
|
|
alert('예약 종료일은 시작일보다 빠를 수 없습니다.');
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
</script>
|