source: branches/comu-ver2/data/class/pages/admin/contents/LC_Page_Admin_Contents_CSV.php @ 18234

Revision 18234, 5.5 KB checked in by Seasoft, 15 years ago (diff)

#528(改行コードが混在している)

  • SVN属性の変更。ただし、以下は除外。
    • /data/module
    • /data/pdf
    • /html/test
  • Property svn:eol-style set to LF
  • Property svn:keywords set to "Id Revision Date"
  • 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-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
25require_once(CLASS_PATH . "pages/LC_Page.php");
26require_once(CLASS_EX_PATH . "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 {
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
51        $this->tpl_mainno = "contents";
52        $this->tpl_subtitle = 'CSV出力設定';
53    }
54
55    /**
56     * Page のプロセス.
57     *
58     * @return void
59     */
60    function process() {
61        $objView = new SC_AdminView();
62        $objSess = new SC_Session();
63        $objCSV = new SC_Helper_CSV_Ex();
64
65        $this->arrSubnavi = $objCSV->arrSubnavi;
66        $this->tpl_subno_csv = $objCSV->arrSubnavi[1];
67        $this->arrSubnaviName = $objCSV->arrSubnaviName;
68
69        // 認証可否の判定
70        $objSess = new SC_Session();
71        SC_Utils_Ex::sfIsSuccess($objSess);
72
73        $arrOutput = array();
74        $arrChoice = array();
75
76        $get_tpl_subno_csv = isset($_GET['tpl_subno_csv'])
77                                     ? $_GET['tpl_subno_csv'] : "";
78
79        // GETで値が送られている場合にはその値を元に画面表示を切り替える
80        if ($get_tpl_subno_csv != ""){
81            // 送られてきた値が配列に登録されていなければTOPを表示
82            if (in_array($get_tpl_subno_csv,$this->arrSubnavi)){
83                $subno_csv = $get_tpl_subno_csv;
84            }else{
85                $subno_csv = $this->arrSubnavi[1];
86            }
87        } else {
88            // GETで値がなければPOSTの値を使用する
89            if (isset($_POST['tpl_subno_csv'])
90                && $_POST['tpl_subno_csv'] != "") {
91
92                $subno_csv = $_POST['tpl_subno_csv'];
93            }else{
94                $subno_csv = $this->arrSubnavi[1];
95            }
96        }
97
98        // subnoの番号を取得
99        $subno_id = array_keys($this->arrSubnavi,$subno_csv);
100        $subno_id = $subno_id[0];
101        // データの登録
102
103        if (!isset($_POST['mode'])) $_POST['mode'] = "";
104
105        if ($_POST["mode"] == "confirm") {
106
107            // エラーチェック
108            $this->arrErr = $this->lfCheckError($_POST['output_list']);
109
110            if (count($this->arrErr) <= 0){
111                // データの更新
112                $this->lfUpdCsvOutput($subno_id, $_POST['output_list']);
113
114                // 画面のリロード
115                $this->reload(array("tpl_subno_csv" => $subno_csv));
116            }
117        }
118
119        // 出力項目の取得
120        $arrOutput = SC_Utils_Ex::sfSwapArray($objCSV->sfgetCsvOutput($subno_csv, "WHERE csv_id = ? AND status = 1", array($subno_id)));
121        $arrOutput = SC_Utils_Ex::sfarrCombine($arrOutput['col'], $arrOutput['disp_name']);
122
123        // 非出力項目の取得
124        $arrChoice = SC_Utils_Ex::sfSwapArray($objCSV->sfgetCsvOutput($subno_csv, "WHERE csv_id = ? AND status = 2", array($subno_id)));
125
126        if (!isset($arrChoice['col'])) $arrChoice['col'] = array();
127        if (!isset($arrChoice['disp_name'])) $arrChoice['disp_name'] = array();
128
129        $arrChoice = SC_Utils_Ex::sfarrCombine($arrChoice['col'], $arrChoice['disp_name']);
130
131        $this->arrOutput=$arrOutput;
132        $this->arrChoice=$arrChoice;
133
134
135        $this->SubnaviName = $this->arrSubnaviName[$subno_id];
136        $this->tpl_subno_csv = $subno_csv;
137
138        // 画面の表示
139        $objView->assignobj($this);
140        $objView->display(MAIN_FRAME);
141    }
142
143   /**
144     * デストラクタ.
145     *
146     * @return void
147     */
148    function destroy() {
149        parent::destroy();
150    }
151
152    function lfUpdCsvOutput($csv_id, $arrData = array()){
153        $objQuery = new SC_Query();
154
155        // ひとまず、全部使用しないで更新する
156        $upd_sql = "UPDATE dtb_csv SET status = 2, rank = NULL, update_date = now() WHERE csv_id = ?";
157        $objQuery->query($upd_sql, array($csv_id));
158
159        // 使用するものだけ、再更新する。
160        if (is_array($arrData)) {
161            foreach($arrData as $key => $val){
162                $upd_sql = "UPDATE dtb_csv SET status = 1, rank = ? WHERE csv_id = ? AND col = ? ";
163                $objQuery->query($upd_sql, array($key+1, $csv_id,$val));
164            }
165        }
166    }
167
168    Function Lfcheckerror($data){
169        $objErr = new SC_CheckError();
170        $objErr->doFunc( array("出力項目", "output_list"), array("EXIST_CHECK") );
171
172        return $objErr->arrErr;
173
174    }
175}
176?>
Note: See TracBrowser for help on using the repository browser.