Ignore:
Timestamp:
2007/07/20 15:58:59 (17 years ago)
Author:
nanasess
Message:

r15064 から svn cp
とりあえず暫定コミット.

  • UTF-8 に変更
  • slib.php, glib.php のクラス化
  • LC_Page の抽象化(一部)
Location:
branches/feature-module-update
Files:
1 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/feature-module-update

    • Property svn:ignore set to
      .cache

      .settings

      .projectOptions
  • branches/feature-module-update/html/products/list.php

    r13581 r15078  
    2020        $this->arrPRODUCTLISTMAX = $arrPRODUCTLISTMAX;       
    2121        /* 
    22          session_start»þ¤Îno-cache¥Ø¥Ã¥À¡¼¤òÍÞÀ©¤¹¤ë¤³¤È¤Ç 
    23          ¡ÖÌá¤ë¡×¥Ü¥¿¥ó»ÈÍÑ»þ¤ÎÍ­¸ú´ü¸ÂÀÚ¤ìɽ¼¨¤òÍÞÀ©¤¹¤ë¡£ 
    24          private-no-expire:¥¯¥é¥¤¥¢¥ó¥È¤Î¥­¥ã¥Ã¥·¥å¤òµö²Ä¤¹¤ë¡£ 
     22         session_start時のno-cacheヘッダーを抑制することで 
     23         「戻る」ボタン使用時の有効期限切れ表示を抑制する。 
     24         private-no-expire:クライアントのキャッシュを許可する。 
    2525        */ 
    2626        session_cache_limiter('private-no-expire'); 
     
    3131$conn = new SC_DBConn(); 
    3232 
    33 //ɽ¼¨·ï¿ô¤ÎÁªÂò 
     33//表示件数の選択 
    3434if(sfIsInt($_POST['disp_number'])) { 
    3535    $objPage->disp_number = $_POST['disp_number']; 
    3636} else { 
    37     //ºÇ¾®É½¼¨·ï¿ô¤òÁªÂò 
     37    //最小表示件数を選択 
    3838    $objPage->disp_number = current(array_keys($arrPRODUCTLISTMAX)); 
    3939} 
    4040 
    41 //ɽ¼¨½ç½ø¤ÎÊݸ 
     41//表示順序の保存 
    4242$objPage->orderby = $_POST['orderby']; 
    4343 
    44 // GET¤Î¥«¥Æ¥´¥êID¤ò¸µ¤ËÀµ¤·¤¤¥«¥Æ¥´¥êID¤ò¼èÆÀ¤¹¤ë¡£ 
     44// GETのカテゴリIDを元に正しいカテゴリIDを取得する。 
    4545$category_id = sfGetCategoryId("", $_GET['category_id']); 
    4646 
    47 // ¥¿¥¤¥È¥ëÊÔ½¸ 
     47// タイトル編集 
    4848$tpl_subtitle = ""; 
    4949if($_GET['mode'] == 'search'){ 
    50     $tpl_subtitle = "¸¡º÷·ë²Ì"; 
     50    $tpl_subtitle = "検索結果"; 
    5151}elseif ($category_id == "" ) { 
    52     $tpl_subtitle = "Á´¾¦ÉÊ"; 
     52    $tpl_subtitle = "全商品"; 
    5353}else{ 
    5454    $arrFirstCat = sfGetFirstCat($category_id); 
     
    5959$count = $objQuery->count("dtb_best_products", "category_id = ?", array($category_id)); 
    6060 
    61 // °Ê²¼¤Î¾ò·ï¤ÇBEST¾¦Éʤòɽ¼¨¤¹¤ë 
    62 // ¡¦BESTºÇÂç¿ô¤Î¾¦Éʤ¬ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë¡£ 
    63 // ¡¦¥«¥Æ¥´¥êID¤¬¥ë¡¼¥ÈID¤Ç¤¢¤ë¡£ 
    64 // ¡¦¸¡º÷¥â¡¼¥É¤Ç¤Ê¤¤¡£ 
     61// 以下の条件でBEST商品を表示する 
     62// ・BEST最大数の商品が登録されている。 
     63// ・カテゴリIDがルートIDである。 
     64// ・検索モードでない。 
    6565if(($count >= BEST_MIN) && lfIsRootCategory($category_id) && ($_GET['mode'] != 'search') ) { 
    66     // ¾¦ÉÊTOP¤Îɽ¼¨½èÍý 
    67     /** ɬ¤º»ØÄꤹ¤ë **/ 
    68     $objPage->tpl_mainpage = HTML_PATH . "user_data/templates/list.tpl";        // ¥á¥¤¥ó¥Æ¥ó¥×¥ì¡¼¥È     
     66    // 商品TOPの表示処理 
     67    /** 必ず指定する **/ 
     68    $objPage->tpl_mainpage = HTML_PATH . "user_data/templates/list.tpl";        // メインテンプレート     
    6969     
    7070    $objPage->arrBestItems = sfGetBestProducts($conn, $category_id); 
     
    7272} else { 
    7373    if ($_GET['mode'] == 'search' && strlen($_GET['category_id']) == 0 ){ 
    74         // ¸¡º÷»þ¤Ëcategory_id¤¬GET¤Ë¸ºß¤·¤Ê¤¤¾ì¹ç¤Ï¡¢²¾¤ËËä¤á¤¿ID¤ò¶õÇò¤ËÌ᤹ 
     74        // 検索時にcategory_idがGETに存在しない場合は、仮に埋めたIDを空白に戻す 
    7575        $category_id = '';   
    7676    } 
    7777     
    78     // ¾¦ÉÊ°ìÍ÷¤Îɽ¼¨½èÍý 
     78    // 商品一覧の表示処理 
    7979    $objPage = lfDispProductsList($category_id, $_GET['name'], $objPage->disp_number, $_POST['orderby']); 
    8080     
    81     // ¸¡º÷¾ò·ï¤ò²èÌ̤Ëɽ¼¨ 
    82     // ¥«¥Æ¥´¥ê¡¼¸¡º÷¾ò·ï 
     81    // 検索条件を画面に表示 
     82    // カテゴリー検索条件 
    8383    if (strlen($_GET['category_id']) == 0) { 
    84         $arrSearch['category'] = "»ØÄê¤Ê¤·"; 
     84        $arrSearch['category'] = "指定なし"; 
    8585    }else{ 
    8686        $arrCat = $conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?",array($category_id)); 
     
    8888    } 
    8989     
    90     // ¾¦ÉÊ̾¸¡º÷¾ò·ï 
     90    // 商品名検索条件 
    9191    if ($_GET['name'] === "") { 
    92         $arrSearch['name'] = "»ØÄê¤Ê¤·"; 
     92        $arrSearch['name'] = "指定なし"; 
    9393    }else{ 
    9494        $arrSearch['name'] = $_GET['name']; 
     
    9696} 
    9797 
    98 // ¥ì¥¤¥¢¥¦¥È¥Ç¥¶¥¤¥ó¤ò¼èÆÀ 
     98// レイアウトデザインを取得 
    9999$objPage = sfGetPageLayout($objPage, false, "products/list.php"); 
    100100 
    101101if($_POST['mode'] == "cart" && $_POST['product_id'] != "") { 
    102     // ÃͤÎÀµÅöÀ­¥Á¥§¥Ã¥¯ 
     102    // 値の正当性チェック 
    103103    if(!sfIsInt($_POST['product_id']) || !sfIsRecord("dtb_products", "product_id", $_POST['product_id'], "del_flg = 0 AND status = 1")) { 
    104104        sfDispSiteError(PRODUCT_NOT_FOUND); 
    105105    } else { 
    106         // ÆþÎÏÃͤÎÊÑ´¹ 
     106        // 入力値の変換 
    107107        $objPage->arrErr = lfCheckError($_POST['product_id']); 
    108108        if(count($objPage->arrErr) == 0) { 
     
    112112            $classcategory_id2 = $_POST[$classcategory_id. '_2']; 
    113113            $quantity = "quantity". $_POST['product_id']; 
    114             // µ¬³Ê1¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç 
     114            // 規格1が設定されていない場合 
    115115            if(!$objPage->tpl_classcat_find1[$_POST['product_id']]) { 
    116116                $classcategory_id1 = '0'; 
    117117            } 
    118             // µ¬³Ê2¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç 
     118            // 規格2が設定されていない場合 
    119119            if(!$objPage->tpl_classcat_find2[$_POST['product_id']]) { 
    120120                $classcategory_id2 = '0'; 
     
    131131$objPage->tpl_subtitle = $tpl_subtitle; 
    132132 
    133 // »ÙʧÊýË¡¤Î¼èÆÀ 
     133// 支払方法の取得 
    134134$objPage->arrPayment = lfGetPayment(); 
    135 // ÆþÎϾðÊó¤òÅϤ¹ 
     135// 入力情報を渡す 
    136136$objPage->arrForm = $_POST; 
    137137 
     
    144144 
    145145//----------------------------------------------------------------------------------------------------------------------------------- 
    146 /* ¥«¥Æ¥´¥êID¤¬¥ë¡¼¥È¤«¤É¤¦¤«¤ÎȽÄê */ 
     146/* カテゴリIDがルートかどうかの判定 */ 
    147147function lfIsRootCategory($category_id) { 
    148148    $objQuery = new SC_Query(); 
     
    154154} 
    155155 
    156 /* ¾¦ÉÊ°ìÍ÷¤Îɽ¼¨ */ 
     156/* 商品一覧の表示 */ 
    157157function lfDispProductsList($category_id, $name, $disp_num, $orderby) { 
    158158    global $objPage; 
     
    160160    $objPage->tpl_pageno = $_POST['pageno']; 
    161161 
    162     //ɽ¼¨·ï¿ô¤Ç¥Æ¥ó¥×¥ì¡¼¥È¤òÀÚ¤êÂؤ¨¤ë 
    163     $objPage->tpl_mainpage = HTML_PATH . "user_data/templates/list.tpl";        // ¥á¥¤¥ó¥Æ¥ó¥×¥ì¡¼¥È         
    164  
    165     //ɽ¼¨½ç½ø 
     162    //表示件数でテンプレートを切り替える 
     163    $objPage->tpl_mainpage = HTML_PATH . "user_data/templates/list.tpl";        // メインテンプレート         
     164 
     165    //表示順序 
    166166    switch($orderby) { 
    167     //²Á³Ê½ç 
     167    //価格順 
    168168    case 'price': 
    169169        $order = "price02_min ASC"; 
    170170        break; 
    171     //¿·Ãå½ç 
     171    //新着順 
    172172    case 'date': 
    173173        $order = "create_date DESC"; 
     
    178178    } 
    179179     
    180     // ¾¦Éʸ¡º÷¾ò·ï¤ÎºîÀ®¡Ê̤ºï½ü¡¢É½¼¨¡Ë 
     180    // 商品検索条件の作成(未削除、表示) 
    181181    $where = "del_flg = 0 AND status = 1 "; 
    182     // ¥«¥Æ¥´¥ê¤«¤é¤ÎWHEREʸ»úÎó¼èÆÀ 
     182    // カテゴリからのWHERE文字列取得 
    183183    if ( $category_id ) { 
    184184        list($tmp_where, $arrval) = sfGetCatWhere($category_id); 
     
    188188    } 
    189189         
    190     // ¾¦ÉÊ̾¤òwhereʸ¤Ë 
     190    // 商品名をwhere文に 
    191191    $name = ereg_replace(",", "", $name); 
    192192    if ( strlen($name) > 0 ){ 
     
    197197    } 
    198198             
    199     // ¹Ô¿ô¤Î¼èÆÀ 
     199    // 行数の取得 
    200200    $linemax = $objQuery->count("vw_products_allclass AS allcls", $where, $arrval); 
    201     $objPage->tpl_linemax = $linemax;   // ²¿·ï¤¬³ºÅö¤·¤Þ¤·¤¿¡£É½¼¨ÍÑ 
    202      
    203     // ¥Ú¡¼¥¸Á÷¤ê¤Î¼èÆÀ 
     201    $objPage->tpl_linemax = $linemax;   // 何件が該当しました。表示用 
     202     
     203    // ページ送りの取得 
    204204    $objNavi = new SC_PageNavi($_POST['pageno'], $linemax, $disp_num, "fnNaviPage", NAVI_PMAX); 
    205205     
    206206    $strnavi = $objNavi->strnavi; 
    207207    $strnavi = str_replace('onclick="fnNaviPage', 'onclick="form1.mode.value=\''.'\'; fnNaviPage', $strnavi); 
    208     $objPage->tpl_strnavi = $strnavi;       // ɽ¼¨Ê¸»úÎó 
    209     $startno = $objNavi->start_row;                 // ³«»Ï¹Ô 
    210      
    211     // ¼èÆÀÈϰϤλØÄê(³«»Ï¹ÔÈֹ桢¹Ô¿ô¤Î¥»¥Ã¥È) 
     208    $objPage->tpl_strnavi = $strnavi;       // 表示文字列 
     209    $startno = $objNavi->start_row;                 // 開始行 
     210     
     211    // 取得範囲の指定(開始行番号、行数のセット) 
    212212    $objQuery->setlimitoffset($disp_num, $startno); 
    213     // ɽ¼¨½ç½ø 
     213    // 表示順序 
    214214    $objQuery->setorder($order); 
    215215     
     
    221221     
    222222     
    223     // ¸¡º÷·ë²Ì¤Î¼èÆÀ 
     223    // 検索結果の取得 
    224224    $objPage->arrProducts = $objQuery->select("*", "vw_products_allclass AS allcls", $where, $arrval); 
    225225     
    226     // µ¬³Ê̾°ìÍ÷ 
     226    // 規格名一覧 
    227227    $arrClassName = sfGetIDValueList("dtb_class", "class_id", "name"); 
    228     // µ¬³ÊʬÎà̾°ìÍ÷ 
     228    // 規格分類名一覧 
    229229    $arrClassCatName = sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); 
    230     // ´ë²è¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹ÀßÄê 
     230    // 企画セレクトボックス設定 
    231231    if($disp_num == 15) { 
    232232        for($i = 0; $i < count($objPage->arrProducts); $i++) { 
    233233            $objPage = lfMakeSelect($objPage->arrProducts[$i]['product_id'], $arrClassName, $arrClassCatName); 
    234             // ¹ØÆþÀ©¸Â¿ô¤ò¼èÆÀ 
     234            // 購入制限数を取得 
    235235            $objPage = lfGetSaleLimit($objPage->arrProducts[$i]); 
    236236        } 
     
    240240} 
    241241 
    242 /* µ¬³Ê¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹¤ÎºîÀ® */ 
     242/* 規格セレクトボックスの作成 */ 
    243243function lfMakeSelect($product_id, $arrClassName, $arrClassCatName) { 
    244244    global $objPage; 
     
    246246    $classcat_find1 = false; 
    247247    $classcat_find2 = false; 
    248     // ºß¸Ë¤¢¤ê¤Î¾¦ÉʤÎ̵ͭ 
     248    // 在庫ありの商品の有無 
    249249    $stock_find = false; 
    250250     
    251     // ¾¦Éʵ¬³Ê¾ðÊó¤Î¼èÆÀ     
     251    // 商品規格情報の取得     
    252252    $arrProductsClass = lfGetProductsClass($product_id); 
    253253     
    254     // µ¬³Ê1¥¯¥é¥¹Ì¾¤Î¼èÆÀ 
     254    // 規格1クラス名の取得 
    255255    $objPage->tpl_class_name1[$product_id] = $arrClassName[$arrProductsClass[0]['class_id1']]; 
    256     // µ¬³Ê2¥¯¥é¥¹Ì¾¤Î¼èÆÀ 
     256    // 規格2クラス名の取得 
    257257    $objPage->tpl_class_name2[$product_id] = $arrClassName[$arrProductsClass[0]['class_id2']]; 
    258258     
    259     // ¤¹¤Ù¤Æ¤ÎÁȤ߹ç¤ï¤»¿ô    
     259    // すべての組み合わせ数    
    260260    $count = count($arrProductsClass); 
    261261     
     
    266266     
    267267    $list_id = 0; 
    268     $arrList[0] = "\tlist". $product_id. "_0 = new Array('ÁªÂò¤·¤Æ¤¯¤À¤µ¤¤'"; 
     268    $arrList[0] = "\tlist". $product_id. "_0 = new Array('選択してください'"; 
    269269    $arrVal[0] = "\tval". $product_id. "_0 = new Array(''"; 
    270270     
    271271    for ($i = 0; $i < $count; $i++) { 
    272         // ºß¸Ë¤Î¥Á¥§¥Ã¥¯ 
     272        // 在庫のチェック 
    273273        if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') { 
    274274            continue; 
     
    277277        $stock_find = true; 
    278278         
    279         // µ¬³Ê1¤Î¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹ÍÑ 
     279        // 規格1のセレクトボックス用 
    280280        if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){ 
    281281            $arrList[$list_id].=");\n"; 
     
    286286        } 
    287287         
    288         // µ¬³Ê2¤Î¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹ÍÑ 
     288        // 規格2のセレクトボックス用 
    289289        $classcat_id2 = $arrProductsClass[$i]['classcategory_id2']; 
    290290         
    291         // ¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹É½¼¨ÃÍ 
     291        // セレクトボックス表示値 
    292292        if($arrList[$list_id] == "") { 
    293             $arrList[$list_id] = "\tlist". $product_id. "_". $list_id. " = new Array('ÁªÂò¤·¤Æ¤¯¤À¤µ¤¤', '". $arrClassCatName[$classcat_id2]. "'"; 
     293            $arrList[$list_id] = "\tlist". $product_id. "_". $list_id. " = new Array('選択してください', '". $arrClassCatName[$classcat_id2]. "'"; 
    294294        } else { 
    295295            $arrList[$list_id].= ", '".$arrClassCatName[$classcat_id2]."'"; 
    296296        } 
    297297         
    298         // ¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹POSTÃÍ 
     298        // セレクトボックスPOST値 
    299299        if($arrVal[$list_id] == "") { 
    300300            $arrVal[$list_id] = "\tval". $product_id. "_". $list_id. " = new Array('', '". $classcat_id2. "'"; 
     
    307307    $arrVal[$list_id].=");\n"; 
    308308         
    309     // µ¬³Ê1 
     309    // 規格1 
    310310    $objPage->arrClassCat1[$product_id] = $arrSele; 
    311311     
     
    336336    $objPage->tpl_javascript.= $vals.");\n"; 
    337337     
    338     // ÁªÂò¤µ¤ì¤Æ¤¤¤ëµ¬³Ê2ID 
     338    // 選択されている規格2ID 
    339339    $classcategory_id = "classcategory_id". $product_id; 
    340340    $objPage->tpl_onload .= "lnSetSelect('".$classcategory_id."_1','".$classcategory_id."_2','".$product_id."','".$_POST[$classcategory_id."_2"]."'); "; 
    341341 
    342     // µ¬³Ê1¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë 
     342    // 規格1が設定されている 
    343343    if($arrProductsClass[0]['classcategory_id1'] != '0') { 
    344344        $classcat_find1 = true; 
    345345    } 
    346346     
    347     // µ¬³Ê2¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë 
     347    // 規格2が設定されている 
    348348    if($arrProductsClass[0]['classcategory_id2'] != '0') { 
    349349        $classcat_find2 = true; 
     
    356356    return $objPage; 
    357357} 
    358 /* ¾¦Éʵ¬³Ê¾ðÊó¤Î¼èÆÀ */ 
     358/* 商品規格情報の取得 */ 
    359359function lfGetProductsClass($product_id) { 
    360360    $arrRet = array(); 
    361361    if(sfIsInt($product_id)) { 
    362         // ¾¦Éʵ¬³Ê¼èÆÀ 
     362        // 商品規格取得 
    363363        $objQuery = new SC_Query(); 
    364364        $col = "product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited"; 
     
    371371} 
    372372 
    373 /* ÆþÎÏÆâÍƤΥÁ¥§¥Ã¥¯ */ 
     373/* 入力内容のチェック */ 
    374374function lfCheckError($id) { 
    375375    global $objPage; 
    376376     
    377     // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£ 
     377    // 入力データを渡す。 
    378378    $objErr = new SC_CheckError(); 
    379379     
     
    381381    $classcategory_id2 = "classcategory_id". $id. "_2"; 
    382382    $quantity = "quantity". $id; 
    383     // Ê£¿ô¹àÌÜ¥Á¥§¥Ã¥¯ 
     383    // 複数項目チェック 
    384384    if ($objPage->tpl_classcat_find1[$id]) { 
    385         $objErr->doFunc(array("µ¬³Ê1", $classcategory_id1, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 
     385        $objErr->doFunc(array("規格1", $classcategory_id1, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 
    386386    } 
    387387    if ($objPage->tpl_classcat_find2[$id]) { 
    388         $objErr->doFunc(array("µ¬³Ê2", $classcategory_id2, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 
    389     } 
    390     $objErr->doFunc(array("¸Ä¿ô", $quantity, INT_LEN), array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 
     388        $objErr->doFunc(array("規格2", $classcategory_id2, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 
     389    } 
     390    $objErr->doFunc(array("個数", $quantity, INT_LEN), array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 
    391391             
    392392    return $objErr->arrErr; 
    393393} 
    394394 
    395 // ¹ØÆþÀ©¸Â¿ô¤ÎÀßÄê 
     395// 購入制限数の設定 
    396396function lfGetSaleLimit($product) { 
    397397    global $objPage; 
    398     //ºß¸Ë¤¬Ìµ¸Â¤Þ¤¿¤Ï¹ØÆþÀ©¸ÂÃͤ¬ÀßÄêÃͤè¤êÂ礭¤¤¾ì¹ç 
     398    //在庫が無限または購入制限値が設定値より大きい場合 
    399399    if($product['sale_unlimited'] == 1 || $product['sale_limit'] > SALE_LIMIT_MAX) { 
    400400        $objPage->tpl_sale_limit[$product['product_id']] = SALE_LIMIT_MAX; 
     
    406406} 
    407407 
    408 //»ÙʧÊýË¡¤Î¼èÆÀ 
    409 //payment_id    1:Âå¶â°ú´¹¡¡2:¶ä¹Ô¿¶¤ê¹þ¤ß¡¡3:¸½¶â½ñα 
     408//支払方法の取得 
     409//payment_id    1:代金引換 2:銀行振り込み 3:現金書留 
    410410function lfGetPayment() { 
    411411    $objQuery = new SC_Query; 
Note: See TracChangeset for help on using the changeset viewer.