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_CampaignCreateTag 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/campaign_create_tag.tpl'; |
---|
47 | $this->tpl_mainno = 'create'; |
---|
48 | $this->tpl_subtitle = '商品設定'; |
---|
49 | $this->allowClientCache(); |
---|
50 | } |
---|
51 | |
---|
52 | /** |
---|
53 | * Page のプロセス. |
---|
54 | * |
---|
55 | * @return void |
---|
56 | */ |
---|
57 | function process() { |
---|
58 | $objView = new SC_AdminView(); |
---|
59 | $objSess = new SC_Session(); |
---|
60 | $objQuery = new SC_Query(); |
---|
61 | $objDb = new SC_Helper_DB_Ex(); |
---|
62 | |
---|
63 | // 認証可否の判定 |
---|
64 | SC_Utils_Ex::sfIsSuccess($objSess); |
---|
65 | |
---|
66 | switch($_POST['mode']) { |
---|
67 | |
---|
68 | // 商品検索 |
---|
69 | case 'search': |
---|
70 | // POST値の引き継ぎ |
---|
71 | $this->arrForm = $_POST; |
---|
72 | // 入力文字の強制変換 |
---|
73 | $this->lfConvertParam(); |
---|
74 | |
---|
75 | $where = "del_flg = 0"; |
---|
76 | |
---|
77 | // where句生成 |
---|
78 | foreach ($this->arrForm as $key => $val) { |
---|
79 | if($val == "") { |
---|
80 | continue; |
---|
81 | } |
---|
82 | |
---|
83 | switch ($key) { |
---|
84 | case 'search_name': |
---|
85 | $where .= " AND name ILIKE ?"; |
---|
86 | $arrval[] = "%$val%"; |
---|
87 | break; |
---|
88 | case 'search_category_id': |
---|
89 | list($tmp_where, $tmp_arrval) = $objDb->sfGetCatWhere($val); |
---|
90 | if($tmp_where != "") { |
---|
91 | $where.= " AND product_id IN (SELECT product_id FROM dtb_product_categories WHERE " . $tmp_where . ")"; |
---|
92 | $arrval = array_merge((array)$arrval, (array)$tmp_arrval); |
---|
93 | } |
---|
94 | break; |
---|
95 | case 'search_product_id': |
---|
96 | if($val != "") { |
---|
97 | $where .= " AND product_id = ?"; |
---|
98 | if(!SC_Utils_Ex::sfIsInt($val)) $val = 0; |
---|
99 | $arrval[] = $val; |
---|
100 | } |
---|
101 | break; |
---|
102 | default: |
---|
103 | break; |
---|
104 | } |
---|
105 | } |
---|
106 | |
---|
107 | $order = "update_date DESC, product_id DESC "; |
---|
108 | |
---|
109 | // 読み込む列とテーブルの指定 |
---|
110 | $col = "product_id, name, category_id, main_list_image, status, product_code, price01, stock, stock_unlimited"; |
---|
111 | $from = "vw_products_nonclass AS noncls "; |
---|
112 | |
---|
113 | // 行数の取得 |
---|
114 | $linemax = $objQuery->count("dtb_products", $where, $arrval); |
---|
115 | $this->tpl_linemax = $linemax; // 何件が該当しました。表示用 |
---|
116 | |
---|
117 | // ページ送りの処理 |
---|
118 | if(is_numeric($_POST['search_page_max'])) { |
---|
119 | $page_max = $_POST['search_page_max']; |
---|
120 | } else { |
---|
121 | $page_max = SEARCH_PMAX; |
---|
122 | } |
---|
123 | |
---|
124 | // ページ送りの取得 |
---|
125 | $objNavi = new SC_PageNavi($_POST['search_pageno'], $linemax, $page_max, "fnNaviSearchOnlyPage", NAVI_PMAX); |
---|
126 | $this->tpl_strnavi = $objNavi->strnavi; // 表示文字列 |
---|
127 | $startno = $objNavi->start_row; |
---|
128 | |
---|
129 | // 取得範囲の指定(開始行番号、行数のセット) |
---|
130 | if(DB_TYPE != "mysql") $objQuery->setlimitoffset($page_max, $startno); |
---|
131 | // 表示順序 |
---|
132 | $objQuery->setorder($order); |
---|
133 | |
---|
134 | // 検索結果の取得 |
---|
135 | $this->arrProducts = $objQuery->select($col, $from, $where, $arrval); |
---|
136 | break; |
---|
137 | |
---|
138 | // タグ表示 |
---|
139 | case 'view': |
---|
140 | |
---|
141 | // タグを生成 |
---|
142 | $create_tag = $this->lfGetCreateTag($_POST['product_id']); |
---|
143 | $this->tpl_create_tag = $create_tag; |
---|
144 | break; |
---|
145 | } |
---|
146 | |
---|
147 | // カテゴリ取得 |
---|
148 | $this->arrCatList = $objDb->sfGetCategoryList(); |
---|
149 | |
---|
150 | //---- ページ表示 |
---|
151 | $objView->assignobj($this); |
---|
152 | $objView->display($this->tpl_mainpage); |
---|
153 | } |
---|
154 | |
---|
155 | /** |
---|
156 | * デストラクタ. |
---|
157 | * |
---|
158 | * @return void |
---|
159 | */ |
---|
160 | function destroy() { |
---|
161 | parent::destroy(); |
---|
162 | } |
---|
163 | |
---|
164 | |
---|
165 | /** |
---|
166 | * 取得する文字数の変換を行うメソッド |
---|
167 | * |
---|
168 | * @return void |
---|
169 | */ |
---|
170 | function lfConvertParam() { |
---|
171 | /* |
---|
172 | * 文字列の変換 |
---|
173 | * K : 「半角(ハンカク)片仮名」を「全角片仮名」に変換 |
---|
174 | * C : 「全角ひら仮名」を「全角かた仮名」に変換 |
---|
175 | * V : 濁点付きの文字を一文字に変換。"K","H"と共に使用します |
---|
176 | * n : 「全角」数字を「半角(ハンカク)」に変換 |
---|
177 | */ |
---|
178 | $arrConvList['search_name'] = "KVa"; |
---|
179 | $arrConvList['search_product_code'] = "KVa"; |
---|
180 | |
---|
181 | // 文字変換 |
---|
182 | foreach ($arrConvList as $key => $val) { |
---|
183 | // POSTされてきた値のみ変換する。 |
---|
184 | if(isset($this->arrForm[$key])) { |
---|
185 | $this->arrForm[$key] = mb_convert_kana($this->arrForm[$key] ,$val); |
---|
186 | } |
---|
187 | } |
---|
188 | } |
---|
189 | |
---|
190 | /** |
---|
191 | * キャンペーンページのための商品用タグを生成するメソッド |
---|
192 | * |
---|
193 | * @param string $product_id 商品ID |
---|
194 | * @return void |
---|
195 | */ |
---|
196 | |
---|
197 | function lfGetCreateTag($product_id) { |
---|
198 | // 書き込みタグ |
---|
199 | $read_file = file_get_contents(CAMPAIGN_BLOC_PATH . "cart_tag.tpl"); |
---|
200 | $read_file = ereg_replace("<{assign_product_id}>", $product_id, $read_file); |
---|
201 | // カートタグ保存用ファイル作成 |
---|
202 | $create_tag .= "<!--{* ▼商品ID$product_id *}-->\n"; |
---|
203 | $create_tag .= $read_file; |
---|
204 | |
---|
205 | return $create_tag; |
---|
206 | } |
---|
207 | |
---|
208 | } |
---|
209 | ?> |
---|