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

Revision 21864, 6.5 KB checked in by h_yoshimoto, 12 years ago (diff)

#1831 Copyrightを更新

  • 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-2012 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/products/LC_Page_Admin_Products_Review.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_Products_Review {
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_mainno = 'products';
48        $this->tpl_subno = 'review';
49        // 両方選択可能
50        $this->tpl_status_change = true;
51
52        $masterData = new SC_DB_MasterData_Ex();
53        $this->arrRECOMMEND = $masterData->getMasterData('mtb_recommend');
54        $this->tpl_maintitle = '商品管理';
55        $this->tpl_subtitle = 'レビュー管理';
56        $this->arrSex = $masterData->getMasterData('mtb_sex');
57    }
58
59    /**
60     * Page のプロセス.
61     *
62     * @return void
63     */
64    function process() {
65        $this->action();
66        $this->sendResponse();
67    }
68
69    /**
70     * Page のアクション.
71     *
72     * @return void
73     */
74    function action() {
75
76        // パラメーター情報の初期化
77        $objFormParam = new SC_FormParam_Ex();
78        $this->lfInitParam($objFormParam);
79        $objFormParam->setParam($_POST);
80        $objFormParam->convParam();
81        // 検索ワードの引き継ぎ
82        $this->arrSearchHidden = $objFormParam->getSearchArray();
83        $this->arrForm = $objFormParam->getHashArray();
84
85        switch ($this->getMode()) {
86            // 登録
87            case 'complete':
88                $this->arrErr = $this->lfCheckError($objFormParam);
89                // エラー無し
90                if (!$this->arrErr) {
91                    // レビュー情報の更新
92                    $this->lfRegistReviewData($this->arrForm['review_id'], $objFormParam);
93                    // レビュー情報のDB取得
94                    $this->arrForm = $this->lfGetReviewData($this->arrForm['review_id']);
95                    $this->tpl_onload = "alert('登録が完了しました。');";
96                }
97                break;
98            default:
99                // レビュー情報のDB取得
100                $this->arrForm = $this->lfGetReviewData($this->arrForm['review_id']);
101                break;
102        }
103
104    }
105
106    /**
107     * デストラクタ.
108     *
109     * @return void
110     */
111    function destroy() {
112        parent::destroy();
113    }
114
115    /**
116     * パラメーター情報の初期化を行う.
117     *
118     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
119     * @return void
120     */
121    function lfInitParam(&$objFormParam) {
122        // 検索条件のパラメーターを初期化
123        parent::lfInitParam($objFormParam);
124        $objFormParam->addParam('レビューID', 'review_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'));
125        $objFormParam->addParam('商品名', 'name', '', '', array(), '', false);
126        $objFormParam->addParam('投稿日', 'create_date', '', '', array(), '', false);
127
128        // 登録情報
129        $objFormParam->addParam('レビュー表示', 'status', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'));
130        $objFormParam->addParam('投稿者名', 'reviewer_name', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK'));
131        $objFormParam->addParam('投稿者URL', 'reviewer_url', URL_LEN, 'KVCa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK'));
132        $objFormParam->addParam('性別', 'sex', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'));
133        $objFormParam->addParam('おすすめレベル', 'recommend_level', INT_LEN, 'n', array('SELECT_CHECK'));
134        $objFormParam->addParam('タイトル', 'title', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK'));
135        $objFormParam->addParam('コメント', 'comment', LTEXT_LEN, 'KVa', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK'));
136    }
137
138    /**
139     * フォーム入力パラメーターエラーチェック
140     *
141     * @param array $objFormParam フォームパラメータークラス
142     * @return array エラー配列
143     */
144    function lfCheckError(&$objFormParam) {
145        $arrErr = $objFormParam->checkError();
146        if (!SC_Utils_Ex::isBlank($arrErr)) {
147            return $arrErr;
148        }
149    }
150
151    /**
152     * レビュー情報のDB取得
153     *
154     * @param integer $review_id レビューID
155     * @return array レビュー情報
156     */
157    function lfGetReviewData($review_id) {
158        $objQuery =& SC_Query_Ex::getSingletonInstance();
159        $select='review_id, A.product_id, reviewer_name, sex, recommend_level, ';
160        $select.='reviewer_url, title, comment, A.status, A.create_date, A.update_date, name';
161        $from = 'dtb_review AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id ';
162        $where = 'A.del_flg = 0 AND B.del_flg = 0 AND review_id = ? ';
163        $arrReview = $objQuery->select($select, $from, $where, array($review_id));
164        if (empty($arrReview)) {
165            SC_Utils_Ex::sfDispError('');
166        }
167        return $arrReview[0];
168    }
169
170    /**
171     * レビュー情報の更新
172     *
173     * @param integer $review_id レビューID
174     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
175     * @return void
176     */
177    function lfRegistReviewData($review_id, &$objFormParam) {
178        $objQuery =& SC_Query_Ex::getSingletonInstance();
179        $arrValues = $objFormParam->getDbArray();
180        $arrValues['update_date'] = 'CURRENT_TIMESTAMP';
181        $objQuery->update('dtb_review', $arrValues, 'review_id = ?', array($review_id));
182    }
183}
Note: See TracBrowser for help on using the repository browser.