Index: /branches/version-2_13-dev/data/class_extends/helper_extends/SC_Helper_Review_Ex.php
===================================================================
--- /branches/version-2_13-dev/data/class_extends/helper_extends/SC_Helper_Review_Ex.php	(revision 23461)
+++ /branches/version-2_13-dev/data/class_extends/helper_extends/SC_Helper_Review_Ex.php	(revision 23461)
@@ -0,0 +1,38 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+require_once CLASS_REALDIR . 'helper/SC_Helper_Review.php';
+
+/**
+ * 商品レビューを管理するヘルパークラス(拡張).
+ *
+ * LC_Helper_Review をカスタマイズする場合はこのクラスを編集する.
+ *
+ * @package Helper
+ * @author pineray
+ * @version $Id:$
+ */
+class SC_Helper_Review_Ex extends SC_Helper_Review
+{
+    //put your code here
+}
Index: /branches/version-2_13-dev/data/class/helper/SC_Helper_Review.php
===================================================================
--- /branches/version-2_13-dev/data/class/helper/SC_Helper_Review.php	(revision 23461)
+++ /branches/version-2_13-dev/data/class/helper/SC_Helper_Review.php	(revision 23461)
@@ -0,0 +1,257 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+/**
+ * 商品レビューを管理するヘルパークラス.
+ *
+ * @package Helper
+ * @author pineray
+ * @version $Id:$
+ */
+class SC_Helper_Review
+{
+    /**
+     * レビュー情報のDB取得
+     *
+     * @param  int $review_id レビューID
+     * @return array レビュー情報
+     */
+    public function get($review_id)
+    {
+        $objQuery =& SC_Query_Ex::getSingletonInstance();
+        $select='review_id, A.product_id, reviewer_name, sex, recommend_level, ';
+        $select.='reviewer_url, title, comment, A.status, A.create_date, A.update_date, name';
+        $from = 'dtb_review AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id ';
+        $where = 'A.del_flg = 0 AND B.del_flg = 0 AND review_id = ? ';
+        $arrReview = $objQuery->select($select, $from, $where, array($review_id));
+
+        return $arrReview[0];
+    }
+
+    /**
+     * 商品に紐付いたレビューの一覧を取得
+     *
+     * @param $product_id
+     * @return array|null
+     */
+    public function getListByProductId($product_id)
+    {
+        $query = array(
+            'product_id' => $product_id
+        );
+        $arrReview = $this->find(array('query' => $query));
+
+        return $arrReview;
+    }
+
+    /**
+     * レビュー情報を登録する.
+     *
+     * @param $data
+     * @return bool
+     */
+    public function save($data)
+    {
+        $objQuery =& SC_Query_Ex::getSingletonInstance();
+
+        $review_id = $data['review_id'];
+        $data['update_date'] = 'CURRENT_TIMESTAMP';
+        // 新規登録
+        if ($review_id == '') {
+            // INSERTの実行
+            $data['creator_id'] = '0';
+            $data['create_date'] = 'CURRENT_TIMESTAMP';
+            $data['review_id'] = $objQuery->nextVal('dtb_review_review_id');
+            $ret = $objQuery->insert('dtb_review', $data);
+        // 既存編集
+        } else {
+            unset($data['creator_id']);
+            unset($data['create_date']);
+            $where = 'review_id = ?';
+            $ret = $objQuery->update('dtb_review', $data, $where, array($review_id));
+        }
+
+        return ($ret) ? $data['review_id'] : FALSE;
+    }
+
+    /**
+     * レビューを削除する（論理削除）.
+     *
+     * @param $review_id
+     */
+    public function delete($review_id)
+    {
+        $objQuery =& SC_Query_Ex::getSingletonInstance();
+        $data['del_flg'] = 1;
+        $objQuery->update('dtb_review', $data, 'review_id = ?', array($review_id));
+    }
+
+    /**
+     * 条件に合うレビュー情報の一覧を取得.
+     *
+     * @param array $params
+     * @return array|null
+     */
+    public function find($params = array())
+    {
+        $objQuery =& SC_Query_Ex::getSingletonInstance();
+
+        // 検索条件を作成
+        $query = (isset($params['query'])) ? $params['query'] : array();
+        list($where, $values) = $this->makeWhere($query);
+
+        // 表示件数
+        if (isset($params['limit'])) {
+            if (isset($params['offset'])) {
+                $objQuery->setLimitOffset($params['limit'], $params['offset']);
+            } else {
+                $objQuery->setLimit($params['limit']);
+            }
+        } elseif (isset($params['offset'])) {
+            $objQuery->setOffset($params['offset']);
+        }
+
+        // 表示順序
+        $order = (isset($params['order'])) ? $params['order'] : 'A.create_date DESC';
+        $objQuery->setOrder($order);
+
+        //検索結果の取得
+        //レビュー情報のカラムの取得
+        $col = 'review_id, A.product_id, reviewer_name, sex, recommend_level, ';
+        $col .= 'reviewer_url, title, comment, A.status, A.create_date, A.update_date, name';
+        $from = 'dtb_review AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id ';
+        $arrReview = $objQuery->select($col, $from, $where, $values);
+
+        return $arrReview;
+    }
+
+    /**
+     * 条件に合うレビュー情報の件数を取得.
+     *
+     * @param array $query
+     * @return int
+     */
+    public function count($query = array())
+    {
+        $objQuery =& SC_Query_Ex::getSingletonInstance();
+        // 検索条件を作成
+        list($where, $values) = $this->makeWhere($query);
+        $from = 'dtb_review AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id ';
+        return $objQuery->count($from, $where, $values);
+    }
+
+    /**
+     * WHERE文の作成
+     *
+     * @param  array $query フォームデータ
+     * @return array WHERE文、判定値
+     */
+    private function makeWhere($query = array())
+    {
+        //削除されていない商品を検索
+        $where = 'A.del_flg = 0 AND B.del_flg = 0';
+        $values = array();
+
+        foreach ($query AS $key => $val) {
+            if (empty($val)) continue;
+
+            switch ($key) {
+                case 'product_id':
+                    if (is_array($val)) {
+                        $where.= ' AND A.product_id IN (' . SC_Utils_Ex::sfGetCommaList($val) . ')';
+                    } else {
+                        $where.= ' AND A.product_id = ?';
+                        $values[] = $val;
+                    }
+                    break;
+
+                case 'reviewer_name':
+                    $val = preg_replace('/ /', '%', $val);
+                    $where.= ' AND reviewer_name LIKE ? ';
+                    $values[] = "%$val%";
+                    break;
+
+                case 'reviewer_url':
+                    $val = preg_replace('/ /', '%', $val);
+                    $where.= ' AND reviewer_url LIKE ? ';
+                    $values[] = "%$val%";
+                    break;
+
+                case 'product_name':
+                    $val = preg_replace('/ /', '%', $val);
+                    $where.= ' AND name LIKE ? ';
+                    $values[] = "%$val%";
+                    break;
+
+                case 'product_code':
+                    $val = preg_replace('/ /', '%', $val);
+                    $where.= ' AND A.product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code LIKE ?)';
+                    $values[] = "%$val%";
+                    break;
+
+                case 'reviewer_sex':
+                    $tmp_where = '';
+                    //$val=配列の中身,$element=各キーの値(1,2)
+                    if (is_array($val)) {
+                        foreach ($val as $element) {
+                            if ($element != '') {
+                                if ($tmp_where == '') {
+                                    $tmp_where .= ' AND (sex = ?';
+                                } else {
+                                    $tmp_where .= ' OR sex = ?';
+                                }
+                                $values[] = $element;
+                            }
+                        }
+                        if ($tmp_where != '') {
+                            $tmp_where .= ')';
+                            $where .= " $tmp_where ";
+                        }
+                    }
+
+                    break;
+
+                case 'recommend_level':
+                    $where.= ' AND recommend_level = ? ';
+                    $values[] = $val;
+                    break;
+
+                case 'date_from':
+                    $where.= ' AND A.create_date >= ? ';
+                    $values[] = $val;
+                    break;
+
+                case 'date_to':
+                    $where.= " AND A.create_date <= cast( ? as date) ";
+                    $values[] = $val;
+                    break;
+
+                default:
+                    break;
+            }
+
+        }
+
+        return array($where, $values);
+    }
+}
Index: /branches/version-2_13-dev/data/class/pages/admin/products/LC_Page_Admin_Products_Review.php
===================================================================
--- /branches/version-2_13-dev/data/class/pages/admin/products/LC_Page_Admin_Products_Review.php	(revision 23129)
+++ /branches/version-2_13-dev/data/class/pages/admin/products/LC_Page_Admin_Products_Review.php	(revision 23461)
@@ -86,4 +86,5 @@
     public function action()
     {
+        $objReview = new SC_Helper_Review_Ex();
         // パラメーター管理クラス
         $objFormParam = new SC_FormParam_Ex();
@@ -105,5 +106,5 @@
         switch ($this->getMode()) {
             case 'delete':
-                $this->lfDeleteReview($this->arrForm['review_id']);
+                $objReview->delete($this->arrForm['review_id']);
             case 'search':
             case 'csv':
@@ -112,8 +113,10 @@
                 list($where, $arrWhereVal) = $this->lfGetWhere($this->arrForm);
                 // 検索結果を取得
-                $this->arrReview = $this->lfGetReview($this->arrForm, $where, $arrWhereVal);
+                $this->arrReview = $this->lfGetReview($objReview);
 
                 //CSVダウンロード
                 if ($this->getMode() == 'csv') {
+                    // 検索条件を取得
+                    list($where, $arrWhereVal) = $this->lfGetWhere($this->arrForm);
                     $this->lfDoOutputCsv($where, $arrWhereVal);
 
@@ -158,17 +161,4 @@
 
         return $objErr->arrErr;
-    }
-
-    /**
-     * 商品レビューの削除
-     *
-     * @param  integer $review_id 商品レビューのID
-     * @return void
-     */
-    public function lfDeleteReview($review_id)
-    {
-        $objQuery =& SC_Query_Ex::getSingletonInstance();
-        $sqlval['del_flg'] = 1;
-        $objQuery->update('dtb_review', $sqlval, 'review_id = ?', array($review_id));
     }
 
@@ -334,25 +324,19 @@
      * レビュー検索結果の取得
      *
-     * @param  array  $arrForm     フォームデータ
-     * @param  string $where       WHERE文
-     * @param  array  $arrWhereVal WHERE文の判定値
+     * @param  SC_Helper_Review $objReview
      * @return array  レビュー一覧
      */
-    public function lfGetReview($arrForm, $where, $arrWhereVal)
-    {
-        $objQuery =& SC_Query_Ex::getSingletonInstance();
-
-        // ページ送りの処理
+    public function lfGetReview(SC_Helper_Review $objReview)
+    {
+        $arrForm = $this->arrForm;
+
+        $query = $this->makeQuery($arrForm);
+        $linemax = $objReview->count($query);
+
+        $this->tpl_linemax = $linemax;
+        $this->tpl_pageno = isset($arrForm['search_pageno']) ? $arrForm['search_pageno'] : '';
+
+        // ページ送りの取得
         $page_max = SC_Utils_Ex::sfGetSearchPageMax($arrForm['search_page_max']);
-
-        if (!isset($arrWhereVal)) $arrWhereVal = array();
-
-        $from = 'dtb_review AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id ';
-        $linemax = $objQuery->count($from, $where, $arrWhereVal);
-        $this->tpl_linemax = $linemax;
-
-        $this->tpl_pageno = isset($arrForm['search_pageno']) ? $arrForm['search_pageno'] : '';
-
-        // ページ送りの取得
         $objNavi = new SC_PageNavi_Ex($this->tpl_pageno, $linemax, $page_max,
                                       'eccube.moveNaviPage', NAVI_PMAX);
@@ -361,17 +345,73 @@
 
         // 取得範囲の指定(開始行番号、行数のセット)
-        $objQuery->setLimitOffset($page_max, $startno);
-
-        // 表示順序
-        $order = 'A.create_date DESC';
-        $objQuery->setOrder($order);
-        //検索結果の取得
-        //レビュー情報のカラムの取得
-        $col = 'review_id, A.product_id, reviewer_name, sex, recommend_level, ';
-        $col .= 'reviewer_url, title, comment, A.status, A.create_date, A.update_date, name';
-        $from = 'dtb_review AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id ';
-        $arrReview = $objQuery->select($col, $from, $where, $arrWhereVal);
+        $params = array(
+            'query' => $query,
+            'limit' => $page_max,
+            'offset' => $startno
+        );
+        $arrReview = $objReview->find($params);
 
         return $arrReview;
     }
+
+    /**
+     * SC_Helper_Reviewインスタンスへ渡す検索条件の配列を作成.
+     *
+     * @param array $data
+     * @return array
+     */
+    private function makeQuery($data = array()) {
+        $query = array();
+
+        foreach ($data AS $key => $val) {
+            if (empty($val)) continue;
+
+            switch ($key) {
+                case 'search_reviewer_name':
+                    $query['reviewer_name'] = $val;
+                    break;
+
+                case 'search_reviewer_url':
+                    $query['reviewer_url'] = $val;
+                    break;
+
+                case 'search_name':
+                    $query['product_name'] = $val;
+                    break;
+
+                case 'search_product_code':
+                    $query['product_code'] = $val;
+                    break;
+
+                case 'search_sex':
+                    $query['reviewer_sex'] = $val;
+                    break;
+
+                case 'search_recommend_level':
+                    $query['recommend_level'] = $val;
+                    break;
+
+                case 'search_startyear':
+                    if (isset($_POST['search_startyear']) && isset($_POST['search_startmonth']) && isset($_POST['search_startday'])) {
+                        $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_startyear'], $_POST['search_startmonth'], $_POST['search_startday']);
+                        $query['date_from'] = $date;
+                    }
+                    break;
+
+                case 'search_endyear':
+                    if (isset($_POST['search_startyear']) && isset($_POST['search_startmonth']) && isset($_POST['search_startday'])) {
+                        $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_endyear'], $_POST['search_endmonth'], $_POST['search_endday']);
+                        $end_date = date('Y/m/d',strtotime('1 day' ,strtotime($date)));
+                        $query['date_to'] = $end_date;
+                    }
+                    break;
+
+                default:
+                    break;
+            }
+
+        }
+
+        return $query;
+    }
 }
Index: /branches/version-2_13-dev/data/class/pages/admin/products/LC_Page_Admin_Products_ReviewEdit.php
===================================================================
--- /branches/version-2_13-dev/data/class/pages/admin/products/LC_Page_Admin_Products_ReviewEdit.php	(revision 23124)
+++ /branches/version-2_13-dev/data/class/pages/admin/products/LC_Page_Admin_Products_ReviewEdit.php	(revision 23461)
@@ -72,4 +72,5 @@
     public function action()
     {
+        $objReview = new SC_Helper_Review_Ex();
         // パラメーター情報の初期化
         $objFormParam = new SC_FormParam_Ex();
@@ -88,7 +89,8 @@
                 if (SC_Utils_Ex::isBlank($this->arrErr)) {
                     // レビュー情報の更新
-                    $this->lfRegistReviewData($this->arrForm['review_id'], $objFormParam);
+                    $arrValues = $objFormParam->getDbArray();
+                    $objReview->save($arrValues);
                     // レビュー情報のDB取得
-                    $this->arrForm = $this->lfGetReviewData($this->arrForm['review_id']);
+                    $this->arrForm = $objReview->get($this->arrForm['review_id']);
                     $this->tpl_onload = "alert('登録が完了しました。');";
                 }
@@ -96,5 +98,5 @@
             default:
                 // レビュー情報のDB取得
-                $this->arrForm = $this->lfGetReviewData($this->arrForm['review_id']);
+                $this->arrForm = $objReview->get($this->arrForm['review_id']);
                 break;
         }
@@ -125,39 +127,3 @@
         $objFormParam->addParam('コメント', 'comment', LTEXT_LEN, 'KVa', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK'));
     }
-
-    /**
-     * レビュー情報のDB取得
-     *
-     * @param  integer $review_id レビューID
-     * @return array   レビュー情報
-     */
-    public function lfGetReviewData($review_id)
-    {
-        $objQuery =& SC_Query_Ex::getSingletonInstance();
-        $select='review_id, A.product_id, reviewer_name, sex, recommend_level, ';
-        $select.='reviewer_url, title, comment, A.status, A.create_date, A.update_date, name';
-        $from = 'dtb_review AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id ';
-        $where = 'A.del_flg = 0 AND B.del_flg = 0 AND review_id = ? ';
-        $arrReview = $objQuery->select($select, $from, $where, array($review_id));
-        if (empty($arrReview)) {
-            SC_Utils_Ex::sfDispError('');
-        }
-
-        return $arrReview[0];
-    }
-
-    /**
-     * レビュー情報の更新
-     *
-     * @param  integer      $review_id    レビューID
-     * @param  SC_FormParam $objFormParam SC_FormParam インスタンス
-     * @return void
-     */
-    public function lfRegistReviewData($review_id, &$objFormParam)
-    {
-        $objQuery =& SC_Query_Ex::getSingletonInstance();
-        $arrValues = $objFormParam->getDbArray();
-        $arrValues['update_date'] = 'CURRENT_TIMESTAMP';
-        $objQuery->update('dtb_review', $arrValues, 'review_id = ?', array($review_id));
-    }
 }
Index: /branches/version-2_13-dev/data/class/pages/products/LC_Page_Products_Review.php
===================================================================
--- /branches/version-2_13-dev/data/class/pages/products/LC_Page_Products_Review.php	(revision 23367)
+++ /branches/version-2_13-dev/data/class/pages/products/LC_Page_Products_Review.php	(revision 23461)
@@ -186,15 +186,9 @@
 
     //登録実行
-    public function lfRegistRecommendData(&$objFormParam)
-    {
-        $objQuery =& SC_Query_Ex::getSingletonInstance();
+    public function lfRegistRecommendData(SC_FormParam &$objFormParam)
+    {
+        $arrRegist = $objFormParam->getDbArray();
+
         $objCustomer = new SC_Customer_Ex();
-
-        $arrRegist = $objFormParam->getDbArray();
-
-        $arrRegist['create_date'] = 'CURRENT_TIMESTAMP';
-        $arrRegist['update_date'] = 'CURRENT_TIMESTAMP';
-        $arrRegist['creator_id'] = '0';
-
         if ($objCustomer->isLoginSuccess(true)) {
             $arrRegist['customer_id'] = $objCustomer->getValue('customer_id');
@@ -202,8 +196,6 @@
 
         //-- 登録実行
-        $objQuery->begin();
-        $arrRegist['review_id'] = $objQuery->nextVal('dtb_review_review_id');
-        $objQuery->insert('dtb_review', $arrRegist);
-        $objQuery->commit();
+        $objReview = new SC_Helper_Review_Ex();
+        $objReview->save($arrRegist);
     }
 }
Index: /branches/version-2_13-dev/data/class/pages/products/LC_Page_Products_Detail.php
===================================================================
--- /branches/version-2_13-dev/data/class/pages/products/LC_Page_Products_Detail.php	(revision 23460)
+++ /branches/version-2_13-dev/data/class/pages/products/LC_Page_Products_Detail.php	(revision 23461)
@@ -305,5 +305,6 @@
         $this->subImageFlag = $this->lfSetFile($this->objUpFile, $this->arrProduct, $this->arrFile);
         //レビュー情報の取得
-        $this->arrReview = $this->lfGetReviewData($product_id);
+        $objReview = new SC_Helper_Review_Ex();
+        $this->arrReview = $objReview->getListByProductId($product_id);
 
         //関連商品情報表示
@@ -520,25 +521,4 @@
 
     /**
-     * 商品ごとのレビュー情報を取得する
-     *
-     * @param int $product_id
-     * @return array
-     */
-    public function lfGetReviewData($product_id)
-    {
-        $objQuery =& SC_Query_Ex::getSingletonInstance();
-        //商品ごとのレビュー情報を取得する
-        $col = 'create_date, reviewer_url, reviewer_name, recommend_level, title, comment';
-        $from = 'dtb_review';
-        $where = 'del_flg = 0 AND status = 1 AND product_id = ?';
-        $objQuery->setOrder('create_date DESC');
-        $objQuery->setLimit(REVIEW_REGIST_MAX);
-        $arrWhereVal = array($product_id);
-        $arrReview = $objQuery->select($col, $from, $where, $arrWhereVal);
-
-        return $arrReview;
-    }
-
-    /**
      * ファイルの情報をセットする
      *
Index: /branches/version-2_13-dev/data/class/util/SC_Utils.php
===================================================================
--- /branches/version-2_13-dev/data/class/util/SC_Utils.php	(revision 23457)
+++ /branches/version-2_13-dev/data/class/util/SC_Utils.php	(revision 23461)
@@ -265,5 +265,5 @@
 
     /* DB用日付文字列取得 */
-    public function sfGetTimestamp($year, $month, $day, $last = false)
+    public static function sfGetTimestamp($year, $month, $day, $last = false)
     {
         if ($year != '' && $month != '' && $day != '') {
@@ -1725,5 +1725,5 @@
      * @return integer 1ページあたりの最大表示件数
      */
-    public function sfGetSearchPageMax($search_page_max)
+    public static function sfGetSearchPageMax($search_page_max)
     {
         if (SC_Utils_Ex::sfIsInt($search_page_max) && $search_page_max > 0) {
