source: branches/version-2_11-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_SearchProducts.php @ 20810

Revision 20810, 5.6 KB checked in by kimoto, 13 years ago (diff)

phpから呼ばれるブロックのtplのファイル名を変更しても大丈夫なように修正 #1228

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • 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-2011 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_SearchProducts.php 15532 2007-08-31 14:39:46Z nanasess $
33 */
34class LC_Page_FrontParts_Bloc_SearchProducts 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    }
47
48    /**
49     * Page のプロセス.
50     *
51     * @return void
52     */
53    function process() {
54        $this->action();
55        $this->sendResponse();
56    }
57
58    /**
59     * Page のアクション.
60     *
61     * @return void
62     */
63    function action() {
64        // 商品ID取得
65        $product_id = $this -> lfGetProductId();
66        // カテゴリID取得
67        $category_id = $this -> lfGetCategoryId();
68        // メーカーID取得
69        $maker_id = $this -> lfGetMakerId();
70        // 選択中のカテゴリIDを判定する
71        $this->category_id = $this->lfGetSelectedCategoryId($product_id, $category_id);
72        // カテゴリ検索用選択リスト
73        $this->arrCatList = $this->lfGetCategoryList();
74        // 選択中のメーカーIDを判定する
75        $this->maker_id = $this->lfGetSelectedMakerId($product_id, $maker_id);
76        // メーカー検索用選択リスト
77        $this->arrMakerList = $this->lfGetMakerList();
78    }
79
80    /**
81     * デストラクタ.
82     *
83     * @return void
84     */
85    function destroy() {
86        parent::destroy();
87    }
88
89    /**
90     * 商品IDを取得する.
91     *
92     * @return string $product_id 商品ID
93     */
94    function lfGetProductId() {
95        $product_id = '';
96        if ( isset($_GET['product_id']) && $_GET['product_id'] != '' && is_numeric($_GET['product_id']) ) {
97            $product_id = $_GET['product_id'];
98        }
99        return $product_id;
100    }
101
102    /**
103     * カテゴリIDを取得する.
104     *
105     * @return string $category_id カテゴリID
106     */
107    function lfGetCategoryId() {
108        $category_id = '';
109        if ( isset($_GET['category_id']) && $_GET['category_id'] != '' && is_numeric($_GET['category_id']) ) {
110            $category_id = $_GET['category_id'];
111        }
112        return $category_id;
113    }
114
115    /**
116     * メーカーIDを取得する.
117     *
118     * @return string $maker_id メーカーID
119     */
120    function lfGetMakerId() {
121        $maker_id = '';
122        if ( isset($_GET['maker_id']) && $_GET['maker_id'] != '' && is_numeric($_GET['maker_id']) ) {
123            $maker_id = $_GET['maker_id'];
124        }
125        return $maker_id;
126    }
127
128    /**
129     * 選択中のカテゴリIDを取得する
130     *
131     * @return array $arrCategoryId 選択中のカテゴリID
132     */
133    function lfGetSelectedCategoryId($product_id, $category_id) {
134        // 選択中のカテゴリIDを判定する
135        $objDb = new SC_Helper_DB_Ex();
136        $arrCategoryId = $objDb->sfGetCategoryId($product_id, $category_id);
137        return $arrCategoryId;
138    }
139
140    /**
141     * 選択中のメーカーIDを取得する
142     *
143     * @return array $arrMakerId 選択中のメーカーID
144     */
145    function lfGetSelectedMakerId($product_id, $maker_id) {
146        // 選択中のメーカーIDを判定する
147        $objDb = new SC_Helper_DB_Ex();
148        $arrMakerId = $objDb->sfGetMakerId($product_id, $maker_id);
149        return $arrMakerId;
150    }
151
152    /**
153     * カテゴリ検索用選択リストを取得する
154     *
155     * @return array $arrCategoryList カテゴリ検索用選択リスト
156     */
157    function lfGetCategoryList() {
158        $objDb = new SC_Helper_DB_Ex();
159        // カテゴリ検索用選択リスト
160        $arrCategoryList = $objDb->sfGetCategoryList('', true, ' ');
161        if (is_array($arrCategoryList)) {
162            // 文字サイズを制限する
163            foreach($arrCategoryList as $key => $val) {
164                $truncate_str = SC_Utils_Ex::sfCutString($val, SEARCH_CATEGORY_LEN, false);
165                $arrCategoryList[$key] = preg_replace('/ /', "&nbsp;&nbsp;", $truncate_str);
166            }
167        }
168        return $arrCategoryList;
169    }
170
171    /**
172     * メーカー検索用選択リストを取得する
173     *
174     * @return array $arrMakerList メーカー検索用選択リスト
175     */
176    function lfGetMakerList() {
177        $objDb = new SC_Helper_DB_Ex();
178        // メーカー検索用選択リスト
179        $arrMakerList = $objDb->sfGetMakerList('', true);
180        if (is_array($arrMakerList)) {
181            // 文字サイズを制限する
182            foreach($arrMakerList as $key => $val) {
183                $arrMakerList[$key] = SC_Utils_Ex::sfCutString($val, SEARCH_CATEGORY_LEN);
184            }
185        }
186        return $arrMakerList;
187    }
188
189}
190?>
Note: See TracBrowser for help on using the repository browser.