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 |
---|
25 | require_once(CLASS_PATH . "pages/LC_Page.php"); |
---|
26 | |
---|
27 | /** |
---|
28 | * おすすめ管理検索 のページクラス. |
---|
29 | * |
---|
30 | * @package Page |
---|
31 | * @author LOCKON CO.,LTD. |
---|
32 | * @version $Id$ |
---|
33 | */ |
---|
34 | class LC_Page_Admin_Contents_RecommendSearch 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 = 'contents/recomend_search.tpl'; |
---|
47 | $this->tpl_mainno = 'contents'; |
---|
48 | $this->tpl_subnavi = ''; |
---|
49 | $this->tpl_subno = ""; |
---|
50 | |
---|
51 | } |
---|
52 | |
---|
53 | /** |
---|
54 | * Page のプロセス. |
---|
55 | * |
---|
56 | * @return void |
---|
57 | */ |
---|
58 | function process() { |
---|
59 | $conn = new SC_DBConn(); |
---|
60 | $objView = new SC_AdminView(); |
---|
61 | $objSess = new SC_Session(); |
---|
62 | $objDb = new SC_Helper_DB_Ex(); |
---|
63 | |
---|
64 | // 認証可否の判定 |
---|
65 | SC_Utils_Ex::sfIsSuccess($objSess); |
---|
66 | |
---|
67 | if (!isset($_POST['mode'])) $_POST['mode'] = ""; |
---|
68 | if ($_POST['mode'] == "search") { |
---|
69 | |
---|
70 | // POST値の引き継ぎ |
---|
71 | $this->arrForm = $_POST; |
---|
72 | // 入力文字の強制変換 |
---|
73 | $this->lfConvertParam(); |
---|
74 | |
---|
75 | |
---|
76 | $where = "del_flg = 0"; |
---|
77 | |
---|
78 | /* 入力エラーなし */ |
---|
79 | foreach ($this->arrForm as $key => $val) { |
---|
80 | if($val == "") { |
---|
81 | continue; |
---|
82 | } |
---|
83 | |
---|
84 | switch ($key) { |
---|
85 | case 'search_name': |
---|
86 | |
---|
87 | $where .= " AND name ILIKE ?"; |
---|
88 | $arrval[] = "%$val%"; |
---|
89 | break; |
---|
90 | case 'search_category_id': |
---|
91 | // 子カテゴリIDの取得 |
---|
92 | $arrRet = $objDb->sfGetChildsID("dtb_category", "parent_category_id", "category_id", $val); |
---|
93 | $tmp_where = ""; |
---|
94 | foreach ($arrRet as $val) { |
---|
95 | if($tmp_where == "") { |
---|
96 | $tmp_where.= " AND ( category_id = ?"; |
---|
97 | } else { |
---|
98 | $tmp_where.= " OR category_id = ?"; |
---|
99 | } |
---|
100 | $arrval[] = $val; |
---|
101 | } |
---|
102 | $where.= $tmp_where . " )"; |
---|
103 | break; |
---|
104 | case 'search_product_code': |
---|
105 | $where .= " AND product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code ILIKE ? GROUP BY product_id)"; |
---|
106 | $where .= " OR product_code ILIKE ?"; |
---|
107 | $arrval[] = "%$val%"; |
---|
108 | $arrval[] = "%$val%"; |
---|
109 | break; |
---|
110 | default: |
---|
111 | break; |
---|
112 | } |
---|
113 | } |
---|
114 | |
---|
115 | $order = "update_date DESC, product_id DESC"; |
---|
116 | |
---|
117 | // 読み込む列とテーブルの指定 |
---|
118 | $col = "product_id, name, category_id, main_list_image, status, product_code, price01, stock, stock_unlimited"; |
---|
119 | $from = "vw_products_nonclass AS noncls "; |
---|
120 | |
---|
121 | $objQuery = new SC_Query(); |
---|
122 | // 行数の取得 |
---|
123 | if (empty($arrval)) $arrval = array(); |
---|
124 | $linemax = $objQuery->count("dtb_products", $where, $arrval); |
---|
125 | $this->tpl_linemax = $linemax; // 何件が該当しました。表示用 |
---|
126 | |
---|
127 | // ページ送りの処理 |
---|
128 | if(isset($_POST['search_page_max']) |
---|
129 | && is_numeric($_POST['search_page_max'])) { |
---|
130 | $page_max = $_POST['search_page_max']; |
---|
131 | } else { |
---|
132 | $page_max = SEARCH_PMAX; |
---|
133 | } |
---|
134 | |
---|
135 | // ページ送りの取得 |
---|
136 | $objNavi = new SC_PageNavi($_POST['search_pageno'], $linemax, $page_max, "fnNaviSearchOnlyPage", NAVI_PMAX); |
---|
137 | $this->tpl_strnavi = $objNavi->strnavi; // 表示文字列 |
---|
138 | $startno = $objNavi->start_row; |
---|
139 | |
---|
140 | // 取得範囲の指定(開始行番号、行数のセット) |
---|
141 | $objQuery->setlimitoffset($page_max, $startno); |
---|
142 | // 表示順序 |
---|
143 | $objQuery->setorder($order); |
---|
144 | |
---|
145 | // 検索結果の取得 |
---|
146 | $this->arrProducts = $objQuery->select($col, $from, $where, $arrval); |
---|
147 | } |
---|
148 | |
---|
149 | // カテゴリ取得 |
---|
150 | $this->arrCatList = $objDb->sfGetCategoryList(); |
---|
151 | |
---|
152 | //---- ページ表示 |
---|
153 | $objView->assignobj($this); |
---|
154 | $objView->display($this->tpl_mainpage); |
---|
155 | |
---|
156 | } |
---|
157 | |
---|
158 | /** |
---|
159 | * デストラクタ. |
---|
160 | * |
---|
161 | * @return void |
---|
162 | */ |
---|
163 | function destroy() { |
---|
164 | parent::destroy(); |
---|
165 | } |
---|
166 | |
---|
167 | /* 取得文字列の変換 */ |
---|
168 | function lfConvertParam() { |
---|
169 | /* |
---|
170 | * 文字列の変換 |
---|
171 | * K : 「半角(ハンカク)片仮名」を「全角片仮名」に変換 |
---|
172 | * C : 「全角ひら仮名」を「全角かた仮名」に変換 |
---|
173 | * V : 濁点付きの文字を一文字に変換。"K","H"と共に使用します |
---|
174 | * n : 「全角」数字を「半角(ハンカク)」に変換 |
---|
175 | */ |
---|
176 | $arrConvList['search_name'] = "KVa"; |
---|
177 | $arrConvList['search_product_code'] = "KVa"; |
---|
178 | |
---|
179 | // 文字変換 |
---|
180 | foreach ($arrConvList as $key => $val) { |
---|
181 | // POSTされてきた値のみ変換する。 |
---|
182 | if(isset($this->arrForm[$key])) { |
---|
183 | $this->arrForm[$key] = mb_convert_kana($this->arrForm[$key] ,$val); |
---|
184 | } |
---|
185 | } |
---|
186 | } |
---|
187 | } |
---|
188 | ?> |
---|