Changeset 16193


Ignore:
Timestamp:
2007/10/01 02:43:35 (16 years ago)
Author:
nanasess
Message:

クラス化対応

Location:
branches/feature-module-update
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • branches/feature-module-update/html/rss/product.php

    r15532 r16193  
    66 */ 
    77 
    8 //共通部品の読み込み 
     8// {{{ requires 
    99require_once("../require.php"); 
     10require_once(CLASS_PATH . "page_extends/rss/LC_Page_Rss_Products_Ex.php"); 
    1011 
    11 class LC_Page{ 
    12     function LC_Page(){ 
    13         $this->tpl_mainpage = "rss/product.tpl"; 
    14         $this->encode = "UTF-8"; 
    15         $this->title = "商品一覧情報"; 
    16     } 
    17 } 
     12// }}} 
     13// {{{ generate page 
    1814 
    19 $objQuery = new SC_Query(); 
    20 $objPage = new LC_Page(); 
    21 $objView = new SC_SiteView(); 
    22 $objSiteInfo = new SC_SiteInfo(); 
    23  
    24 //店舗情報をセット 
    25 $arrSiteInfo = $objSiteInfo->data; 
    26  
    27 //商品IDを取得 
    28 $product_id = $_GET['product_id']; 
    29 $mode = $_GET['mode']; 
    30  
    31 if(($product_id != "" and is_numeric($product_id)) or $mode == "all"){ 
    32     //商品詳細を取得 
    33     ($mode == "all") ? $arrProduct = lfGetProductsDetail($objQuery, $mode) : $arrProduct = lfGetProductsDetail($objQuery, $product_id); 
    34  
    35     // 値のセットし直し 
    36     foreach($arrProduct as $key => $val){ 
    37         //商品価格を税込みに編集 
    38         $arrProduct[$key]["price02"] = sfPreTax($arrProduct[$key]["price02"], $arrSiteInfo["tax"], $arrSiteInfo["tax_rule"]); 
    39          
    40         // 画像ファイルのURLセット 
    41         (file_exists(IMAGE_SAVE_DIR . $arrProduct[$key]["main_list_image"])) ? $dir = IMAGE_SAVE_URL_RSS : $dir = IMAGE_TEMP_URL_RSS; 
    42         $arrProduct[$key]["main_list_image"] = $dir . $arrProduct[$key]["main_list_image"]; 
    43         (file_exists(IMAGE_SAVE_DIR . $arrProduct[$key]["main_image"])) ? $dir = IMAGE_SAVE_URL_RSS : $dir = IMAGE_TEMP_URL_RSS; 
    44         $arrProduct[$key]["main_image"] = $dir . $arrProduct[$key]["main_image"]; 
    45         (file_exists(IMAGE_SAVE_DIR . $arrProduct[$key]["main_large_image"])) ? $dir = IMAGE_SAVE_URL_RSS : $dir = IMAGE_TEMP_URL_RSS; 
    46         $arrProduct[$key]["main_large_image"] = $dir . $arrProduct[$key]["main_large_image"]; 
    47          
    48         // ポイント計算 
    49         $arrProduct[$key]["point"] = sfPrePoint($arrProduct[$key]["price02"], $arrProduct[$key]["point_rate"], POINT_RULE, $arrProduct[$key]["product_id"]); 
    50     } 
    51 }elseif($mode == "list"){ 
    52     //商品一覧を取得 
    53     $arrProduct = $objQuery->getall("SELECT product_id, name AS product_name FROM dtb_products"); 
    54 }else{ 
    55     $arrProduct = lfGetProductsAllclass($objQuery); 
    56      
    57     // 値のセットし直し 
    58     foreach($arrProduct as $key => $val){ 
    59         //商品価格を税込みに編集 
    60         $arrProduct[$key]["price01_max"] = sfPreTax($arrProduct[$key]["price01_max"], $arrSiteInfo["tax"], $arrSiteInfo["tax_rule"]); 
    61         $arrProduct[$key]["price01_min"] = sfPreTax($arrProduct[$key]["price01_min"], $arrSiteInfo["tax"], $arrSiteInfo["tax_rule"]); 
    62         $arrProduct[$key]["price02_max"] = sfPreTax($arrProduct[$key]["price02_max"], $arrSiteInfo["tax"], $arrSiteInfo["tax_rule"]); 
    63         $arrProduct[$key]["price02_min"] = sfPreTax($arrProduct[$key]["price02_min"], $arrSiteInfo["tax"], $arrSiteInfo["tax_rule"]); 
    64          
    65         // 画像ファイルのURLセット 
    66         (file_exists(IMAGE_SAVE_DIR . $arrProduct[$key]["main_list_image"])) ? $dir = IMAGE_SAVE_URL_RSS : $dir = IMAGE_TEMP_URL_RSS; 
    67         $arrProduct[$key]["main_list_image"] = $dir . $arrProduct[$key]["main_list_image"]; 
    68         (file_exists(IMAGE_SAVE_DIR . $arrProduct[$key]["main_image"])) ? $dir = IMAGE_SAVE_URL_RSS : $dir = IMAGE_TEMP_URL_RSS; 
    69         $arrProduct[$key]["main_image"] = $dir . $arrProduct[$key]["main_image"]; 
    70         (file_exists(IMAGE_SAVE_DIR . $arrProduct[$key]["main_large_image"])) ? $dir = IMAGE_SAVE_URL_RSS : $dir = IMAGE_TEMP_URL_RSS; 
    71         $arrProduct[$key]["main_large_image"] = $dir . $arrProduct[$key]["main_large_image"]; 
    72          
    73         // ポイント計算 
    74         $arrProduct[$key]["point_max"] = sfPrePoint($arrProduct[$key]["price02_max"], $arrProduct[$key]["point_rate"], POINT_RULE, $arrProduct[$key]["product_id"]); 
    75         $arrProduct[$key]["point_min"] = sfPrePoint($arrProduct[$key]["price02_min"], $arrProduct[$key]["point_rate"], POINT_RULE, $arrProduct[$key]["product_id"]); 
    76     } 
    77 } 
    78  
    79 //商品情報をセット 
    80 $objPage->arrProduct = $arrProduct; 
    81 if(is_array(sfswaparray($arrProduct))){ 
    82     $objPage->arrProductKeys = array_keys(sfswaparray($arrProduct)); 
    83 } 
    84  
    85 //店舗情報をセット 
    86 $objPage->arrSiteInfo = $arrSiteInfo; 
    87  
    88 //セットしたデータをテンプレートファイルに出力 
    89 $objView->assignobj($objPage); 
    90  
    91 //キャッシュしない(念のため) 
    92 header("Pragma: no-cache"); 
    93  
    94 //XMLテキスト(これがないと正常にRSSとして認識してくれないツールがあるため) 
    95 header("Content-type: application/xml"); 
    96 DETAIL_P_HTML; 
    97  
    98 //画面表示 
    99 $objView->display($objPage->tpl_mainpage, true); 
    100  
    101 //--------------------------------------------------------------------------------------------------------------------- 
    102 /************************************************************************************************************** 
    103  * 関数名:lfGetProducts 
    104  * 説明 :商品情報を取得する 
    105  * 引数1:$objQuery        DB操作クラス 
    106  * 引数2:$product_id  商品ID 
    107  * 戻り値:$arrProduct  取得結果を配列で返す 
    108  **************************************************************************************************************/ 
    109 function lfGetProductsDetail($objQuery, $product_id = "all"){ 
    110     $sql = ""; 
    111     $sql .= "SELECT "; 
    112     $sql .= "   prod.product_id "; 
    113     $sql .= "   ,prod.name AS product_name "; 
    114     $sql .= "   ,prod.category_id "; 
    115     $sql .= "   ,prod.point_rate "; 
    116     $sql .= "   ,prod.comment3 "; 
    117     $sql .= "   ,prod.main_list_comment "; 
    118     $sql .= "   ,prod.main_list_image "; 
    119     $sql .= "   ,prod.main_comment "; 
    120     $sql .= "   ,prod.main_image "; 
    121     $sql .= "   ,prod.main_large_image "; 
    122     $sql .= "   ,cls.product_code "; 
    123     $sql .= "   ,cls.price01 "; 
    124     $sql .= "   ,cls.price02 "; 
    125     $sql .= "   ,cls.classcategory_id1 "; 
    126     $sql .= "   ,cls.classcategory_id2 "; 
    127     $sql .= "   ,(SELECT name FROM dtb_classcategory AS clscat WHERE clscat.classcategory_id = cls.classcategory_id1) AS classcategory_name1 "; 
    128     $sql .= "   ,(SELECT name FROM dtb_classcategory AS clscat WHERE clscat.classcategory_id = cls.classcategory_id2) AS classcategory_name2 "; 
    129     $sql .= "   ,(SELECT category_name FROM dtb_category AS cat WHERE cat.category_id = prod.category_id) AS category_name"; 
    130     $sql .= " FROM dtb_products AS prod, dtb_products_class AS cls"; 
    131     $sql .= " WHERE prod.product_id = cls.product_id AND prod.del_flg = 0 AND prod.status = 1"; 
    132      
    133     if($product_id != "all"){ 
    134         $sql .= " AND prod.product_id = ?"; 
    135         $arrval = array($product_id); 
    136     } 
    137     $sql .= " ORDER BY prod.product_id, cls.classcategory_id1, cls.classcategory_id2"; 
    138     $arrProduct = $objQuery->getall($sql, $arrval); 
    139     return $arrProduct; 
    140 } 
    141  
    142 /************************************************************************************************************** 
    143  * 関数名:lfGetProductsAllclass 
    144  * 説明 :商品情報を取得する(vw_products_allclass使用) 
    145  * 引数1:$objQuery        DB操作クラス 
    146  * 戻り値:$arrProduct  取得結果を配列で返す 
    147  **************************************************************************************************************/ 
    148 function lfGetProductsAllclass($objQuery){ 
    149     $sql = ""; 
    150     $sql .= "SELECT   
    151                 product_id 
    152                 ,name as product_name 
    153                 ,category_id 
    154                 ,point_rate 
    155                 ,comment3 
    156                 ,main_list_comment 
    157                 ,main_image 
    158                 ,main_list_image 
    159                 ,product_code_min 
    160                 ,product_code_max 
    161                 ,price01_min 
    162                 ,price01_max 
    163                 ,price02_min 
    164                 ,price02_max 
    165                 ,(SELECT category_name FROM dtb_category AS cat WHERE cat.category_id = allcls.category_id) AS category_name 
    166                 ,(SELECT main_large_image FROM dtb_products AS prod WHERE prod.product_id = allcls.product_id) AS main_large_image 
    167             FROM  vw_products_allclass as allcls 
    168             WHERE allcls.del_flg = 0 AND allcls.status = 1"; 
    169     $sql .= " ORDER BY allcls.product_id"; 
    170     $arrProduct = $objQuery->getall($sql); 
    171     return $arrProduct; 
    172 } 
    173  
    174  
     15$objPage = new LC_Page_Rss_Products_Ex(); 
     16$objPage->init(); 
     17$objPage->process(); 
     18register_shutdown_function(array($objPage, "destroy")); 
    17519?> 
Note: See TracChangeset for help on using the changeset viewer.