source: branches/feature-module-update/data/class/pages/rss/LC_Page_Rss_Products.php @ 16582

Revision 16582, 9.3 KB checked in by nanasess, 16 years ago (diff)

ライセンス表記変更

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id Date Revision
  • Property svn:mime-type set to text/x-httpd-php
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2007 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_PATH . "pages/LC_Page.php");
26
27/**
28 * RSS(商品) のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Rss_Products extends LC_Page {
35
36    // }}}
37    // {{{ functions
38
39    /**
40     * Page を初期化する.
41     *
42     * @return void
43     */
44    function init() {
45        parent::init();
46        $this->tpl_mainpage = "rss/product.tpl";
47        $this->encode = "UTF-8";
48        $this->title = "商品一覧情報";
49    }
50
51    /**
52     * Page のプロセス.
53     *
54     * @return void
55     */
56    function process() {
57        $objQuery = new SC_Query();
58        $objView = new SC_SiteView();
59        $objSiteInfo = new SC_SiteInfo();
60
61        //店舗情報をセット
62        $arrSiteInfo = $objSiteInfo->data;
63
64        //商品IDを取得
65        $product_id = $_GET['product_id'];
66        $mode = $_GET['mode'];
67
68        if(($product_id != "" and is_numeric($product_id)) or $mode == "all"){
69            //商品詳細を取得
70            ($mode == "all") ? $arrProduct = $this->lfGetProductsDetail($objQuery, $mode) : $arrProduct = $this->lfGetProductsDetail($objQuery, $product_id);
71
72            // 値のセットし直し
73            foreach($arrProduct as $key => $val){
74                //商品価格を税込みに編集
75                $arrProduct[$key]["price02"] = SC_Utils_Ex::sfPreTax($arrProduct[$key]["price02"], $arrSiteInfo["tax"], $arrSiteInfo["tax_rule"]);
76
77                // 画像ファイルのURLセット
78                (file_exists(IMAGE_SAVE_DIR . $arrProduct[$key]["main_list_image"])) ? $dir = IMAGE_SAVE_URL_RSS : $dir = IMAGE_TEMP_URL_RSS;
79                $arrProduct[$key]["main_list_image"] = $dir . $arrProduct[$key]["main_list_image"];
80                (file_exists(IMAGE_SAVE_DIR . $arrProduct[$key]["main_image"])) ? $dir = IMAGE_SAVE_URL_RSS : $dir = IMAGE_TEMP_URL_RSS;
81                $arrProduct[$key]["main_image"] = $dir . $arrProduct[$key]["main_image"];
82                (file_exists(IMAGE_SAVE_DIR . $arrProduct[$key]["main_large_image"])) ? $dir = IMAGE_SAVE_URL_RSS : $dir = IMAGE_TEMP_URL_RSS;
83                $arrProduct[$key]["main_large_image"] = $dir . $arrProduct[$key]["main_large_image"];
84
85                // ポイント計算
86                $arrProduct[$key]["point"] = SC_Utils_Ex::sfPrePoint($arrProduct[$key]["price02"], $arrProduct[$key]["point_rate"], POINT_RULE, $arrProduct[$key]["product_id"]);
87            }
88        }elseif($mode == "list"){
89            //商品一覧を取得
90            $arrProduct = $objQuery->getall("SELECT product_id, name AS product_name FROM dtb_products");
91        }else{
92            $arrProduct = $this->lfGetProductsAllclass($objQuery);
93
94            // 値のセットし直し
95            foreach($arrProduct as $key => $val){
96                //商品価格を税込みに編集
97                $arrProduct[$key]["price01_max"] = SC_Utils_Ex::sfPreTax($arrProduct[$key]["price01_max"], $arrSiteInfo["tax"], $arrSiteInfo["tax_rule"]);
98                $arrProduct[$key]["price01_min"] = SC_Utils_Ex::sfPreTax($arrProduct[$key]["price01_min"], $arrSiteInfo["tax"], $arrSiteInfo["tax_rule"]);
99                $arrProduct[$key]["price02_max"] = SC_Utils_Ex::sfPreTax($arrProduct[$key]["price02_max"], $arrSiteInfo["tax"], $arrSiteInfo["tax_rule"]);
100                $arrProduct[$key]["price02_min"] = SC_Utils_Ex::sfPreTax($arrProduct[$key]["price02_min"], $arrSiteInfo["tax"], $arrSiteInfo["tax_rule"]);
101
102                // 画像ファイルのURLセット
103                (file_exists(IMAGE_SAVE_DIR . $arrProduct[$key]["main_list_image"])) ? $dir = IMAGE_SAVE_URL_RSS : $dir = IMAGE_TEMP_URL_RSS;
104                $arrProduct[$key]["main_list_image"] = $dir . $arrProduct[$key]["main_list_image"];
105                (file_exists(IMAGE_SAVE_DIR . $arrProduct[$key]["main_image"])) ? $dir = IMAGE_SAVE_URL_RSS : $dir = IMAGE_TEMP_URL_RSS;
106                $arrProduct[$key]["main_image"] = $dir . $arrProduct[$key]["main_image"];
107                (file_exists(IMAGE_SAVE_DIR . $arrProduct[$key]["main_large_image"])) ? $dir = IMAGE_SAVE_URL_RSS : $dir = IMAGE_TEMP_URL_RSS;
108                $arrProduct[$key]["main_large_image"] = $dir . $arrProduct[$key]["main_large_image"];
109
110                // ポイント計算
111                $arrProduct[$key]["point_max"] = SC_Utils_Ex::sfPrePoint($arrProduct[$key]["price02_max"], $arrProduct[$key]["point_rate"], POINT_RULE, $arrProduct[$key]["product_id"]);
112                $arrProduct[$key]["point_min"] = SC_Utils_Ex::sfPrePoint($arrProduct[$key]["price02_min"], $arrProduct[$key]["point_rate"], POINT_RULE, $arrProduct[$key]["product_id"]);
113            }
114        }
115
116        //商品情報をセット
117        $this->arrProduct = $arrProduct;
118        if(is_array(SC_Utils_Ex::sfswaparray($arrProduct))){
119            $this->arrProductKeys = array_keys(SC_Utils_Ex::sfswaparray($arrProduct));
120        }
121
122        //店舗情報をセット
123        $this->arrSiteInfo = $arrSiteInfo;
124
125        //セットしたデータをテンプレートファイルに出力
126        $objView->assignobj($this);
127
128        //キャッシュしない(念のため)
129        header("Pragma: no-cache");
130
131        //XMLテキスト(これがないと正常にRSSとして認識してくれないツールがあるため)
132        header("Content-type: application/xml");
133        DETAIL_P_HTML;
134
135        //画面表示
136        $objView->display($this->tpl_mainpage, true);
137    }
138
139    /**
140     * デストラクタ.
141     *
142     * @return void
143     */
144    function destroy() {
145        parent::destroy();
146    }
147
148    /**
149     * 商品情報を取得する
150     *
151     * @param SC_Query $objQuery DB操作クラス
152     * @param integer $product_id 商品ID
153     * @return array $arrProduct 取得結果を配列で返す
154     */
155    function lfGetProductsDetail(&$objQuery, $product_id = "all"){
156        $sql = "";
157        $sql .= "SELECT ";
158        $sql .= "   prod.product_id ";
159        $sql .= "   ,prod.name AS product_name ";
160        $sql .= "   ,prod.category_id ";
161        $sql .= "   ,prod.point_rate ";
162        $sql .= "   ,prod.comment3 ";
163        $sql .= "   ,prod.main_list_comment ";
164        $sql .= "   ,prod.main_list_image ";
165        $sql .= "   ,prod.main_comment ";
166        $sql .= "   ,prod.main_image ";
167        $sql .= "   ,prod.main_large_image ";
168        $sql .= "   ,cls.product_code ";
169        $sql .= "   ,cls.price01 ";
170        $sql .= "   ,cls.price02 ";
171        $sql .= "   ,cls.classcategory_id1 ";
172        $sql .= "   ,cls.classcategory_id2 ";
173        $sql .= "   ,(SELECT name FROM dtb_classcategory AS clscat WHERE clscat.classcategory_id = cls.classcategory_id1) AS classcategory_name1 ";
174        $sql .= "   ,(SELECT name FROM dtb_classcategory AS clscat WHERE clscat.classcategory_id = cls.classcategory_id2) AS classcategory_name2 ";
175        $sql .= "   ,(SELECT category_name FROM dtb_category AS cat WHERE cat.category_id = prod.category_id) AS category_name";
176        $sql .= " FROM dtb_products AS prod, dtb_products_class AS cls";
177        $sql .= " WHERE prod.product_id = cls.product_id AND prod.del_flg = 0 AND prod.status = 1";
178
179        if($product_id != "all"){
180            $sql .= " AND prod.product_id = ?";
181            $arrval = array($product_id);
182        }
183        $sql .= " ORDER BY prod.product_id, cls.classcategory_id1, cls.classcategory_id2";
184        $arrProduct = $objQuery->getall($sql, $arrval);
185        return $arrProduct;
186    }
187
188    /**
189     * 商品情報を取得する(vw_products_allclass使用)
190     *
191     * @param SC_Query $objQuery DB操作クラス
192     * @return array $arrProduct 取得結果を配列で返す
193     */
194    function lfGetProductsAllclass($objQuery){
195        $sql = "";
196        $sql .= "SELECT
197                product_id
198                ,name as product_name
199                ,category_id
200                ,point_rate
201                ,comment3
202                ,main_list_comment
203                ,main_image
204                ,main_list_image
205                ,product_code_min
206                ,product_code_max
207                ,price01_min
208                ,price01_max
209                ,price02_min
210                ,price02_max
211                ,(SELECT category_name FROM dtb_category AS cat WHERE cat.category_id = allcls.category_id) AS category_name
212                ,(SELECT main_large_image FROM dtb_products AS prod WHERE prod.product_id = allcls.product_id) AS main_large_image
213            FROM  vw_products_allclass as allcls
214            WHERE allcls.del_flg = 0 AND allcls.status = 1";
215        $sql .= " ORDER BY allcls.product_id";
216        $arrProduct = $objQuery->getall($sql);
217        return $arrProduct;
218    }
219}
220?>
Note: See TracBrowser for help on using the repository browser.