Index: /branches/version-2_12-dev/data/class_extends/helper_extends/SC_Helper_Kiyaku_Ex.php
===================================================================
--- /branches/version-2_12-dev/data/class_extends/helper_extends/SC_Helper_Kiyaku_Ex.php	(revision 22570)
+++ /branches/version-2_12-dev/data/class_extends/helper_extends/SC_Helper_Kiyaku_Ex.php	(revision 22570)
@@ -0,0 +1,39 @@
+<?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.
+ */
+
+// {{{ requires
+require_once CLASS_REALDIR . 'helper/SC_Helper_Kiyaku.php';
+
+/**
+ * 会員規約を管理するヘルパークラス(拡張).
+ *
+ * LC_Helper_Kiyaku をカスタマイズする場合はこのクラスを編集する.
+ *
+ * @package Helper
+ * @author pineray
+ * @version $Id:$
+ */
+class SC_Helper_Kiyaku_Ex extends SC_Helper_Kiyaku
+{
+    //put your code here
+}
Index: /branches/version-2_12-dev/data/class/helper/SC_Helper_Kiyaku.php
===================================================================
--- /branches/version-2_12-dev/data/class/helper/SC_Helper_Kiyaku.php	(revision 22570)
+++ /branches/version-2_12-dev/data/class/helper/SC_Helper_Kiyaku.php	(revision 22570)
@@ -0,0 +1,160 @@
+<?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_Kiyaku
+{
+    /**
+     * 会員規約の情報を取得.
+     * 
+     * @param integer $kiyaku_id 会員規約ID
+     * @param boolean $has_deleted 削除された会員規約も含む場合 true; 初期値 false
+     * @return array
+     */
+    public function get($kiyaku_id, $has_deleted = false)
+    {
+        $objQuery =& SC_Query_Ex::getSingletonInstance();
+        $where = 'kiyaku_id = ?';
+        if (!$has_deleted) {
+            $where .= ' AND del_flg = 0';
+        }
+        $arrRet = $objQuery->select('*', 'dtb_kiyaku', $where, array($kiyaku_id));
+        return $arrRet[0];
+    }
+
+    /**
+     * 会員規約一覧の取得.
+     *
+     * @param boolean $has_deleted 削除された会員規約も含む場合 true; 初期値 false
+     * @return array
+     */
+    public function getList($has_deleted = false)
+    {
+        $objQuery =& SC_Query_Ex::getSingletonInstance();
+        $col = 'kiyaku_id, kiyaku_title, kiyaku_text';
+        $where = '';
+        if (!$has_deleted) {
+            $where .= 'del_flg = 0';
+        }
+        $table = 'dtb_kiyaku';
+        $objQuery->setOrder('rank DESC');
+        $arrRet = $objQuery->select($col, $table, $where);
+        return $arrRet;
+    }
+
+    /**
+     * 会員規約の登録.
+     * 
+     * @param array $sqlval
+     * @return multiple 登録成功:会員規約ID, 失敗:FALSE
+     */
+    public function save($sqlval)
+    {
+        $objQuery =& SC_Query_Ex::getSingletonInstance();
+
+        $kiyaku_id = $sqlval['kiyaku_id'];
+        $sqlval['update_date'] = 'CURRENT_TIMESTAMP';
+        // 新規登録
+        if ($kiyaku_id == '') {
+            // INSERTの実行
+            $sqlval['rank'] = $objQuery->max('rank', 'dtb_kiyaku') + 1;
+            $sqlval['create_date'] = 'CURRENT_TIMESTAMP';
+            $sqlval['kiyaku_id'] = $objQuery->nextVal('dtb_kiyaku_kiyaku_id');
+            $ret = $objQuery->insert('dtb_kiyaku', $sqlval);
+        // 既存編集
+        } else {
+            unset($sqlval['creator_id']);
+            unset($sqlval['create_date']);
+            $where = 'kiyaku_id = ?';
+            $ret = $objQuery->update('dtb_kiyaku', $sqlval, $where, array($kiyaku_id));
+        }
+        return ($ret) ? $sqlval['kiyaku_id'] : FALSE;
+    }
+
+    /**
+     * 会員規約の削除.
+     * 
+     * @param integer $kiyaku_id 会員規約ID
+     * @return void
+     */
+    public function delete($kiyaku_id)
+    {
+        $objDb = new SC_Helper_DB_Ex();
+        // ランク付きレコードの削除
+        $objDb->sfDeleteRankRecord('dtb_kiyaku', 'kiyaku_id', $kiyaku_id);
+    }
+
+    /**
+     * 会員規約の表示順をひとつ上げる.
+     * 
+     * @param integer $kiyaku_id 会員規約ID
+     * @return void
+     */
+    public function rankUp($kiyaku_id)
+    {
+        $objDb = new SC_Helper_DB_Ex();
+        $objDb->sfRankUp('dtb_kiyaku', 'kiyaku_id', $kiyaku_id);
+    }
+
+    /**
+     * 会員規約の表示順をひとつ下げる.
+     * 
+     * @param integer $kiyaku_id 会員規約ID
+     * @return void
+     */
+    public function rankDown($kiyaku_id)
+    {
+        $objDb = new SC_Helper_DB_Ex();
+        $objDb->sfRankDown('dtb_kiyaku', 'kiyaku_id', $kiyaku_id);
+    }
+
+    /**
+     * 同じタイトルの規約が存在するか確認.
+     * 
+     * @param string $title 規約タイトル
+     * @param integer $kiyaku_id 会員規約ID
+     * @return boolean 同名のタイトルが存在:TRUE
+     */
+    public function isTitleExist($title, $kiyaku_id = NULL)
+    {
+        $objQuery =& SC_Query_Ex::getSingletonInstance();
+        
+        $where  = 'del_flg = 0 AND kiyaku_title = ?';
+        $arrVal = array($title);
+        
+        if(!SC_Utils_Ex::isBlank($kiyaku_id)) {
+            $where   .= ' AND kiyaku_id <> ?';
+            $arrVal[] = $kiyaku_id;
+        }
+        
+        $arrRet = $objQuery->select('kiyaku_id, kiyaku_title', 'dtb_kiyaku', $where, $arrVal);
+
+        return !SC_Utils_Ex::isBlank($arrRet);
+    }
+}
Index: /branches/version-2_12-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Kiyaku.php
===================================================================
--- /branches/version-2_12-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Kiyaku.php	(revision 22567)
+++ /branches/version-2_12-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Kiyaku.php	(revision 22570)
@@ -72,5 +72,5 @@
     {
 
-        $objDb = new SC_Helper_DB_Ex();
+        $objKiyaku = new SC_Helper_Kiyaku_Ex();
 
         $mode = $this->getMode();
@@ -87,5 +87,5 @@
             case 'confirm':
                 // エラーチェック
-                $this->arrErr = $this->lfCheckError($objFormParam);
+                $this->arrErr = $this->lfCheckError($objFormParam, $objKiyaku);
                 if (!SC_Utils_Ex::isBlank($this->arrErr['kiyaku_id'])) {
                     trigger_error('', E_USER_ERROR);
@@ -93,13 +93,9 @@
                 }
 
-                // POST値の引き継ぎ
-                $arrParam = $objFormParam->getHashArray();
                 if (SC_Utils_Ex::isBlank($this->arrErr)) {
-                    if (SC_Utils_Ex::isBlank($kiyaku_id)) {
-                        $res_kiyaku_id = $this->lfInsertClass($arrParam, $_SESSION['member_id']);    // 新規作成
-                    } else {
-                        $res_kiyaku_id = $this->lfUpdateClass($arrParam, $kiyaku_id);    // 既存編集
-                    }
-
+                    // POST値の引き継ぎ
+                    $arrParam = $objFormParam->getHashArray();
+                    // 登録実行
+                    $res_kiyaku_id = $this->doRegist($kiyaku_id, $arrParam, $objKiyaku);
                     if ($res_kiyaku_id !== FALSE) {
                         // 完了メッセージ
@@ -114,5 +110,5 @@
             // 削除
             case 'delete':
-                $objDb->sfDeleteRankRecord('dtb_kiyaku', 'kiyaku_id', $kiyaku_id, '', true);
+                $objKiyaku->delete($kiyaku_id);
                 break;
 
@@ -120,6 +116,6 @@
             case 'pre_edit':
                 // 編集項目を取得する。
-                $arrKiyakuData = $this->lfGetKiyakuDataByKiyakuID($kiyaku_id);
-                $objFormParam->setParam($arrKiyakuData[0]);
+                $arrKiyakuData = $objKiyaku->get($kiyaku_id);
+                $objFormParam->setParam($arrKiyakuData);
 
                 // 編集中の規約IDを渡す
@@ -128,5 +124,5 @@
 
             case 'down':
-                $objDb->sfRankDown('dtb_kiyaku', 'kiyaku_id', $kiyaku_id);
+                $objKiyaku->rankDown($kiyaku_id);
 
                 // 再表示
@@ -135,5 +131,5 @@
 
             case 'up':
-                $objDb->sfRankUp('dtb_kiyaku', 'kiyaku_id', $kiyaku_id);
+                $objKiyaku->rankUp($kiyaku_id);
 
                 // 再表示
@@ -148,5 +144,5 @@
 
         // 規約一覧を取得
-        $this->arrKiyaku = $this->lfGetKiyakuList();
+        $this->arrKiyaku = $objKiyaku->getList();
 }
 
@@ -161,51 +157,17 @@
     }
 
-    /* DBへの挿入 */
-    function lfInsertClass($arrData, $member_id)
-    {
-        $objQuery =& SC_Query_Ex::getSingletonInstance();
-        // INSERTする値を作成する。
-        $sqlval = array();
-        $sqlval['kiyaku_title'] = $arrData['kiyaku_title'];
-        $sqlval['kiyaku_text'] = $arrData['kiyaku_text'];
-        $sqlval['creator_id'] = $member_id;
-        $sqlval['rank'] = $objQuery->max('rank', 'dtb_kiyaku') + 1;
-        $sqlval['update_date'] = 'CURRENT_TIMESTAMP';
-        $sqlval['create_date'] = 'CURRENT_TIMESTAMP';
-        // INSERTの実行
-        $sqlval['kiyaku_id'] = $objQuery->nextVal('dtb_kiyaku_kiyaku_id');
-        $ret = $objQuery->insert('dtb_kiyaku', $sqlval);
-        return ($ret) ? $sqlval['kiyaku_id'] : FALSE;
-    }
-
-    function lfGetKiyakuDataByKiyakuID($kiyaku_id)
-    {
-        $objQuery =& SC_Query_Ex::getSingletonInstance();
-
-        $where = 'kiyaku_id = ?';
-        return $objQuery->select('kiyaku_text, kiyaku_title', 'dtb_kiyaku', $where, array($kiyaku_id));
-    }
-
-    function lfGetKiyakuList()
-    {
-        $objQuery =& SC_Query_Ex::getSingletonInstance();
-
-        $where = 'del_flg <> 1';
-        $objQuery->setOrder('rank DESC');
-        return $objQuery->select('kiyaku_title, kiyaku_text, kiyaku_id', 'dtb_kiyaku', $where);
-    }
-
-    /* DBへの更新 */
-    function lfUpdateClass($arrData, $kiyaku_id)
-    {
-        $objQuery =& SC_Query_Ex::getSingletonInstance();
-        // UPDATEする値を作成する。
-        $sqlval['kiyaku_title'] = $arrData['kiyaku_title'];
-        $sqlval['kiyaku_text'] = $arrData['kiyaku_text'];
-        $sqlval['update_date'] = 'CURRENT_TIMESTAMP';
-        $where = 'kiyaku_id = ?';
-        // UPDATEの実行
-        $ret = $objQuery->update('dtb_kiyaku', $sqlval, $where, array($kiyaku_id));
-        return ($ret) ? $kiyaku_id : FALSE;
+    /**
+     * 登録処理を実行.
+     * 
+     * @param integer $kiyaku_id
+     * @param array $sqlval
+     * @param object $objKiyaku
+     * @return multiple
+     */
+    function doRegist($kiyaku_id, $sqlval, SC_Helper_Kiyaku_Ex &$objKiyaku)
+    {
+        $sqlval['kiyaku_id'] = $kiyaku_id;
+        $sqlval['creator_id'] = $_SESSION['member_id'];
+        return $objKiyaku->save($sqlval);
     }
 
@@ -232,24 +194,15 @@
      *
      * @param string $mode
+     * @param object $objKiyaku
      * @return array
      */
-    function lfCheckError($objFormParam)
+    function lfCheckError($objFormParam, SC_Helper_Kiyaku_Ex &$objKiyaku)
     {
         $arrErr = $objFormParam->checkError();
         $arrForm = $objFormParam->getHashArray();
-        $objQuery =& SC_Query_Ex::getSingletonInstance();
-        
-        $where  = 'del_flg = 0 AND kiyaku_title = ?';
-        $arrVal = array($arrForm['kiyaku_title']);
-        
-        if(!SC_Utils_Ex::isBlank($arrForm['kiyaku_id'])) {
-            $where   .= ' AND kiyaku_id <> ?';
-            $arrVal[] = $arrForm['kiyaku_id'];
-        }
-        
-        $arrRet = $objQuery->select('kiyaku_id, kiyaku_title', 'dtb_kiyaku', $where, $arrVal);
-
+
+        $isTitleExist = $objKiyaku->isTitleExist($arrForm['kiyaku_title'], $arrForm['kiyaku_id']);
         // 編集中のレコード以外に同じ名称が存在する場合
-        if (!SC_Utils_Ex::isBlank($arrRet)) {
+        if ($isTitleExist) {
             $arrErr['name'] = '※ 既に同じ内容の登録が存在します。<br />';
         }
Index: /branches/version-2_12-dev/data/class/pages/guide/LC_Page_Guide_Kiyaku.php
===================================================================
--- /branches/version-2_12-dev/data/class/pages/guide/LC_Page_Guide_Kiyaku.php	(revision 22567)
+++ /branches/version-2_12-dev/data/class/pages/guide/LC_Page_Guide_Kiyaku.php	(revision 22570)
@@ -92,7 +92,6 @@
     function lfGetKiyaku($index, &$objPage)
     {
-        $objQuery =& SC_Query_Ex::getSingletonInstance();
-        $objQuery->setOrder('rank DESC');
-        $arrKiyaku = $objQuery->select('kiyaku_title, kiyaku_text', 'dtb_kiyaku', 'del_flg <> 1');
+        $objKiyaku = new SC_Helper_Kiyaku_Ex();
+        $arrKiyaku = $objKiyaku->getList();
 
         $number = count($arrKiyaku);
Index: /branches/version-2_12-dev/data/class/pages/entry/LC_Page_Entry_Kiyaku.php
===================================================================
--- /branches/version-2_12-dev/data/class/pages/entry/LC_Page_Entry_Kiyaku.php	(revision 22567)
+++ /branches/version-2_12-dev/data/class/pages/entry/LC_Page_Entry_Kiyaku.php	(revision 22570)
@@ -120,9 +120,6 @@
     function lfGetKiyakuData()
     {
-
-        $objQuery   = SC_Query_Ex::getSingletonInstance();
-
-        $objQuery->setOrder('rank DESC');
-        $arrKiyaku  = $objQuery->select('kiyaku_title, kiyaku_text', 'dtb_kiyaku', 'del_flg <> 1');
+        $objKiyaku = new SC_Helper_Kiyaku_Ex();
+        $arrKiyaku = $objKiyaku->getList();
 
         return $arrKiyaku;
