source: branches/version-2_5-dev/data/class/pages/admin/contents/LC_Page_Admin_Contents_RecommendSearch.php @ 20116

Revision 20116, 5.6 KB checked in by nanasess, 13 years ago (diff)
  • svn properties を再設定
  • 再設定用のスクリプト追加
  • 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-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/admin/LC_Page_Admin.php");
26
27/**
28 * おすすめ商品管理 商品検索のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Admin_Contents_RecommendSearch extends LC_Page_Admin {
35
36    // }}}
37    // {{{ functions
38
39    /**
40     * Page を初期化する.
41     *
42     * @return void
43     */
44    function init() {
45        parent::init();
46        $this->tpl_mainno = 'contents';
47        $this->tpl_subnavi = '';
48        $this->tpl_subno = "";
49
50    }
51
52    /**
53     * Page のプロセス.
54     *
55     * @return void
56     */
57    function process() {
58        $this->action();
59        $this->sendResponse();
60    }
61
62    /**
63     * Page のアクション.
64     *
65     * @return void
66     */
67    function action() {
68        $objSess = new SC_Session();
69        $objDb = new SC_Helper_DB_Ex();
70
71        // 認証可否の判定
72        SC_Utils_Ex::sfIsSuccess($objSess);
73
74        switch ($this->getMode()) {
75        case 'search':
76            // POST値の引き継ぎ
77            $this->arrForm = $_POST;
78            // 入力文字の強制変換
79            $this->lfConvertParam();
80
81            $where = 'del_flg = 0';
82
83            /* 入力エラーなし */
84            foreach ($this->arrForm as $key => $val) {
85                if($val == "") {
86                    continue;
87                }
88
89                switch ($key) {
90                case 'search_name':
91                    $where .= " AND name ILIKE ?";
92                    $arrval[] = "%$val%";
93                    break;
94                case 'search_category_id':
95                     list($tmp_where, $tmp_arrval) = $objDb->sfGetCatWhere($val);
96                    if($tmp_where != "") {
97                        $where.= " AND product_id IN (SELECT product_id FROM dtb_product_categories WHERE " . $tmp_where . ")";
98                        $arrval = array_merge((array)$arrval, (array)$tmp_arrval);
99                    }
100                    break;
101                case 'search_product_code':
102                    $where .= " AND product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code LIKE ? GROUP BY product_id)";
103                    $arrval[] = "$val%";
104                    break;
105                default:
106                    break;
107                }
108            }
109
110            $order = "update_date DESC, product_id DESC";
111
112            $objQuery = new SC_Query();
113            // 行数の取得
114            if (empty($arrval)) $arrval = array();
115            $linemax = $objQuery->count("dtb_products", $where, $arrval);
116            $this->tpl_linemax = $linemax;               // 何件が該当しました。表示用
117
118            // ページ送りの処理
119            if(isset($_POST['search_page_max'])
120               && is_numeric($_POST['search_page_max'])) {
121                $page_max = $_POST['search_page_max'];
122            } else {
123                $page_max = SEARCH_PMAX;
124            }
125
126            // ページ送りの取得
127            $objNavi = new SC_PageNavi($_POST['search_pageno'], $linemax, $page_max, "fnNaviSearchOnlyPage", NAVI_PMAX);
128            $this->tpl_strnavi = $objNavi->strnavi;      // 表示文字列
129            $startno = $objNavi->start_row;
130
131            // 取得範囲の指定(開始行番号、行数のセット)
132            $objQuery->setLimitOffset($page_max, $startno);
133            // 表示順序
134            $objQuery->setOrder($order);
135
136            // FIXME 商品コードの表示
137            // 検索結果の取得
138            $this->arrProducts = $objQuery->select("*", SC_Product::alldtlSQL(), $where, $arrval);
139            break;
140        default:
141            break;
142        }
143
144        // カテゴリ取得
145        $this->arrCatList = $objDb->sfGetCategoryList();
146
147        $this->setTemplate('contents/recomend_search.tpl');
148    }
149
150    /**
151     * デストラクタ.
152     *
153     * @return void
154     */
155    function destroy() {
156        parent::destroy();
157    }
158
159    /* 取得文字列の変換 */
160    function lfConvertParam() {
161        /*
162         *  文字列の変換
163         *  K :  「半角(ハンカク)片仮名」を「全角片仮名」に変換
164         *  C :  「全角ひら仮名」を「全角かた仮名」に変換
165         *  V :  濁点付きの文字を一文字に変換。"K","H"と共に使用します
166         *  n :  「全角」数字を「半角(ハンカク)」に変換
167         */
168        $arrConvList['search_name'] = "KVa";
169        $arrConvList['search_product_code'] = "KVa";
170
171        // 文字変換
172        foreach ($arrConvList as $key => $val) {
173            // POSTされてきた値のみ変換する。
174            if(isset($this->arrForm[$key])) {
175                $this->arrForm[$key] = mb_convert_kana($this->arrForm[$key] ,$val);
176            }
177        }
178    }
179}
180?>
Note: See TracBrowser for help on using the repository browser.