source: branches/feature-module-update/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Category.php @ 15367

Revision 15367, 2.6 KB checked in by nanasess, 17 years ago (diff)

クラス化対応

  • Property svn:keywords set to Id Revision Date
Line 
1<?php
2/*
3 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7
8// {{{ requires
9require_once(CLASS_PATH . "pages/LC_Page.php");
10
11/**
12 * カテゴリ のページクラス.
13 *
14 * @package Page
15 * @author LOCKON CO.,LTD.
16 * @version $Id$
17 */
18class LC_Page_FrontParts_Bloc_Category extends LC_Page {
19
20    // }}}
21    // {{{ functions
22
23    /**
24     * Page を初期化する.
25     *
26     * @return void
27     */
28    function init() {
29        parent::init();
30        $this->tpl_mainpage = BLOC_PATH . 'category.tpl';
31    }
32
33    /**
34     * Page のプロセス.
35     *
36     * @return void
37     */
38    function process() {
39        $objSubView = new SC_SiteView();
40        $objDb = new SC_Helper_DB_Ex();
41
42        // 選択中のカテゴリIDを判定する
43        $category_id = $objDb->sfGetCategoryId($_GET['product_id'], $_GET['category_id']);
44
45        // 選択中のカテゴリID
46        $this->tpl_category_id = $category_id;
47        $this = $this->lfGetCatTree($category_id, true, $this);
48
49        $objSubView->assignobj($this);
50        $objSubView->display($this->tpl_mainpage);
51    }
52
53    /**
54     * デストラクタ.
55     *
56     * @return void
57     */
58    function destroy() {
59        parent::destroy();
60    }
61
62    // カテゴリツリーの取得
63    function lfGetCatTree($parent_category_id, $count_check = false, $objSubPage) {
64        $objQuery = new SC_Query();
65        $objDb = new SC_Helper_DB_Ex();
66        $col = "*";
67        $from = "dtb_category left join dtb_category_total_count using (category_id)";
68        // 登録商品数のチェック
69        if($count_check) {
70            $where = "del_flg = 0 AND product_count > 0";
71        } else {
72            $where = "del_flg = 0";
73        }
74        $objQuery->setoption("ORDER BY rank DESC");
75        $arrRet = $objQuery->select($col, $from, $where);
76
77        $arrParentID = $objDb->sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $parent_category_id);
78        $arrBrothersID = SC_Utils_Ex::sfGetBrothersArray($arrRet, 'parent_category_id', 'category_id', $arrParentID);
79        $arrChildrenID = SC_Utils_Ex::sfGetUnderChildrenArray($arrRet, 'parent_category_id', 'category_id', $parent_category_id);
80
81        $objSubPage->root_parent_id = $arrParentID[0];
82
83        $arrDispID = array_merge($arrBrothersID, $arrChildrenID);
84
85        foreach($arrRet as $key => $array) {
86            foreach($arrDispID as $val) {
87                if($array['category_id'] == $val) {
88                    $arrRet[$key]['display'] = 1;
89                    break;
90                }
91            }
92        }
93
94        $objSubPage->arrTree = $arrRet;
95        return $objSubPage;
96    }
97}
98?>
Note: See TracBrowser for help on using the repository browser.