Files
dnssash/theme/rb.basic/rb.custom/tech_section/module.php
T
2026-06-11 18:47:38 +09:00

97 lines
4.3 KiB
PHP

<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
// --- 데이터 처리 ---
$patents_data = array();
$sql = " SELECT wr_id, wr_subject, wr_content FROM {$g5['write_prefix']}patents WHERE wr_is_comment = 0 ORDER BY wr_num, wr_reply LIMIT 3 ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++) {
$file = get_file('patents', $row['wr_id']);
$image_url = (isset($file[0]['path']) && isset($file[0]['file'])) ? $file[0]['path'].'/'.$file[0]['file'] : G5_THEME_URL.'/img/no_image.png';
$patents_data[] = array(
'id' => $row['wr_id'],
'title' => get_text($row['wr_subject']),
'description' => get_text(cut_str(strip_tags($row['wr_content']), 100)),
'image' => $image_url
);
}
$patents_json = json_encode($patents_data, JSON_UNESCAPED_UNICODE);
// 💡 [개선] CSS와 JS 파일의 버전을 파일 수정 시간으로 자동 갱신하여 캐시 관리를 최적화합니다.
$module_css_path = G5_THEME_PATH.'/rb.custom/tech_section/module.css';
$module_js_path = G5_THEME_PATH.'/rb.custom/tech_section/module.js';
$module_css_ver = file_exists($module_css_path) ? filemtime($module_css_path) : G5_CSS_VER;
$module_js_ver = file_exists($module_js_path) ? filemtime($module_js_path) : G5_JS_VER;
// 💡 [핵심] 이 모듈만의 고유 ID를 생성합니다.
$module_id = 'tech_section_'.uniqid();
?>
<!-- 💡 [핵심 수정] 모듈의 가장 바깥 요소에 고유 ID를 부여합니다. -->
<div id="<?php echo $module_id; ?>" class="tech-section-module">
<!-- TECH: 기술력 및 특허 섹션 -->
<section class="products-trend-section" data-patents='<?php echo htmlspecialchars($patents_json, ENT_QUOTES, 'UTF-8'); ?>'>
<div class="container">
<div class="section-header">
<span class="subtitle">Technology</span>
<h2>문 하나에 사람을 담았습니다.</h2>
<p>당신의 공간이 더욱 안전하고 조용해지도록, 우리는 문 하나를 넘어서고 있습니다.</p>
</div>
<div class="product-grid">
<!-- JS로 특허증 카드 생성 -->
</div>
</div>
</section>
<!-- 💡 [핵심 수정] 모듈 내부에 모달 HTML을 포함시킵니다. -->
<div class="image-modal">
<div class="modal-content">
<span class="close-btn">&times;</span>
<img class="modal-image" src="" alt="제품 이미지">
<div class="modal-info">
<h3 class="modal-title"></h3>
<p class="modal-desc"></p>
</div>
</div>
</div>
</div>
<!-- 이 모듈에 필요한 CSS 파일을 불러옵니다. -->
<link rel="stylesheet" href="<?php echo G5_THEME_URL; ?>/rb.custom/tech_section/module.css?ver=<?php echo $module_css_ver; ?>">
<?php // 💡 [핵심 수정] AJAX로 로드될 때도 스크립트가 확실하게 실행되도록 동적 로딩 방식으로 변경합니다. ?>
<script>
(function() {
// 💡 [핵심 수정] 이 모듈의 고유 ID를 자바스크립트로 전달합니다.
const currentModuleId = '<?php echo $module_id; ?>';
const scriptId = 'tech-section-module-script';
// 스크립트가 이미 로드되었는지 확인 (중복 실행 방지)
if (document.getElementById(scriptId)) {
// 이미 로드되었다면, 초기화 함수만 다시 호출
if (typeof window.initTechSectionModule === 'function') {
window.initTechSectionModule(currentModuleId);
}
return;
}
const script = document.createElement('script');
script.id = scriptId;
script.src = '<?php echo G5_THEME_URL; ?>/rb.custom/tech_section/module.js?ver=<?php echo $module_js_ver; ?>';
script.async = true;
// 💡 [핵심 수정] 스크립트 로드가 완료되면, 고유 ID를 인자로 전달하여 초기화 함수를 호출합니다.
script.onload = () => {
if (typeof window.initTechSectionModule === 'function') {
window.initTechSectionModule(currentModuleId);
}
};
script.onerror = () => {
console.error('Failed to load tech_section/module.js');
};
document.head.appendChild(script);
})();
</script>