[Svn-src-all:1282] [version-2_5-dev 20171] #964 リファクタリング 共通処理をヘルパークラスへ移動

coelacanth admin @ mail.ec-cube.net
2011年 2月 16日 (水) 14:12:31 JST


Subversion committed to /home/svn/open 20171
http://svn.ec-cube.net/open_trac/changeset/20171
┌────────────────────────────┐
│更新者 :  coelacanth                                   │
│更新日時:  2011-02-16 14:12:30 +0900 (水, 16  2月 2011)│
└────────────────────────────┘

Log:
--------------------------------------------------------
#964 リファクタリング 共通処理をヘルパークラスへ移動

Changed:                      [U:修正,A:追加,D:削除]
--------------------------------------------------------
U   branches/version-2_5-dev/data/class/helper/SC_Helper_DB.php
U   branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis.php
U   branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Point.php
U   branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Tradelaw.php

変更: branches/version-2_5-dev/data/class/helper/SC_Helper_DB.php
===================================================================
--- branches/version-2_5-dev/data/class/helper/SC_Helper_DB.php	2011-02-15 10:31:00 UTC (rev 20170)
+++ branches/version-2_5-dev/data/class/helper/SC_Helper_DB.php	2011-02-16 05:12:30 UTC (rev 20171)
@@ -137,25 +137,42 @@
      * 店舗基本情報を取得する.
      *
      * @param boolean $force 強制的にDB取得するか
+     * @param string $col 取得カラムを指定する
      * @return array 店舗基本情報の配列
      */
-    function sfGetBasisData($force = false) {
+    function sfGetBasisData($force = false, $col = "") {
         static $data;
 
         if ($force || !isset($data)) {
             $objQuery =& SC_Query::getSingletonInstance();
-            $arrRet = $objQuery->select('*', 'dtb_baseinfo');
 
+            if ($col === "") {
+                $arrRet = $objQuery->select('*', 'dtb_baseinfo');
+            } else {
+                $arrRet = $objQuery->select($col, "dtb_baseinfo");
+            }
+
             if (isset($arrRet[0])) {
                 $data = $arrRet[0];
             } else {
                 $data = array();
             }
         }
-
         return $data;
     }
 
+    /**
+     * 基本情報の登録数を取得する
+     *
+     * @return int
+     */
+    function sfGetBasisCount() {
+        $objQuery =& SC_Query::getSingletonInstance();
+
+        return $objQuery->count("dtb_baseinfo");
+    }
+
+
     /* 選択中のアイテムのルートカテゴリIDを取得する */
     function sfGetRootId() {
 

変更: branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis.php	2011-02-15 10:31:00 UTC (rev 20170)
+++ branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis.php	2011-02-16 05:12:30 UTC (rev 20171)
@@ -83,8 +83,9 @@
         // 認証可否の判定
         SC_Utils_Ex::sfIsSuccess($objSess);
 
-        $cnt = $this->lfGetBaseInfoCount();
+        $objDb = new SC_Helper_DB_Ex();
 
+        $cnt = $objDb->sfGetBasisCount();
         if ($cnt > 0) {
             $this->tpl_mode = "update";
         } else {
@@ -122,8 +123,8 @@
         } else {
             $arrCol = $this->lfGetCol();
             $col    = SC_Utils_Ex::sfGetCommaList($arrCol);
-            $arrRet = $this->lfGetBaseInfoData($col);
-            $this->arrForm = $arrRet[0];
+            $arrRet = $objDb->sfGetBasisData(true, $col);
+            $this->arrForm = $arrRet;
 
             $regular_holiday_ids = explode('|', $this->arrForm['regular_holiday_ids']);
             $this->arrForm['regular_holiday_ids'] = $regular_holiday_ids;
@@ -140,28 +141,6 @@
         parent::destroy();
     }
 
-    /**
-     * 基本情報の登録数を取得する
-     *
-     * @return int
-     */
-    function lfGetBaseInfoCount() {
-        $objQuery =& SC_Query::getSingletonInstance();
-
-        return $objQuery->count("dtb_baseinfo");
-    }
-
-    /**
-     * 基本情報のデータを取得する
-     *
-     * @return array
-     */
-    function lfGetBaseInfoData($col) {
-        $objQuery =& SC_Query::getSingletonInstance();
-
-        return $objQuery->select($col, "dtb_baseinfo");
-    }
-
     // 基本情報用のカラムを取り出す。
     function lfGetCol() {
         $arrCol = array(

変更: branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Point.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Point.php	2011-02-15 10:31:00 UTC (rev 20170)
+++ branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Point.php	2011-02-16 05:12:30 UTC (rev 20171)
@@ -76,6 +76,8 @@
         // 認証可否の判定
         SC_Utils_Ex::sfIsSuccess($objSess);
 
+        $objDb = new SC_Helper_DB_Ex();
+
         // パラメータ管理クラス
         $this->objFormParam = new SC_FormParam();
         // パラメータ情報の初期化
@@ -83,7 +85,7 @@
         // POST値の取得
         $this->objFormParam->setParam($_POST);
 
-        $cnt = $this->lfGetBaseInfoCount();
+        $cnt = $objDb->sfGetBasisCount();
         if ($cnt > 0) {
             $this->tpl_mode = "update";
         } else {
@@ -113,8 +115,8 @@
         } else {
             $arrCol = $this->objFormParam->getKeyList(); // キー名一覧を取得
             $col    = SC_Utils_Ex::sfGetCommaList($arrCol);
-            $arrRet = $this->lfGetBaseInfoData($col);
-            $this->objFormParam->setParam($arrRet[0]);
+            $arrRet = $objDb->sfGetBasisData(true, $col);
+            $this->objFormParam->setParam($arrRet);
         }
 
         $this->arrForm = $this->objFormParam->getFormParamList();
@@ -129,28 +131,6 @@
         parent::destroy();
     }
 
-    /**
-     * 基本情報の登録数を取得する
-     *
-     * @return int
-     */
-    function lfGetBaseInfoCount() {
-        $objQuery =& SC_Query::getSingletonInstance();
-
-        return $objQuery->count("dtb_baseinfo");
-    }
-
-    /**
-     * 基本情報のデータを取得する
-     *
-     * @return array
-     */
-    function lfGetBaseInfoData($col) {
-        $objQuery =& SC_Query::getSingletonInstance();
-
-        return $objQuery->select($col, "dtb_baseinfo");
-    }
-
     /* パラメータ情報の初期化 */
     function lfInitParam() {
         $this->objFormParam->addParam("ポイント付与率", "point_rate", PERCENTAGE_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));

変更: branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Tradelaw.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Tradelaw.php	2011-02-15 10:31:00 UTC (rev 20170)
+++ branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Tradelaw.php	2011-02-16 05:12:30 UTC (rev 20171)
@@ -79,6 +79,8 @@
         // 認証可否の判定
         SC_Utils_Ex::sfIsSuccess($objSess);
 
+        $objDb = new SC_Helper_DB_Ex();
+
         // パラメータ管理クラス
         $this->objFormParam = new SC_FormParam();
         // パラメータ情報の初期化
@@ -86,8 +88,7 @@
         // POST値の取得
         $this->objFormParam->setParam($_POST);
 
-        $cnt = $this->lfGetBaseInfoCount();
-
+        $cnt = $objDb->sfGetBasisCount();
         if ($cnt > 0) {
             $this->tpl_mode = "update";
         } else {
@@ -117,8 +118,8 @@
         } else {
             $arrCol = $this->objFormParam->getKeyList(); // キー名一覧を取得
             $col    = SC_Utils_Ex::sfGetCommaList($arrCol);
-            $arrRet = $this->lfGetBaseInfoData($col);
-            $this->objFormParam->setParam($arrRet[0]);
+            $arrRet = $objDb->sfGetBasisData(true, $col);
+            $this->objFormParam->setParam($arrRet);
         }
 
         $this->arrForm = $this->objFormParam->getFormParamList();
@@ -133,28 +134,6 @@
         parent::destroy();
     }
 
-    /**
-     * 基本情報の登録数を取得する
-     *
-     * @return int
-     */
-    function lfGetBaseInfoCount() {
-        $objQuery =& SC_Query::getSingletonInstance();
-
-        return $objQuery->count("dtb_baseinfo");
-    }
-
-    /**
-     * 基本情報のデータを取得する
-     *
-     * @return array
-     */
-    function lfGetBaseInfoData($col) {
-        $objQuery =& SC_Query::getSingletonInstance();
-
-        return $objQuery->select($col, "dtb_baseinfo");
-    }
-
     /* パラメータ情報の初期化 */
     function lfInitParam() {
         $this->objFormParam->addParam("販売業者", "law_company", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));




Svn-src-all メーリングリストの案内