Index: branches/version-2_12-dev/data/class/pages/products/LC_Page_Products_List.php
===================================================================
--- branches/version-2_12-dev/data/class/pages/products/LC_Page_Products_List.php	(revision 21949)
+++ branches/version-2_12-dev/data/class/pages/products/LC_Page_Products_List.php	(revision 21953)
@@ -135,80 +135,9 @@
 
             case 'json':
-                $this->arrProducts = $this->setStatusDataTo($this->arrProducts, $this->arrSTATUS, $this->arrSTATUS_IMAGE);
-                $this->arrProducts = $objProduct->setPriceTaxTo($this->arrProducts);
-
-                // 一覧メイン画像の指定が無い商品のための処理
-                foreach ($this->arrProducts as $key=>$val) {
-                    $this->arrProducts[$key]['main_list_image'] = SC_Utils_Ex::sfNoImageMainList($val['main_list_image']);
-                }
-
-                echo SC_Utils_Ex::jsonEncode($this->arrProducts);
-                SC_Response_Ex::actionExit();
+                $this->doJson($objProduct);
                 break;
 
             default:
-
-                //商品一覧の表示処理
-                $strnavi            = $this->objNavi->strnavi;
-                // 表示文字列
-                $this->tpl_strnavi  = empty($strnavi) ? '&nbsp;' : $strnavi;
-
-                // 規格1クラス名
-                $this->tpl_class_name1  = $objProduct->className1;
-
-                // 規格2クラス名
-                $this->tpl_class_name2  = $objProduct->className2;
-
-                // 規格1
-                $this->arrClassCat1     = $objProduct->classCats1;
-
-                // 規格1が設定されている
-                $this->tpl_classcat_find1 = $objProduct->classCat1_find;
-                // 規格2が設定されている
-                $this->tpl_classcat_find2 = $objProduct->classCat2_find;
-
-                $this->tpl_stock_find       = $objProduct->stock_find;
-                $this->tpl_product_class_id = $objProduct->product_class_id;
-                $this->tpl_product_type     = $objProduct->product_type;
-
-                // 商品ステータスを取得
-                $this->productStatus = $this->arrProducts['productStatus'];
-                unset($this->arrProducts['productStatus']);
-                $this->tpl_javascript .= 'var productsClassCategories = ' . SC_Utils_Ex::jsonEncode($objProduct->classCategories) . ';';
-                //onloadスクリプトを設定. 在庫ありの商品のみ出力する
-                foreach ($this->arrProducts as $arrProduct) {
-                    if ($arrProduct['stock_unlimited_max'] || $arrProduct['stock_max'] > 0) {
-                        $js_fnOnLoad .= "fnSetClassCategories(document.product_form{$arrProduct['product_id']});";
-                    }
-                }
-
-                //カート処理
-                $target_product_id = intval($this->arrForm['product_id']);
-                if ($target_product_id > 0) {
-                    // 商品IDの正当性チェック
-                    if (!SC_Utils_Ex::sfIsInt($this->arrForm['product_id'])
-                        || !SC_Helper_DB_Ex::sfIsRecord('dtb_products', 'product_id', $this->arrForm['product_id'], 'del_flg = 0 AND status = 1')) {
-                        SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
-                    }
-
-                    // 入力内容のチェック
-                    $arrErr = $this->lfCheckError($target_product_id, $this->arrForm, $this->tpl_classcat_find1, $this->tpl_classcat_find2);
-                    if (empty($arrErr)) {
-                        $this->lfAddCart($this->arrForm, $_SERVER['HTTP_REFERER']);
-
-
-                        SC_Response_Ex::sendRedirect(CART_URLPATH);
-                        SC_Response_Ex::actionExit();
-                    }
-                    $js_fnOnLoad .= $this->lfSetSelectedData($this->arrProducts, $this->arrForm, $arrErr, $target_product_id);
-                } else {
-                    // カート「戻るボタン」用に保持
-                    $netURL = new Net_URL();
-                    //該当メソッドが無いため、$_SESSIONに直接セット
-                    $_SESSION['cart_referer_url'] = $netURL->getURL();
-                }
-
-                $this->tpl_javascript   .= 'function fnOnLoad(){' . $js_fnOnLoad . '}';
-                $this->tpl_onload       .= 'fnOnLoad(); ';
+                $this->doDefault($objProduct);
                 break;
         }
@@ -516,3 +445,91 @@
         return $arrProducts;
     }
+
+    /**
+     *
+     * @param type $objProduct 
+     * @return void
+     */
+    function doJson(&$objProduct) {
+        $this->arrProducts = $this->setStatusDataTo($this->arrProducts, $this->arrSTATUS, $this->arrSTATUS_IMAGE);
+        $this->arrProducts = $objProduct->setPriceTaxTo($this->arrProducts);
+
+        // 一覧メイン画像の指定が無い商品のための処理
+        foreach ($this->arrProducts as $key=>$val) {
+            $this->arrProducts[$key]['main_list_image'] = SC_Utils_Ex::sfNoImageMainList($val['main_list_image']);
+        }
+
+        echo SC_Utils_Ex::jsonEncode($this->arrProducts);
+        SC_Response_Ex::actionExit();
+    }
+
+    /**
+     *
+     * @param type $objProduct 
+     * @return void
+     */
+    function doDefault(&$objProduct) {
+        //商品一覧の表示処理
+        $strnavi            = $this->objNavi->strnavi;
+        // 表示文字列
+        $this->tpl_strnavi  = empty($strnavi) ? '&nbsp;' : $strnavi;
+
+        // 規格1クラス名
+        $this->tpl_class_name1  = $objProduct->className1;
+
+        // 規格2クラス名
+        $this->tpl_class_name2  = $objProduct->className2;
+
+        // 規格1
+        $this->arrClassCat1     = $objProduct->classCats1;
+
+        // 規格1が設定されている
+        $this->tpl_classcat_find1 = $objProduct->classCat1_find;
+        // 規格2が設定されている
+        $this->tpl_classcat_find2 = $objProduct->classCat2_find;
+
+        $this->tpl_stock_find       = $objProduct->stock_find;
+        $this->tpl_product_class_id = $objProduct->product_class_id;
+        $this->tpl_product_type     = $objProduct->product_type;
+
+        // 商品ステータスを取得
+        $this->productStatus = $this->arrProducts['productStatus'];
+        unset($this->arrProducts['productStatus']);
+        $this->tpl_javascript .= 'var productsClassCategories = ' . SC_Utils_Ex::jsonEncode($objProduct->classCategories) . ';';
+        //onloadスクリプトを設定. 在庫ありの商品のみ出力する
+        foreach ($this->arrProducts as $arrProduct) {
+            if ($arrProduct['stock_unlimited_max'] || $arrProduct['stock_max'] > 0) {
+                $js_fnOnLoad .= "fnSetClassCategories(document.product_form{$arrProduct['product_id']});";
+            }
+        }
+
+        //カート処理
+        $target_product_id = intval($this->arrForm['product_id']);
+        if ($target_product_id > 0) {
+            // 商品IDの正当性チェック
+            if (!SC_Utils_Ex::sfIsInt($this->arrForm['product_id'])
+                || !SC_Helper_DB_Ex::sfIsRecord('dtb_products', 'product_id', $this->arrForm['product_id'], 'del_flg = 0 AND status = 1')) {
+                SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
+            }
+
+            // 入力内容のチェック
+            $arrErr = $this->lfCheckError($target_product_id, $this->arrForm, $this->tpl_classcat_find1, $this->tpl_classcat_find2);
+            if (empty($arrErr)) {
+                $this->lfAddCart($this->arrForm, $_SERVER['HTTP_REFERER']);
+
+
+                SC_Response_Ex::sendRedirect(CART_URLPATH);
+                SC_Response_Ex::actionExit();
+            }
+            $js_fnOnLoad .= $this->lfSetSelectedData($this->arrProducts, $this->arrForm, $arrErr, $target_product_id);
+        } else {
+            // カート「戻るボタン」用に保持
+            $netURL = new Net_URL();
+            //該当メソッドが無いため、$_SESSIONに直接セット
+            $_SESSION['cart_referer_url'] = $netURL->getURL();
+        }
+
+        $this->tpl_javascript   .= 'function fnOnLoad(){' . $js_fnOnLoad . '}';
+        $this->tpl_onload       .= 'fnOnLoad(); ';
+    }
 }
Index: branches/version-2_12-dev/data/class/pages/products/LC_Page_Products_Detail.php
===================================================================
--- branches/version-2_12-dev/data/class/pages/products/LC_Page_Products_Detail.php	(revision 21900)
+++ branches/version-2_12-dev/data/class/pages/products/LC_Page_Products_Detail.php	(revision 21953)
@@ -149,51 +149,13 @@
         switch ($this->mode) {
             case 'cart':
-                $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam,
-                                                    $this->tpl_classcat_find1,
-                                                    $this->tpl_classcat_find2);
-                if (count($this->arrErr) == 0) {
-                    $objCartSess = new SC_CartSession_Ex();
-                    $product_class_id = $this->objFormParam->getValue('product_class_id');
-
-                    $objCartSess->addProduct($product_class_id, $this->objFormParam->getValue('quantity'));
-
-
-                    SC_Response_Ex::sendRedirect(CART_URLPATH);
-                    SC_Response_Ex::actionExit();
-                }
+                $this->doCart();
                 break;
+
             case 'add_favorite':
-                // ログイン中のユーザが商品をお気に入りにいれる処理
-                if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) {
-                    $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam);
-                    if (count($this->arrErr) == 0) {
-                        if (!$this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'),$objCustomer->getValue('customer_id'))) {
-
-                            $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
-                            $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite', array($this));
-
-                            SC_Response_Ex::actionExit();
-                        }
-                    }
-                }
+                $this->doAddFavorite($objCustomer);
                 break;
 
             case 'add_favorite_sphone':
-                // ログイン中のユーザが商品をお気に入りにいれる処理(スマートフォン用)
-                if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) {
-                    $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam);
-                    if (count($this->arrErr) == 0) {
-                        if ($this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'),$objCustomer->getValue('customer_id'))) {
-
-                            $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
-                            $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite_sphone', array($this));
-
-                            print 'true';
-                            SC_Response_Ex::actionExit();
-                        }
-                    }
-                    print 'error';
-                    SC_Response_Ex::actionExit();
-                }
+                $this->doAddFavoriteSphone($objCustomer);
                 break;
 
@@ -209,7 +171,5 @@
 
             default:
-                // カート「戻るボタン」用に保持
-                $netURL = new Net_URL();
-                $_SESSION['cart_referer_url'] = $netURL->getURL();
+                $this->doDefault();
                 break;
         }
@@ -219,75 +179,21 @@
             switch ($this->mode) {
                 case 'select':
-                    // 規格1が設定されている場合
-                    if ($this->tpl_classcat_find1) {
-                        // templateの変更
-                        $this->tpl_mainpage = 'products/select_find1.tpl';
-                        break;
-                    }
-
-                    // 数量の入力を行う
-                    $this->tpl_mainpage = 'products/select_item.tpl';
+                    $this->doMobileSelect();
                     break;
 
                 case 'select2':
-                    $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam,$this->tpl_classcat_find1,$this->tpl_classcat_find2);
-
-                    // 規格1が設定されていて、エラーを検出した場合
-                    if ($this->tpl_classcat_find1 and $this->arrErr['classcategory_id1']) {
-                        // templateの変更
-                        $this->tpl_mainpage = 'products/select_find1.tpl';
-                        break;
-                    }
-
-                    // 規格2が設定されている場合
-                    if ($this->tpl_classcat_find2) {
-                        $this->arrErr = array();
-
-                        $this->tpl_mainpage = 'products/select_find2.tpl';
-                        break;
-                    }
+                    $this->doMobileSelect2();
+                    break;
                     
                 case 'selectItem':
-                    $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam,$this->tpl_classcat_find1,$this->tpl_classcat_find2);
-
-                    // 規格2が設定されていて、エラーを検出した場合
-                    if ($this->tpl_classcat_find2 and $this->arrErr['classcategory_id2']) {
-                        // templateの変更
-                        $this->tpl_mainpage = 'products/select_find2.tpl';
-                        break;
-                    }
-
-                    $value1 = $this->objFormParam->getValue('classcategory_id1');
-                    
-                    // 規格2が設定されている場合.
-                    if (SC_Utils_Ex::isBlank($this->objFormParam->getValue('classcategory_id2')) == false){
-                        $value2 = '#' . $this->objFormParam->getValue('classcategory_id2');
-                    } else {
-                        $value2 = '#0';
-                    }
-                    
-                    if (strlen($value1) === 0) {
-                        $value1 = '__unselected';
-                    }
-
-                    $this->tpl_product_class_id = $objProduct->classCategories[$product_id][$value1][$value2]['product_class_id'];
-
-                    // この段階では、数量の入力チェックエラーを出させない。
-                    unset($this->arrErr['quantity']);
-
-                    // 数量の入力を行う
-                    $this->tpl_mainpage = 'products/select_item.tpl';
+                    $this->doMobileSelectItem();
                     break;
 
                 case 'cart':
-                    // この段階でエラーが出る場合は、数量の入力エラーのはず
-                    if (count($this->arrErr)) {
-                        // 数量の入力を行う
-                        $this->tpl_mainpage = 'products/select_item.tpl';
-                    }
+                    $this->doMobileCart();
                     break;
 
                 default:
-                    $this->tpl_mainpage = 'products/detail.tpl';
+                    $this->doMobileDefault();
                     break;
             }
@@ -577,3 +483,179 @@
         }
     }
+
+    /**
+     * Add product(s) into the cart.
+     * 
+     * @return void 
+     */
+    function doCart() {
+        $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam,
+                                            $this->tpl_classcat_find1,
+                                            $this->tpl_classcat_find2);
+        if (count($this->arrErr) == 0) {
+            $objCartSess = new SC_CartSession_Ex();
+            $product_class_id = $this->objFormParam->getValue('product_class_id');
+
+            $objCartSess->addProduct($product_class_id, $this->objFormParam->getValue('quantity'));
+
+
+            SC_Response_Ex::sendRedirect(CART_URLPATH);
+            SC_Response_Ex::actionExit();
+        }
+    }
+
+    /**
+     * Add product to authenticated user's favorites.
+     *
+     * @param type $objCustomer 
+     * @return void
+     */
+    function doAddFavorite(&$objCustomer) {
+        // ログイン中のユーザが商品をお気に入りにいれる処理
+        if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) {
+            $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam);
+            if (count($this->arrErr) == 0) {
+                if (!$this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'),$objCustomer->getValue('customer_id'))) {
+
+                    $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
+                    $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite', array($this));
+
+                    SC_Response_Ex::actionExit();
+                }
+            }
+        }
+    }
+
+    /**
+     * Add product to authenticated user's favorites. (for Smart phone)
+     *
+     * @param type $objCustomer 
+     * @return void
+     */
+    function doAddFavoriteSphone($objCustomer) {
+        // ログイン中のユーザが商品をお気に入りにいれる処理(スマートフォン用)
+        if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) {
+            $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam);
+            if (count($this->arrErr) == 0) {
+                if ($this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'),$objCustomer->getValue('customer_id'))) {
+
+                    $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
+                    $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite_sphone', array($this));
+
+                    print 'true';
+                    SC_Response_Ex::actionExit();
+                }
+            }
+            print 'error';
+            SC_Response_Ex::actionExit();
+        }
+    }
+
+    /**
+     * 
+     * 
+     * @return void 
+     */
+    function doDefault() {
+        // カート「戻るボタン」用に保持
+        $netURL = new Net_URL();
+        $_SESSION['cart_referer_url'] = $netURL->getURL();
+    }
+
+    /**
+     * 
+     * @return void
+     */
+    function doMobileSelect() {
+        // 規格1が設定されている場合
+        if ($this->tpl_classcat_find1) {
+            // templateの変更
+            $this->tpl_mainpage = 'products/select_find1.tpl';
+            return;
+        }
+
+        // 数量の入力を行う
+        $this->tpl_mainpage = 'products/select_item.tpl';
+    }
+
+    /**
+     *
+     * @return type 
+     */
+    function doMobileSelect2() {
+        $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam,$this->tpl_classcat_find1,$this->tpl_classcat_find2);
+
+        // 規格1が設定されていて、エラーを検出した場合
+        if ($this->tpl_classcat_find1 and $this->arrErr['classcategory_id1']) {
+            // templateの変更
+            $this->tpl_mainpage = 'products/select_find1.tpl';
+            return;
+        }
+
+        // 規格2が設定されている場合
+        if ($this->tpl_classcat_find2) {
+            $this->arrErr = array();
+
+            $this->tpl_mainpage = 'products/select_find2.tpl';
+            return;
+        }
+
+        $this->doMobileSelectItem();
+    }
+
+    /**
+     * 
+     * @return void
+     */
+    function doMobileSelectItem() {
+        $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam,$this->tpl_classcat_find1,$this->tpl_classcat_find2);
+
+        // 規格2が設定されていて、エラーを検出した場合
+        if ($this->tpl_classcat_find2 and $this->arrErr['classcategory_id2']) {
+            // templateの変更
+            $this->tpl_mainpage = 'products/select_find2.tpl';
+            break;
+        }
+
+        $value1 = $this->objFormParam->getValue('classcategory_id1');
+
+        // 規格2が設定されている場合.
+        if (SC_Utils_Ex::isBlank($this->objFormParam->getValue('classcategory_id2')) == false){
+            $value2 = '#' . $this->objFormParam->getValue('classcategory_id2');
+        } else {
+            $value2 = '#0';
+        }
+
+        if (strlen($value1) === 0) {
+            $value1 = '__unselected';
+        }
+
+        $this->tpl_product_class_id = $objProduct->classCategories[$product_id][$value1][$value2]['product_class_id'];
+
+        // この段階では、数量の入力チェックエラーを出させない。
+        unset($this->arrErr['quantity']);
+
+        // 数量の入力を行う
+        $this->tpl_mainpage = 'products/select_item.tpl';
+    }
+
+    /**
+     *
+     * @return void 
+     */
+    function doMobileCart() {
+        // この段階でエラーが出る場合は、数量の入力エラーのはず
+        if (count($this->arrErr)) {
+            // 数量の入力を行う
+            $this->tpl_mainpage = 'products/select_item.tpl';
+        }
+    }
+
+    /**
+     *
+     * @return void 
+     */
+    function doMobileDefault() {
+        $this->tpl_mainpage = 'products/detail.tpl';
+    }
 }
