source: branches/feature-module-update/data/class/pages/admin/products/LC_Page_Admin_Products_ReviewEdit.php @ 16582

Revision 16582, 7.7 KB checked in by nanasess, 16 years ago (diff)

ライセンス表記変更

  • 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("タイトル", "title", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
142        $objErr->doFunc(array("性別", "sex", STEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
143        return $objErr->arrErr;
144    }
145
146    //---- 取得文字列の変換
147    function lfConvertParam($array, $arrRegistColumn) {
148        /*
149         *  文字列の変換
150         *  K :  「半角(ハンカク)片仮名」を「全角片仮名」に変換
151         *  C :  「全角ひら仮名」を「全角かた仮名」に変換
152         *  V :  濁点付きの文字を一文字に変換。"K","H"と共に使用します
153         *  n :  「全角」数字を「半角(ハンカク)」に変換
154         *  a :  全角英数字を半角英数字に変換する
155         */
156        // カラム名とコンバート情報
157        foreach ($arrRegistColumn as $data) {
158            $arrConvList[ $data["column"] ] = isset($data["convert"])
159                ? $data["convert"] : "";
160        }
161
162        // 文字変換
163        foreach ($arrConvList as $key => $val) {
164            // POSTされてきた値のみ変換する。
165            if(strlen(($array[$key])) > 0) {
166                $array[$key] = mb_convert_kana($array[$key] ,$val);
167            }
168        }
169        return $array;
170    }
171
172    //レビュー情報の取得
173    function lfGetReviewData($review_id){
174        $select="review_id, A.product_id, reviewer_name, sex, recommend_level, ";
175        $select.="reviewer_url, title, comment, A.status, A.create_date, A.update_date, name";
176        $from = "dtb_review AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id ";
177        $where = "A.del_flg = 0 AND B.del_flg = 0 AND review_id = ? ";
178        $arrReview = $this->objQuery->select($select, $from, $where, array($review_id));
179        if(!empty($arrReview)) {
180            $this->arrReview = $arrReview[0];
181        } else {
182            SC_Utils_Ex::sfDispError("");
183        }
184        return $this->arrReview;
185    }
186
187    //レビュー情報の編集登録
188    function lfRegistReviewData($array, $arrRegistColumn){
189        foreach ($arrRegistColumn as $data) {
190            if (strlen($array[ $data["column"] ]) > 0 ) {
191                $arrRegist[ $data["column"] ] = $array[ $data["column"] ];
192            }
193            if ($data['column'] == 'update_date'){
194                $arrRegist['update_date'] = 'now()';
195            }
196        }
197        //登録実行
198        $this->objQuery->begin();
199        $this->objQuery->update("dtb_review", $arrRegist, "review_id='".$_POST['review_id']."'");
200        $this->objQuery->commit();
201    }
202}
203?>
Note: See TracBrowser for help on using the repository browser.