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,75 @@
<?php
if (!defined('_GNUBOARD_')) exit;
/**
* 게시판 최신글 또는 콘텐츠 페이지를 탭으로 생성하는 함수
*
* @param array $tabs_config 탭 설정 배열
* @return string 생성된 탭 HTML
*/
function rb_tabs($tabs_config) {
// 💡 [복원] 설정값이 유효한지 확인하는 필수 코드
if (!is_array($tabs_config) || empty($tabs_config)) {
return '';
}
// 💡 [복원] 고유 ID 생성 (한 페이지에 여러 탭 모듈이 있어도 충돌 방지)
$module_id = 'rb-tab-module-' . uniqid();
// 💡 [복원] 이 모듈에 필요한 CSS와 JS를 동적으로 추가합니다.
add_stylesheet('<link rel="stylesheet" href="'.G5_THEME_URL.'/rb.custom/tabs/tab_style.css?ver='.G5_SERVER_TIME.'">', 0);
add_javascript('<script src="'.G5_THEME_URL.'/rb.custom/tabs/tab_script.js?ver='.G5_SERVER_TIME.'"></script>', 10);
// 💡 [복원] HTML 출력을 안전하게 버퍼에 담기 시작
ob_start();
?>
<div class="rb-tab-module" id="<?php echo $module_id; ?>">
<!-- 1. 탭 네비게이션 -->
<ul class="rb-tab-nav">
<?php foreach ($tabs_config as $index => $tab): ?>
<?php
$tab_id = $tab['type'] . '-' . $tab['id'];
$is_active = ($index === 0) ? 'active' : '';
?>
<li><a href="#<?php echo $tab_id; ?>" class="<?php echo $is_active; ?>"><?php echo htmlspecialchars($tab['title']); ?></a></li>
<?php endforeach; ?>
</ul>
<!-- 2. 탭 콘텐츠 -->
<div class="rb-tab-content-wrapper">
<?php foreach ($tabs_config as $index => $tab): ?>
<?php
$tab_id = $tab['type'] . '-' . $tab['id'];
$is_active = ($index === 0) ? 'active' : '';
?>
<div id="<?php echo $tab_id; ?>" class="rb-tab-content <?php echo $is_active; ?>">
<?php
// 💡 [핵심] 탭 타입에 따라 다른 내용을 불러옵니다.
switch ($tab['type']) {
case 'board':
// 💡 [개선] 타입이 'board'이면 탭 전용 최신글 스킨(rb_tab_basic)을 불러옵니다.
$options = $tab['options'] ?? [];
$rows = $options['rows'] ?? 5;
$subject_len = $options['subject_len'] ?? 40;
echo latest('rb_tab_basic', $tab['id'], $rows, $subject_len);
break;
case 'content':
// 타입이 'content'이면 g5_content 테이블에서 내용을 불러옵니다.
$co = get_content_db($tab['id']);
if ($co) {
echo conv_content($co['co_content'], $co['co_html']);
} else {
echo '<div class="no-posts">콘텐츠('.htmlspecialchars($tab['id']).')를 찾을 수 없습니다.</div>';
}
break;
}
?>
</div>
<?php endforeach; ?>
</div>
</div>
<?php
// 💡 [복원] 버퍼에 담긴 HTML을 반환하고 버퍼를 비웁니다.
return ob_get_clean();
}
@@ -0,0 +1,24 @@
document.addEventListener('DOMContentLoaded', function() {
const tabModules = document.querySelectorAll('.rb-tab-module');
tabModules.forEach(module => {
const navLinks = module.querySelectorAll('.rb-tab-nav a');
const contentPanes = module.querySelectorAll('.rb-tab-content');
navLinks.forEach(link => {
link.addEventListener('click', function(e) {
e.preventDefault();
navLinks.forEach(item => item.classList.remove('active'));
contentPanes.forEach(pane => pane.classList.remove('active'));
this.classList.add('active');
const targetId = this.getAttribute('href');
const targetPane = module.querySelector(targetId);
if (targetPane) {
targetPane.classList.add('active');
}
});
});
});
});
@@ -0,0 +1,58 @@
/* 탭 모듈 전체 */
.rb-tab-module {
border: 1px solid #e9e9e9;
border-radius: 8px;
overflow: hidden;
background: #fff;
margin-bottom: 20px;
}
/* 탭 네비게이션 */
.rb-tab-nav {
display: flex;
list-style: none;
padding: 0;
margin: 0;
border-bottom: 1px solid #e9e9e9;
background-color: #f9f9f9;
}
.rb-tab-nav a {
display: block;
padding: 12px 20px;
text-decoration: none;
color: #555;
font-weight: 500;
border-bottom: 3px solid transparent;
transition: all 0.2s ease-in-out;
}
.rb-tab-nav a.active {
color: #0056b3;
font-weight: 700;
border-bottom-color: #0056b3;
background-color: #fff;
}
/* 탭 콘텐츠 */
.rb-tab-content-wrapper {
padding: 15px;
position: relative;
}
.rb-tab-content {
display: none;
}
.rb-tab-content.active {
display: block;
}
.rb-tab-content .no-posts {
color: #999;
padding: 30px 0;
text-align: center;
}
/* latest 스킨(basic)을 탭 내부에 맞게 스타일 조정 */
.rb-tab-content .lat {
border: none;
padding: 0;
}
.rb-tab-content .lat ul {
margin: 0;
}