Ignore:
Timestamp:
2011/02/12 14:44:10 (13 years ago)
Author:
kimoto
Message:

リファクタリング
*SC_PageNaviの改善 eregの除去 携帯/PC両方で使えるようにパラメーターの追加 htmlspecialcharsを内部でやるように追記 all_rowを返せるように追記

File:
1 edited

Legend:

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

    r20148 r20155  
    4949    function init() { 
    5050        parent::init(); 
    51         $this->tpl_title        = 'MYページ'; 
    52         if (Net_UserAgent_Mobile::isMobile() === true){ 
     51        $this->tpl_mypageno = 'index'; 
     52        if (SC_Display::detectDevice() === DEVICE_TYPE_MOBILE){ 
    5353            $this->tpl_subtitle = 'MYページ'; 
    5454        } else { 
    5555            $this->tpl_subtitle = '購入履歴一覧'; 
    5656        } 
    57         $this->tpl_navi         = TEMPLATE_REALDIR . 'mypage/navi.tpl'; 
    58         $this->tpl_mainno       = 'mypage'; 
    59         $this->tpl_mypageno     = 'index'; 
    6057        $this->httpCacheControl('nocache'); 
    6158    } 
     
    7774    function action() { 
    7875 
    79         $objQuery = new SC_Query(); 
    8076        $objCustomer = new SC_Customer(); 
     77        $customer_id = $objCustomer->getvalue('customer_id'); 
    8178 
    8279        //ページ送り用 
    83         if (isset($_POST['pageno'])) { 
    84             $this->tpl_pageno = htmlspecialchars($_POST['pageno'], ENT_QUOTES, CHAR_CODE); 
    85         } 
     80        $this->objNavi = new SC_PageNavi($_REQUEST['pageno'], 
     81                                         $this->lfGetOrderHistory($customer_id), 
     82                                         SEARCH_PMAX, 
     83                                         "fnNaviPage", 
     84                                         NAVI_PMAX, 
     85                                         'pageno=#page#', 
     86                                         SC_Display::detectDevice() !== DEVICE_TYPE_MOBILE); 
    8687 
    87         $col = "order_id, create_date, payment_id, payment_total"; 
    88         $from = "dtb_order"; 
    89         $where = "del_flg = 0 AND customer_id=?"; 
    90         $arrval = array($objCustomer->getvalue('customer_id')); 
    91         $order = "order_id DESC"; 
    92  
    93         $linemax = $objQuery->count($from, $where, $arrval); 
    94         $this->tpl_linemax = $linemax; 
    95  
    96         if (Net_UserAgent_Mobile::isMobile() === true){ 
    97             define ("HISTORY_NUM", 5);  // TODO 
    98             $pageNo = isset($_GET['pageno']) ? (int) $_GET['pageno'] : 0; // TODO 
    99  
    100             // ページ送りの取得 
    101             // next 
    102             if ($pageNo + HISTORY_NUM < $linemax) { 
    103                 $next = "<a href='?pageno=" . ($pageNo + HISTORY_NUM) . "'>次へ→</a>"; 
    104             } else { 
    105                 $next = ""; 
    106             } 
    107  
    108             // previous 
    109             if ($pageNo - HISTORY_NUM > 0) { 
    110                 $previous = "<a href='?pageno=" . ($pageNo - HISTORY_NUM) . "'>←前へ</a>"; 
    111             } elseif ($pageNo == 0) { 
    112                 $previous = ""; 
    113             } else { 
    114                 $previous = "<a href='?pageno=0'>←前へ</a>"; 
    115             } 
    116  
    117             // bar 
    118             if ($next != '' && $previous != '') { 
    119                 $bar = " | "; 
    120             } else { 
    121                 $bar = ""; 
    122             } 
    123  
    124             $this->tpl_strnavi = $previous . $bar . $next; 
    125  
    126             // 取得範囲の指定(開始行番号、行数のセット) 
    127             $objQuery->setLimitOffset(HISTORY_NUM, $pageNo); 
    128         } else { 
    129             // ページ送りの取得 
    130             $objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, SEARCH_PMAX, "fnNaviPage", NAVI_PMAX); 
    131             $this->tpl_strnavi = $objNavi->strnavi;     // 表示文字列 
    132             $startno = $objNavi->start_row; 
    133  
    134             // 取得範囲の指定(開始行番号、行数のセット) 
    135             $objQuery->setLimitOffset(SEARCH_PMAX, $startno); 
    136         } 
    137  
    138         // 表示順序 
    139         $objQuery->setOrder($order); 
    140  
    141         //購入履歴の取得 
    142         $this->arrOrder = $objQuery->select($col, $from, $where, $arrval); 
     88        $this->arrOrder = $this->lfGetOrderHistory($customer_id, $this->objNavi->start_row); 
    14389 
    14490        // 支払い方法の取得 
    145         $objDb = new SC_Helper_DB_Ex(); 
    146         $this->arrPayment = $objDb->sfGetIDValueList("dtb_payment", "payment_id", "payment_method"); 
    147  
     91        $this->arrPayment = SC_Helper_DB_Ex::sfGetIDValueList("dtb_payment", "payment_id", "payment_method"); 
    14892    } 
    14993 
     
    156100        parent::destroy(); 
    157101    } 
     102 
     103 
     104    /** 
     105     * 受注履歴を返す 
     106     * 
     107     * @param mixed $customer_id 
     108     * @param mixed $startno 0以上の場合は受注履歴を返却する -1の場合は件数を返す 
     109     * @access private 
     110     * @return void 
     111     */ 
     112    function lfGetOrderHistory($customer_id, $startno = -1) { 
     113        $objQuery   = SC_Query::getSingletonInstance(); 
     114 
     115        $col        = "order_id, create_date, payment_id, payment_total"; 
     116        $from       = "dtb_order"; 
     117        $where      = "del_flg = 0 AND customer_id = ?"; 
     118        $arrval     = array($customer_id); 
     119        $order      = "order_id DESC"; 
     120 
     121        if ($startno == -1) { 
     122            return $objQuery->count($from, $where, $arrval); 
     123        } 
     124 
     125        $objQuery->setLimitOffset(SEARCH_PMAX, $startno); 
     126        // 表示順序 
     127        $objQuery->setOrder($order); 
     128 
     129        //購入履歴の取得 
     130        return $objQuery->select($col, $from, $where, $arrval); 
     131    } 
    158132} 
Note: See TracChangeset for help on using the changeset viewer.