136 lines
5.4 KiB
PHP
136 lines
5.4 KiB
PHP
<?php
|
|
if (!defined('_GNUBOARD_')) exit;
|
|
|
|
// 1. 설정 파일 로드
|
|
$config_path = __DIR__ . '/config.php';
|
|
if (!file_exists($config_path)) return;
|
|
include_once($config_path);
|
|
include_once(G5_LIB_PATH.'/thumbnail.lib.php');
|
|
|
|
// 💡 [핵심] $md_id 변수를 사용하여 모듈 설정 로드
|
|
// 이 파일이 include 될 때 상위 스코프에서 $md_id가 정의되어 있어야 합니다.
|
|
// 보통 index.php 등에서 모듈을 호출할 때 $md_id를 설정하고 include 합니다.
|
|
if (isset($md_id) && $md_id) {
|
|
$rb_skin = get_rb_module_config($md_id);
|
|
} else {
|
|
$rb_skin = array(); // md_id가 없을 경우 빈 배열
|
|
}
|
|
|
|
// 2. 데이터 가져오기
|
|
$position = $rolling_banner_config['position'];
|
|
$sql = " SELECT * FROM `rb_banner` WHERE bn_position = '{$position}' AND bn_begin_time <= NOW() AND bn_end_time >= NOW() ORDER BY bn_order ASC, bn_id DESC ";
|
|
$result = sql_query($sql);
|
|
|
|
$banners = [];
|
|
while ($row = sql_fetch_array($result)) {
|
|
$banners[] = $row;
|
|
}
|
|
|
|
$visual_id = 'rbf_' . uniqid();
|
|
?>
|
|
|
|
<!-- Rebuilder 표준 구조 -->
|
|
<!--<div class="rb_layout_box" data-id="rolling_banner_footer">-->
|
|
<!-- --><?php //if ($is_admin) { ?>
|
|
<!-- <div class="rb_module_set">-->
|
|
<!-- <a href="javascript:;" onclick="set_module_send(this);" class="btn_module_setup"><i class="fa fa-cog"></i></a>-->
|
|
<!-- </div>-->
|
|
<!-- --><?php //} ?>
|
|
|
|
<div class="rolling-banner-footer" id="<?php echo $visual_id; ?>">
|
|
<!-- <div class="container">-->
|
|
<!-- { -->
|
|
<ul class="bbs_main_wrap_tit" style="display:<?php echo (isset($rb_skin['md_title_hide']) && $rb_skin['md_title_hide'] == '1') ? 'none' : 'block'; ?>">
|
|
|
|
<li class="bbs_main_wrap_tit_l">
|
|
<!-- 타이틀 { -->
|
|
<a href="<?php echo $links_url; ?>">
|
|
<h2 class="<?php echo isset($rb_skin['md_title_font']) ? $rb_skin['md_title_font'] : 'font-B'; ?>" style="color:<?php echo isset($rb_skin['md_title_color']) ? $rb_skin['md_title_color'] : '#25282b'; ?>; font-size:<?php echo isset($rb_skin['md_title_size']) ? $rb_skin['md_title_size'] : '20'; ?>px; "><?php echo isset($rb_skin['md_title']) ? $rb_skin['md_title'] : '하단 롤링 배너'; ?></h2>
|
|
</a>
|
|
<!-- } -->
|
|
</li>
|
|
<div class="cb"></div>
|
|
</ul>
|
|
|
|
<div class="rolling-banner-wrap">
|
|
<!-- 💡 [핵심 수정] Swiper 구조로 변경 -->
|
|
<div class="swiper-container rolling-swiper"
|
|
data-autoplay-delay="<?php echo $rolling_banner_config['timeout']; ?>"
|
|
data-slides-per-view="<?php echo $rolling_banner_config['visible']; ?>">
|
|
<div class="swiper-wrapper">
|
|
<?php foreach ($banners as $banner):
|
|
$bimg = G5_DATA_PATH.'/banners/'.$banner['bn_id'];
|
|
if (!file_exists($bimg)) continue;
|
|
$img_src = G5_DATA_URL.'/banners/'.$banner['bn_id'];
|
|
?>
|
|
<div class="swiper-slide banner-item">
|
|
<a href="<?php echo $banner['bn_url']; ?>" target="<?php echo $banner['bn_new_win'] ? '_blank' : '_self'; ?>">
|
|
<img src="<?php echo $img_src; ?>" alt="<?php echo get_text($banner['bn_alt']); ?>">
|
|
</a>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="slider-controls">
|
|
<div class="swiper-button-prev btn-prev"><i class="fa fa-chevron-left"></i></div>
|
|
<div class="swiper-button-next btn-next"><i class="fa fa-chevron-right"></i></div>
|
|
</div>
|
|
|
|
<?php if (empty($banners)): ?>
|
|
<div class="empty-banner">등록된 배너가 없습니다.</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<link rel="stylesheet" href="<?php echo G5_THEME_URL; ?>/rb.custom/rolling_banner_footer/module.css?ver=<?php echo G5_CSS_VER; ?>">
|
|
|
|
<!-- 통합 동적 로더 -->
|
|
<script>
|
|
(function() {
|
|
var currentModuleId = '<?php echo $visual_id; ?>';
|
|
var initFunctionName = 'initRollingBannerFooter';
|
|
var themeUrl = '<?php echo G5_THEME_URL; ?>';
|
|
var jsVer = '<?php echo G5_JS_VER; ?>';
|
|
|
|
function loadScript(src, id, callback) {
|
|
if (document.getElementById(id)) {
|
|
if (callback) callback();
|
|
return;
|
|
}
|
|
var script = document.createElement('script');
|
|
script.id = id;
|
|
script.src = src;
|
|
script.async = false;
|
|
if (callback) {
|
|
script.onload = callback;
|
|
}
|
|
document.head.appendChild(script);
|
|
}
|
|
|
|
function finalAction() {
|
|
if (typeof window[initFunctionName] === 'function') {
|
|
window[initFunctionName](currentModuleId);
|
|
}
|
|
}
|
|
|
|
function loadModuleScript() {
|
|
loadScript(themeUrl + '/rb.custom/rolling_banner_footer/module.js?ver=' + jsVer, 'rolling-banner-footer-js', finalAction);
|
|
}
|
|
|
|
// 💡 [핵심] Swiper 라이브러리 로드 확인
|
|
if (typeof Swiper === 'undefined') {
|
|
// Swiper CSS 로드
|
|
var link = document.createElement('link');
|
|
link.rel = 'stylesheet';
|
|
link.href = 'https://unpkg.com/swiper/swiper-bundle.min.css';
|
|
document.head.appendChild(link);
|
|
|
|
// Swiper JS 로드
|
|
loadScript('https://unpkg.com/swiper/swiper-bundle.min.js', 'swiper-bundle-js', loadModuleScript);
|
|
} else {
|
|
loadModuleScript();
|
|
}
|
|
})();
|
|
</script>
|