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

Revision 20692, 7.9 KB checked in by coelacanth, 13 years ago (diff)

#1150 [管理画面]コンテンツ管理(CSV出力設定):登録完了の表示が、他のページと違う

  • 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_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';
26require_once CLASS_EX_REALDIR . 'helper_extends/SC_Helper_CSV_Ex.php';
27
28/**
29 * CSV項目設定 のページクラス.
30 *
31 * @package Page
32 * @author LOCKON CO.,LTD.
33 * @version $Id$
34 */
35class LC_Page_Admin_Contents_CSV extends LC_Page_Admin_Ex {
36
37    // }}}
38    // {{{ functions
39
40    /**
41     * Page を初期化する.
42     *
43     * @return void
44     */
45    function init() {
46        parent::init();
47        $this->tpl_mainpage = 'contents/csv.tpl';
48        $this->tpl_subnavi = 'contents/subnavi.tpl';
49        $this->tpl_subno = 'csv';
50        $this->tpl_mainno = 'contents';
51        $this->tpl_subtitle = 'CSV出力設定';
52
53        $objCSV = new SC_Helper_CSV_Ex();
54        $this->arrSubnavi = $objCSV->arrSubnavi; // 別名
55        $this->tpl_subno_csv = $objCSV->arrSubnavi[1]; //デフォルト
56        $this->arrSubnaviName = $objCSV->arrSubnaviName; // 表示名
57    }
58
59    /**
60     * Page のプロセス.
61     *
62     * @return void
63     */
64    function process() {
65        $this->action();
66        $this->sendResponse();
67    }
68
69    /**
70     * Page のアクション.
71     *
72     * @return void
73     */
74    function action() {
75        // パラメータ管理クラス
76        $objFormParam = new SC_FormParam_Ex();
77        // パラメータ設定
78        $this->lfInitParam($objFormParam);
79        $objFormParam->setParam($_POST);
80        $objFormParam->setParam($_GET);
81        $objFormParam->convParam();
82
83        // CSV_IDの読み込み
84        $this->tpl_subno_csv = $objFormParam->getValue('tpl_subno_csv');
85        $this->tpl_csv_id = $this->lfGetCsvId($this->tpl_subno_csv);
86
87        switch ($this->getMode()) {
88        case 'confirm':
89            // 入力パラメーターチェック
90            $this->arrErr = $objFormParam->checkError();
91            if(SC_Utils_Ex::isBlank($this->arrErr)) {
92                // 更新
93                $this->tpl_is_update = $this->lfUpdCsvOutput($this->tpl_csv_id, $objFormParam->getValue('output_list'));
94            }
95            break;
96        case 'defaultset':
97            //初期値に戻す
98            $this->tpl_is_update = $this->lfSetDefaultCsvOutput($this->tpl_csv_id);
99            break;
100        default:
101            break;
102        }
103        $this->arrSelected = $this->lfGetSelected($this->tpl_csv_id);
104        $this->arrOptions = $this->lfGetOptions($this->tpl_csv_id);
105        $this->tpl_subtitle .= ' - ' . $this->arrSubnaviName[ $this->tpl_csv_id ];
106
107        if ($this->tpl_is_update) {
108            $this->tpl_onload = "window.alert('正常に更新されました。');";
109        }
110    }
111
112    /**
113     * パラメーター情報の初期化
114     *
115     * @param array $objFormParam フォームパラメータークラス
116     * @return void
117     */
118    function lfInitParam(&$objFormParam) {
119        $objFormParam->addParam('編集種別', 'tpl_subno_csv', STEXT_LEN, 'a', array("ALNUM_CHECK", "MAX_LENGTH_CHECK"), 'product');
120        $objFormParam->addParam('出力設定リスト', 'output_list', INT_LEN, 'n', array("NUM_CHECK", "MAX_LENGTH_CHECK", "EXIST_CHECK"));
121        //デフォルト値で上書き
122        $objFormParam->setParam(array('tpl_subno_csv' => 'product'));
123    }
124
125    /**
126     * CSVカラム設定の読み込み
127     *
128     * @param integer $csv_id CSV ID
129     * @param integer $csv_status_flg 読み込む対象のフラグ CSV_COLUMN_STATUS_FLG_ENABLE or ''
130     * @return array SwapArrayしたカラム設定
131     */
132    function lfGetCSVColumn($csv_id, $csv_status_flg = '', $order ='rank, no') {
133        $objCSV = new SC_Helper_CSV_Ex();
134        if(SC_Utils_Ex::sfIsInt($csv_id)) {
135            if($csv_status_flg !="") {
136                $arrData = $objCSV->sfGetCsvOutput($csv_id, 'status = ?' , array($csv_status_flg), $order);
137            }else{
138                $arrData = $objCSV->sfGetCsvOutput($csv_id, '', array(), $order);
139            }
140            $arrData = SC_Utils_Ex::sfSwapArray($arrData);
141        }else{
142            $arrData = array();
143        }
144        return $arrData;
145    }
146
147    /**
148     * 選択済みカラム列情報を取得
149     *
150     * @param integer $csv_id CSV ID
151     * @return array 選択済みカラム列情報
152     */
153    function lfGetSelected($csv_id) {
154        $arrData = $this->lfGetCSVColumn($csv_id, CSV_COLUMN_STATUS_FLG_ENABLE);
155        if (!isset($arrData['no'])) {
156            $arrData['no'] = array();
157        }
158        return $arrData['no'];
159    }
160
161    /**
162     * カラム列情報と表示名情報を取得
163     *
164     * @param integer $csv_id CSV ID
165     * @return array 選択済みカラム列情報
166     */
167    function lfGetOptions($csv_id) {
168        $arrData = $this->lfGetCSVColumn($csv_id);
169        if (!isset($arrData['no'])) {
170            $arrData['no'] = array();
171            $arrData['disp_name'] = array();
172        }
173        $arrData = SC_Utils_Ex::sfArrCombine($arrData['no'], $arrData['disp_name']);
174        return $arrData;
175    }
176
177   /**
178     * デストラクタ.
179     *
180     * @return void
181     */
182    function destroy() {
183        parent::destroy();
184    }
185
186    /**
187     * CSV名からCSV_IDを取得する。
188     *
189     * @param string $subno_csv CSV名
190     * @return integer CSV_ID
191     */
192    function lfGetCsvId($subno_csv) {
193        $objCSV = new SC_Helper_CSV_Ex();
194        $arrKey = array_keys($objCSV->arrSubnavi,$subno_csv);
195        $csv_id = $arrKey[0];
196        if(!SC_Utils_Ex::sfIsInt($csv_id)) {
197            //初期値取りだし
198            $arrKey = array_keys($objCSV->arrSubnavi);
199            $csv_id = $arrKey[0];
200        }
201        return $csv_id;
202    }
203
204    /**
205     * CSV出力項目設定を初期化する
206     *
207     * @param integer $csv_id CSV_ID
208     * @return boolean 成功:true
209     */
210    function lfSetDefaultCsvOutput($csv_id) {
211        $arrData = $this->lfGetCSVColumn($csv_id, '', $order = 'no');
212        if (!isset($arrData['no'])) {
213            $arrData['no'] = array();
214        }
215        return $this->lfUpdCsvOutput($csv_id, $arrData['no']);
216    }
217
218    /**
219     * CSV出力項目設定を更新する処理
220     *
221     * @param integer $csv_id CSV_ID
222     * @param array $arrData 有効にするCSV列データ配列
223     * @return boolean 成功:true
224     */
225    function lfUpdCsvOutput($csv_id, $arrData = array()){
226        $objQuery =& SC_Query_Ex::getSingletonInstance();
227        // ひとまず、全部使用しないで更新する
228        $table = "dtb_csv";
229        $where = "csv_id = ?";
230        $arrWhereVal = array($csv_id);
231        $arrUpdVal = array( 'status' => '2', 'rank' => NULL, 'update_date' => 'now()' );
232
233        $objQuery->begin();
234        $objQuery->update($table, $arrUpdVal, $where, $arrWhereVal);
235        // 使用するものだけ、再更新する。
236        if (is_array($arrData)) {
237            $where .= " AND no = ?";
238            $arrUpdVal = array('status' => '1');
239            foreach($arrData as $key => $val){
240                $arrWhereVal = array($csv_id, $val);
241                $arrUpdVal['rank'] = $key + 1;
242                $objQuery->update($table, $arrUpdVal, $where, $arrWhereVal);
243            }
244        }
245        $objQuery->commit();
246        return true;
247    }
248}
249?>
Note: See TracBrowser for help on using the repository browser.