source: branches/version-2_5-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Category.php @ 19807

Revision 19807, 5.3 KB checked in by Seasoft, 13 years ago (diff)

#834(パラメータの定数名に「URL」を含むにもかかわらず、パスのみのものがある)

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id Revision Date
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23
24// {{{ requires
25require_once(CLASS_REALDIR . "pages/frontparts/bloc/LC_Page_FrontParts_Bloc.php");
26
27/**
28 * カテゴリ のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id:LC_Page_FrontParts_Bloc_Category.php 15532 2007-08-31 14:39:46Z nanasess $
33 */
34class LC_Page_FrontParts_Bloc_Category extends LC_Page_FrontParts_Bloc {
35
36    // }}}
37    // {{{ functions
38
39    /**
40     * Page を初期化する.
41     *
42     * @return void
43     */
44    function init() {
45        parent::init();
46        $this->setTplMainpage('category.tpl');
47    }
48
49    /**
50     * Page のプロセス.
51     *
52     * @return void
53     */
54    function process() {
55        $this->action();
56        $this->sendResponse();
57    }
58
59    /**
60     * Page のアクション.
61     *
62     * @return void
63     */
64    function action() {
65        $objDb = new SC_Helper_DB_Ex();
66
67        // 選択中のカテゴリIDを判定する
68        $arrCategory_id = $objDb->sfGetCategoryId($_GET['product_id'], $_GET['category_id']);
69
70        // 選択中のカテゴリID
71        $this->tpl_category_id = empty($arrCategory_id) ? array(0) : $arrCategory_id;;
72        $this->lfGetCatTree($this->tpl_category_id, true, $this);
73    }
74
75    /**
76     * モバイルページを初期化する.
77     *
78     * @return void
79     */
80    function mobileInit() {
81        $this->tpl_mainpage = MOBILE_TEMPLATE_REALDIR . "frontparts/"
82            . BLOC_DIR . 'category.tpl';
83    }
84
85    /**
86     * Page のプロセス(モバイル).
87     *
88     * @return void
89     */
90    function mobileProcess() {
91        $objSubView = new SC_MobileView();
92
93       $this->lfGetMainCat(true, $this);
94
95        $objSubView->assignobj($this);
96        $objSubView->display($this->tpl_mainpage);
97    }
98
99    /**
100     * デストラクタ.
101     *
102     * @return void
103     */
104    function destroy() {
105        parent::destroy();
106    }
107
108    // カテゴリツリーの取得
109    function lfGetCatTree($arrParent_category_id, $count_check = false) {
110        $objQuery = new SC_Query();
111        $objDb = new SC_Helper_DB_Ex();
112        $col = "*";
113        $from = "dtb_category left join dtb_category_total_count using (category_id)";
114        // 登録商品数のチェック
115        if($count_check) {
116            $where = "del_flg = 0 AND product_count > 0";
117        } else {
118            $where = "del_flg = 0";
119        }
120        $objQuery->setOption("ORDER BY rank DESC");
121        $arrRet = $objQuery->select($col, $from, $where);
122
123        foreach ($arrParent_category_id as $category_id) {
124            $arrParentID = $objDb->sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $category_id);
125            $arrBrothersID = SC_Utils_Ex::sfGetBrothersArray($arrRet, 'parent_category_id', 'category_id', $arrParentID);
126            $arrChildrenID = SC_Utils_Ex::sfGetUnderChildrenArray($arrRet, 'parent_category_id', 'category_id', $category_id);
127
128            $this->root_parent_id[] = $arrParentID[0];
129
130            $arrDispID = array_merge($arrBrothersID, $arrChildrenID);
131
132            foreach($arrRet as $key => $array) {
133                foreach($arrDispID as $val) {
134                    if($array['category_id'] == $val) {
135                        $arrRet[$key]['display'] = 1;
136                        break;
137                    }
138                }
139            }
140        }
141
142        $this->arrTree = $arrRet;
143    }
144
145    // メインカテゴリーの取得
146    function lfGetMainCat($count_check = false, &$objSubPage) {
147        $objQuery = new SC_Query();
148        $col = "*";
149        $from = "dtb_category left join dtb_category_total_count using (category_id)";
150        // メインカテゴリーとその直下のカテゴリーを取得する。
151        $where = 'level <= 2 AND del_flg = 0';
152        // 登録商品数のチェック
153        if($count_check) {
154            $where .= " AND product_count > 0";
155        }
156        $objQuery->setOption("ORDER BY rank DESC");
157        $arrRet = $objQuery->select($col, $from, $where);
158
159        // メインカテゴリーを抽出する。
160        $arrMainCat = array();
161        foreach ($arrRet as $cat) {
162            if ($cat['level'] != 1) {
163                continue;
164            }
165
166            // 子カテゴリーを持つかどうかを調べる。
167            $arrChildrenID = SC_Utils_Ex::sfGetUnderChildrenArray($arrRet, 'parent_category_id', 'category_id', $cat['category_id']);
168            $cat['has_children'] = count($arrChildrenID) > 0;
169            $arrMainCat[] = $cat;
170        }
171
172        $objSubPage->arrCat = $arrMainCat;
173        return $objSubPage;
174    }
175}
176?>
Note: See TracBrowser for help on using the repository browser.