Changeset 19826


Ignore:
Timestamp:
2011/01/05 17:38:00 (13 years ago)
Author:
kotani
Message:

#880(mobile/sphoneディレクトリを削除)に対応。まずmobileのみ意図通りの動作になるように一部コミット(products/detail.php)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_5-dev/data/class/pages/products/LC_Page_Products_Detail.php

    r19805 r19826  
    9292        $product_id = $this->lfCheckProductId(); 
    9393 
     94        // XXX 削除可能か、SC_SiteViewクラスコンストラクタ内の処理を要確認 
    9495        $objView = new SC_SiteView(strlen($_POST['mode']) == 0); 
     96         
    9597        $objCustomer = new SC_Customer(); 
    96         $objQuery = new SC_Query(); 
    9798        $objDb = new SC_Helper_DB_Ex(); 
     99        $objProduct = new SC_Product(); 
    98100 
    99101        // ログイン中のユーザが商品をお気に入りにいれる処理 
     
    131133 
    132134        // 規格選択セレクトボックスの作成 
    133         $this->lfMakeSelect($product_id); 
    134  
    135         $objProduct = new SC_Product(); 
    136         $objProduct->setProductsClassByProductIds(array($product_id)); 
    137  
    138         // 規格1クラス名 
    139         $this->tpl_class_name1 = $objProduct->className1[$product_id]; 
    140  
    141         // 規格2クラス名 
    142         $this->tpl_class_name2 = $objProduct->className2[$product_id]; 
    143  
    144         // 規格1 
    145         $this->arrClassCat1 = $objProduct->classCats1[$product_id]; 
    146  
    147         // 規格1が設定されている 
    148         $this->tpl_classcat_find1 = $objProduct->classCat1_find[$product_id]; 
    149         // 規格2が設定されている 
    150         $this->tpl_classcat_find2 = $objProduct->classCat2_find[$product_id]; 
    151  
    152         $this->tpl_stock_find = $objProduct->stock_find[$product_id]; 
    153         $this->tpl_product_class_id = $objProduct->classCategories[$product_id]['']['']['product_class_id']; 
    154         $this->tpl_product_type = $objProduct->classCategories[$product_id]['']['']['product_type']; 
    155  
    156         $objJson = new Services_JSON(); 
    157         $this->tpl_javascript .= 'classCategories = ' . $objJson->encode($objProduct->classCategories[$product_id]) . ';'; 
    158         $this->tpl_javascript .= 'function lnOnLoad(){' . $this->js_lnOnload . '}'; 
    159         $this->tpl_onload .= 'lnOnLoad();'; 
    160  
    161         // 商品IDをFORM内に保持する。 
     135        if(Net_UserAgent_Mobile::isMobile() === true) { 
     136            $this->lfMakeSelectMobile($this, $product_id); 
     137        } else { 
     138            $this->lfMakeSelect($product_id); 
     139 
     140            $objProduct->setProductsClassByProductIds(array($product_id)); 
     141 
     142            // 規格1クラス名 
     143            $this->tpl_class_name1 = $objProduct->className1[$product_id]; 
     144 
     145            // 規格2クラス名 
     146            $this->tpl_class_name2 = $objProduct->className2[$product_id]; 
     147 
     148            // 規格1 
     149            $this->arrClassCat1 = $objProduct->classCats1[$product_id]; 
     150 
     151            // 規格1が設定されている 
     152            $this->tpl_classcat_find1 = $objProduct->classCat1_find[$product_id]; 
     153            // 規格2が設定されている 
     154            $this->tpl_classcat_find2 = $objProduct->classCat2_find[$product_id]; 
     155 
     156            $this->tpl_stock_find = $objProduct->stock_find[$product_id]; 
     157            $this->tpl_product_class_id = $objProduct->classCategories[$product_id]['']['']['product_class_id']; 
     158            $this->tpl_product_type = $objProduct->classCategories[$product_id]['']['']['product_type']; 
     159 
     160            $objJson = new Services_JSON(); 
     161            $this->tpl_javascript .= 'classCategories = ' . $objJson->encode($objProduct->classCategories[$product_id]) . ';'; 
     162            $this->tpl_javascript .= 'function lnOnLoad(){' . $this->js_lnOnload . '}'; 
     163            $this->tpl_onload .= 'lnOnLoad();'; 
     164        } 
     165 
     166        // 商品IDをFORM内に保持する 
    162167        $this->tpl_product_id = $product_id; 
    163168 
     169        // POSTされるmodeにより処理切り替え 
    164170        if (!isset($_POST['mode'])) $_POST['mode'] = ""; 
     171        if(Net_UserAgent_Mobile::isMobile() === true) { 
     172            $this->lfPostActionMobile(); 
     173        } else { 
     174            $this->arrErr = $this->lfPostAction(); 
     175        } 
     176 
     177        // 商品詳細を取得 
     178        $this->arrProduct = $objProduct->getDetail($product_id); 
     179 
     180        // サブタイトルを取得 
     181        $this->tpl_subtitle = $this->arrProduct['name']; 
     182 
     183        // 関連カテゴリを取得 
     184        $this->arrRelativeCat = $objDb->sfGetMultiCatTree($product_id); 
     185 
     186        // 商品ステータスを取得 
     187        $this->productStatus = $objProduct->getProductStatus($product_id); 
     188 
     189        // 画像ファイル指定がない場合の置換処理 
     190        $this->arrProduct['main_image'] 
     191            = SC_Utils_Ex::sfNoImageMain($this->arrProduct['main_image']); 
     192 
     193        $this->lfSetFile(); 
     194        // 支払方法の取得 
     195        $this->arrPayment = $this->lfGetPayment(); 
     196        // 入力情報を渡す 
     197        $this->arrForm = $this->objFormParam->getFormParamList(); 
     198        //レビュー情報の取得 
     199        $this->arrReview = $this->lfGetReviewData($product_id); 
     200        // トラックバック情報の取得 
     201 
     202        // トラックバック機能の稼働状況チェック 
     203        if (SC_Utils_Ex::sfGetSiteControlFlg(SITE_CONTROL_TRACKBACK) != 1) { 
     204            $this->arrTrackbackView = "OFF"; 
     205        } else { 
     206            $this->arrTrackbackView = "ON"; 
     207            $this->arrTrackback = $this->lfGetTrackbackData($product_id); 
     208        } 
     209        $this->trackback_url = TRACKBACK_TO_URL . $product_id; 
     210        //関連商品情報表示 
     211        $this->arrRecommend = $this->lfPreGetRecommendProducts($product_id); 
     212 
     213        $this->lfConvertParam(); 
     214    } 
     215 
     216    /** 
     217     * デストラクタ. 
     218     * 
     219     * @return void 
     220     */ 
     221    function destroy() { 
     222        parent::destroy(); 
     223    } 
     224 
     225    /** 
     226     * POSTされるmodeにより処理切り替え 
     227     * 
     228     * @return array Error messages. 
     229     */ 
     230    function lfPostAction() { 
    165231        $arrErr = array(); 
    166  
     232         
    167233        switch($_POST['mode']) { 
    168234            case 'cart': 
     
    210276                break; 
    211277        } 
    212         $this->arrErr = $arrErr; 
    213  
    214         // 商品詳細を取得 
    215         $this->arrProduct = $objProduct->getDetail($product_id); 
    216  
    217         // サブタイトルを取得 
    218         $this->tpl_subtitle = $this->arrProduct['name']; 
    219  
    220         // 関連カテゴリを取得 
    221         $this->arrRelativeCat = $objDb->sfGetMultiCatTree($product_id); 
    222  
    223         // 商品ステータスを取得 
    224         $this->productStatus = $objProduct->getProductStatus($product_id); 
    225  
    226         // 画像ファイル指定がない場合の置換処理 
    227         $this->arrProduct['main_image'] 
    228             = SC_Utils_Ex::sfNoImageMain($this->arrProduct['main_image']); 
    229  
    230         $this->lfSetFile(); 
    231         // 支払方法の取得 
    232         $this->arrPayment = $this->lfGetPayment(); 
    233         // 入力情報を渡す 
    234         $this->arrForm = $this->objFormParam->getFormParamList(); 
    235         //レビュー情報の取得 
    236         $this->arrReview = $this->lfGetReviewData($product_id); 
    237         // トラックバック情報の取得 
    238  
    239         // トラックバック機能の稼働状況チェック 
    240         if (SC_Utils_Ex::sfGetSiteControlFlg(SITE_CONTROL_TRACKBACK) != 1) { 
    241             $this->arrTrackbackView = "OFF"; 
    242         } else { 
    243             $this->arrTrackbackView = "ON"; 
    244             $this->arrTrackback = $this->lfGetTrackbackData($product_id); 
    245         } 
    246         $this->trackback_url = TRACKBACK_TO_URL . $product_id; 
    247         //関連商品情報表示 
    248         $this->arrRecommend = $this->lfPreGetRecommendProducts($product_id); 
    249  
    250         $this->lfConvertParam(); 
    251  
    252         //$objView->assignobj($this); 
    253         //$objView->display(SITE_FRAME); 
     278 
     279        return $arrErr; 
    254280    } 
    255281 
    256282    /** 
    257      * デストラクタ. 
     283     * POSTされるmodeにより処理切り替え(モバイル) 
    258284     * 
    259285     * @return void 
    260286     */ 
    261     function destroy() { 
    262         parent::destroy(); 
    263     } 
    264  
    265     /** 
    266      * モバイルページを初期化する. 
    267      * 
    268      * @return void 
    269      */ 
    270     function mobileInit() { 
    271         $this->init(); 
    272         $this->tpl_mainpage = "products/detail.tpl"; 
    273     } 
    274  
    275     /** 
    276      * Page のプロセス(モバイル). 
    277      * @return void 
    278      */ 
    279     function mobileProcess() { 
    280         parent::mobileProcess(); 
    281         $this->mobileAction(); 
    282         $this->sendResponse(); 
    283     } 
    284  
    285     /** 
    286      * Page のAction(モバイル). 
    287      * 
    288      * FIXME 要リファクタリング 
    289      * 
    290      * @return void 
    291      */ 
    292     function mobileAction() { 
    293         // プロダクトIDの正当性チェック 
    294         $product_id = $this->lfCheckProductId(); 
    295  
    296         //$objView = new SC_MobileView(); 
    297         $objCustomer = new SC_Customer(); 
    298         $objQuery = new SC_Query(); 
    299         $objDb = new SC_Helper_DB_Ex(); 
    300  
    301         // パラメータ管理クラス 
    302         $this->objFormParam = new SC_FormParam(); 
    303         // パラメータ情報の初期化 
    304         $this->lfInitParam(); 
    305         // POST値の取得 
    306         $this->objFormParam->setParam($_POST); 
    307  
    308         // ファイル管理クラス 
    309         $this->objUpFile = new SC_UploadFile(IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR); 
    310         // ファイル情報の初期化 
    311         $this->lfInitFile(); 
    312  
    313         // ログイン判定 
    314         if($objCustomer->isLoginSuccess(true)) { 
    315             //お気に入りボタン表示 
    316             $this->tpl_login = true; 
    317         } 
    318  
    319         // 規格選択セレクトボックスの作成 
    320         $this->lfMakeSelectMobile($this, $product_id); 
    321  
    322         // 商品IDをFORM内に保持する。 
    323         $this->tpl_product_id = $product_id; 
    324  
     287    function lfPostActionMobile() { 
    325288        switch($_POST['mode']) { 
    326         case 'select': 
    327             // 規格1が設定されている場合 
    328             if($this->tpl_classcat_find1) { 
    329                 // templateの変更 
    330                 $this->tpl_mainpage = "products/select_find1.tpl"; 
     289            case 'select': 
     290                // 規格1が設定されている場合 
     291                if($this->tpl_classcat_find1) { 
     292                    // templateの変更 
     293                    $this->tpl_mainpage = "products/select_find1.tpl"; 
     294                    break; 
     295                } 
     296 
     297            case 'select2': 
     298                $this->arrErr = $this->lfCheckError(); 
     299 
     300                // 規格1が設定されている場合 
     301                if($this->tpl_classcat_find1 and $this->arrErr['classcategory_id1']) { 
     302                    // templateの変更 
     303                    $this->tpl_mainpage = "products/select_find1.tpl"; 
     304                    break; 
     305                } 
     306 
     307                // 規格2が設定されている場合 
     308                if($this->tpl_classcat_find2) { 
     309                    $this->arrErr = array(); 
     310 
     311                    $this->tpl_mainpage = "products/select_find2.tpl"; 
     312                    break; 
     313                } 
     314 
     315            case 'selectItem': 
     316                $this->arrErr = $this->lfCheckError(); 
     317 
     318                // 規格1が設定されている場合 
     319                if($this->tpl_classcat_find2 and $this->arrErr['classcategory_id2']) { 
     320                    // templateの変更 
     321                    $this->tpl_mainpage = "products/select_find2.tpl"; 
     322                    break; 
     323                } 
     324                // 商品数の選択を行う 
     325                $this->tpl_mainpage = "products/select_item.tpl"; 
    331326                break; 
    332             } 
    333  
    334         case 'select2': 
    335             $this->arrErr = $this->lfCheckError(); 
    336  
    337             // 規格1が設定されている場合 
    338             if($this->tpl_classcat_find1 and $this->arrErr['classcategory_id1']) { 
    339                 // templateの変更 
    340                 $this->tpl_mainpage = "products/select_find1.tpl"; 
     327 
     328            case 'cart': 
     329                // 入力値の変換 
     330                $this->objFormParam->convParam(); 
     331                $this->arrErr = $this->lfCheckError(); 
     332                if(count($this->arrErr) == 0) { 
     333                    $objCartSess = new SC_CartSession(); 
     334                    $product_class_id = $_POST['product_class_id']; 
     335                    $classcategory_id1 = $_POST['classcategory_id1']; 
     336                    $classcategory_id2 = $_POST['classcategory_id2']; 
     337 
     338                    // 規格1が設定されていない場合 
     339                    if(!$this->tpl_classcat_find1) { 
     340                        $classcategory_id1 = '0'; 
     341                    } 
     342 
     343                    // 規格2が設定されていない場合 
     344                    if(!$this->tpl_classcat_find2) { 
     345                        $classcategory_id2 = '0'; 
     346                    } 
     347 
     348                    $objCartSess->addProduct(array($_POST['product_id'], $product_class_id, $classcategory_id1, $classcategory_id2), $this->objFormParam->getValue('quantity')); 
     349                    $this->objDisplay->redirect($this->getLocation(URL_CART_TOP)); 
     350                    exit; 
     351                } 
    341352                break; 
    342             } 
    343  
    344             // 規格2が設定されている場合 
    345             if($this->tpl_classcat_find2) { 
    346                 $this->arrErr = array(); 
    347  
    348                 $this->tpl_mainpage = "products/select_find2.tpl"; 
     353 
     354            default: 
     355                $this->tpl_mainpage = "products/detail.tpl"; 
    349356                break; 
    350             } 
    351  
    352         case 'selectItem': 
    353             $this->arrErr = $this->lfCheckError(); 
    354  
    355             // 規格1が設定されている場合 
    356             if($this->tpl_classcat_find2 and $this->arrErr['classcategory_id2']) { 
    357                 // templateの変更 
    358                 $this->tpl_mainpage = "products/select_find2.tpl"; 
    359                 break; 
    360             } 
    361             // 商品数の選択を行う 
    362             $this->tpl_mainpage = "products/select_item.tpl"; 
    363             break; 
    364  
    365         case 'cart': 
    366             // 入力値の変換 
    367             $this->objFormParam->convParam(); 
    368             $this->arrErr = $this->lfCheckError(); 
    369             if(count($this->arrErr) == 0) { 
    370                 $objCartSess = new SC_CartSession(); 
    371                 $product_class_id = $_POST['product_class_id']; 
    372                 $classcategory_id1 = $_POST['classcategory_id1']; 
    373                 $classcategory_id2 = $_POST['classcategory_id2']; 
    374  
    375                 // 規格1が設定されていない場合 
    376                 if(!$this->tpl_classcat_find1) { 
    377                     $classcategory_id1 = '0'; 
    378                 } 
    379  
    380                 // 規格2が設定されていない場合 
    381                 if(!$this->tpl_classcat_find2) { 
    382                     $classcategory_id2 = '0'; 
    383                 } 
    384  
    385                 $objCartSess->addProduct(array($_POST['product_id'], $product_class_id, $classcategory_id1, $classcategory_id2), $this->objFormParam->getValue('quantity')); 
    386                 $this->objDisplay->redirect($this->getLocation(MOBILE_URL_CART_TOP)); 
    387                 exit; 
    388             } 
    389             break; 
    390  
    391         default: 
    392             break; 
    393         } 
    394  
    395         // 商品詳細を取得 
    396         $objProduct = new SC_Product(); 
    397         $this->arrProduct = $objProduct->getDetail($product_id); 
    398  
    399         // サブタイトルを取得 
    400         $this->tpl_subtitle = $this->arrProduct["name"]; 
    401  
    402         // 画像ファイル指定がない場合の置換処理 
    403         $this->arrProduct['main_image'] 
    404             = SC_Utils_Ex::sfNoImageMain($this->arrProduct['main_image']); 
    405  
    406         // ファイル情報のセット 
    407         $this->lfSetFile(); 
    408         // 支払方法の取得 
    409         $this->arrPayment = $this->lfGetPayment(); 
    410         // 入力情報を渡す 
    411         $this->arrForm = $this->objFormParam->getFormParamList(); 
    412         //レビュー情報の取得 
    413         $this->arrReview = $this->lfGetReviewData($product_id); 
    414         // タイトルに商品名を入れる 
    415         $this->tpl_title = "商品詳細 ". $this->arrProduct["name"]; 
    416         //関連商品情報表示 
    417         $this->arrRecommend = $this->lfPreGetRecommendProducts($product_id); 
    418  
    419         //$objView->assignobj($this); 
    420         //$objView->display(SITE_FRAME); 
     357        } 
    421358    } 
    422359 
     
    484421    } 
    485422 
    486     /* 規格選択セレクトボックスの作成 
    487      * FIXME 要リファクタリング 
    488      */ 
     423    /* 規格選択セレクトボックスの作成(モバイル) */ 
    489424    function lfMakeSelectMobile(&$objPage, $product_id) { 
    490425 
     
    569504    /* 商品規格情報の取得 */ 
    570505    function lfGetProductsClass($product_id) { 
    571         $arrRet = array(); 
    572         if(SC_Utils_Ex::sfIsInt($product_id)) { 
    573             // 商品規格取得 
    574             $objQuery = new SC_Query(); 
    575             $col = "product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited"; 
    576             $table = "vw_product_class AS prdcls"; 
    577             $where = "product_id = ?"; 
    578             $objQuery->setOrder("rank1 DESC, rank2 DESC"); 
    579             $arrRet = $objQuery->select($col, $table, $where, array($product_id)); 
    580         } 
    581         return $arrRet; 
     506        $objProduct = new SC_Product(); 
     507        return $objProduct->getProductsClassFullByProductId($product_id); 
    582508    } 
    583509 
Note: See TracChangeset for help on using the changeset viewer.