Changeset 23461
- Timestamp:
- 2014/05/29 18:54:58 (10 years ago)
- Location:
- branches/version-2_13-dev/data
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_13-dev/data/class/pages/admin/products/LC_Page_Admin_Products_Review.php
r23129 r23461 86 86 public function action() 87 87 { 88 $objReview = new SC_Helper_Review_Ex(); 88 89 // パラメーター管理クラス 89 90 $objFormParam = new SC_FormParam_Ex(); … … 105 106 switch ($this->getMode()) { 106 107 case 'delete': 107 $ this->lfDeleteReview($this->arrForm['review_id']);108 $objReview->delete($this->arrForm['review_id']); 108 109 case 'search': 109 110 case 'csv': … … 112 113 list($where, $arrWhereVal) = $this->lfGetWhere($this->arrForm); 113 114 // 検索結果を取得 114 $this->arrReview = $this->lfGetReview($ this->arrForm, $where, $arrWhereVal);115 $this->arrReview = $this->lfGetReview($objReview); 115 116 116 117 //CSVダウンロード 117 118 if ($this->getMode() == 'csv') { 119 // 検索条件を取得 120 list($where, $arrWhereVal) = $this->lfGetWhere($this->arrForm); 118 121 $this->lfDoOutputCsv($where, $arrWhereVal); 119 122 … … 158 161 159 162 return $objErr->arrErr; 160 }161 162 /**163 * 商品レビューの削除164 *165 * @param integer $review_id 商品レビューのID166 * @return void167 */168 public function lfDeleteReview($review_id)169 {170 $objQuery =& SC_Query_Ex::getSingletonInstance();171 $sqlval['del_flg'] = 1;172 $objQuery->update('dtb_review', $sqlval, 'review_id = ?', array($review_id));173 163 } 174 164 … … 334 324 * レビュー検索結果の取得 335 325 * 336 * @param array $arrForm フォームデータ 337 * @param string $where WHERE文 338 * @param array $arrWhereVal WHERE文の判定値 326 * @param SC_Helper_Review $objReview 339 327 * @return array レビュー一覧 340 328 */ 341 public function lfGetReview($arrForm, $where, $arrWhereVal) 342 { 343 $objQuery =& SC_Query_Ex::getSingletonInstance(); 344 345 // ページ送りの処理 329 public function lfGetReview(SC_Helper_Review $objReview) 330 { 331 $arrForm = $this->arrForm; 332 333 $query = $this->makeQuery($arrForm); 334 $linemax = $objReview->count($query); 335 336 $this->tpl_linemax = $linemax; 337 $this->tpl_pageno = isset($arrForm['search_pageno']) ? $arrForm['search_pageno'] : ''; 338 339 // ページ送りの取得 346 340 $page_max = SC_Utils_Ex::sfGetSearchPageMax($arrForm['search_page_max']); 347 348 if (!isset($arrWhereVal)) $arrWhereVal = array();349 350 $from = 'dtb_review AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id ';351 $linemax = $objQuery->count($from, $where, $arrWhereVal);352 $this->tpl_linemax = $linemax;353 354 $this->tpl_pageno = isset($arrForm['search_pageno']) ? $arrForm['search_pageno'] : '';355 356 // ページ送りの取得357 341 $objNavi = new SC_PageNavi_Ex($this->tpl_pageno, $linemax, $page_max, 358 342 'eccube.moveNaviPage', NAVI_PMAX); … … 361 345 362 346 // 取得範囲の指定(開始行番号、行数のセット) 363 $objQuery->setLimitOffset($page_max, $startno); 364 365 // 表示順序 366 $order = 'A.create_date DESC'; 367 $objQuery->setOrder($order); 368 //検索結果の取得 369 //レビュー情報のカラムの取得 370 $col = 'review_id, A.product_id, reviewer_name, sex, recommend_level, '; 371 $col .= 'reviewer_url, title, comment, A.status, A.create_date, A.update_date, name'; 372 $from = 'dtb_review AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id '; 373 $arrReview = $objQuery->select($col, $from, $where, $arrWhereVal); 347 $params = array( 348 'query' => $query, 349 'limit' => $page_max, 350 'offset' => $startno 351 ); 352 $arrReview = $objReview->find($params); 374 353 375 354 return $arrReview; 376 355 } 356 357 /** 358 * SC_Helper_Reviewインスタンスへ渡す検索条件の配列を作成. 359 * 360 * @param array $data 361 * @return array 362 */ 363 private function makeQuery($data = array()) { 364 $query = array(); 365 366 foreach ($data AS $key => $val) { 367 if (empty($val)) continue; 368 369 switch ($key) { 370 case 'search_reviewer_name': 371 $query['reviewer_name'] = $val; 372 break; 373 374 case 'search_reviewer_url': 375 $query['reviewer_url'] = $val; 376 break; 377 378 case 'search_name': 379 $query['product_name'] = $val; 380 break; 381 382 case 'search_product_code': 383 $query['product_code'] = $val; 384 break; 385 386 case 'search_sex': 387 $query['reviewer_sex'] = $val; 388 break; 389 390 case 'search_recommend_level': 391 $query['recommend_level'] = $val; 392 break; 393 394 case 'search_startyear': 395 if (isset($_POST['search_startyear']) && isset($_POST['search_startmonth']) && isset($_POST['search_startday'])) { 396 $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_startyear'], $_POST['search_startmonth'], $_POST['search_startday']); 397 $query['date_from'] = $date; 398 } 399 break; 400 401 case 'search_endyear': 402 if (isset($_POST['search_startyear']) && isset($_POST['search_startmonth']) && isset($_POST['search_startday'])) { 403 $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_endyear'], $_POST['search_endmonth'], $_POST['search_endday']); 404 $end_date = date('Y/m/d',strtotime('1 day' ,strtotime($date))); 405 $query['date_to'] = $end_date; 406 } 407 break; 408 409 default: 410 break; 411 } 412 413 } 414 415 return $query; 416 } 377 417 } -
branches/version-2_13-dev/data/class/pages/admin/products/LC_Page_Admin_Products_ReviewEdit.php
r23124 r23461 72 72 public function action() 73 73 { 74 $objReview = new SC_Helper_Review_Ex(); 74 75 // パラメーター情報の初期化 75 76 $objFormParam = new SC_FormParam_Ex(); … … 88 89 if (SC_Utils_Ex::isBlank($this->arrErr)) { 89 90 // レビュー情報の更新 90 $this->lfRegistReviewData($this->arrForm['review_id'], $objFormParam); 91 $arrValues = $objFormParam->getDbArray(); 92 $objReview->save($arrValues); 91 93 // レビュー情報のDB取得 92 $this->arrForm = $ this->lfGetReviewData($this->arrForm['review_id']);94 $this->arrForm = $objReview->get($this->arrForm['review_id']); 93 95 $this->tpl_onload = "alert('登録が完了しました。');"; 94 96 } … … 96 98 default: 97 99 // レビュー情報のDB取得 98 $this->arrForm = $ this->lfGetReviewData($this->arrForm['review_id']);100 $this->arrForm = $objReview->get($this->arrForm['review_id']); 99 101 break; 100 102 } … … 125 127 $objFormParam->addParam('コメント', 'comment', LTEXT_LEN, 'KVa', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); 126 128 } 127 128 /**129 * レビュー情報のDB取得130 *131 * @param integer $review_id レビューID132 * @return array レビュー情報133 */134 public function lfGetReviewData($review_id)135 {136 $objQuery =& SC_Query_Ex::getSingletonInstance();137 $select='review_id, A.product_id, reviewer_name, sex, recommend_level, ';138 $select.='reviewer_url, title, comment, A.status, A.create_date, A.update_date, name';139 $from = 'dtb_review AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id ';140 $where = 'A.del_flg = 0 AND B.del_flg = 0 AND review_id = ? ';141 $arrReview = $objQuery->select($select, $from, $where, array($review_id));142 if (empty($arrReview)) {143 SC_Utils_Ex::sfDispError('');144 }145 146 return $arrReview[0];147 }148 149 /**150 * レビュー情報の更新151 *152 * @param integer $review_id レビューID153 * @param SC_FormParam $objFormParam SC_FormParam インスタンス154 * @return void155 */156 public function lfRegistReviewData($review_id, &$objFormParam)157 {158 $objQuery =& SC_Query_Ex::getSingletonInstance();159 $arrValues = $objFormParam->getDbArray();160 $arrValues['update_date'] = 'CURRENT_TIMESTAMP';161 $objQuery->update('dtb_review', $arrValues, 'review_id = ?', array($review_id));162 }163 129 } -
branches/version-2_13-dev/data/class/pages/products/LC_Page_Products_Detail.php
r23460 r23461 305 305 $this->subImageFlag = $this->lfSetFile($this->objUpFile, $this->arrProduct, $this->arrFile); 306 306 //レビュー情報の取得 307 $this->arrReview = $this->lfGetReviewData($product_id); 307 $objReview = new SC_Helper_Review_Ex(); 308 $this->arrReview = $objReview->getListByProductId($product_id); 308 309 309 310 //関連商品情報表示 … … 520 521 521 522 /** 522 * 商品ごとのレビュー情報を取得する523 *524 * @param int $product_id525 * @return array526 */527 public function lfGetReviewData($product_id)528 {529 $objQuery =& SC_Query_Ex::getSingletonInstance();530 //商品ごとのレビュー情報を取得する531 $col = 'create_date, reviewer_url, reviewer_name, recommend_level, title, comment';532 $from = 'dtb_review';533 $where = 'del_flg = 0 AND status = 1 AND product_id = ?';534 $objQuery->setOrder('create_date DESC');535 $objQuery->setLimit(REVIEW_REGIST_MAX);536 $arrWhereVal = array($product_id);537 $arrReview = $objQuery->select($col, $from, $where, $arrWhereVal);538 539 return $arrReview;540 }541 542 /**543 523 * ファイルの情報をセットする 544 524 * -
branches/version-2_13-dev/data/class/pages/products/LC_Page_Products_Review.php
r23367 r23461 186 186 187 187 //登録実行 188 public function lfRegistRecommendData(&$objFormParam) 189 { 190 $objQuery =& SC_Query_Ex::getSingletonInstance(); 188 public function lfRegistRecommendData(SC_FormParam &$objFormParam) 189 { 190 $arrRegist = $objFormParam->getDbArray(); 191 191 192 $objCustomer = new SC_Customer_Ex(); 192 193 $arrRegist = $objFormParam->getDbArray();194 195 $arrRegist['create_date'] = 'CURRENT_TIMESTAMP';196 $arrRegist['update_date'] = 'CURRENT_TIMESTAMP';197 $arrRegist['creator_id'] = '0';198 199 193 if ($objCustomer->isLoginSuccess(true)) { 200 194 $arrRegist['customer_id'] = $objCustomer->getValue('customer_id'); … … 202 196 203 197 //-- 登録実行 204 $objQuery->begin(); 205 $arrRegist['review_id'] = $objQuery->nextVal('dtb_review_review_id'); 206 $objQuery->insert('dtb_review', $arrRegist); 207 $objQuery->commit(); 198 $objReview = new SC_Helper_Review_Ex(); 199 $objReview->save($arrRegist); 208 200 } 209 201 } -
branches/version-2_13-dev/data/class/util/SC_Utils.php
r23457 r23461 265 265 266 266 /* DB用日付文字列取得 */ 267 public function sfGetTimestamp($year, $month, $day, $last = false)267 public static function sfGetTimestamp($year, $month, $day, $last = false) 268 268 { 269 269 if ($year != '' && $month != '' && $day != '') { … … 1725 1725 * @return integer 1ページあたりの最大表示件数 1726 1726 */ 1727 public function sfGetSearchPageMax($search_page_max)1727 public static function sfGetSearchPageMax($search_page_max) 1728 1728 { 1729 1729 if (SC_Utils_Ex::sfIsInt($search_page_max) && $search_page_max > 0) {
Note: See TracChangeset
for help on using the changeset viewer.