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

Revision 20116, 7.1 KB checked in by nanasess, 13 years ago (diff)
  • svn properties を再設定
  • 再設定用のスクリプト追加
  • 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_REALDIR . "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        switch ($this->getMode()) {
89            // 登録
90            case 'complete':
91                // 取得文字列の変換用カラム
92                $arrRegistColumn = array (
93                    array("column" => "status"),
94                    array("column" => "recommend_level"),
95                    array("column" => "title", "convert" => "KVa"),
96                    array("column" => "comment", "convert" => "KVa"),
97                    array("column" => "reviewer_name", "convert" => "KVa"),
98                    array("column" => "reviewer_url", "convert" => "KVa"),
99                    array("column" => "sex", "convert" => "n")
100                );
101
102                // フォーム値の変換
103                $arrReview = $this->lfConvertParam($_POST, $arrRegistColumn);
104                $this->arrErr = $this->lfCheckError($arrReview);
105
106                // エラー有り
107                if ($this->arrErr) {
108                    // 入力内容を引き継ぐ
109                    $this->arrReview = $arrReview;
110                }
111                // エラー無し
112                else {
113                    // レビュー情報の更新
114                    $this->lfRegistReviewData($arrReview, $arrRegistColumn);
115
116                    // レビュー情報のDB取得
117                    $this->arrReview = $this->lfGetReviewData($arrReview['review_id']);
118
119                    $this->tpl_onload = "alert('登録が完了しました。');";
120                }
121                break;
122
123            default:
124                // レビュー情報のDB取得
125                $this->arrReview = $this->lfGetReviewData($_POST['review_id']);
126                break;
127        }
128    }
129
130    /**
131     * デストラクタ.
132     *
133     * @return void
134     */
135    function destroy() {
136        parent::destroy();
137    }
138
139    /**
140     * 入力エラーチェック
141     *
142     */
143    function lfCheckError($arrReview) {
144        $objErr = new SC_CheckError($arrReview);
145        $objErr->doFunc(array("おすすめレベル", "recommend_level"), array("SELECT_CHECK"));
146        $objErr->doFunc(array("タイトル", "title", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
147        $objErr->doFunc(array("コメント", "comment", LTEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
148        $objErr->doFunc(array("投稿者名", "reviewer_name", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
149        $objErr->doFunc(array("投稿者URL", "reviewer_url", URL_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
150        $objErr->doFunc(array("性別", "sex", STEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
151        return $objErr->arrErr;
152    }
153
154    /**
155     * 取得文字列の変換
156     *
157     */
158    function lfConvertParam($array, $arrRegistColumn) {
159        /*
160         *  文字列の変換
161         *  K :  「半角(ハンカク)片仮名」を「全角片仮名」に変換
162         *  C :  「全角ひら仮名」を「全角かた仮名」に変換
163         *  V :  濁点付きの文字を一文字に変換。"K","H"と共に使用します
164         *  n :  「全角」数字を「半角(ハンカク)」に変換
165         *  a :  全角英数字を半角英数字に変換する
166         */
167        // カラム名とコンバート情報
168        foreach ($arrRegistColumn as $data) {
169            $arrConvList[ $data["column"] ] = isset($data["convert"])
170                ? $data["convert"] : "";
171        }
172
173        // 文字変換
174        foreach ($arrConvList as $key => $val) {
175            // POSTされてきた値のみ変換する。
176            if(strlen(($array[$key])) > 0) {
177                $array[$key] = mb_convert_kana($array[$key] ,$val);
178            }
179        }
180        return $array;
181    }
182
183    /**
184     * レビュー情報のDB取得
185     *
186     */
187    function lfGetReviewData($review_id){
188        $select="review_id, A.product_id, reviewer_name, sex, recommend_level, ";
189        $select.="reviewer_url, title, comment, A.status, A.create_date, A.update_date, name";
190        $from = "dtb_review AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id ";
191        $where = "A.del_flg = 0 AND B.del_flg = 0 AND review_id = ? ";
192        $arrReview = $this->objQuery->select($select, $from, $where, array($review_id));
193        if (empty($arrReview)) {
194            SC_Utils_Ex::sfDispError("");
195        }
196
197        return $arrReview[0];
198    }
199
200    /**
201     * レビュー情報の更新
202     *
203     */
204    function lfRegistReviewData($arrReview, $arrRegistColumn){
205        foreach ($arrRegistColumn as $data) {
206            $arrRegist[ $data["column"] ] = $arrReview[ $data["column"] ];
207        }
208        $arrRegist['update_date'] = 'now()';
209
210        // 更新実行
211        $this->objQuery->update("dtb_review", $arrRegist, "review_id = ?", array($arrReview['review_id']));
212    }
213}
214?>
Note: See TracBrowser for help on using the repository browser.