1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2013 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_EX_REALDIR . 'page_extends/admin/products/LC_Page_Admin_Products_Ex.php'; |
---|
26 | |
---|
27 | /** |
---|
28 | * 商品登録 のページクラス |
---|
29 | * |
---|
30 | * @package Page |
---|
31 | * @author LOCKON CO.,LTD. |
---|
32 | * @version $Id$ |
---|
33 | */ |
---|
34 | class LC_Page_Admin_Products_Product extends LC_Page_Admin_Products_Ex { |
---|
35 | |
---|
36 | // }}} |
---|
37 | // {{{ functions |
---|
38 | |
---|
39 | /** |
---|
40 | * Page を初期化する. |
---|
41 | * |
---|
42 | * @return void |
---|
43 | */ |
---|
44 | function init() { |
---|
45 | parent::init(); |
---|
46 | $this->tpl_mainpage = 'products/product.tpl'; |
---|
47 | $this->tpl_mainno = 'products'; |
---|
48 | $this->tpl_subno = 'product'; |
---|
49 | $this->tpl_maintitle = '商品管理'; |
---|
50 | $this->tpl_subtitle = '商品登録'; |
---|
51 | |
---|
52 | $masterData = new SC_DB_MasterData_Ex(); |
---|
53 | $this->arrProductType = $masterData->getMasterData('mtb_product_type'); |
---|
54 | $this->arrDISP = $masterData->getMasterData('mtb_disp'); |
---|
55 | $this->arrSTATUS = $masterData->getMasterData('mtb_status'); |
---|
56 | $this->arrSTATUS_IMAGE = $masterData->getMasterData('mtb_status_image'); |
---|
57 | $this->arrDELIVERYDATE = $masterData->getMasterData('mtb_delivery_date'); |
---|
58 | $this->arrMaker = SC_Helper_DB_Ex::sfGetIDValueList('dtb_maker', 'maker_id', 'name'); |
---|
59 | $this->arrAllowedTag = $masterData->getMasterData('mtb_allowed_tag'); |
---|
60 | } |
---|
61 | |
---|
62 | /** |
---|
63 | * Page のプロセス. |
---|
64 | * |
---|
65 | * @return void |
---|
66 | */ |
---|
67 | function process() { |
---|
68 | $this->action(); |
---|
69 | $this->sendResponse(); |
---|
70 | } |
---|
71 | |
---|
72 | /** |
---|
73 | * Page のアクション. |
---|
74 | * |
---|
75 | * @return void |
---|
76 | */ |
---|
77 | function action() { |
---|
78 | |
---|
79 | $objFormParam = new SC_FormParam_Ex(); |
---|
80 | |
---|
81 | // アップロードファイル情報の初期化 |
---|
82 | $objUpFile = new SC_UploadFile_Ex(IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR); |
---|
83 | $this->lfInitFile($objUpFile); |
---|
84 | $objUpFile->setHiddenFileList($_POST); |
---|
85 | |
---|
86 | // ダウンロード販売ファイル情報の初期化 |
---|
87 | $objDownFile = new SC_UploadFile_Ex(DOWN_TEMP_REALDIR, DOWN_SAVE_REALDIR); |
---|
88 | $this->lfInitDownFile($objDownFile); |
---|
89 | $objDownFile->setHiddenFileList($_POST); |
---|
90 | |
---|
91 | // 検索パラメーター引き継ぎ |
---|
92 | $this->arrSearchHidden = $this->lfGetSearchParam($_POST); |
---|
93 | |
---|
94 | $mode = $this->getMode(); |
---|
95 | switch ($mode) { |
---|
96 | case 'pre_edit': |
---|
97 | case 'copy' : |
---|
98 | // パラメーター初期化(商品ID) |
---|
99 | $this->lfInitFormParam_PreEdit($objFormParam, $_POST); |
---|
100 | // エラーチェック |
---|
101 | $this->arrErr = $objFormParam->checkError(); |
---|
102 | if (count($this->arrErr) > 0) { |
---|
103 | trigger_error('', E_USER_ERROR); |
---|
104 | } |
---|
105 | |
---|
106 | // 商品ID取得 |
---|
107 | $product_id = $objFormParam->getValue('product_id'); |
---|
108 | // 商品データ取得 |
---|
109 | $arrForm = $this->lfGetFormParam_PreEdit($objUpFile, $objDownFile, $product_id); |
---|
110 | |
---|
111 | // 複製の場合は、ダウンロード商品情報部分はコピーしない |
---|
112 | if ($mode == 'copy') { |
---|
113 | // ダウンロード商品ファイル名をunset |
---|
114 | $arrForm['down_filename'] = ''; |
---|
115 | |
---|
116 | // $objDownFile->setDBDownFile()でsetされたダウンロードファイル名をunset |
---|
117 | unset($objDownFile->save_file[0]); |
---|
118 | } |
---|
119 | |
---|
120 | // ページ表示用パラメーター設定 |
---|
121 | $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); |
---|
122 | |
---|
123 | // 商品複製の場合、画像ファイルコピー |
---|
124 | if ($mode == 'copy') { |
---|
125 | $this->arrForm['copy_product_id'] = $this->arrForm['product_id']; |
---|
126 | $this->arrForm['product_id'] = ''; |
---|
127 | // 画像ファイルのコピー |
---|
128 | $this->lfCopyProductImageFiles($objUpFile); |
---|
129 | } |
---|
130 | |
---|
131 | // ページonload時のJavaScript設定 |
---|
132 | $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage(); |
---|
133 | break; |
---|
134 | |
---|
135 | case 'edit': |
---|
136 | // パラメーター初期化, 取得 |
---|
137 | $this->lfInitFormParam($objFormParam, $_POST); |
---|
138 | $arrForm = $objFormParam->getHashArray(); |
---|
139 | // エラーチェック |
---|
140 | $this->arrErr = $this->lfCheckError_Edit($objFormParam, $objUpFile, $objDownFile, $arrForm); |
---|
141 | if (count($this->arrErr) == 0) { |
---|
142 | // 確認画面表示設定 |
---|
143 | $this->tpl_mainpage = 'products/confirm.tpl'; |
---|
144 | $this->arrCatList = $this->lfGetCategoryList_Edit(); |
---|
145 | $this->arrForm = $this->lfSetViewParam_ConfirmPage($objUpFile, $objDownFile, $arrForm); |
---|
146 | } else { |
---|
147 | // 入力画面表示設定 |
---|
148 | $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); |
---|
149 | // ページonload時のJavaScript設定 |
---|
150 | $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage(); |
---|
151 | } |
---|
152 | break; |
---|
153 | |
---|
154 | case 'complete': |
---|
155 | // パラメーター初期化, 取得 |
---|
156 | $this->lfInitFormParam($objFormParam, $_POST); |
---|
157 | $arrForm = $this->lfGetFormParam_Complete($objFormParam); |
---|
158 | // エラーチェック |
---|
159 | $this->arrErr = $this->lfCheckError_Edit($objFormParam, $objUpFile, $objDownFile, $arrForm); |
---|
160 | if (count($this->arrErr) == 0) { |
---|
161 | // DBへデータ登録 |
---|
162 | $product_id = $this->lfRegistProduct($objUpFile, $objDownFile, $arrForm); |
---|
163 | |
---|
164 | // 件数カウントバッチ実行 |
---|
165 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
166 | $objDb = new SC_Helper_DB_Ex(); |
---|
167 | $objDb->sfCountCategory($objQuery); |
---|
168 | $objDb->sfCountMaker($objQuery); |
---|
169 | |
---|
170 | // ダウンロード商品の複製時に、ダウンロード商品用ファイルを |
---|
171 | // 変更すると、複製元のファイルが削除されるのを回避。 |
---|
172 | if (!empty($arrForm['copy_product_id'])) { |
---|
173 | $objDownFile->save_file = array(); |
---|
174 | } |
---|
175 | |
---|
176 | // 一時ファイルを本番ディレクトリに移動する |
---|
177 | $this->lfSaveUploadFiles($objUpFile, $objDownFile, $product_id); |
---|
178 | |
---|
179 | $this->tpl_mainpage = 'products/complete.tpl'; |
---|
180 | $this->arrForm['product_id'] = $product_id; |
---|
181 | } else { |
---|
182 | // 入力画面表示設定 |
---|
183 | $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); |
---|
184 | // ページonload時のJavaScript設定 |
---|
185 | $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage(); |
---|
186 | } |
---|
187 | break; |
---|
188 | |
---|
189 | // 画像のアップロード |
---|
190 | case 'upload_image': |
---|
191 | case 'delete_image': |
---|
192 | // パラメーター初期化 |
---|
193 | $this->lfInitFormParam_UploadImage($objFormParam); |
---|
194 | $this->lfInitFormParam($objFormParam, $_POST); |
---|
195 | $arrForm = $objFormParam->getHashArray(); |
---|
196 | |
---|
197 | switch ($mode) { |
---|
198 | case 'upload_image': |
---|
199 | // ファイルを一時ディレクトリにアップロード |
---|
200 | $this->arrErr[$arrForm['image_key']] = $objUpFile->makeTempFile($arrForm['image_key'], IMAGE_RENAME); |
---|
201 | if ($this->arrErr[$arrForm['image_key']] == '') { |
---|
202 | // 縮小画像作成 |
---|
203 | $this->lfSetScaleImage($objUpFile, $arrForm['image_key']); |
---|
204 | } |
---|
205 | break; |
---|
206 | case 'delete_image': |
---|
207 | // ファイル削除 |
---|
208 | $this->lfDeleteTempFile($objUpFile, $arrForm['image_key']); |
---|
209 | break; |
---|
210 | default: |
---|
211 | break; |
---|
212 | } |
---|
213 | |
---|
214 | // 入力画面表示設定 |
---|
215 | $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); |
---|
216 | // ページonload時のJavaScript設定 |
---|
217 | $anchor_hash = $this->getAnchorHash($arrForm['image_key']); |
---|
218 | $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage($anchor_hash); |
---|
219 | break; |
---|
220 | |
---|
221 | // ダウンロード商品ファイルアップロード |
---|
222 | case 'upload_down': |
---|
223 | case 'delete_down': |
---|
224 | // パラメーター初期化 |
---|
225 | $this->lfInitFormParam_UploadDown($objFormParam); |
---|
226 | $this->lfInitFormParam($objFormParam, $_POST); |
---|
227 | $arrForm = $objFormParam->getHashArray(); |
---|
228 | |
---|
229 | switch ($mode) { |
---|
230 | case 'upload_down': |
---|
231 | // ファイルを一時ディレクトリにアップロード |
---|
232 | $this->arrErr[$arrForm['down_key']] = $objDownFile->makeTempDownFile(); |
---|
233 | break; |
---|
234 | case 'delete_down': |
---|
235 | // ファイル削除 |
---|
236 | $objDownFile->deleteFile($arrForm['down_key']); |
---|
237 | break; |
---|
238 | default: |
---|
239 | break; |
---|
240 | } |
---|
241 | |
---|
242 | // 入力画面表示設定 |
---|
243 | $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); |
---|
244 | // ページonload時のJavaScript設定 |
---|
245 | $anchor_hash = $this->getAnchorHash($arrForm['down_key']); |
---|
246 | $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage($anchor_hash); |
---|
247 | break; |
---|
248 | |
---|
249 | // 関連商品選択 |
---|
250 | case 'recommend_select' : |
---|
251 | // パラメーター初期化 |
---|
252 | $this->lfInitFormParam_RecommendSelect($objFormParam); |
---|
253 | $this->lfInitFormParam($objFormParam, $_POST); |
---|
254 | $arrForm = $objFormParam->getHashArray(); |
---|
255 | // 入力画面表示設定 |
---|
256 | $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); |
---|
257 | |
---|
258 | // 選択された関連商品IDがすでに登録している関連商品と重複していないかチェック |
---|
259 | $this->lfCheckError_RecommendSelect($this->arrForm, $this->arrErr); |
---|
260 | |
---|
261 | // ページonload時のJavaScript設定 |
---|
262 | $anchor_hash = $this->getAnchorHash($this->arrForm['anchor_key']); |
---|
263 | $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage($anchor_hash); |
---|
264 | break; |
---|
265 | |
---|
266 | // 確認ページからの戻り |
---|
267 | case 'confirm_return': |
---|
268 | // パラメーター初期化 |
---|
269 | $this->lfInitFormParam($objFormParam, $_POST); |
---|
270 | $arrForm = $objFormParam->getHashArray(); |
---|
271 | // 入力画面表示設定 |
---|
272 | $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); |
---|
273 | // ページonload時のJavaScript設定 |
---|
274 | $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage(); |
---|
275 | break; |
---|
276 | |
---|
277 | default: |
---|
278 | // 入力画面表示設定 |
---|
279 | $arrForm = array(); |
---|
280 | $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); |
---|
281 | // ページonload時のJavaScript設定 |
---|
282 | $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage(); |
---|
283 | break; |
---|
284 | } |
---|
285 | |
---|
286 | // 関連商品の読み込み |
---|
287 | $this->arrRecommend = $this->lfGetRecommendProducts($this->arrForm); |
---|
288 | |
---|
289 | } |
---|
290 | |
---|
291 | /** |
---|
292 | * デストラクタ. |
---|
293 | * |
---|
294 | * @return void |
---|
295 | */ |
---|
296 | function destroy() { |
---|
297 | parent::destroy(); |
---|
298 | } |
---|
299 | |
---|
300 | /** |
---|
301 | * パラメーター情報の初期化 |
---|
302 | * - 編集/複製モード |
---|
303 | * |
---|
304 | * @param object $objFormParam SC_FormParamインスタンス |
---|
305 | * @param array $arrPost $_POSTデータ |
---|
306 | * @return void |
---|
307 | */ |
---|
308 | function lfInitFormParam_PreEdit(&$objFormParam, $arrPost) { |
---|
309 | $objFormParam->addParam('商品ID', 'product_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
310 | $objFormParam->setParam($arrPost); |
---|
311 | $objFormParam->convParam(); |
---|
312 | } |
---|
313 | |
---|
314 | /** |
---|
315 | * パラメーター情報の初期化 |
---|
316 | * |
---|
317 | * @param object $objFormParam SC_FormParamインスタンス |
---|
318 | * @param array $arrPost $_POSTデータ |
---|
319 | * @return void |
---|
320 | */ |
---|
321 | function lfInitFormParam(&$objFormParam, $arrPost) { |
---|
322 | $objFormParam->addParam('商品ID', 'product_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
323 | $objFormParam->addParam('商品名', 'name', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
324 | $objFormParam->addParam('商品カテゴリ', 'category_id', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
325 | $objFormParam->addParam('公開・非公開', 'status', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
326 | $objFormParam->addParam('商品ステータス', 'product_status', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
327 | |
---|
328 | if (!$arrPost['has_product_class']) { |
---|
329 | // 新規登録, 規格なし商品の編集の場合 |
---|
330 | $objFormParam->addParam('商品種別', 'product_type_id', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
331 | $objFormParam->addParam('ダウンロード商品ファイル名', 'down_filename', STEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
332 | $objFormParam->addParam('ダウンロード商品実ファイル名', 'down_realfilename', MTEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
333 | $objFormParam->addParam('temp_down_file', 'temp_down_file', '', '', array()); |
---|
334 | $objFormParam->addParam('save_down_file', 'save_down_file', '', '', array()); |
---|
335 | $objFormParam->addParam('商品コード', 'product_code', STEXT_LEN, 'KVna', array('EXIST_CHECK', 'SPTAB_CHECK','MAX_LENGTH_CHECK')); |
---|
336 | $objFormParam->addParam(NORMAL_PRICE_TITLE, 'price01', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
337 | $objFormParam->addParam(SALE_PRICE_TITLE, 'price02', PRICE_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
338 | $objFormParam->addParam('在庫数', 'stock', AMOUNT_LEN, 'n', array('SPTAB_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
339 | $objFormParam->addParam('在庫無制限', 'stock_unlimited', INT_LEN, 'n', array('SPTAB_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
340 | } |
---|
341 | $objFormParam->addParam('商品送料', 'deliv_fee', PRICE_LEN, 'n', array('NUM_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
342 | $objFormParam->addParam('ポイント付与率', 'point_rate', PERCENTAGE_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
343 | $objFormParam->addParam('発送日目安', 'deliv_date_id', INT_LEN, 'n', array('NUM_CHECK')); |
---|
344 | $objFormParam->addParam('販売制限数', 'sale_limit', AMOUNT_LEN, 'n', array('SPTAB_CHECK', 'ZERO_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
345 | $objFormParam->addParam('メーカー', 'maker_id', INT_LEN, 'n', array('NUM_CHECK')); |
---|
346 | $objFormParam->addParam('メーカーURL', 'comment1', URL_LEN, 'a', array('SPTAB_CHECK', 'URL_CHECK', 'MAX_LENGTH_CHECK')); |
---|
347 | $objFormParam->addParam('検索ワード', 'comment3', LLTEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
348 | $objFormParam->addParam('備考欄(SHOP専用)', 'note', LLTEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
349 | $objFormParam->addParam('一覧-メインコメント', 'main_list_comment', MTEXT_LEN, 'KVa', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
350 | $objFormParam->addParam('詳細-メインコメント', 'main_comment', LLTEXT_LEN, 'KVa', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
351 | $objFormParam->addParam('save_main_list_image', 'save_main_list_image', '', '', array()); |
---|
352 | $objFormParam->addParam('save_main_image', 'save_main_image', '', '', array()); |
---|
353 | $objFormParam->addParam('save_main_large_image', 'save_main_large_image', '', '', array()); |
---|
354 | $objFormParam->addParam('temp_main_list_image', 'temp_main_list_image', '', '', array()); |
---|
355 | $objFormParam->addParam('temp_main_image', 'temp_main_image', '', '', array()); |
---|
356 | $objFormParam->addParam('temp_main_large_image', 'temp_main_large_image', '', '', array()); |
---|
357 | |
---|
358 | for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { |
---|
359 | $objFormParam->addParam('詳細-サブタイトル' . $cnt, 'sub_title' . $cnt, STEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
360 | $objFormParam->addParam('詳細-サブコメント' . $cnt, 'sub_comment' . $cnt, LLTEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
361 | $objFormParam->addParam('save_sub_image' . $cnt, 'save_sub_image' . $cnt, '', '', array()); |
---|
362 | $objFormParam->addParam('save_sub_large_image' . $cnt, 'save_sub_large_image' . $cnt, '', '', array()); |
---|
363 | $objFormParam->addParam('temp_sub_image' . $cnt, 'temp_sub_image' . $cnt, '', '', array()); |
---|
364 | $objFormParam->addParam('temp_sub_large_image' . $cnt, 'temp_sub_large_image' . $cnt, '', '', array()); |
---|
365 | } |
---|
366 | |
---|
367 | for ($cnt = 1; $cnt <= RECOMMEND_PRODUCT_MAX; $cnt++) { |
---|
368 | $objFormParam->addParam('関連商品コメント' . $cnt, 'recommend_comment' . $cnt, LTEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
369 | $objFormParam->addParam('関連商品ID' . $cnt, 'recommend_id' . $cnt, INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
370 | $objFormParam->addParam('recommend_delete' . $cnt, 'recommend_delete' . $cnt, '', 'n', array()); |
---|
371 | } |
---|
372 | |
---|
373 | $objFormParam->addParam('商品ID', 'copy_product_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
374 | |
---|
375 | $objFormParam->addParam('has_product_class', 'has_product_class', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
376 | $objFormParam->addParam('product_class_id', 'product_class_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
377 | |
---|
378 | $objFormParam->setParam($arrPost); |
---|
379 | $objFormParam->convParam(); |
---|
380 | } |
---|
381 | |
---|
382 | /** |
---|
383 | * パラメーター情報の初期化 |
---|
384 | * - 画像ファイルアップロードモード |
---|
385 | * |
---|
386 | * @param object $objFormParam SC_FormParamインスタンス |
---|
387 | * @return void |
---|
388 | */ |
---|
389 | function lfInitFormParam_UploadImage(&$objFormParam) { |
---|
390 | $objFormParam->addParam('image_key', 'image_key', '', '', array()); |
---|
391 | } |
---|
392 | |
---|
393 | /** |
---|
394 | * パラメーター情報の初期化 |
---|
395 | * - ダウンロード商品ファイルアップロードモード |
---|
396 | * |
---|
397 | * @param object $objFormParam SC_FormParamインスタンス |
---|
398 | * @return void |
---|
399 | */ |
---|
400 | function lfInitFormParam_UploadDown(&$objFormParam) { |
---|
401 | $objFormParam->addParam('down_key', 'down_key', '', '', array()); |
---|
402 | } |
---|
403 | |
---|
404 | /** |
---|
405 | * パラメーター情報の初期化 |
---|
406 | * - 関連商品追加モード |
---|
407 | * |
---|
408 | * @param object $objFormParam SC_FormParamインスタンス |
---|
409 | * @return void |
---|
410 | */ |
---|
411 | function lfInitFormParam_RecommendSelect(&$objFormParam) { |
---|
412 | $objFormParam->addParam('anchor_key', 'anchor_key', '', '', array()); |
---|
413 | $objFormParam->addParam('select_recommend_no', 'select_recommend_no', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
414 | } |
---|
415 | |
---|
416 | /** |
---|
417 | * アップロードファイルパラメーター情報の初期化 |
---|
418 | * - 画像ファイル用 |
---|
419 | * |
---|
420 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
421 | * @return void |
---|
422 | */ |
---|
423 | function lfInitFile(&$objUpFile) { |
---|
424 | $objUpFile->addFile('一覧-メイン画像', 'main_list_image', array('jpg', 'gif', 'png'),IMAGE_SIZE, false, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT); |
---|
425 | $objUpFile->addFile('詳細-メイン画像', 'main_image', array('jpg', 'gif', 'png'), IMAGE_SIZE, false, NORMAL_IMAGE_WIDTH, NORMAL_IMAGE_HEIGHT); |
---|
426 | $objUpFile->addFile('詳細-メイン拡大画像', 'main_large_image', array('jpg', 'gif', 'png'), IMAGE_SIZE, false, LARGE_IMAGE_WIDTH, LARGE_IMAGE_HEIGHT); |
---|
427 | for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { |
---|
428 | $objUpFile->addFile("詳細-サブ画像$cnt", "sub_image$cnt", array('jpg', 'gif', 'png'), IMAGE_SIZE, false, NORMAL_SUBIMAGE_WIDTH, NORMAL_SUBIMAGE_HEIGHT); |
---|
429 | $objUpFile->addFile("詳細-サブ拡大画像$cnt", "sub_large_image$cnt", array('jpg', 'gif', 'png'), IMAGE_SIZE, false, LARGE_SUBIMAGE_WIDTH, LARGE_SUBIMAGE_HEIGHT); |
---|
430 | } |
---|
431 | } |
---|
432 | |
---|
433 | /** |
---|
434 | * アップロードファイルパラメーター情報の初期化 |
---|
435 | * - ダウンロード商品ファイル用 |
---|
436 | * |
---|
437 | * @param object $objDownFile SC_UploadFileインスタンス |
---|
438 | * @return void |
---|
439 | */ |
---|
440 | function lfInitDownFile(&$objDownFile) { |
---|
441 | $objDownFile->addFile('ダウンロード販売用ファイル', 'down_file', explode(',', DOWNLOAD_EXTENSION),DOWN_SIZE, true, 0, 0); |
---|
442 | } |
---|
443 | |
---|
444 | /** |
---|
445 | * フォーム入力パラメーターのエラーチェック |
---|
446 | * |
---|
447 | * @param object $objFormParam SC_FormParamインスタンス |
---|
448 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
449 | * @param object $objDownFile SC_UploadFileインスタンス |
---|
450 | * @param array $arrForm フォーム入力パラメーター配列 |
---|
451 | * @return array エラー情報を格納した連想配列 |
---|
452 | */ |
---|
453 | function lfCheckError_Edit(&$objFormParam, &$objUpFile, &$objDownFile, $arrForm) { |
---|
454 | $objErr = new SC_CheckError_Ex($arrForm); |
---|
455 | $arrErr = array(); |
---|
456 | |
---|
457 | // 入力パラメーターチェック |
---|
458 | $arrErr = $objFormParam->checkError(); |
---|
459 | |
---|
460 | // アップロードファイル必須チェック |
---|
461 | $arrErr = array_merge((array)$arrErr, (array)$objUpFile->checkExists()); |
---|
462 | |
---|
463 | // HTMLタグ許可チェック |
---|
464 | $objErr->doFunc(array('詳細-メインコメント', 'main_comment', $this->arrAllowedTag), array('HTML_TAG_CHECK')); |
---|
465 | for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { |
---|
466 | $objErr->doFunc(array('詳細-サブコメント' . $cnt, 'sub_comment' . $cnt, $this->arrAllowedTag), array('HTML_TAG_CHECK')); |
---|
467 | } |
---|
468 | |
---|
469 | // 規格情報がない商品の場合のチェック |
---|
470 | if ($arrForm['has_product_class'] != true) { |
---|
471 | // 在庫必須チェック(在庫無制限ではない場合) |
---|
472 | if ($arrForm['stock_unlimited'] != UNLIMITED_FLG_UNLIMITED) { |
---|
473 | $objErr->doFunc(array('在庫数', 'stock'), array('EXIST_CHECK')); |
---|
474 | } |
---|
475 | // ダウンロード商品ファイル必須チェック(ダウンロード商品の場合) |
---|
476 | if ($arrForm['product_type_id'] == PRODUCT_TYPE_DOWNLOAD) { |
---|
477 | $arrErr = array_merge((array)$arrErr, (array)$objDownFile->checkExists()); |
---|
478 | $objErr->doFunc(array('ダウンロード商品ファイル名', 'down_filename'), array('EXIST_CHECK')); |
---|
479 | } |
---|
480 | } |
---|
481 | |
---|
482 | $arrErr = array_merge((array)$arrErr, (array)$objErr->arrErr); |
---|
483 | return $arrErr; |
---|
484 | } |
---|
485 | |
---|
486 | /** |
---|
487 | * 関連商品の重複登録チェック、エラーチェック |
---|
488 | * |
---|
489 | * 関連商品の重複があった場合はエラーメッセージを格納し、該当の商品IDをリセットする |
---|
490 | * |
---|
491 | * @param array $arrForm 入力値の配列 |
---|
492 | * @param array $arrErr エラーメッセージの配列 |
---|
493 | * @return void |
---|
494 | */ |
---|
495 | function lfCheckError_RecommendSelect(&$arrForm, &$arrErr) { |
---|
496 | $select_recommend_no = $arrForm['select_recommend_no']; |
---|
497 | $select_recommend_id = $arrForm['recommend_id' . $select_recommend_no]; |
---|
498 | |
---|
499 | foreach ($arrForm as $key => $value) { |
---|
500 | if (preg_match('/^recommend_id/', $key)) { |
---|
501 | if ($select_recommend_no == preg_replace('/^recommend_id/', '', $key)) { |
---|
502 | continue; |
---|
503 | } |
---|
504 | |
---|
505 | if ($select_recommend_id == $arrForm[$key]) { |
---|
506 | // 重複した場合、選択されたデータをリセットする |
---|
507 | $arrForm['recommend_id' . $select_recommend_no] = ''; |
---|
508 | $arrErr['recommend_comment' . $select_recommend_no] = '※ すでに登録されている関連商品です。<br />'; |
---|
509 | break; |
---|
510 | } |
---|
511 | } |
---|
512 | } |
---|
513 | } |
---|
514 | |
---|
515 | /** |
---|
516 | * 検索パラメーター引き継ぎ用配列取得 |
---|
517 | * |
---|
518 | * @param array $arrPost $_POSTデータ |
---|
519 | * @return array 検索パラメーター配列 |
---|
520 | */ |
---|
521 | function lfGetSearchParam($arrPost) { |
---|
522 | $arrSearchParam = array(); |
---|
523 | $objFormParam = new SC_FormParam_Ex(); |
---|
524 | |
---|
525 | parent::lfInitParam($objFormParam); |
---|
526 | $objFormParam->setParam($arrPost); |
---|
527 | $arrSearchParam = $objFormParam->getSearchArray(); |
---|
528 | |
---|
529 | return $arrSearchParam; |
---|
530 | } |
---|
531 | |
---|
532 | /** |
---|
533 | * フォームパラメーター取得 |
---|
534 | * - 編集/複製モード |
---|
535 | * |
---|
536 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
537 | * @param object $objDownFile SC_UploadFileインスタンス |
---|
538 | * @param integer $product_id 商品ID |
---|
539 | * @return array フォームパラメーター配列 |
---|
540 | */ |
---|
541 | function lfGetFormParam_PreEdit(&$objUpFile, &$objDownFile, $product_id) { |
---|
542 | $arrForm = array(); |
---|
543 | |
---|
544 | // DBから商品データ取得 |
---|
545 | $arrForm = $this->lfGetProductData_FromDB($product_id); |
---|
546 | // DBデータから画像ファイル名の読込 |
---|
547 | $objUpFile->setDBFileList($arrForm); |
---|
548 | // DBデータからダウンロードファイル名の読込 |
---|
549 | $objDownFile->setDBDownFile($arrForm); |
---|
550 | |
---|
551 | return $arrForm; |
---|
552 | } |
---|
553 | |
---|
554 | /** |
---|
555 | * フォームパラメーター取得 |
---|
556 | * - 登録モード |
---|
557 | * |
---|
558 | * @param object $objFormParam SC_FormParamインスタンス |
---|
559 | * @return array フォームパラメーター配列 |
---|
560 | */ |
---|
561 | function lfGetFormParam_Complete(&$objFormParam) { |
---|
562 | $arrForm = $objFormParam->getHashArray(); |
---|
563 | $arrForm['category_id'] = unserialize($arrForm['category_id']); |
---|
564 | $objFormParam->setValue('category_id', $arrForm['category_id']); |
---|
565 | |
---|
566 | return $arrForm; |
---|
567 | } |
---|
568 | |
---|
569 | /** |
---|
570 | * 表示用フォームパラメーター取得 |
---|
571 | * - 入力画面 |
---|
572 | * |
---|
573 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
574 | * @param object $objDownFile SC_UploadFileインスタンス |
---|
575 | * @param array $arrForm フォーム入力パラメーター配列 |
---|
576 | * @return array 表示用フォームパラメーター配列 |
---|
577 | */ |
---|
578 | function lfSetViewParam_InputPage(&$objUpFile, &$objDownFile, &$arrForm) { |
---|
579 | // カテゴリマスターデータ取得 |
---|
580 | $objDb = new SC_Helper_DB_Ex(); |
---|
581 | list($this->arrCatVal, $this->arrCatOut) = $objDb->sfGetLevelCatList(false); |
---|
582 | |
---|
583 | if (isset($arrForm['category_id']) && !is_array($arrForm['category_id'])) { |
---|
584 | $arrForm['category_id'] = unserialize($arrForm['category_id']); |
---|
585 | } |
---|
586 | if ($arrForm['status'] == '') { |
---|
587 | $arrForm['status'] = DEFAULT_PRODUCT_DISP; |
---|
588 | } |
---|
589 | if ($arrForm['product_type_id'] == '') { |
---|
590 | $arrForm['product_type_id'] = DEFAULT_PRODUCT_DOWN; |
---|
591 | } |
---|
592 | // アップロードファイル情報取得(Hidden用) |
---|
593 | $arrHidden = $objUpFile->getHiddenFileList(); |
---|
594 | $arrForm['arrHidden'] = array_merge((array)$arrHidden, (array)$objDownFile->getHiddenFileList()); |
---|
595 | |
---|
596 | // 画像ファイル表示用データ取得 |
---|
597 | $arrForm['arrFile'] = $objUpFile->getFormFileList(IMAGE_TEMP_URLPATH, IMAGE_SAVE_URLPATH); |
---|
598 | |
---|
599 | // ダウンロード商品実ファイル名取得 |
---|
600 | $arrForm['down_realfilename'] = $objDownFile->getFormDownFile(); |
---|
601 | |
---|
602 | // 基本情報(デフォルトポイントレート用) |
---|
603 | $arrForm['arrInfo'] = SC_Helper_DB_Ex::sfGetBasisData(); |
---|
604 | |
---|
605 | // サブ情報ありなしフラグ |
---|
606 | $arrForm['sub_find'] = $this->hasSubProductData($arrForm); |
---|
607 | |
---|
608 | return $arrForm; |
---|
609 | } |
---|
610 | |
---|
611 | /** |
---|
612 | * 表示用フォームパラメーター取得 |
---|
613 | * - 確認画面 |
---|
614 | * |
---|
615 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
616 | * @param object $objDownFile SC_UploadFileインスタンス |
---|
617 | * @param array $arrForm フォーム入力パラメーター配列 |
---|
618 | * @return array 表示用フォームパラメーター配列 |
---|
619 | */ |
---|
620 | function lfSetViewParam_ConfirmPage(&$objUpFile, &$objDownFile, &$arrForm) { |
---|
621 | // カテゴリ表示用 |
---|
622 | $arrForm['arrCategoryId'] = $arrForm['category_id']; |
---|
623 | // hidden に渡す値は serialize する |
---|
624 | $arrForm['category_id'] = serialize($arrForm['category_id']); |
---|
625 | // 画像ファイル用データ取得 |
---|
626 | $arrForm['arrFile'] = $objUpFile->getFormFileList(IMAGE_TEMP_URLPATH, IMAGE_SAVE_URLPATH); |
---|
627 | // ダウンロード商品実ファイル名取得 |
---|
628 | $arrForm['down_realfilename'] = $objDownFile->getFormDownFile(); |
---|
629 | |
---|
630 | return $arrForm; |
---|
631 | } |
---|
632 | |
---|
633 | /** |
---|
634 | * 縮小した画像をセットする |
---|
635 | * |
---|
636 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
637 | * @param string $image_key 画像ファイルキー |
---|
638 | * @return void |
---|
639 | */ |
---|
640 | function lfSetScaleImage(&$objUpFile, $image_key) { |
---|
641 | $subno = str_replace('sub_large_image', '', $image_key); |
---|
642 | switch ($image_key) { |
---|
643 | case 'main_large_image': |
---|
644 | // 詳細メイン画像 |
---|
645 | $this->lfMakeScaleImage($objUpFile, $image_key, 'main_image'); |
---|
646 | case 'main_image': |
---|
647 | // 一覧メイン画像 |
---|
648 | $this->lfMakeScaleImage($objUpFile, $image_key, 'main_list_image'); |
---|
649 | break; |
---|
650 | case 'sub_large_image' . $subno: |
---|
651 | // サブメイン画像 |
---|
652 | $this->lfMakeScaleImage($objUpFile, $_POST['image_key'], 'sub_image' . $subno); |
---|
653 | break; |
---|
654 | default: |
---|
655 | break; |
---|
656 | } |
---|
657 | } |
---|
658 | |
---|
659 | /** |
---|
660 | * 画像ファイルのコピー |
---|
661 | * |
---|
662 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
663 | * @return void |
---|
664 | */ |
---|
665 | function lfCopyProductImageFiles(&$objUpFile) { |
---|
666 | $arrKey = $objUpFile->keyname; |
---|
667 | $arrSaveFile = $objUpFile->save_file; |
---|
668 | |
---|
669 | foreach ($arrSaveFile as $key => $val) { |
---|
670 | $this->lfMakeScaleImage($objUpFile, $arrKey[$key], $arrKey[$key], true); |
---|
671 | } |
---|
672 | } |
---|
673 | |
---|
674 | /** |
---|
675 | * 縮小画像生成 |
---|
676 | * |
---|
677 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
678 | * @param string $from_key 元画像ファイルキー |
---|
679 | * @param string $to_key 縮小画像ファイルキー |
---|
680 | * @param boolean $forced |
---|
681 | * @return void |
---|
682 | */ |
---|
683 | function lfMakeScaleImage(&$objUpFile, $from_key, $to_key, $forced = false) { |
---|
684 | $arrImageKey = array_flip($objUpFile->keyname); |
---|
685 | $from_path = ''; |
---|
686 | |
---|
687 | if ($objUpFile->temp_file[$arrImageKey[$from_key]]) { |
---|
688 | $from_path = $objUpFile->temp_dir . $objUpFile->temp_file[$arrImageKey[$from_key]]; |
---|
689 | } elseif ($objUpFile->save_file[$arrImageKey[$from_key]]) { |
---|
690 | $from_path = $objUpFile->save_dir . $objUpFile->save_file[$arrImageKey[$from_key]]; |
---|
691 | } |
---|
692 | |
---|
693 | if (file_exists($from_path)) { |
---|
694 | // 生成先の画像サイズを取得 |
---|
695 | $to_w = $objUpFile->width[$arrImageKey[$to_key]]; |
---|
696 | $to_h = $objUpFile->height[$arrImageKey[$to_key]]; |
---|
697 | |
---|
698 | if ($forced) { |
---|
699 | $objUpFile->save_file[$arrImageKey[$to_key]] = ''; |
---|
700 | } |
---|
701 | |
---|
702 | if (empty($objUpFile->temp_file[$arrImageKey[$to_key]]) |
---|
703 | && empty($objUpFile->save_file[$arrImageKey[$to_key]]) |
---|
704 | ) { |
---|
705 | // リネームする際は、自動生成される画像名に一意となるように、Suffixを付ける |
---|
706 | $dst_file = $objUpFile->lfGetTmpImageName(IMAGE_RENAME, '', $objUpFile->temp_file[$arrImageKey[$from_key]]) . $this->lfGetAddSuffix($to_key); |
---|
707 | $path = $objUpFile->makeThumb($from_path, $to_w, $to_h, $dst_file); |
---|
708 | $objUpFile->temp_file[$arrImageKey[$to_key]] = basename($path); |
---|
709 | } |
---|
710 | } |
---|
711 | } |
---|
712 | |
---|
713 | /** |
---|
714 | * アップロードファイルパラメーター情報から削除 |
---|
715 | * 一時ディレクトリに保存されている実ファイルも削除する |
---|
716 | * |
---|
717 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
718 | * @param string $image_key 画像ファイルキー |
---|
719 | * @return void |
---|
720 | */ |
---|
721 | function lfDeleteTempFile(&$objUpFile, $image_key) { |
---|
722 | // TODO: SC_UploadFile::deleteFileの画像削除条件見直し要 |
---|
723 | $arrTempFile = $objUpFile->temp_file; |
---|
724 | $arrKeyName = $objUpFile->keyname; |
---|
725 | |
---|
726 | foreach ($arrKeyName as $key => $keyname) { |
---|
727 | if ($keyname != $image_key) continue; |
---|
728 | |
---|
729 | if (!empty($arrTempFile[$key])) { |
---|
730 | $temp_file = $arrTempFile[$key]; |
---|
731 | $arrTempFile[$key] = ''; |
---|
732 | |
---|
733 | if (!in_array($temp_file, $arrTempFile)) { |
---|
734 | $objUpFile->deleteFile($image_key); |
---|
735 | } else { |
---|
736 | $objUpFile->temp_file[$key] = ''; |
---|
737 | $objUpFile->save_file[$key] = ''; |
---|
738 | } |
---|
739 | } else { |
---|
740 | $objUpFile->temp_file[$key] = ''; |
---|
741 | $objUpFile->save_file[$key] = ''; |
---|
742 | } |
---|
743 | } |
---|
744 | } |
---|
745 | |
---|
746 | /** |
---|
747 | * アップロードファイルを保存する |
---|
748 | * |
---|
749 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
750 | * @param object $objDownFile SC_UploadFileインスタンス |
---|
751 | * @param integer $product_id 商品ID |
---|
752 | * @return void |
---|
753 | */ |
---|
754 | function lfSaveUploadFiles(&$objUpFile, &$objDownFile, $product_id) { |
---|
755 | // TODO: SC_UploadFile::moveTempFileの画像削除条件見直し要 |
---|
756 | $objImage = new SC_Image_Ex($objUpFile->temp_dir); |
---|
757 | $arrKeyName = $objUpFile->keyname; |
---|
758 | $arrTempFile = $objUpFile->temp_file; |
---|
759 | $arrSaveFile = $objUpFile->save_file; |
---|
760 | $arrImageKey = array(); |
---|
761 | foreach ($arrTempFile as $key => $temp_file) { |
---|
762 | if ($temp_file) { |
---|
763 | $objImage->moveTempImage($temp_file, $objUpFile->save_dir); |
---|
764 | $arrImageKey[] = $arrKeyName[$key]; |
---|
765 | if (!empty($arrSaveFile[$key]) |
---|
766 | && !$this->lfHasSameProductImage($product_id, $arrImageKey, $arrSaveFile[$key]) |
---|
767 | && !in_array($temp_file, $arrSaveFile) |
---|
768 | ) { |
---|
769 | $objImage->deleteImage($arrSaveFile[$key], $objUpFile->save_dir); |
---|
770 | } |
---|
771 | } |
---|
772 | } |
---|
773 | $objDownFile->moveTempDownFile(); |
---|
774 | } |
---|
775 | |
---|
776 | /** |
---|
777 | * 同名画像ファイル登録の有無を確認する. |
---|
778 | * |
---|
779 | * 画像ファイルの削除可否判定用。 |
---|
780 | * 同名ファイルの登録がある場合には画像ファイルの削除を行わない。 |
---|
781 | * 戻り値: 同名ファイル有り(true) 同名ファイル無し(false) |
---|
782 | * |
---|
783 | * @param string $product_id 商品ID |
---|
784 | * @param string $arrImageKey 対象としない画像カラム名 |
---|
785 | * @param string $image_file_name 画像ファイル名 |
---|
786 | * @return boolean |
---|
787 | */ |
---|
788 | function lfHasSameProductImage($product_id, $arrImageKey, $image_file_name) { |
---|
789 | if (!SC_Utils_Ex::sfIsInt($product_id)) return false; |
---|
790 | if (!$arrImageKey) return false; |
---|
791 | if (!$image_file_name) return false; |
---|
792 | |
---|
793 | $arrWhere = array(); |
---|
794 | $sqlval = array('0', $product_id); |
---|
795 | foreach ($arrImageKey as $image_key) { |
---|
796 | $arrWhere[] = "{$image_key} = ?"; |
---|
797 | $sqlval[] = $image_file_name; |
---|
798 | } |
---|
799 | $where = implode(' OR ', $arrWhere); |
---|
800 | $where = "del_flg = ? AND ((product_id <> ? AND ({$where}))"; |
---|
801 | |
---|
802 | $arrKeyName = $this->objUpFile->keyname; |
---|
803 | foreach ($arrKeyName as $key => $keyname) { |
---|
804 | if (in_array($keyname, $arrImageKey)) continue; |
---|
805 | $where .= " OR {$keyname} = ?"; |
---|
806 | $sqlval[] = $image_file_name; |
---|
807 | } |
---|
808 | $where .= ')'; |
---|
809 | |
---|
810 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
811 | $exists = $objQuery->exists('dtb_products', $where, $sqlval); |
---|
812 | return $exists; |
---|
813 | } |
---|
814 | |
---|
815 | /** |
---|
816 | * DBから商品データを取得する |
---|
817 | * |
---|
818 | * @param integer $product_id 商品ID |
---|
819 | * @return array 商品データ配列 |
---|
820 | */ |
---|
821 | function lfGetProductData_FromDB($product_id) { |
---|
822 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
823 | $arrProduct = array(); |
---|
824 | |
---|
825 | // 商品データ取得 |
---|
826 | $col = '*'; |
---|
827 | $table = <<< __EOF__ |
---|
828 | dtb_products AS T1 |
---|
829 | LEFT JOIN ( |
---|
830 | SELECT product_id AS product_id_sub, |
---|
831 | product_code, |
---|
832 | price01, |
---|
833 | price02, |
---|
834 | deliv_fee, |
---|
835 | stock, |
---|
836 | stock_unlimited, |
---|
837 | sale_limit, |
---|
838 | point_rate, |
---|
839 | product_type_id, |
---|
840 | down_filename, |
---|
841 | down_realfilename |
---|
842 | FROM dtb_products_class |
---|
843 | ) AS T2 |
---|
844 | ON T1.product_id = T2.product_id_sub |
---|
845 | __EOF__; |
---|
846 | $where = 'product_id = ?'; |
---|
847 | $objQuery->setLimit('1'); |
---|
848 | $arrProduct = $objQuery->select($col, $table, $where, array($product_id)); |
---|
849 | |
---|
850 | // カテゴリID取得 |
---|
851 | $col = 'category_id'; |
---|
852 | $table = 'dtb_product_categories'; |
---|
853 | $where = 'product_id = ?'; |
---|
854 | $objQuery->setOption(''); |
---|
855 | $arrProduct[0]['category_id'] = $objQuery->getCol($col, $table, $where, array($product_id)); |
---|
856 | |
---|
857 | // 規格情報ありなしフラグ取得 |
---|
858 | $objDb = new SC_Helper_DB_Ex(); |
---|
859 | $arrProduct[0]['has_product_class'] = $objDb->sfHasProductClass($product_id); |
---|
860 | |
---|
861 | // 規格が登録されていなければ規格ID取得 |
---|
862 | if ($arrProduct[0]['has_product_class'] == false) { |
---|
863 | $arrProduct[0]['product_class_id'] = SC_Utils_Ex::sfGetProductClassId($product_id,'0','0'); |
---|
864 | } |
---|
865 | |
---|
866 | // 商品ステータス取得 |
---|
867 | $objProduct = new SC_Product_Ex(); |
---|
868 | $productStatus = $objProduct->getProductStatus(array($product_id)); |
---|
869 | $arrProduct[0]['product_status'] = $productStatus[$product_id]; |
---|
870 | |
---|
871 | // 関連商品データ取得 |
---|
872 | $arrRecommend = $this->lfGetRecommendProductsData_FromDB($product_id); |
---|
873 | $arrProduct[0] = array_merge($arrProduct[0], $arrRecommend); |
---|
874 | |
---|
875 | return $arrProduct[0]; |
---|
876 | } |
---|
877 | |
---|
878 | /** |
---|
879 | * DBから関連商品データを取得する |
---|
880 | * |
---|
881 | * @param integer $product_id 商品ID |
---|
882 | * @return array 関連商品データ配列 |
---|
883 | */ |
---|
884 | function lfGetRecommendProductsData_FromDB($product_id) { |
---|
885 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
886 | $arrRecommendProducts = array(); |
---|
887 | |
---|
888 | $col = 'recommend_product_id,'; |
---|
889 | $col.= 'comment'; |
---|
890 | $table = 'dtb_recommend_products'; |
---|
891 | $where = 'product_id = ?'; |
---|
892 | $objQuery->setOrder('rank DESC'); |
---|
893 | $arrRet = $objQuery->select($col, $table, $where, array($product_id)); |
---|
894 | |
---|
895 | $no = 1; |
---|
896 | foreach ($arrRet as $arrVal) { |
---|
897 | $arrRecommendProducts['recommend_id' . $no] = $arrVal['recommend_product_id']; |
---|
898 | $arrRecommendProducts['recommend_comment' . $no] = $arrVal['comment']; |
---|
899 | $no++; |
---|
900 | } |
---|
901 | |
---|
902 | return $arrRecommendProducts; |
---|
903 | } |
---|
904 | |
---|
905 | /** |
---|
906 | * 関連商品データ表示用配列を取得する |
---|
907 | * |
---|
908 | * @param string $arrForm フォーム入力パラメーター配列 |
---|
909 | * @return array 関連商品データ配列 |
---|
910 | */ |
---|
911 | function lfGetRecommendProducts(&$arrForm) { |
---|
912 | $arrRecommend = array(); |
---|
913 | |
---|
914 | for ($i = 1; $i <= RECOMMEND_PRODUCT_MAX; $i++) { |
---|
915 | $keyname = 'recommend_id' . $i; |
---|
916 | $delkey = 'recommend_delete' . $i; |
---|
917 | $commentkey = 'recommend_comment' . $i; |
---|
918 | |
---|
919 | if (!isset($arrForm[$delkey])) $arrForm[$delkey] = null; |
---|
920 | |
---|
921 | if ((isset($arrForm[$keyname]) && !empty($arrForm[$keyname])) && $arrForm[$delkey] != 1) { |
---|
922 | $objProduct = new SC_Product_Ex(); |
---|
923 | $arrRecommend[$i] = $objProduct->getDetail($arrForm[$keyname]); |
---|
924 | $arrRecommend[$i]['product_id'] = $arrForm[$keyname]; |
---|
925 | $arrRecommend[$i]['comment'] = $arrForm[$commentkey]; |
---|
926 | } |
---|
927 | } |
---|
928 | return $arrRecommend; |
---|
929 | } |
---|
930 | |
---|
931 | /** |
---|
932 | * 表示用カテゴリマスターデータ配列を取得する |
---|
933 | * - 編集モード |
---|
934 | * |
---|
935 | * @param void |
---|
936 | * @return array カテゴリマスターデータ配列 |
---|
937 | */ |
---|
938 | function lfGetCategoryList_Edit() { |
---|
939 | $objDb = new SC_Helper_DB_Ex(); |
---|
940 | $arrCategoryList = array(); |
---|
941 | |
---|
942 | list($arrCatVal, $arrCatOut) = $objDb->sfGetLevelCatList(false); |
---|
943 | for ($i = 0; $i < count($arrCatVal); $i++) { |
---|
944 | $arrCategoryList[$arrCatVal[$i]] = $arrCatOut[$i]; |
---|
945 | } |
---|
946 | |
---|
947 | return $arrCategoryList; |
---|
948 | } |
---|
949 | |
---|
950 | /** |
---|
951 | * ページonload用JavaScriptを取得する |
---|
952 | * - 入力画面 |
---|
953 | * |
---|
954 | * @param string $anchor_hash アンカー用ハッシュ文字列(省略可) |
---|
955 | * @return string ページonload用JavaScript |
---|
956 | */ |
---|
957 | function lfSetOnloadJavaScript_InputPage($anchor_hash = '') { |
---|
958 | return "fnCheckStockLimit('" . DISABLED_RGB . "'); fnMoveSelect('category_id_unselect', 'category_id');" . $anchor_hash; |
---|
959 | } |
---|
960 | |
---|
961 | /** |
---|
962 | * DBに商品データを登録する |
---|
963 | * |
---|
964 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
965 | * @param object $objDownFile SC_UploadFileインスタンス |
---|
966 | * @param array $arrList フォーム入力パラメーター配列 |
---|
967 | * @return integer 登録商品ID |
---|
968 | */ |
---|
969 | function lfRegistProduct(&$objUpFile, &$objDownFile, $arrList) { |
---|
970 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
971 | $objDb = new SC_Helper_DB_Ex(); |
---|
972 | |
---|
973 | // 配列の添字を定義 |
---|
974 | $checkArray = array('name', 'status', |
---|
975 | 'main_list_comment', 'main_comment', |
---|
976 | 'deliv_fee', 'comment1', 'comment2', 'comment3', |
---|
977 | 'comment4', 'comment5', 'comment6', |
---|
978 | 'sale_limit', 'deliv_date_id', 'maker_id', 'note'); |
---|
979 | $arrList = SC_Utils_Ex::arrayDefineIndexes($arrList, $checkArray); |
---|
980 | |
---|
981 | // INSERTする値を作成する。 |
---|
982 | $sqlval['name'] = $arrList['name']; |
---|
983 | $sqlval['status'] = $arrList['status']; |
---|
984 | $sqlval['main_list_comment'] = $arrList['main_list_comment']; |
---|
985 | $sqlval['main_comment'] = $arrList['main_comment']; |
---|
986 | $sqlval['comment1'] = $arrList['comment1']; |
---|
987 | $sqlval['comment2'] = $arrList['comment2']; |
---|
988 | $sqlval['comment3'] = $arrList['comment3']; |
---|
989 | $sqlval['comment4'] = $arrList['comment4']; |
---|
990 | $sqlval['comment5'] = $arrList['comment5']; |
---|
991 | $sqlval['comment6'] = $arrList['comment6']; |
---|
992 | $sqlval['deliv_date_id'] = $arrList['deliv_date_id']; |
---|
993 | $sqlval['maker_id'] = $arrList['maker_id']; |
---|
994 | $sqlval['note'] = $arrList['note']; |
---|
995 | $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
996 | $sqlval['creator_id'] = $_SESSION['member_id']; |
---|
997 | $arrRet = $objUpFile->getDBFileList(); |
---|
998 | $sqlval = array_merge($sqlval, $arrRet); |
---|
999 | |
---|
1000 | for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { |
---|
1001 | $sqlval['sub_title'.$cnt] = $arrList['sub_title'.$cnt]; |
---|
1002 | $sqlval['sub_comment'.$cnt] = $arrList['sub_comment'.$cnt]; |
---|
1003 | } |
---|
1004 | |
---|
1005 | $objQuery->begin(); |
---|
1006 | |
---|
1007 | // 新規登録(複製時を含む) |
---|
1008 | if ($arrList['product_id'] == '') { |
---|
1009 | $product_id = $objQuery->nextVal('dtb_products_product_id'); |
---|
1010 | $sqlval['product_id'] = $product_id; |
---|
1011 | |
---|
1012 | // INSERTの実行 |
---|
1013 | $sqlval['create_date'] = 'CURRENT_TIMESTAMP'; |
---|
1014 | $objQuery->insert('dtb_products', $sqlval); |
---|
1015 | |
---|
1016 | $arrList['product_id'] = $product_id; |
---|
1017 | |
---|
1018 | // カテゴリを更新 |
---|
1019 | $objDb->updateProductCategories($arrList['category_id'], $product_id); |
---|
1020 | |
---|
1021 | // 複製商品の場合には規格も複製する |
---|
1022 | if ($arrList['copy_product_id'] != '' && SC_Utils_Ex::sfIsInt($arrList['copy_product_id'])) { |
---|
1023 | if (!$arrList['has_product_class']) { |
---|
1024 | //規格なしの場合、複製は価格等の入力が発生しているため、その内容で追加登録を行う |
---|
1025 | $this->lfCopyProductClass($arrList, $objQuery); |
---|
1026 | } else { |
---|
1027 | //規格がある場合の複製は複製元の内容で追加登録を行う |
---|
1028 | // dtb_products_class のカラムを取得 |
---|
1029 | $dbFactory = SC_DB_DBFactory_Ex::getInstance(); |
---|
1030 | $arrColList = $objQuery->listTableFields('dtb_products_class'); |
---|
1031 | $arrColList_tmp = array_flip($arrColList); |
---|
1032 | |
---|
1033 | // 複製しない列 |
---|
1034 | unset($arrColList[$arrColList_tmp['product_class_id']]); //規格ID |
---|
1035 | unset($arrColList[$arrColList_tmp['product_id']]); //商品ID |
---|
1036 | unset($arrColList[$arrColList_tmp['create_date']]); |
---|
1037 | |
---|
1038 | // 複製元商品の規格データ取得 |
---|
1039 | $col = SC_Utils_Ex::sfGetCommaList($arrColList); |
---|
1040 | $table = 'dtb_products_class'; |
---|
1041 | $where = 'product_id = ?'; |
---|
1042 | $objQuery->setOrder('product_class_id'); |
---|
1043 | $arrProductsClass = $objQuery->select($col, $table, $where, array($arrList['copy_product_id'])); |
---|
1044 | |
---|
1045 | // 規格データ登録 |
---|
1046 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
1047 | foreach ($arrProductsClass as $arrData) { |
---|
1048 | $sqlval = $arrData; |
---|
1049 | $sqlval['product_class_id'] = $objQuery->nextVal('dtb_products_class_product_class_id'); |
---|
1050 | $sqlval['deliv_fee'] = $arrList['deliv_fee']; |
---|
1051 | $sqlval['point_rate'] = $arrList['point_rate']; |
---|
1052 | $sqlval['sale_limit'] = $arrList['sale_limit']; |
---|
1053 | $sqlval['product_id'] = $product_id; |
---|
1054 | $sqlval['create_date'] = 'CURRENT_TIMESTAMP'; |
---|
1055 | $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
1056 | $objQuery->insert($table, $sqlval); |
---|
1057 | } |
---|
1058 | } |
---|
1059 | } |
---|
1060 | // 更新 |
---|
1061 | } else { |
---|
1062 | $product_id = $arrList['product_id']; |
---|
1063 | // 削除要求のあった既存ファイルの削除 |
---|
1064 | $arrRet = $this->lfGetProductData_FromDB($arrList['product_id']); |
---|
1065 | // TODO: SC_UploadFile::deleteDBFileの画像削除条件見直し要 |
---|
1066 | $objImage = new SC_Image_Ex($objUpFile->temp_dir); |
---|
1067 | $arrKeyName = $objUpFile->keyname; |
---|
1068 | $arrSaveFile = $objUpFile->save_file; |
---|
1069 | $arrImageKey = array(); |
---|
1070 | foreach ($arrKeyName as $key => $keyname) { |
---|
1071 | if ($arrRet[$keyname] && !$arrSaveFile[$key]) { |
---|
1072 | $arrImageKey[] = $keyname; |
---|
1073 | $has_same_image = $this->lfHasSameProductImage($arrList['product_id'], $arrImageKey, $arrRet[$keyname]); |
---|
1074 | if (!$has_same_image) { |
---|
1075 | $objImage->deleteImage($arrRet[$keyname], $objUpFile->save_dir); |
---|
1076 | } |
---|
1077 | } |
---|
1078 | } |
---|
1079 | $objDownFile->deleteDBDownFile($arrRet); |
---|
1080 | // UPDATEの実行 |
---|
1081 | $where = 'product_id = ?'; |
---|
1082 | $objQuery->update('dtb_products', $sqlval, $where, array($product_id)); |
---|
1083 | |
---|
1084 | // カテゴリを更新 |
---|
1085 | $objDb->updateProductCategories($arrList['category_id'], $product_id); |
---|
1086 | } |
---|
1087 | |
---|
1088 | // 商品登録の時は規格を生成する。複製の場合は規格も複製されるのでこの処理は不要。 |
---|
1089 | if ($arrList['copy_product_id'] == '') { |
---|
1090 | // 規格登録 |
---|
1091 | if ($objDb->sfHasProductClass($product_id)) { |
---|
1092 | // 規格あり商品(商品規格テーブルのうち、商品登録フォームで設定するパラメーターのみ更新) |
---|
1093 | $this->lfUpdateProductClass($arrList); |
---|
1094 | } else { |
---|
1095 | // 規格なし商品(商品規格テーブルの更新) |
---|
1096 | $this->lfInsertDummyProductClass($arrList); |
---|
1097 | } |
---|
1098 | } |
---|
1099 | |
---|
1100 | // 商品ステータス設定 |
---|
1101 | $objProduct = new SC_Product_Ex(); |
---|
1102 | $objProduct->setProductStatus($product_id, $arrList['product_status']); |
---|
1103 | |
---|
1104 | // 関連商品登録 |
---|
1105 | $this->lfInsertRecommendProducts($objQuery, $arrList, $product_id); |
---|
1106 | |
---|
1107 | $objQuery->commit(); |
---|
1108 | return $product_id; |
---|
1109 | } |
---|
1110 | |
---|
1111 | /** |
---|
1112 | * 規格を設定していない商品を商品規格テーブルに登録 |
---|
1113 | * |
---|
1114 | * @param array $arrList |
---|
1115 | * @return void |
---|
1116 | */ |
---|
1117 | function lfInsertDummyProductClass($arrList) { |
---|
1118 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
1119 | $objDb = new SC_Helper_DB_Ex(); |
---|
1120 | |
---|
1121 | // 配列の添字を定義 |
---|
1122 | $checkArray = array('product_class_id', 'product_id', 'product_code', 'stock', 'stock_unlimited', 'price01', 'price02', 'sale_limit', 'deliv_fee', 'point_rate' ,'product_type_id', 'down_filename', 'down_realfilename'); |
---|
1123 | $sqlval = SC_Utils_Ex::sfArrayIntersectKeys($arrList, $checkArray); |
---|
1124 | $sqlval = SC_Utils_Ex::arrayDefineIndexes($sqlval, $checkArray); |
---|
1125 | |
---|
1126 | $sqlval['stock_unlimited'] = $sqlval['stock_unlimited'] ? UNLIMITED_FLG_UNLIMITED : UNLIMITED_FLG_LIMITED; |
---|
1127 | $sqlval['creator_id'] = strlen($_SESSION['member_id']) >= 1 ? $_SESSION['member_id'] : '0'; |
---|
1128 | |
---|
1129 | if (strlen($sqlval['product_class_id']) == 0) { |
---|
1130 | $sqlval['product_class_id'] = $objQuery->nextVal('dtb_products_class_product_class_id'); |
---|
1131 | $sqlval['create_date'] = 'CURRENT_TIMESTAMP'; |
---|
1132 | $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
1133 | // INSERTの実行 |
---|
1134 | $objQuery->insert('dtb_products_class', $sqlval); |
---|
1135 | } else { |
---|
1136 | $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
1137 | // UPDATEの実行 |
---|
1138 | $objQuery->update('dtb_products_class', $sqlval, 'product_class_id = ?', array($sqlval['product_class_id'])); |
---|
1139 | |
---|
1140 | } |
---|
1141 | } |
---|
1142 | |
---|
1143 | /** |
---|
1144 | * 規格を設定している商品の商品規格テーブルを更新 |
---|
1145 | * (deliv_fee, point_rate, sale_limit) |
---|
1146 | * |
---|
1147 | * @param array $arrList |
---|
1148 | * @return void |
---|
1149 | */ |
---|
1150 | function lfUpdateProductClass($arrList) { |
---|
1151 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
1152 | $sqlval = array(); |
---|
1153 | |
---|
1154 | $sqlval['deliv_fee'] = $arrList['deliv_fee']; |
---|
1155 | $sqlval['point_rate'] = $arrList['point_rate']; |
---|
1156 | $sqlval['sale_limit'] = $arrList['sale_limit']; |
---|
1157 | $where = 'product_id = ?'; |
---|
1158 | $objQuery->update('dtb_products_class', $sqlval, $where, array($arrList['product_id'])); |
---|
1159 | } |
---|
1160 | |
---|
1161 | /** |
---|
1162 | * DBに関連商品データを登録する |
---|
1163 | * |
---|
1164 | * @param object $objQuery SC_Queryインスタンス |
---|
1165 | * @param string $arrList フォーム入力パラメーター配列 |
---|
1166 | * @param integer $product_id 登録する商品ID |
---|
1167 | * @return void |
---|
1168 | */ |
---|
1169 | function lfInsertRecommendProducts(&$objQuery, $arrList, $product_id) { |
---|
1170 | // 一旦関連商品をすべて削除する |
---|
1171 | $objQuery->delete('dtb_recommend_products', 'product_id = ?', array($product_id)); |
---|
1172 | $sqlval['product_id'] = $product_id; |
---|
1173 | $rank = RECOMMEND_PRODUCT_MAX; |
---|
1174 | for ($i = 1; $i <= RECOMMEND_PRODUCT_MAX; $i++) { |
---|
1175 | $keyname = 'recommend_id' . $i; |
---|
1176 | $commentkey = 'recommend_comment' . $i; |
---|
1177 | $deletekey = 'recommend_delete' . $i; |
---|
1178 | |
---|
1179 | if (!isset($arrList[$deletekey])) $arrList[$deletekey] = null; |
---|
1180 | |
---|
1181 | if ($arrList[$keyname] != '' && $arrList[$deletekey] != '1') { |
---|
1182 | $sqlval['recommend_product_id'] = $arrList[$keyname]; |
---|
1183 | $sqlval['comment'] = $arrList[$commentkey]; |
---|
1184 | $sqlval['rank'] = $rank; |
---|
1185 | $sqlval['creator_id'] = $_SESSION['member_id']; |
---|
1186 | $sqlval['create_date'] = 'CURRENT_TIMESTAMP'; |
---|
1187 | $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
1188 | $objQuery->insert('dtb_recommend_products', $sqlval); |
---|
1189 | $rank--; |
---|
1190 | } |
---|
1191 | } |
---|
1192 | } |
---|
1193 | |
---|
1194 | /** |
---|
1195 | * 規格データをコピーする |
---|
1196 | * |
---|
1197 | * @param array $arrList フォーム入力パラメーター配列 |
---|
1198 | * @param object $objQuery SC_Queryインスタンス |
---|
1199 | * @return boolean エラーフラグ |
---|
1200 | */ |
---|
1201 | function lfCopyProductClass($arrList, &$objQuery) { |
---|
1202 | // 複製元のdtb_products_classを取得(規格なしのため、1件のみの取得) |
---|
1203 | $col = '*'; |
---|
1204 | $table = 'dtb_products_class'; |
---|
1205 | $where = 'product_id = ?'; |
---|
1206 | $arrProductClass = $objQuery->select($col, $table, $where, array($arrList['copy_product_id'])); |
---|
1207 | |
---|
1208 | //トランザクション開始 |
---|
1209 | $objQuery->begin(); |
---|
1210 | $err_flag = false; |
---|
1211 | //非編集項目は複製、編集項目は上書きして登録 |
---|
1212 | foreach ($arrProductClass as $records) { |
---|
1213 | foreach ($records as $key => $value) { |
---|
1214 | if (isset($arrList[$key])) { |
---|
1215 | switch ($key) { |
---|
1216 | case 'stock_unlimited': |
---|
1217 | $records[$key] = (int)$arrList[$key]; |
---|
1218 | break; |
---|
1219 | default: |
---|
1220 | $records[$key] = $arrList[$key]; |
---|
1221 | break; |
---|
1222 | } |
---|
1223 | } |
---|
1224 | } |
---|
1225 | |
---|
1226 | $records['product_class_id'] = $objQuery->nextVal('dtb_products_class_product_class_id'); |
---|
1227 | $records['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
1228 | $records['create_date'] = 'CURRENT_TIMESTAMP'; |
---|
1229 | $objQuery->insert($table, $records); |
---|
1230 | //エラー発生時は中断 |
---|
1231 | if ($objQuery->isError()) { |
---|
1232 | $err_flag = true; |
---|
1233 | continue; |
---|
1234 | } |
---|
1235 | } |
---|
1236 | //トランザクション終了 |
---|
1237 | if ($err_flag) { |
---|
1238 | $objQuery->rollback(); |
---|
1239 | } else { |
---|
1240 | $objQuery->commit(); |
---|
1241 | } |
---|
1242 | return !$err_flag; |
---|
1243 | } |
---|
1244 | |
---|
1245 | /** |
---|
1246 | * リネームする際は、自動生成される画像名に一意となるように、Suffixを付ける |
---|
1247 | * |
---|
1248 | * @param string $to_key |
---|
1249 | * @return string |
---|
1250 | */ |
---|
1251 | function lfGetAddSuffix($to_key) { |
---|
1252 | if ( IMAGE_RENAME === true) return; |
---|
1253 | |
---|
1254 | // 自動生成される画像名 |
---|
1255 | $dist_name = ''; |
---|
1256 | switch ($to_key) { |
---|
1257 | case 'main_list_image': |
---|
1258 | $dist_name = '_s'; |
---|
1259 | break; |
---|
1260 | case 'main_image': |
---|
1261 | $dist_name = '_m'; |
---|
1262 | break; |
---|
1263 | default: |
---|
1264 | $arrRet = explode('sub_image', $to_key); |
---|
1265 | $dist_name = '_sub' .$arrRet[1]; |
---|
1266 | break; |
---|
1267 | } |
---|
1268 | return $dist_name; |
---|
1269 | } |
---|
1270 | |
---|
1271 | /** |
---|
1272 | * サブ情報の登録があるかを取得する |
---|
1273 | * タイトル, コメント, 画像のいずれかに登録があれば「あり」と判定する |
---|
1274 | * |
---|
1275 | * @param array $arrSubProductData サブ情報配列 |
---|
1276 | * @return boolean true: サブ情報あり, false: サブ情報なし |
---|
1277 | */ |
---|
1278 | function hasSubProductData($arrSubProductData) { |
---|
1279 | $has_subproduct_data = false; |
---|
1280 | |
---|
1281 | for ($i = 1; $i <= PRODUCTSUB_MAX; $i++) { |
---|
1282 | if (SC_Utils_Ex::isBlank($arrSubProductData['sub_title'.$i]) == false |
---|
1283 | || SC_Utils_Ex::isBlank($arrSubProductData['sub_comment'.$i]) == false |
---|
1284 | || SC_Utils_Ex::isBlank($arrSubProductData['sub_image'.$i]) == false |
---|
1285 | || SC_Utils_Ex::isBlank($arrSubProductData['sub_large_image'.$i]) == false |
---|
1286 | || SC_Utils_Ex::isBlank($arrSubProductData['temp_sub_image'.$i]) == false |
---|
1287 | || SC_Utils_Ex::isBlank($arrSubProductData['temp_sub_large_image'.$i]) == false |
---|
1288 | ) { |
---|
1289 | $has_subproduct_data = true; |
---|
1290 | break; |
---|
1291 | } |
---|
1292 | } |
---|
1293 | |
---|
1294 | return $has_subproduct_data; |
---|
1295 | } |
---|
1296 | |
---|
1297 | /** |
---|
1298 | * アンカーハッシュ文字列を取得する |
---|
1299 | * アンカーキーをサニタイジングする |
---|
1300 | * |
---|
1301 | * @param string $anchor_key フォーム入力パラメーターで受け取ったアンカーキー |
---|
1302 | * @return <type> |
---|
1303 | */ |
---|
1304 | function getAnchorHash($anchor_key) { |
---|
1305 | if ($anchor_key != '') { |
---|
1306 | return "location.hash='#" . htmlspecialchars($anchor_key) . "'"; |
---|
1307 | } else { |
---|
1308 | return ''; |
---|
1309 | } |
---|
1310 | } |
---|
1311 | } |
---|