Changeset 23461


Ignore:
Timestamp:
2014/05/29 18:54:58 (10 years ago)
Author:
pineray
Message:

#2560 pageクラスからdtb_reviewテーブルを直接指定している箇所をなくす

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  
    8686    public function action() 
    8787    { 
     88        $objReview = new SC_Helper_Review_Ex(); 
    8889        // パラメーター管理クラス 
    8990        $objFormParam = new SC_FormParam_Ex(); 
     
    105106        switch ($this->getMode()) { 
    106107            case 'delete': 
    107                 $this->lfDeleteReview($this->arrForm['review_id']); 
     108                $objReview->delete($this->arrForm['review_id']); 
    108109            case 'search': 
    109110            case 'csv': 
     
    112113                list($where, $arrWhereVal) = $this->lfGetWhere($this->arrForm); 
    113114                // 検索結果を取得 
    114                 $this->arrReview = $this->lfGetReview($this->arrForm, $where, $arrWhereVal); 
     115                $this->arrReview = $this->lfGetReview($objReview); 
    115116 
    116117                //CSVダウンロード 
    117118                if ($this->getMode() == 'csv') { 
     119                    // 検索条件を取得 
     120                    list($where, $arrWhereVal) = $this->lfGetWhere($this->arrForm); 
    118121                    $this->lfDoOutputCsv($where, $arrWhereVal); 
    119122 
     
    158161 
    159162        return $objErr->arrErr; 
    160     } 
    161  
    162     /** 
    163      * 商品レビューの削除 
    164      * 
    165      * @param  integer $review_id 商品レビューのID 
    166      * @return void 
    167      */ 
    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)); 
    173163    } 
    174164 
     
    334324     * レビュー検索結果の取得 
    335325     * 
    336      * @param  array  $arrForm     フォームデータ 
    337      * @param  string $where       WHERE文 
    338      * @param  array  $arrWhereVal WHERE文の判定値 
     326     * @param  SC_Helper_Review $objReview 
    339327     * @return array  レビュー一覧 
    340328     */ 
    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        // ページ送りの取得 
    346340        $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         // ページ送りの取得 
    357341        $objNavi = new SC_PageNavi_Ex($this->tpl_pageno, $linemax, $page_max, 
    358342                                      'eccube.moveNaviPage', NAVI_PMAX); 
     
    361345 
    362346        // 取得範囲の指定(開始行番号、行数のセット) 
    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); 
    374353 
    375354        return $arrReview; 
    376355    } 
     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    } 
    377417} 
  • branches/version-2_13-dev/data/class/pages/admin/products/LC_Page_Admin_Products_ReviewEdit.php

    r23124 r23461  
    7272    public function action() 
    7373    { 
     74        $objReview = new SC_Helper_Review_Ex(); 
    7475        // パラメーター情報の初期化 
    7576        $objFormParam = new SC_FormParam_Ex(); 
     
    8889                if (SC_Utils_Ex::isBlank($this->arrErr)) { 
    8990                    // レビュー情報の更新 
    90                     $this->lfRegistReviewData($this->arrForm['review_id'], $objFormParam); 
     91                    $arrValues = $objFormParam->getDbArray(); 
     92                    $objReview->save($arrValues); 
    9193                    // レビュー情報のDB取得 
    92                     $this->arrForm = $this->lfGetReviewData($this->arrForm['review_id']); 
     94                    $this->arrForm = $objReview->get($this->arrForm['review_id']); 
    9395                    $this->tpl_onload = "alert('登録が完了しました。');"; 
    9496                } 
     
    9698            default: 
    9799                // レビュー情報のDB取得 
    98                 $this->arrForm = $this->lfGetReviewData($this->arrForm['review_id']); 
     100                $this->arrForm = $objReview->get($this->arrForm['review_id']); 
    99101                break; 
    100102        } 
     
    125127        $objFormParam->addParam('コメント', 'comment', LTEXT_LEN, 'KVa', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); 
    126128    } 
    127  
    128     /** 
    129      * レビュー情報のDB取得 
    130      * 
    131      * @param  integer $review_id レビューID 
    132      * @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    レビューID 
    153      * @param  SC_FormParam $objFormParam SC_FormParam インスタンス 
    154      * @return void 
    155      */ 
    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     } 
    163129} 
  • branches/version-2_13-dev/data/class/pages/products/LC_Page_Products_Detail.php

    r23460 r23461  
    305305        $this->subImageFlag = $this->lfSetFile($this->objUpFile, $this->arrProduct, $this->arrFile); 
    306306        //レビュー情報の取得 
    307         $this->arrReview = $this->lfGetReviewData($product_id); 
     307        $objReview = new SC_Helper_Review_Ex(); 
     308        $this->arrReview = $objReview->getListByProductId($product_id); 
    308309 
    309310        //関連商品情報表示 
     
    520521 
    521522    /** 
    522      * 商品ごとのレビュー情報を取得する 
    523      * 
    524      * @param int $product_id 
    525      * @return array 
    526      */ 
    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     /** 
    543523     * ファイルの情報をセットする 
    544524     * 
  • branches/version-2_13-dev/data/class/pages/products/LC_Page_Products_Review.php

    r23367 r23461  
    186186 
    187187    //登録実行 
    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 
    191192        $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  
    199193        if ($objCustomer->isLoginSuccess(true)) { 
    200194            $arrRegist['customer_id'] = $objCustomer->getValue('customer_id'); 
     
    202196 
    203197        //-- 登録実行 
    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); 
    208200    } 
    209201} 
  • branches/version-2_13-dev/data/class/util/SC_Utils.php

    r23457 r23461  
    265265 
    266266    /* DB用日付文字列取得 */ 
    267     public function sfGetTimestamp($year, $month, $day, $last = false) 
     267    public static function sfGetTimestamp($year, $month, $day, $last = false) 
    268268    { 
    269269        if ($year != '' && $month != '' && $day != '') { 
     
    17251725     * @return integer 1ページあたりの最大表示件数 
    17261726     */ 
    1727     public function sfGetSearchPageMax($search_page_max) 
     1727    public static function sfGetSearchPageMax($search_page_max) 
    17281728    { 
    17291729        if (SC_Utils_Ex::sfIsInt($search_page_max) && $search_page_max > 0) { 
Note: See TracChangeset for help on using the changeset viewer.