source: branches/comu-ver2/data/class/pages/admin/products/LC_Page_Admin_Products_ReviewEdit.php @ 17109

Revision 17109, 7.5 KB checked in by pineray, 16 years ago (diff)

merge r17054 - r17057 r17085 r17086 r17092

  • Property svn:eol-style set to LF
  • Property svn:keywords set to "Id Revision Date"
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");
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 {
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        $objView = new SC_AdminView();
64        $objSess = new SC_Session();
65        $this->objQuery = new SC_Query();
66        // 認証可否の判定
67        SC_Utils_Ex::sfIsSuccess($objSess);
68
69        //検索ワードの引継ぎ
70        foreach ($_POST as $key => $val){
71            if (ereg("^search_", $key)){
72                $this->arrSearchHidden[$key] = $val;
73            }
74        }
75
76        //取得文字列の変換用カラム
77        $arrRegistColumn = array (
78                                  array( "column" => "update_date"),
79                                  array( "column" => "status"),
80                                  array( "column" => "recommend_level"),
81                                  array(    "column" => "title","convert" => "KVa"),
82                                  array(    "column" => "comment","convert" => "KVa"),
83                                  array(    "column" => "reviewer_name","convert" => "KVa"),
84                                  array(    "column" => "reviewer_url","convert" => "KVa"),
85                                  array(    "column" => "sex","convert" => "n")
86
87                                  );
88
89        //レビューIDを渡す
90        $this->tpl_review_id = isset($_POST['review_id']) ? $_POST['review_id'] : "";
91        //レビュー情報のカラムの取得
92        $this->arrReview = $this->lfGetReviewData($this->tpl_review_id);
93        //登録済みのステータスを渡す
94        $this->tpl_pre_status = $this->arrReview['status'];
95        //商品ごとのレビュー表示数取得
96        $count = $this->objQuery->count("dtb_review", "del_flg=0 AND status=1 AND product_id=?", array($this->arrReview['product_id']));
97        //両方選択可能
98        $this->tpl_status_change = true;
99
100        if (!isset($_POST['mode'])) $_POST['mode'] = "";
101        switch($_POST['mode']) {
102            //登録
103        case 'complete':
104            //フォーム値の変換
105            $arrReview = $this->lfConvertParam($_POST, $arrRegistColumn);
106            $this->arrErr = $this->lfCheckError($arrReview);
107            //エラー無し
108            if (!$this->arrErr){
109                //レビュー情報の編集登録
110                $this->lfRegistReviewData($arrReview, $arrRegistColumn);
111                $this->arrReview = $arrReview;
112                $this->tpl_onload = "confirm('登録が完了しました。');";
113            }
114            break;
115        default:
116            break;
117        }
118
119        $objView->assignobj($this);
120        $objView->display(MAIN_FRAME);
121    }
122
123    /**
124     * デストラクタ.
125     *
126     * @return void
127     */
128    function destroy() {
129        parent::destroy();
130    }
131
132
133    // 入力エラーチェック
134    function lfCheckError($array) {
135        $objErr = new SC_CheckError($array);
136        $objErr->doFunc(array("おすすめレベル", "recommend_level"), array("SELECT_CHECK"));
137        $objErr->doFunc(array("タイトル", "title", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
138        $objErr->doFunc(array("コメント", "comment", LTEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
139        $objErr->doFunc(array("投稿者名", "reviewer_name", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
140        $objErr->doFunc(array("ホームページアドレス", "reviewer_url", URL_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
141        $objErr->doFunc(array("性別", "sex", STEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
142        return $objErr->arrErr;
143    }
144
145    //---- 取得文字列の変換
146    function lfConvertParam($array, $arrRegistColumn) {
147        /*
148         *  文字列の変換
149         *  K :  「半角(ハンカク)片仮名」を「全角片仮名」に変換
150         *  C :  「全角ひら仮名」を「全角かた仮名」に変換
151         *  V :  濁点付きの文字を一文字に変換。"K","H"と共に使用します
152         *  n :  「全角」数字を「半角(ハンカク)」に変換
153         *  a :  全角英数字を半角英数字に変換する
154         */
155        // カラム名とコンバート情報
156        foreach ($arrRegistColumn as $data) {
157            $arrConvList[ $data["column"] ] = isset($data["convert"])
158                ? $data["convert"] : "";
159        }
160
161        // 文字変換
162        foreach ($arrConvList as $key => $val) {
163            // POSTされてきた値のみ変換する。
164            if(strlen(($array[$key])) > 0) {
165                $array[$key] = mb_convert_kana($array[$key] ,$val);
166            }
167        }
168        return $array;
169    }
170
171    //レビュー情報の取得
172    function lfGetReviewData($review_id){
173        $select="review_id, A.product_id, reviewer_name, sex, recommend_level, ";
174        $select.="reviewer_url, title, comment, A.status, A.create_date, A.update_date, name";
175        $from = "dtb_review AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id ";
176        $where = "A.del_flg = 0 AND B.del_flg = 0 AND review_id = ? ";
177        $arrReview = $this->objQuery->select($select, $from, $where, array($review_id));
178        if(!empty($arrReview)) {
179            $this->arrReview = $arrReview[0];
180        } else {
181            SC_Utils_Ex::sfDispError("");
182        }
183        return $this->arrReview;
184    }
185
186    //レビュー情報の編集登録
187    function lfRegistReviewData($array, $arrRegistColumn){
188        foreach ($arrRegistColumn as $data) {
189            if (strlen($array[ $data["column"] ]) > 0 ) {
190                $arrRegist[ $data["column"] ] = $array[ $data["column"] ];
191            }
192            if ($data['column'] == 'update_date'){
193                $arrRegist['update_date'] = 'now()';
194            }
195        }
196        //登録実行
197        $this->objQuery->begin();
198        $this->objQuery->update("dtb_review", $arrRegist, "review_id='".$_POST['review_id']."'");
199        $this->objQuery->commit();
200    }
201}
202?>
Note: See TracBrowser for help on using the repository browser.