[15898] | 1 | <?php |
---|
| 2 | /* |
---|
[16582] | 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
[15898] | 5 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. |
---|
| 6 | * |
---|
| 7 | * http://www.lockon.co.jp/ |
---|
[16582] | 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. |
---|
[15898] | 22 | */ |
---|
| 23 | |
---|
| 24 | // {{{ requires |
---|
| 25 | require_once(CLASS_PATH . "pages/LC_Page.php"); |
---|
| 26 | |
---|
| 27 | /** |
---|
| 28 | * レビュー編集 のページクラス. |
---|
| 29 | * |
---|
| 30 | * @package Page |
---|
| 31 | * @author LOCKON CO.,LTD. |
---|
| 32 | * @version $Id$ |
---|
| 33 | */ |
---|
| 34 | class 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 | |
---|
[18031] | 69 | // 検索ワードの引継ぎ |
---|
[15898] | 70 | foreach ($_POST as $key => $val){ |
---|
| 71 | if (ereg("^search_", $key)){ |
---|
| 72 | $this->arrSearchHidden[$key] = $val; |
---|
| 73 | } |
---|
| 74 | } |
---|
| 75 | |
---|
[18031] | 76 | // 両方選択可能 |
---|
[15898] | 77 | $this->tpl_status_change = true; |
---|
| 78 | |
---|
| 79 | if (!isset($_POST['mode'])) $_POST['mode'] = ""; |
---|
[18031] | 80 | switch ($_POST['mode']) { |
---|
| 81 | // 登録 |
---|
| 82 | case 'complete': |
---|
| 83 | // 取得文字列の変換用カラム |
---|
| 84 | $arrRegistColumn = array ( |
---|
| 85 | array("column" => "status"), |
---|
| 86 | array("column" => "recommend_level"), |
---|
| 87 | array("column" => "title", "convert" => "KVa"), |
---|
| 88 | array("column" => "comment", "convert" => "KVa"), |
---|
| 89 | array("column" => "reviewer_name", "convert" => "KVa"), |
---|
| 90 | array("column" => "reviewer_url", "convert" => "KVa"), |
---|
| 91 | array("column" => "sex", "convert" => "n") |
---|
| 92 | ); |
---|
| 93 | |
---|
| 94 | // フォーム値の変換 |
---|
| 95 | $arrReview = $this->lfConvertParam($_POST, $arrRegistColumn); |
---|
| 96 | $this->arrErr = $this->lfCheckError($arrReview); |
---|
| 97 | |
---|
| 98 | // エラー有り |
---|
| 99 | if ($this->arrErr) { |
---|
| 100 | // 入力内容を引き継ぐ |
---|
| 101 | $this->arrReview = $arrReview; |
---|
| 102 | } |
---|
| 103 | // エラー無し |
---|
| 104 | else { |
---|
| 105 | // レビュー情報の更新 |
---|
| 106 | $this->lfRegistReviewData($arrReview, $arrRegistColumn); |
---|
| 107 | |
---|
| 108 | // レビュー情報のDB取得 |
---|
| 109 | $this->arrReview = $this->lfGetReviewData($arrReview['review_id']); |
---|
| 110 | |
---|
| 111 | $this->tpl_onload = "alert('登録が完了しました。');"; |
---|
| 112 | } |
---|
| 113 | break; |
---|
| 114 | |
---|
| 115 | default: |
---|
| 116 | // レビュー情報のDB取得 |
---|
| 117 | $this->arrReview = $this->lfGetReviewData($_POST['review_id']); |
---|
| 118 | break; |
---|
[15898] | 119 | } |
---|
| 120 | |
---|
| 121 | $objView->assignobj($this); |
---|
| 122 | $objView->display(MAIN_FRAME); |
---|
| 123 | } |
---|
| 124 | |
---|
| 125 | /** |
---|
| 126 | * デストラクタ. |
---|
| 127 | * |
---|
| 128 | * @return void |
---|
| 129 | */ |
---|
| 130 | function destroy() { |
---|
| 131 | parent::destroy(); |
---|
| 132 | } |
---|
| 133 | |
---|
| 134 | |
---|
[18031] | 135 | /** |
---|
| 136 | * 入力エラーチェック |
---|
| 137 | * |
---|
| 138 | */ |
---|
| 139 | function lfCheckError($arrReview) { |
---|
| 140 | $objErr = new SC_CheckError($arrReview); |
---|
[15898] | 141 | $objErr->doFunc(array("おすすめレベル", "recommend_level"), array("SELECT_CHECK")); |
---|
| 142 | $objErr->doFunc(array("タイトル", "title", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 143 | $objErr->doFunc(array("コメント", "comment", LTEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 144 | $objErr->doFunc(array("投稿者名", "reviewer_name", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 145 | $objErr->doFunc(array("ホームページアドレス", "reviewer_url", URL_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 146 | $objErr->doFunc(array("性別", "sex", STEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 147 | return $objErr->arrErr; |
---|
| 148 | } |
---|
| 149 | |
---|
[18031] | 150 | /** |
---|
| 151 | * 取得文字列の変換 |
---|
| 152 | * |
---|
| 153 | */ |
---|
[15898] | 154 | function lfConvertParam($array, $arrRegistColumn) { |
---|
| 155 | /* |
---|
| 156 | * 文字列の変換 |
---|
| 157 | * K : 「半角(ハンカク)片仮名」を「全角片仮名」に変換 |
---|
| 158 | * C : 「全角ひら仮名」を「全角かた仮名」に変換 |
---|
| 159 | * V : 濁点付きの文字を一文字に変換。"K","H"と共に使用します |
---|
| 160 | * n : 「全角」数字を「半角(ハンカク)」に変換 |
---|
| 161 | * a : 全角英数字を半角英数字に変換する |
---|
| 162 | */ |
---|
| 163 | // カラム名とコンバート情報 |
---|
| 164 | foreach ($arrRegistColumn as $data) { |
---|
| 165 | $arrConvList[ $data["column"] ] = isset($data["convert"]) |
---|
| 166 | ? $data["convert"] : ""; |
---|
| 167 | } |
---|
| 168 | |
---|
| 169 | // 文字変換 |
---|
| 170 | foreach ($arrConvList as $key => $val) { |
---|
| 171 | // POSTされてきた値のみ変換する。 |
---|
| 172 | if(strlen(($array[$key])) > 0) { |
---|
| 173 | $array[$key] = mb_convert_kana($array[$key] ,$val); |
---|
| 174 | } |
---|
| 175 | } |
---|
| 176 | return $array; |
---|
| 177 | } |
---|
| 178 | |
---|
[18031] | 179 | /** |
---|
| 180 | * レビュー情報のDB取得 |
---|
| 181 | * |
---|
| 182 | */ |
---|
[15898] | 183 | function lfGetReviewData($review_id){ |
---|
| 184 | $select="review_id, A.product_id, reviewer_name, sex, recommend_level, "; |
---|
| 185 | $select.="reviewer_url, title, comment, A.status, A.create_date, A.update_date, name"; |
---|
| 186 | $from = "dtb_review AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id "; |
---|
| 187 | $where = "A.del_flg = 0 AND B.del_flg = 0 AND review_id = ? "; |
---|
| 188 | $arrReview = $this->objQuery->select($select, $from, $where, array($review_id)); |
---|
[18031] | 189 | |
---|
| 190 | if (empty($arrReview)) { |
---|
[15898] | 191 | SC_Utils_Ex::sfDispError(""); |
---|
| 192 | } |
---|
[18031] | 193 | |
---|
| 194 | return $arrReview[0]; |
---|
[15898] | 195 | } |
---|
| 196 | |
---|
[18031] | 197 | /** |
---|
| 198 | * レビュー情報の更新 |
---|
| 199 | * |
---|
| 200 | */ |
---|
| 201 | function lfRegistReviewData($arrReview, $arrRegistColumn){ |
---|
[15898] | 202 | foreach ($arrRegistColumn as $data) { |
---|
[18031] | 203 | $arrRegist[ $data["column"] ] = $arrReview[ $data["column"] ]; |
---|
[15898] | 204 | } |
---|
[18031] | 205 | $arrRegist['update_date'] = 'now()'; |
---|
| 206 | |
---|
| 207 | // 更新実行 |
---|
| 208 | $this->objQuery->update("dtb_review", $arrRegist, "review_id = ?", array($arrReview['review_id'])); |
---|
[15898] | 209 | } |
---|
| 210 | } |
---|
| 211 | ?> |
---|