[Svn-src-all:1394] [version-2_5-dev 20284] refs #982 リファクタリンク:モハイルカテコリ一覧

tao admin @ mail.ec-cube.net
2011年 2月 21日 (月) 02:51:58 JST


Subversion committed to /home/svn/open 20284
http://svn.ec-cube.net/open_trac/changeset/20284
┌────────────────────────────┐
│更新者 :  tao                                          │
│更新日時:  2011-02-21 02:51:58 +0900 (月, 21  2月 2011)│
└────────────────────────────┘

Log:
--------------------------------------------------------
refs #982 リファクタリンク:モハイルカテコリ一覧

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/products/LC_Page_Products_CategoryList.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-20 17:30:21 UTC (rev 20283)
+++ branches/version-2_5-dev/data/class/helper/SC_Helper_DB.php	2011-02-20 17:51:58 UTC (rev 20284)
@@ -253,7 +253,7 @@
         $objQuery->setOption("ORDER BY rank DESC");
         $arrRet = $objQuery->select($col, $from, $where);
 
-        $arrParentID = $this->sfGetParents('dtb_category', 'parent_category_id', 'category_id', $parent_category_id);
+        $arrParentID = SC_Helper_DB_Ex::sfGetParents('dtb_category', 'parent_category_id', 'category_id', $parent_category_id);
 
         foreach($arrRet as $key => $array) {
             foreach($arrParentID as $val) {

変更: branches/version-2_5-dev/data/class/pages/products/LC_Page_Products_CategoryList.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/products/LC_Page_Products_CategoryList.php	2011-02-20 17:30:21 UTC (rev 20283)
+++ branches/version-2_5-dev/data/class/pages/products/LC_Page_Products_CategoryList.php	2011-02-20 17:51:58 UTC (rev 20284)
@@ -65,7 +65,10 @@
         $this->lfCheckCategoryId();
 
         // カテゴリー情報を取得する。
-        $this->lfGetCategories(@$_GET['category_id'], true, $this);
+        $objFormParam = $this->lfInitParam($_REQUEST);
+        $arrCategoryData = $this->lfGetCategories($objFormParam->getValue('category_id'), true, $this);
+        $this->arrCategory = $arrCategoryData["arrCategory"];
+        $this->arrChildren = $arrCategoryData["arrChildren"];
         $this->tpl_subtitle = $this->arrCategory['category_name'];
     }
 
@@ -79,16 +82,11 @@
     }
 
     /* カテゴリIDの正当性チェック */
-    function lfCheckCategoryId() {
-        $objDb = new SC_Helper_DB_Ex();
-        $category_id = $_POST['category_id'] ? $_POST['category_id'] : $_GET['category_id'];
-        if (!defined('MOBILE_SITE') && !isset($_REQUEST['category_id']))
-            SC_Utils_Ex::sfDispSiteError(CATEGORY_NOT_FOUND);
-        if ($category_id
-                && (!SC_Utils_Ex::sfIsInt($category_id)
-                || SC_Utils_Ex::sfIsZeroFilling($category_id)
-                || !$objDb->sfIsRecord('dtb_category', 'category_id', (array)$category_id, 'del_flg = 0')))
-            SC_Utils_Ex::sfDispSiteError(CATEGORY_NOT_FOUND);
+    function lfCheckCategoryId($category_id) {
+        if ($category_id && !SC_Helper_DB_Ex::sfIsRecord('dtb_category', 'category_id', (array)$category_id, 'del_flg = 0')){
+            return 0;
+        }
+        return $category_id;
     }
 
     /**
@@ -101,10 +99,8 @@
      * @return void
      */
     function lfGetCategories($category_id, $count_check = false, &$objPage) {
-        $objDb = new SC_Helper_DB_Ex();
         // カテゴリーの正しいIDを取得する。
-        $arrCategory_id = $objDb->sfGetCategoryId('', $category_id);
-        $category_id = $arrCategory_id[0];
+        $category_id = $this->lfCheckCategoryId($category_id);
         if ($category_id == 0) {
             SC_Utils_Ex::sfDispSiteError(CATEGORY_NOT_FOUND);
         }
@@ -112,7 +108,7 @@
         $arrCategory = null;	// 選択されたカテゴリー
         $arrChildren = array();	// 子カテゴリー
 
-        $arrAll = $objDb->sfGetCatTree($category_id, $count_check);
+        $arrAll = SC_Helper_DB_Ex::sfGetCatTree($category_id, $count_check);
         foreach ($arrAll as $category) {
             // 選択されたカテゴリーの場合
             if ($category['category_id'] == $category_id) {
@@ -148,9 +144,24 @@
             array_unshift($arrChildren, $arrCategory);
         }
 
-        // 結果を格納する。
-        $objPage->arrCategory = $arrCategory;
-        $objPage->arrChildren = $arrChildren;
+        return array("arrChildren"=>$arrChildren, "arrCategory"=>$arrCategory);
     }
+
+    /**
+     * ユーザ入力値の処理
+     *
+     * @return object
+     */
+    function lfInitParam($arrRequest) {
+        $objFormParam = new SC_FormParam();
+        $objFormParam->addParam("カテゴリID", "category_id", INT_LEN, "n", array('NUM_CHECK',"MAX_LENGTH_CHECK"));
+        // 値の取得
+        $objFormParam->setParam($arrRequest);
+        // 入力値の変換
+        $objFormParam->convParam();
+        return $objFormParam;        
+    }
+
+
 }
 ?>




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