From e2d215c36836bf213fb7e4c756c9d948c893cd77 Mon Sep 17 00:00:00 2001 From: whitedot Date: Tue, 15 Sep 2026 06:18:07 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=87=BC=ED=95=91=EB=AA=B0=205=EB=8B=A8?= =?UTF-8?q?=EA=B3=84=20=EB=B6=84=EB=A5=98=20=EA=B2=BD=EB=A1=9C=EC=99=80=20?= =?UTF-8?q?=EC=84=9C=EB=B8=8C=EB=A9=94=EB=89=B4=20=ED=91=9C=EC=8B=9C=20?= =?UTF-8?q?=EC=9D=BC=EA=B4=80=EC=84=B1=20=EB=B3=B4=EC=99=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PC·basic 테마 breadcrumb를 5단계로 확장하고 기존 위치와 스타일을 유지한다. PC·모바일 서브메뉴는 5단계가 있으면 해당 목록만, 없으면 4단계 형제 목록만 표시한다. 검증: 8개 분류 경로와 네 스킨의 메뉴·선택 상태, Chromium 목록·상세 단계별 레이아웃 검사, PHP 5.2 및 현재 PHP 구문 검사 통과. --- lib/shop.data.lib.php | 42 +++++++++- mobile/skin/shop/basic/listcategory.skin.php | 53 ++++--------- skin/shop/basic/listcategory.skin.php | 53 ++++--------- skin/shop/basic/navigation.skin.php | 47 +++-------- tests/shop_category_layout.js | 44 +++++++++++ tests/shop_category_navigation.php | 79 +++++++++++++++++++ .../skin/shop/basic/listcategory.skin.php | 53 ++++--------- .../skin/shop/basic/listcategory.skin.php | 53 ++++--------- .../basic/skin/shop/basic/navigation.skin.php | 47 +++-------- 9 files changed, 252 insertions(+), 219 deletions(-) create mode 100644 tests/shop_category_layout.js create mode 100644 tests/shop_category_navigation.php diff --git a/lib/shop.data.lib.php b/lib/shop.data.lib.php index 4eef513b1..1cc638768 100644 --- a/lib/shop.data.lib.php +++ b/lib/shop.data.lib.php @@ -82,9 +82,49 @@ function get_shop_navigation_data($is_cache, $ca_id, $ca_id2='', $ca_id3=''){ } } + // 공통 전체 분류 트리는 기존 3단계 구조를 유지하고 현재 경로의 깊은 단계만 조회한다. + for ($depth = 4; $depth <= 5 && strlen($ca_id) >= $depth * 2; $depth++) { + $parent = substr($ca_id, 0, ($depth - 1) * 2); + $result = sql_query(get_shop_category_sql($parent, $depth * 2)); + while ($row = sql_fetch_array($result)) { + $row['url'] = shop_category_url($row['ca_id']); + $datas[$depth - 1][] = $row; + } + } + return $datas; } +// 4·5단계에서는 선택 경로의 5단계를 우선 표시하고, 없으면 4단계 형제를 표시한다. +function get_shop_category_menu_groups($ca_id) +{ + $length = strlen($ca_id); + $groups = array(); + if ($length >= 8) { + $queries = array( + array('5단계 분류', substr($ca_id, 0, 8), 10), + array('4단계 분류', substr($ca_id, 0, 6), 8), + ); + } else { + $queries = array(array('하위 분류', $ca_id, $length + 2)); + } + foreach ($queries as $query) { + $rows = array(); + $result = sql_query(get_shop_category_sql($query[1], $query[2])); + while ($row = sql_fetch_array($result)) $rows[] = $row; + if (!$rows && $length < 8) { + $query[0] = '현재 단계 분류'; + $result = sql_query(get_shop_category_sql(substr($ca_id, 0, -2), $length)); + while ($row = sql_fetch_array($result)) $rows[] = $row; + } + if ($rows) { + $groups[] = array('label' => $query[0], 'categories' => $rows); + break; + } + } + return $groups; +} + function get_shop_category_by($is_cache, $case, $value){ if( $case === 'ca_id' ){ @@ -268,4 +308,4 @@ function get_shop_item_options($it_id, $subject, $no) } return $str; -} \ No newline at end of file +} diff --git a/mobile/skin/shop/basic/listcategory.skin.php b/mobile/skin/shop/basic/listcategory.skin.php index ddd995594..f966ab733 100644 --- a/mobile/skin/shop/basic/listcategory.skin.php +++ b/mobile/skin/shop/basic/listcategory.skin.php @@ -1,44 +1,25 @@ '.$row['ca_name'].' '.$row2['cnt'].''; - $exists = true; -} - -if ($exists) { - - // add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨 +$category_groups = get_shop_category_menu_groups($ca_id); +if ($category_groups) { add_stylesheet('', 0); ?> - - - - -'.$row['ca_name'].' ('.$row2['cnt'].')'; - $exists = true; -} - -if ($exists) { - - // add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨 +$category_groups = get_shop_category_menu_groups($ca_id); +if ($category_groups) { add_stylesheet('', 0); ?> - - - - - substr($ca_id,0,2), - 'ca_id2' => substr($ca_id,0,4), - 'ca_id3' => substr($ca_id,0,6), - ); -} else if( $is_item_view && isset($it) && is_array($it) ) { - $navi_datas = get_shop_navigation_data(true, $it['ca_id']); - $ca_ids = array( - 'ca_id' => substr($it['ca_id'],0,2), - 'ca_id2' => substr($it['ca_id'],0,4), - 'ca_id3' => substr($it['ca_id'],0,6) - ); -} +$is_item_view = (isset($it_id, $it['it_id']) && $it_id === $it['it_id']); +$navigation_ca_id = $is_item_view ? $it['ca_id'] : $ca_id; +$navi_datas = $navigation_ca_id ? get_shop_navigation_data(true, $navigation_ca_id) : array(); $location_class = array(); if($is_item_view){ @@ -27,7 +12,7 @@ if($is_item_view){ $location_class[] = 'is_list is_right'; // view_location는 리스트 말고 상품보기에서만 표시 } -// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨 +// add_stylesheet('css 구문', 출력순서); add_stylesheet('', 0); add_javascript('', 10); ?> @@ -37,26 +22,14 @@ add_javascript(' - - - - + $categories) { + $selected_ca_id = substr($navigation_ca_id, 0, ($depth + 1) * 2); + if ($depth > 0) { ?> - - - - + + diff --git a/tests/shop_category_layout.js b/tests/shop_category_layout.js new file mode 100644 index 000000000..541c09d1e --- /dev/null +++ b/tests/shop_category_layout.js @@ -0,0 +1,44 @@ +// 실행: NODE_PATH=/node_modules CHROME_PATH= node tests/shop_category_layout.js +const fs = require('fs'); +const path = require('path'); +const assert = require('assert'); +const {execFileSync} = require('child_process'); +const {chromium} = require('playwright'); +const root = path.dirname(__dirname); +const read = file => fs.readFileSync(path.join(root, file), 'utf8'); +const fixtures = JSON.parse(execFileSync('php', [path.join(__dirname, 'shop_category_navigation.php'), '--json'], {encoding:'utf8'})); +(async () => { + const browser = await chromium.launch({headless:true, ...(process.env.CHROME_PATH ? {executablePath:process.env.CHROME_PATH} : {}), args:['--no-sandbox']}); + try { + for (const skin of ['skin/shop/basic', 'theme/basic/skin/shop/basic']) { + for (const view of ['list', 'item']) { + const page = await browser.newPage({viewport:{width:1920, height:1080}}); + let baseline; + for (const id of ['10', '101010', '10101010', '1010101010']) { + let html = fixtures[skin][id].replace(/', 10); ?> @@ -37,26 +22,14 @@ add_javascript(' - - - - + $categories) { + $selected_ca_id = substr($navigation_ca_id, 0, ($depth + 1) * 2); + if ($depth > 0) { ?> - - - - + +