상태 및 정렬 우선순위를 설정하고 그에 따라 정렬 출력, 상태를 설정했기 때문에 날짜를 if로 받아 처리하던 부분을 switch 로 변경하여 처리

This commit is contained in:
2025-07-09 10:07:54 +09:00
parent 8440069b81
commit 1154d140c1

View File

@ -107,6 +107,45 @@ $rb_skin['md_auto_is'] 자동롤링 여부(1,0)
<div class="rb-swiper-wrapper swiper-wrapper">
<?php
$todays = date('Y-m-d');
foreach ($list as &$item) {
$start_date = $item['wr_1'] ?? '';
$end_date = $item['wr_2'] ?? '';
// 상태 및 정렬 우선순위 설정
if ($start_date && $end_date) {
if ($todays < $start_date) {
$item['_status'] = '예정'; // 예정
$item['_sort'] = 1;
} elseif ($todays > $end_date) {
$item['_status'] = '종료'; // 종료
$item['_sort'] = 3;
} else {
$item['_status'] = '진행'; // 진행 중
$item['_sort'] = 0;
}
} else {
$item['_status'] = '기타';
$item['_sort'] = 9;
}
// 시작일 없을 경우를 고려한 비교용 날짜 (미입력 시 최후순)
$item['_start_date'] = $start_date ? $start_date : '9999-99-99';
}
unset($item);
// 정렬: 상태 우선순위(_sort) → 시작일(_start_date)
usort($list, function ($a, $b) {
if ($a['_sort'] === $b['_sort']) {
return strcmp($a['_start_date'], $b['_start_date']);
}
return $a['_sort'] <=> $b['_sort'];
});
// 정렬 후 list_count 재설정 (안전)
$list_count = count($list);
for ($i=0; $i<$list_count; $i++) {
//썸네일
@ -139,6 +178,18 @@ $rb_skin['md_auto_is'] 자동롤링 여부(1,0)
$end_date = isset($list[$i]['wr_2']) ? $list[$i]['wr_2'] : '';
$rb_ev_ico = '';
switch ($list[$i]['_status']) {
case '예정':
$rb_ev_ico = '<span class="rb_latest_event_label ev_label1 font-R" style="opacity:0.5;">예정</span>';
break;
case '종료':
$rb_ev_ico = '<span class="rb_latest_event_label ev_label2 font-R">종료</span>';
break;
case '진행':
$rb_ev_ico = '<span class="rb_latest_event_label main_rb_bg color-fff font-R">진행</span>';
break;
}
/* switch 로 대체
if($start_date && $end_date) {
if ($todays < $start_date) {
// 진행 전
@ -151,6 +202,7 @@ $rb_skin['md_auto_is'] 자동롤링 여부(1,0)
$rb_ev_ico = '<span class="rb_latest_event_label main_rb_bg color-fff font-R">진행</span>';
}
}
*/
?>
<div class="rb_swiper_list">