source: branches/version-2_5-dev/data/class/pages/admin/products/LC_Page_Admin_Products_ReviewEdit.php @ 19803

Revision 19803, 7.2 KB checked in by Seasoft, 13 years ago (diff)

#834(パラメータの定数名に「URL」を含むにもかかわらず、パスのみのものがある)

  • 一斉置換前の現状記録のためのコミット

#628(未使用処理・定義などの削除)

  • 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-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_FILE_PATH . "pages/admin/LC_Page_Admin.php");
26
27/**
28 * レビュー編集 のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Admin_Products_ReviewEdit extends LC_Page_Admin {
35
36    // }}}
37    // {{{ functions
38
39    /**
40     * Page を初期化する.
41     *
42     * @return void
43     */
44    function init() {
45        parent::init();
46        $this->tpl_mainpage = 'products/review_edit.tpl';
47        $this->tpl_subnavi = 'products/subnavi.tpl';
48        $this->tpl_mainno = 'products';
49        $this->tpl_subno = 'review';
50
51        $masterData = new SC_DB_MasterData_Ex();
52        $this->arrRECOMMEND = $masterData->getMasterData("mtb_recommend");
53        $this->tpl_subtitle = 'レビュー管理';
54        $this->arrSex = $masterData->getMasterData("mtb_sex");
55    }
56
57    /**
58     * Page のプロセス.
59     *
60     * @return void
61     */
62    function process() {
63        $this->action();
64        $this->sendResponse();
65    }
66
67    /**
68     * Page のアクション.
69     *
70     * @return void
71     */
72    function action() {
73        $objSess = new SC_Session();
74        $this->objQuery = new SC_Query();
75        // 認証可否の判定
76        SC_Utils_Ex::sfIsSuccess($objSess);
77
78        // 検索ワードの引継ぎ
79        foreach ($_POST as $key => $val){
80            if (ereg("^search_", $key)){
81                $this->arrSearchHidden[$key] = $val;
82            }
83        }
84
85        // 両方選択可能
86        $this->tpl_status_change = true;
87
88        if (!isset($_POST['mode'])) $_POST['mode'] = "";
89        switch ($_POST['mode']) {
90            // 登録
91            case 'complete':
92                // 取得文字列の変換用カラム
93                $arrRegistColumn = array (
94                    array("column" => "status"),
95                    array("column" => "recommend_level"),
96                    array("column" => "title", "convert" => "KVa"),
97                    array("column" => "comment", "convert" => "KVa"),
98                    array("column" => "reviewer_name", "convert" => "KVa"),
99                    array("column" => "reviewer_url", "convert" => "KVa"),
100                    array("column" => "sex", "convert" => "n")
101                );
102
103                // フォーム値の変換
104                $arrReview = $this->lfConvertParam($_POST, $arrRegistColumn);
105                $this->arrErr = $this->lfCheckError($arrReview);
106
107                // エラー有り
108                if ($this->arrErr) {
109                    // 入力内容を引き継ぐ
110                    $this->arrReview = $arrReview;
111                }
112                // エラー無し
113                else {
114                    // レビュー情報の更新
115                    $this->lfRegistReviewData($arrReview, $arrRegistColumn);
116
117                    // レビュー情報のDB取得
118                    $this->arrReview = $this->lfGetReviewData($arrReview['review_id']);
119
120                    $this->tpl_onload = "alert('登録が完了しました。');";
121                }
122                break;
123
124            default:
125                // レビュー情報のDB取得
126                $this->arrReview = $this->lfGetReviewData($_POST['review_id']);
127                break;
128        }
129    }
130
131    /**
132     * デストラクタ.
133     *
134     * @return void
135     */
136    function destroy() {
137        parent::destroy();
138    }
139
140    /**
141     * 入力エラーチェック
142     *
143     */
144    function lfCheckError($arrReview) {
145        $objErr = new SC_CheckError($arrReview);
146        $objErr->doFunc(array("おすすめレベル", "recommend_level"), array("SELECT_CHECK"));
147        $objErr->doFunc(array("タイトル", "title", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
148        $objErr->doFunc(array("コメント", "comment", LTEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
149        $objErr->doFunc(array("投稿者名", "reviewer_name", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
150        $objErr->doFunc(array("投稿者URL", "reviewer_url", URL_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
151        $objErr->doFunc(array("性別", "sex", STEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
152        return $objErr->arrErr;
153    }
154
155    /**
156     * 取得文字列の変換
157     *
158     */
159    function lfConvertParam($array, $arrRegistColumn) {
160        /*
161         *  文字列の変換
162         *  K :  「半角(ハンカク)片仮名」を「全角片仮名」に変換
163         *  C :  「全角ひら仮名」を「全角かた仮名」に変換
164         *  V :  濁点付きの文字を一文字に変換。"K","H"と共に使用します
165         *  n :  「全角」数字を「半角(ハンカク)」に変換
166         *  a :  全角英数字を半角英数字に変換する
167         */
168        // カラム名とコンバート情報
169        foreach ($arrRegistColumn as $data) {
170            $arrConvList[ $data["column"] ] = isset($data["convert"])
171                ? $data["convert"] : "";
172        }
173
174        // 文字変換
175        foreach ($arrConvList as $key => $val) {
176            // POSTされてきた値のみ変換する。
177            if(strlen(($array[$key])) > 0) {
178                $array[$key] = mb_convert_kana($array[$key] ,$val);
179            }
180        }
181        return $array;
182    }
183
184    /**
185     * レビュー情報のDB取得
186     *
187     */
188    function lfGetReviewData($review_id){
189        $select="review_id, A.product_id, reviewer_name, sex, recommend_level, ";
190        $select.="reviewer_url, title, comment, A.status, A.create_date, A.update_date, name";
191        $from = "dtb_review AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id ";
192        $where = "A.del_flg = 0 AND B.del_flg = 0 AND review_id = ? ";
193        $arrReview = $this->objQuery->select($select, $from, $where, array($review_id));
194        if (empty($arrReview)) {
195            SC_Utils_Ex::sfDispError("");
196        }
197
198        return $arrReview[0];
199    }
200
201    /**
202     * レビュー情報の更新
203     *
204     */
205    function lfRegistReviewData($arrReview, $arrRegistColumn){
206        foreach ($arrRegistColumn as $data) {
207            $arrRegist[ $data["column"] ] = $arrReview[ $data["column"] ];
208        }
209        $arrRegist['update_date'] = 'now()';
210
211        // 更新実行
212        $this->objQuery->update("dtb_review", $arrRegist, "review_id = ?", array($arrReview['review_id']));
213    }
214}
215?>
Note: See TracBrowser for help on using the repository browser.