Changeset 20076


Ignore:
Timestamp:
2011/02/03 18:40:05 (13 years ago)
Author:
yomoro
Message:

#986 リファクタリング

Location:
branches/version-2_5-dev/data/class/pages/frontparts
Files:
9 edited

Legend:

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

    r20041 r20076  
    6565     */ 
    6666    function action() { 
     67        // URLチェック 
     68        $this->lfCheckValidAccess(); 
     69         
     70        // 会員管理クラス 
    6771        $objCustomer = new SC_Customer(); 
     72        // クッキー管理クラス 
     73        $objCookie = new SC_Cookie(COOKIE_EXPIRE); 
     74        // パラメータ管理クラス 
     75        $this->objFormParam = new SC_FormParam(); 
     76         
     77        // パラメータ情報の初期化 
     78        $this->lfInitParam($this->objFormParam); 
     79         
     80        // リクエスト値をフォームにセット 
     81        $objFormParam->setParam($this->lfConvertParam($_POST)); 
     82         
     83        // モードによって分岐 
     84        switch ($this->getMode()) { 
     85        case 'login': 
     86            // ログイン 
     87            $this->lfLogin($objCustomer, $objCookie); 
     88            break; 
     89        case 'logout': 
     90            // ログアウト 
     91            $this->lfLogout($objCustomer); 
     92            break; 
     93        default: 
     94            break; 
     95        } 
     96         
     97    } 
     98 
     99    /** 
     100     * デストラクタ. 
     101     * 
     102     * @return void 
     103     */ 
     104    function destroy() { 
     105        parent::destroy(); 
     106    } 
     107 
     108    /** 
     109     * 正常なアクセスかチェックする. 
     110     * 
     111     * @return void 
     112     */ 
     113    function lfCheckValidAccess() { 
     114         
    68115        // 不正なURLがPOSTされた場合はエラー表示 
    69116        if (!SC_Helper_Session_Ex::isValidToken()) { 
     
    71118            SC_Utils_Ex::sfDispSiteError(PAGE_ERROR); 
    72119        } 
    73         // クッキー管理クラス 
    74         $objCookie = new SC_Cookie(COOKIE_EXPIRE); 
    75         // パラメータ管理クラス 
    76         $this->objFormParam = new SC_FormParam(); 
    77         // パラメータ情報の初期化 
    78         $this->lfInitParam(); 
    79         //パスワード・Eメールにある空白をトリム 
    80         $_POST["login_email"] = preg_replace('/^[  \r\n]*(.*?)[  \r\n]*$/u', '$1', $_POST["login_email"]); 
    81         $_POST["login_pass"] = trim($_POST["login_pass"]); //認証用 
    82         $_POST["login_pass1"] = $_POST["login_pass"];      //最小桁数比較用 
    83         $_POST["login_pass2"] = $_POST["login_pass"];      //最大桁数比較用 
    84         // POST値の取得 
    85         $this->objFormParam->setParam($_POST); 
    86  
    87         switch($this->getMode()) { 
    88         case 'login': 
    89             $this->objFormParam->toLower('login_email'); 
    90             $arrErr = $this->objFormParam->checkError(); 
    91  
    92             // エラーの場合はエラー画面に遷移 
    93             if (count($arrErr) > 0) { 
    94                 SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR); 
     120         
     121    } 
     122 
     123    /** 
     124     * パラメータ情報の初期化. 
     125     * 
     126     * @param SC_FormParam $objFormParam パラメータ管理クラス 
     127     * @return SC_FormParam $objFormParam 初期化したパラメータ管理クラスを返す 
     128     */ 
     129    function lfInitParam(&$objFormParam) { 
     130        $objFormParam->addParam('記憶する', 'login_memory', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); 
     131        $objFormParam->addParam('メールアドレス', 'login_email', MTEXT_LEN, 'a', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'EMAIL_CHECK', 'NO_SPTAB' ,'EMAIL_CHAR_CHECK')); 
     132        $objFormParam->addParam('パスワード', 'login_pass', PASSWORD_LEN1, '', array('EXIST_CHECK')); 
     133        $objFormParam->addParam('パスワード', 'login_pass1', PASSWORD_LEN1, '', array('EXIST_CHECK', 'MIN_LENGTH_CHECK')); 
     134        $objFormParam->addParam('パスワード', 'login_pass2', PASSWORD_LEN2, '', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); 
     135        return $objFormParam; 
     136    } 
     137 
     138    /** 
     139     * リクエスト値の整形. 
     140     * 
     141     * @param array $arrRequest リクエスト 
     142     * @return array $arrRequest 整形したリクエストを返す 
     143     */ 
     144    function lfConvertParam($arrRequest) { 
     145        // パスワード・Eメールにある空白をトリム 
     146        $arrRequest['login_email'] = preg_replace('/^[  \r\n]*(.*?)[  \r\n]*$/u', '$1', $arrRequest['login_email']); 
     147        $arrRequest['login_pass'] = trim($arrRequest['login_pass']); //認証用 
     148        $arrRequest['login_pass1'] = $arrRequest['login_pass'];      //最小桁数比較用 
     149        $arrRequest['login_pass2'] = $arrRequest['login_pass'];      //最大桁数比較用 
     150        return $arrRequest; 
     151    } 
     152 
     153    /** 
     154     * ログイン. 
     155     * 
     156     * @param SC_Customer $objCustomer 会員管理クラス 
     157     * @param SC_Cookie $objCookie クッキー管理クラス 
     158     * @return void 
     159     */ 
     160    function lfLogin($objCustomer, $objCookie) { 
     161        // 入力値のエラーチェック 
     162        $this->objFormParam->toLower('login_email'); 
     163        $arrErr = $this->objFormParam->checkError(); 
     164         
     165        // エラーの場合はエラー画面に遷移 
     166        if (count($arrErr) > 0) { 
     167            SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR); 
     168        } 
     169         
     170        // 入力チェック後の値を取得 
     171        $arrForm = $this->objFormParam->getHashArray(); 
     172         
     173        // クッキー保存判定 
     174        if ($arrForm['login_memory'] == '1' && $arrForm['login_email'] != '') { 
     175            $objCookie->setCookie('login_email', $arrForm['login_email']); 
     176        } else { 
     177            $objCookie->setCookie('login_email', ''); 
     178        } 
     179         
     180        // 遷移先の制御 
     181        if (count($arrErr) == 0) { 
     182            // ログイン処理 
     183            if ($objCustomer->getCustomerDataFromEmailPass($arrForm['login_pass'], $arrForm['login_email'], true)) { 
     184                // --- ログインに成功した場合 
     185                SC_Response_Ex::sendRedirect(HTTP_URL); 
     186                exit; 
     187            } else { 
     188                // --- ログインに失敗した場合 
     189                $arrForm['login_email'] = strtolower($arrForm['login_email']); 
     190                $objQuery = SC_Query::getSingletonInstance(); 
     191                $where = '(email = ? OR email_mobile = ?) AND status = 1 AND del_flg = 0'; 
     192                $ret = $objQuery->count("dtb_customer", $where, array($arrForm['login_email'], $arrForm['login_email'])); 
     193                // ログインエラー表示 
     194                if($ret > 0) { 
     195                    SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR); 
     196                } else { 
     197                    SC_Utils_Ex::sfDispSiteError(SITE_LOGIN_ERROR); 
     198                } 
    95199            } 
    96             $arrForm =  $this->objFormParam->getHashArray(); 
    97             // クッキー保存判定 
    98             if ($arrForm['login_memory'] == "1" && $arrForm['login_email'] != "") { 
    99                 $objCookie->setCookie('login_email', $_POST['login_email']); 
    100             } else { 
    101                 $objCookie->setCookie('login_email', ''); 
    102             } 
    103  
    104             if(count($arrErr) == 0) { 
    105                 if($objCustomer->getCustomerDataFromEmailPass($arrForm['login_pass'], $arrForm['login_email'], true)) { 
    106                     SC_Response_Ex::sendRedirect(HTTP_URL); 
    107                     exit; 
    108                 } else { 
    109                     $arrForm['login_email'] = strtolower($arrForm['login_email']); 
    110                     $objQuery = new SC_Query; 
    111                     $where = "(email = ? OR email_mobile = ?) AND status = 1 AND del_flg = 0"; 
    112                     $ret = $objQuery->count("dtb_customer", $where, array($arrForm['login_email'], $arrForm['login_email'])); 
    113  
    114                     if($ret > 0) { 
    115                         SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR); 
    116                     } else { 
    117                         SC_Utils_Ex::sfDispSiteError(SITE_LOGIN_ERROR); 
    118                     } 
    119                 } 
    120             } else { 
    121                 // 入力エラーの場合、元のアドレスに戻す。 
    122                 // FIXME $_POST['url'] には、URL ではなく、url-path が渡るもよう。HTTPS 利用に関わる問題も考えられるので、URL が渡るように改善した方が良いように感じる。 
    123                 SC_Response_Ex::sendRedirect($_POST['url']); 
    124                 exit; 
    125             } 
    126             break; 
    127         case 'logout': 
    128             // ログイン情報の解放 
    129             $objCustomer->EndSession(); 
    130             $mypage_url_search = strpos('.'.$_POST['url'], "mypage"); 
    131             //マイページログイン中はログイン画面へ移行 
    132             if ($mypage_url_search == 2){ 
    133                 SC_Response_Ex::sendRedirectFromUrlPath('mypage/login.php'); 
    134             } 
     200        } else { 
     201            // 入力エラーの場合、元のアドレスに戻す。 
     202            // FIXME $_POST['url'] には、URL ではなく、url-path が渡るもよう。HTTPS 利用に関わる問題も考えられるので、URL が渡るように改善した方が良いように感じる。 
     203            SC_Response_Ex::sendRedirect($_POST['url']); 
     204            exit; 
     205        } 
     206    } 
     207 
     208    /** 
     209     * ログアウト. 
     210     * 
     211     * @param SC_Customer $objCustomer 会員管理クラス 
     212     * @return void 
     213     */ 
     214    function lfLogout($objCustomer) { 
     215        // ログイン情報の解放 
     216        $objCustomer->EndSession(); 
     217         
     218        // 画面遷移の制御 
     219        $mypage_url_search = strpos('.'.$_POST['url'], 'mypage'); 
     220        if ($mypage_url_search == 2) { 
     221            // マイページログイン中はログイン画面へ移行 
     222            SC_Response_Ex::sendRedirectFromUrlPath('mypage/login.php'); 
     223        } else { 
    135224            // 上記以外の場合、トップへ遷移 
    136             else{ 
    137                 SC_Response_Ex::sendRedirect(HTTP_URL); 
    138             } 
    139             exit; 
    140             break; 
    141         } 
    142     } 
    143  
    144     /** 
    145      * デストラクタ. 
    146      * 
    147      * @return void 
    148      */ 
    149     function destroy() { 
    150         parent::destroy(); 
    151     } 
    152  
    153     /* パラメータ情報の初期化 */ 
    154     function lfInitParam() { 
    155         $this->objFormParam->addParam("記憶する", "login_memory", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); 
    156         $this->objFormParam->addParam("メールアドレス", "login_email", MTEXT_LEN, "a", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "EMAIL_CHECK", "NO_SPTAB" ,"EMAIL_CHAR_CHECK")); 
    157         $this->objFormParam->addParam("パスワード", "login_pass", PASSWORD_LEN1, "", array("EXIST_CHECK")); 
    158         $this->objFormParam->addParam("パスワード", "login_pass1", PASSWORD_LEN1, "", array("EXIST_CHECK", "MIN_LENGTH_CHECK")); 
    159         $this->objFormParam->addParam("パスワード", "login_pass2", PASSWORD_LEN2, "", array("EXIST_CHECK", "MAX_LENGTH_CHECK")); 
    160     } 
     225            SC_Response_Ex::sendRedirect(HTTP_URL); 
     226        } 
     227         
     228        exit; 
     229    } 
     230 
    161231} 
    162232?> 
  • branches/version-2_5-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc.php

    r19805 r20076  
    3434class LC_Page_FrontParts_Bloc extends LC_Page { 
    3535 
    36     // TODO 
     36    /** 
     37     * Page を初期化する. 
     38     * 
     39     * @return void 
     40     */ 
    3741    function init() { 
    3842        // 開始時刻を設定する。 
  • branches/version-2_5-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Best5.php

    r19903 r20076  
    8181    } 
    8282 
    83     //おすすめ商品検索 
     83    /** 
     84     * おすすめ商品検索. 
     85     * 
     86     * @return array $arrBestProducts 検索結果配列 
     87     */ 
    8488    function lfGetRanking(){ 
    85         $objQuery = new SC_Query(); 
     89        $objQuery = SC_Query::getSingletonInstance(); 
    8690        // FIXME SC_Product クラスを使用した実装 
    87         $col = "DISTINCT A.*, name, price02_min, price01_min, main_list_image "; 
    88         $from = "dtb_best_products AS A INNER JOIN vw_products_allclass AS allcls using(product_id)"; 
    89         $where = "allcls.del_flg = 0 AND allcls.status = 1"; 
     91        $col = 'DISTINCT A.*, name, price02_min, price01_min, main_list_image '; 
     92        $from = 'dtb_best_products AS A INNER JOIN vw_products_allclass AS allcls using(product_id)'; 
     93        $where = 'allcls.del_flg = 0 AND allcls.status = 1'; 
    9094         
    9195        // 在庫無し商品の非表示 
     
    9498        } 
    9599         
    96         $order = "rank"; 
     100        $order = 'rank'; 
    97101        $objQuery->setOrder($order); 
    98102        $objQuery->setLimit(RECOMMEND_NUM); 
  • branches/version-2_5-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Calendar.php

    r19807 r20076  
    8080     */ 
    8181    function mobileInit() { 
    82          $this->tpl_mainpage = MOBILE_TEMPLATE_REALDIR . "frontparts/" 
     82         $this->tpl_mainpage = MOBILE_TEMPLATE_REALDIR . 'frontparts/' 
    8383            . BLOC_DIR . 'best5.tpl'; 
    8484    } 
     
    102102    } 
    103103 
    104     // カレンダー情報取得 
     104    /** 
     105     * カレンダー情報取得. 
     106     * 
     107     * @param integer $disp_month 表示する月数 
     108     * @return array $arrCalendar カレンダー情報の配列を返す 
     109     */ 
    105110    function lfGetCalendar($disp_month = 1){ 
    106111 
     
    113118            } 
    114119 
    115             $Month = new Calendar_Month_Weekdays($year, $month, 0); 
    116             $Month->build(); 
     120            $objMonth = new Calendar_Month_Weekdays($year, $month, 0); 
     121            $objMonth->build(); 
    117122            $i = 0; 
    118             while ($Day = $Month->fetch()) { 
    119                 if ($month == $Day->month) { 
     123            while ($objDay = $objMonth->fetch()) { 
     124                if ($month == $objDay->month) { 
    120125                    $arrCalendar[$j][$i]['in_month'] = true; 
    121126                } else { 
    122127                    $arrCalendar[$j][$i]['in_month'] = false; 
    123128                } 
    124                 $arrCalendar[$j][$i]['first'] = $Day->first; 
    125                 $arrCalendar[$j][$i]['last'] = $Day->last; 
    126                 $arrCalendar[$j][$i]['empty'] = $Day->empty; 
     129                $arrCalendar[$j][$i]['first'] = $objDay->first; 
     130                $arrCalendar[$j][$i]['last'] = $objDay->last; 
     131                $arrCalendar[$j][$i]['empty'] = $objDay->empty; 
    127132                $arrCalendar[$j][$i]['year'] = $year; 
    128133                $arrCalendar[$j][$i]['month'] = $month; 
    129                 $arrCalendar[$j][$i]['day'] = $Day->day; 
    130                 if ($this->lfCheckHoliday($year, $month, $Day->day)) { 
     134                $arrCalendar[$j][$i]['day'] = $objDay->day; 
     135                if ($this->lfCheckHoliday($year, $month, $objDay->day)) { 
    131136                    $arrCalendar[$j][$i]['holiday'] = true; 
    132137                } else { 
     
    140145    } 
    141146 
    142     // 休日取得 
     147    /** 
     148     * 休日取得. 
     149     * 
     150     * @return array $arrHoliday 休日情報の配列を返す 
     151     */ 
    143152    function lfGetHoliday() { 
    144         $objQuery = new SC_Query(); 
    145         $objQuery->setOrder("rank DESC"); 
     153        $objQuery = SC_Query::getSingletonInstance(); 
     154        $objQuery->setOrder('rank DESC'); 
    146155 
    147         $where = "del_flg <> 1"; 
    148         $arrRet = $objQuery->select("month, day", "dtb_holiday", $where); 
     156        $where = 'del_flg <> 1'; 
     157        $arrRet = $objQuery->select('month, day', 'dtb_holiday', $where); 
    149158        foreach ($arrRet AS $key=>$val) { 
    150159            $arrHoliday[$val['month']][] = $val['day']; 
     
    153162    } 
    154163 
    155     // 定休日取得 
     164    /** 
     165     * 定休日取得. 
     166     * 
     167     * @return array $arrRegularHoliday 定休日情報の配列を返す 
     168     */ 
    156169    function lfGetRegularHoliday() { 
    157         $objSIteInfo = new SC_SiteInfo(); 
    158         $arrRegularHoliday = explode('|', $objSIteInfo->data['regular_holiday_ids']); 
     170        $objSiteInfo = new SC_SiteInfo(); 
     171        $arrRegularHoliday = explode('|', $objSiteInfo->data['regular_holiday_ids']); 
    159172        return $arrRegularHoliday; 
    160173    } 
    161174 
    162     // 休日チェック 
     175    /** 
     176     * 休日チェック取得. 
     177     * 
     178     * @param integer $year 年 
     179     * @param integer $month 月 
     180     * @param integer $day 日 
     181     * @return boolean 休日の場合trueを返す 
     182     */ 
    163183    function lfCheckHoliday($year, $month, $day) { 
    164184        if (!empty($this->arrHoliday[$month])) { 
     
    168188        } 
    169189        if (!empty($this->arrRegularHoliday)) { 
    170             $w = date('w', mktime(0,0,0 ,$month, $day, $year)); 
    171             if (in_array($w, $this->arrRegularHoliday)) { 
     190            $day = date('w', mktime(0,0,0 ,$month, $day, $year)); 
     191            if (in_array($day, $this->arrRegularHoliday)) { 
    172192                return true; 
    173193            } 
  • branches/version-2_5-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Cart.php

    r20007 r20076  
    6565        $objCart = new SC_CartSession(); 
    6666        $objSiteInfo = new SC_SiteInfo; 
    67  
    68         $cartKeys = $objCart->getKeys(); 
    69         foreach ($cartKeys as $cartKey) { 
    70  
    71             // カート情報を取得 
    72             $arrCartList = $objCart->getCartList($cartKey); 
    73  
    74             // カート内の商品ID一覧を取得 
    75             $arrAllProductID = $objCart->getAllProductID($cartKey); 
    76             // 商品が1つ以上入っている場合には商品名称を取得 
    77             if (count($arrCartList) > 0){ 
    78  
    79                 foreach($arrCartList['productsClass'] as $key => $val){ 
    80                     $arrCartList[$key]['product_name'] = $val['name']; 
    81                 } 
    82             } 
    83             // 購入金額合計 
    84             $ProductsTotal += $objCart->getAllProductsTotal($cartKey); 
    85             // 合計数量 
    86             $TotalQuantity += $objCart->getTotalQuantity($cartKey); 
    87  
    88         } 
    89  
    90         // 店舗情報の取得 
    91         $arrInfo = $objSiteInfo->data; 
    92  
    93         // 送料無料までの金額 
    94         $arrCartList[0]['ProductsTotal'] = $ProductsTotal; 
    95         $arrCartList[0]['TotalQuantity'] = $TotalQuantity; 
    96  
    97         $deliv_free = $arrInfo['free_rule'] - $ProductsTotal; 
    98         $arrCartList[0]['free_rule'] = $arrInfo['free_rule']; 
    99         $arrCartList[0]['deliv_free'] = $deliv_free; 
    100  
    10167        $this->isMultiple = $objCart->isMultiple(); 
    102         $this->arrCartList = $arrCartList; 
     68        $this->arrCartList = $this->lfGetCartData($objCart, $objSiteInfo); 
    10369    } 
    10470 
     
    11177        parent::destroy(); 
    11278    } 
     79 
     80    /** 
     81     * カートの情報を取得する 
     82     * 
     83     * @param SC_CartSession $objCart カートセッション管理クラス 
     84     * @param SC_SiteInfo $objSiteInfo サイト情報クラス 
     85     * @return array $arrCartList カートデータ配列 
     86     */ 
     87    function lfGetCartData($objCart, $objSiteInfo) { 
     88        $arrCartKeys = $objCart->getKeys(); 
     89        foreach ($arrCartKeys as $cart_key) { 
     90            // カート情報を取得 
     91            $arrCartList = $objCart->getCartList($cart_key); 
     92            // カート内の商品ID一覧を取得 
     93            $arrAllProductID = $objCart->getAllProductID($cart_key); 
     94            // 商品が1つ以上入っている場合には商品名称を取得 
     95            if (count($arrCartList) > 0){ 
     96                 
     97                foreach($arrCartList['productsClass'] as $key => $val){ 
     98                    $arrCartList[$key]['product_name'] = $val['name']; 
     99                } 
     100            } 
     101            // 購入金額合計 
     102            $products_total += $objCart->getAllProductsTotal($cart_key); 
     103            // 合計数量 
     104            $total_quantity += $objCart->getTotalQuantity($cart_key); 
     105        } 
     106         
     107        // 店舗情報の取得 
     108        $arrInfo = $objSiteInfo->data; 
     109         
     110        // 送料無料までの金額 
     111        $arrCartList[0]['ProductsTotal'] = $products_total; 
     112        $arrCartList[0]['TotalQuantity'] = $total_quantity; 
     113         
     114        $deliv_free = $arrInfo['free_rule'] - $products_total; 
     115        $arrCartList[0]['free_rule'] = $arrInfo['free_rule']; 
     116        $arrCartList[0]['deliv_free'] = $deliv_free; 
     117         
     118        return $arrCartList; 
     119         
     120    } 
     121 
    113122} 
    114123?> 
  • branches/version-2_5-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Category.php

    r20038 r20076  
    6363     */ 
    6464    function action() { 
    65         if(Net_UserAgent_Mobile::isMobile() === true) { 
    66             $this->lfGetMainCat(true, $this); 
     65        // モバイル判定 
     66        if (SC_Display::detectDevice() === true) { 
     67            // --- モバイルの場合 
     68            // メインカテゴリーの取得 
     69            $this->arrCat = $this->lfGetMainCat(true); 
    6770        } else { 
    68             $objDb = new SC_Helper_DB_Ex(); 
    69  
    70             // 選択中のカテゴリIDを判定する 
    71             $arrCategory_id = $objDb->sfGetCategoryId($_GET['product_id'], $_GET['category_id']); 
    72  
     71            // --- PCの場合 
    7372            // 選択中のカテゴリID 
    74             $this->tpl_category_id = empty($arrCategory_id) ? array(0) : $arrCategory_id;; 
    75             $this->lfGetCatTree($this->tpl_category_id, true, $this); 
     73            $this->tpl_category_id = $this->lfGetSelectedCategoryId(); 
     74            // カテゴリツリーの取得 
     75            $this->arrTree = $this->lfGetCatTree($this->tpl_category_id, true); 
    7676        } 
    7777    } 
     
    8686    } 
    8787 
    88     // カテゴリツリーの取得 
    89     function lfGetCatTree($arrParent_category_id, $count_check = false) { 
     88    /** 
     89     * 選択中のカテゴリIDを取得する. 
     90     * 
     91     * @return array $arrCategoryId 選択中のカテゴリID 
     92     */ 
     93    function lfGetSelectedCategoryId() { 
     94        // 商品ID取得 
     95        if ( !isset($_GET['product_id']) || $_GET['product_id'] == '' || !is_numeric($_GET['product_id']) ) { 
     96            return array(0); 
     97        } 
     98        $product_id = $_GET['product_id']; 
     99        // カテゴリID取得 
     100        if ( !isset($_GET['category_id']) || $_GET['category_id'] == '' || !is_numeric($_GET['category_id']) ) { 
     101            return array(0); 
     102        } 
     103        $category_id = $_GET['category_id']; 
     104        // 選択中のカテゴリIDを判定する 
     105        $objDb = new SC_Helper_DB_Ex(); 
     106        $arrCategoryId = $objDb->sfGetCategoryId($product_id, $category_id); 
     107        if (empty($arrCategoryId)) { 
     108            $arrCategoryId = array(0); 
     109        } 
     110        return $arrCategoryId; 
     111    } 
     112 
     113    /** 
     114     * カテゴリツリーの取得. 
     115     * 
     116     * @param array $arrParentCategoryId 親カテゴリの配列 
     117     * @param boolean $count_check 登録商品数をチェックする場合はtrue 
     118     * @return array $arrRet カテゴリーツリーの配列を返す 
     119     */ 
     120    function lfGetCatTree($arrParentCategoryId, $count_check = false) { 
    90121        $objQuery = new SC_Query(); 
    91122        $objDb = new SC_Helper_DB_Ex(); 
    92         $col = "*"; 
    93         $from = "dtb_category left join dtb_category_total_count using (category_id)"; 
     123        $col = '*'; 
     124        $from = 'dtb_category left join dtb_category_total_count using (category_id)'; 
    94125        // 登録商品数のチェック 
    95126        if($count_check) { 
    96             $where = "del_flg = 0 AND product_count > 0"; 
     127            $where = 'del_flg = 0 AND product_count > 0'; 
    97128        } else { 
    98             $where = "del_flg = 0"; 
    99         } 
    100         $objQuery->setOption("ORDER BY rank DESC"); 
     129            $where = 'del_flg = 0'; 
     130        } 
     131        $objQuery->setOption('ORDER BY rank DESC'); 
    101132        $arrRet = $objQuery->select($col, $from, $where); 
    102  
    103         foreach ($arrParent_category_id as $category_id) { 
    104             $arrParentID = $objDb->sfGetParents('dtb_category', 'parent_category_id', 'category_id', $category_id); 
    105             $arrBrothersID = SC_Utils_Ex::sfGetBrothersArray($arrRet, 'parent_category_id', 'category_id', $arrParentID); 
    106             $arrChildrenID = SC_Utils_Ex::sfGetUnderChildrenArray($arrRet, 'parent_category_id', 'category_id', $category_id); 
    107  
     133        foreach ($arrParentCategoryId as $category_id) { 
     134            $arrParentID = $objDb->sfGetParents( 
     135                'dtb_category', 
     136                'parent_category_id', 
     137                'category_id', 
     138                $category_id 
     139            ); 
     140            $arrBrothersID = SC_Utils_Ex::sfGetBrothersArray( 
     141                $arrRet, 
     142                'parent_category_id', 
     143                'category_id', 
     144                $arrParentID 
     145            ); 
     146            $arrChildrenID = SC_Utils_Ex::sfGetUnderChildrenArray( 
     147                $arrRet, 
     148                'parent_category_id', 
     149                'category_id', 
     150                $category_id 
     151            ); 
    108152            $this->root_parent_id[] = $arrParentID[0]; 
    109  
    110153            $arrDispID = array_merge($arrBrothersID, $arrChildrenID); 
    111  
    112154            foreach($arrRet as $key => $array) { 
    113155                foreach($arrDispID as $val) { 
     
    119161            } 
    120162        } 
    121  
    122         $this->arrTree = $arrRet; 
    123     } 
    124  
    125     // メインカテゴリーの取得 
    126     function lfGetMainCat($count_check = false, &$objSubPage) { 
     163        return $arrRet; 
     164    } 
     165 
     166    /** 
     167     * メインカテゴリーの取得. 
     168     * 
     169     * @param boolean $count_check 登録商品数をチェックする場合はtrue 
     170     * @return array $arrMainCat メインカテゴリーの配列を返す 
     171     */ 
     172    function lfGetMainCat($count_check = false) { 
    127173        $objQuery = new SC_Query(); 
    128         $col = "*"; 
    129         $from = "dtb_category left join dtb_category_total_count using (category_id)"; 
     174        $col = '*'; 
     175        $from = 'dtb_category left join dtb_category_total_count using (category_id)'; 
    130176        // メインカテゴリーとその直下のカテゴリーを取得する。 
    131177        $where = 'level <= 2 AND del_flg = 0'; 
    132178        // 登録商品数のチェック 
    133179        if($count_check) { 
    134             $where .= " AND product_count > 0"; 
    135         } 
    136         $objQuery->setOption("ORDER BY rank DESC"); 
     180            $where .= ' AND product_count > 0'; 
     181        } 
     182        $objQuery->setOption('ORDER BY rank DESC'); 
    137183        $arrRet = $objQuery->select($col, $from, $where); 
    138  
    139184        // メインカテゴリーを抽出する。 
    140185        $arrMainCat = array(); 
     
    143188                continue; 
    144189            } 
    145  
    146190            // 子カテゴリーを持つかどうかを調べる。 
    147             $arrChildrenID = SC_Utils_Ex::sfGetUnderChildrenArray($arrRet, 'parent_category_id', 'category_id', $cat['category_id']); 
     191            $arrChildrenID = SC_Utils_Ex::sfGetUnderChildrenArray( 
     192                $arrRet, 
     193                'parent_category_id', 
     194                'category_id', 
     195                $cat['category_id'] 
     196            ); 
    148197            $cat['has_children'] = count($arrChildrenID) > 0; 
    149198            $arrMainCat[] = $cat; 
    150199        } 
    151  
    152         $objSubPage->arrCat = $arrMainCat; 
    153         return $objSubPage; 
     200        return $arrMainCat; 
    154201    } 
    155202} 
  • branches/version-2_5-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Login.php

    r19805 r20076  
    7979            // クッキー判定 
    8080            $this->tpl_login_email = $objCookie->getCookie('login_email'); 
    81             if($this->tpl_login_email != "") { 
    82                 $this->tpl_login_memory = "1"; 
     81            if($this->tpl_login_email != '') { 
     82                $this->tpl_login_memory = '1'; 
    8383            } 
    84  
    8584            // POSTされてきたIDがある場合は優先する。 
    86             if($_POST['login_email'] != "") { 
     85            if( isset($_POST['login_email']) && $_POST['login_email'] != '') { 
    8786                $this->tpl_login_email = $_POST['login_email']; 
    8887            } 
     
    102101    } 
    103102 
     103    /** 
     104     * lfCheckDisableLogout. 
     105     * 
     106     * @return boolean 
     107     */ 
    104108    function lfCheckDisableLogout() { 
    105109        $masterData = new SC_DB_MasterData_Ex(); 
    106         $arrDISABLE_LOGOUT = $masterData->getMasterData("mtb_disable_logout"); 
    107         $nowpage = $_SERVER['PHP_SELF']; 
     110        $arrDisableLogout = $masterData->getMasterData('mtb_disable_logout'); 
     111         
     112        $current_page = $_SERVER['PHP_SELF']; 
    108113 
    109         foreach($arrDISABLE_LOGOUT as $val) { 
    110             if($nowpage == $val) { 
     114        foreach($arrDisableLogout as $val) { 
     115            if($current_page == $val) { 
    111116                return true; 
    112117            } 
  • branches/version-2_5-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_News.php

    r19903 r20076  
    7575    } 
    7676 
     77    /** 
     78     * 新着情報を取得する. 
     79     * 
     80     * @return array $arrNewsList 新着情報の配列を返す 
     81     */ 
    7782    function lfGetNews(){ 
    7883        $objQuery = new SC_Query(); 
    79         $sql = "SELECT *, cast(news_date as date) as news_date_disp FROM dtb_news WHERE del_flg = '0' ORDER BY rank DESC"; 
    80         $list_data = $objQuery->getAll($sql); 
    81         return $list_data; 
     84        $sql = ''; 
     85        $sql .= " SELECT "; 
     86        $sql .= "   *, "; 
     87        $sql .= "   cast(news_date as date) as news_date_disp "; 
     88        $sql .= " FROM "; 
     89        $sql .= "   dtb_news "; 
     90        $sql .= " WHERE "; 
     91        $sql .= "   del_flg = '0' "; 
     92        $sql .= " ORDER BY "; 
     93        $sql .= "   rank DESC "; 
     94         
     95        $arrNewsList = $objQuery->getAll($sql); 
     96        return $arrNewsList; 
    8297    } 
    8398} 
  • branches/version-2_5-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_SearchProducts.php

    r19805 r20076  
    6363     */ 
    6464    function action() { 
    65         $arrSearch = array();   // 検索項目表示用 
    66         $objDb = new SC_Helper_DB_Ex(); 
    6765        // 選択中のカテゴリIDを判定する 
    68         $this->category_id = $objDb->sfGetCategoryId($_GET['product_id'], $_GET['category_id']); 
     66        $this->category_id = $this->lfGetSelectedCategoryId(); 
    6967        // カテゴリ検索用選択リスト 
    70         $arrRet = $objDb->sfGetCategoryList('', true, ' '); 
    71  
    72         if(is_array($arrRet)) { 
    73             // 文字サイズを制限する 
    74             foreach($arrRet as $key => $val) { 
    75                 $str = SC_Utils_Ex::sfCutString($val, SEARCH_CATEGORY_LEN, false); 
    76                 $arrRet[$key] = preg_replace('/ /', "&nbsp;&nbsp;", $str); 
    77             } 
    78         } 
    79         $this->arrCatList = $arrRet; 
    80  
     68        $this->arrCatList = $this->lfGetCategoryList(); 
    8169        // 選択中のメーカーIDを判定する 
    82         $this->maker_id = $objDb->sfGetMakerId($_GET['product_id'], $_GET['maker_id']); 
     70        $this->maker_id = $this->lfGetSelectedMakerId(); 
    8371        // メーカー検索用選択リスト 
    84         $arrRet = $objDb->sfGetMakerList('', true); 
    85         if(is_array($arrRet)) { 
    86             // 文字サイズを制限する 
    87             foreach($arrRet as $key => $val) { 
    88                 $arrRet[$key] = SC_Utils_Ex::sfCutString($val, SEARCH_CATEGORY_LEN); 
    89             } 
    90         } 
    91         $this->arrMakerList = $arrRet; 
     72        $this->arrMakerList = $this->lfGetMakerList(); 
    9273    } 
    9374 
     
    10081        parent::destroy(); 
    10182    } 
     83 
     84    /** 
     85     * 選択中のカテゴリIDを取得する 
     86     * 
     87     * @return array $arrCategoryId 選択中のカテゴリID 
     88     */ 
     89    function lfGetSelectedCategoryId() { 
     90        // 商品ID取得 
     91        if ( !isset($_GET['product_id']) || $_GET['product_id'] == '' || !is_numeric($_GET['product_id']) ) { 
     92            return array(); 
     93        } 
     94        $product_id = $_GET['product_id']; 
     95        // カテゴリID取得 
     96        if ( !isset($_GET['category_id']) || $_GET['category_id'] == '' || !is_numeric($_GET['category_id']) ) { 
     97            return array(); 
     98        } 
     99        $category_id = $_GET['category_id']; 
     100        // 選択中のカテゴリIDを判定する 
     101        $objDb = new SC_Helper_DB_Ex(); 
     102        $arrCategoryId = $objDb->sfGetCategoryId($product_id, $category_id); 
     103        return $arrCategoryId; 
     104    } 
     105 
     106    /** 
     107     * 選択中のメーカーIDを取得する 
     108     * 
     109     * @return array $arrMakerId 選択中のメーカーID 
     110     */ 
     111    function lfGetSelectedMakerId() { 
     112        // 商品ID取得 
     113        if ( !isset($_GET['product_id']) || $_GET['product_id'] == '' || !is_numeric($_GET['product_id']) ) { 
     114            return array(); 
     115        } 
     116        $product_id = $_GET['product_id']; 
     117        // メーカーID取得 
     118        if ( !isset($_GET['maker_id']) || $_GET['maker_id'] == '' || !is_numeric($_GET['maker_id']) ) { 
     119            return array(); 
     120        } 
     121        $maker_id = $_GET['maker_id']; 
     122        // 選択中のメーカーIDを判定する 
     123        $objDb = new SC_Helper_DB_Ex(); 
     124        $arrMakerId = $objDb->sfGetMakerId($product_id, $maker_id); 
     125        return $arrMakerId; 
     126    } 
     127 
     128    /** 
     129     * カテゴリ検索用選択リストを取得する 
     130     * 
     131     * @return array $arrCategoryList カテゴリ検索用選択リスト 
     132     */ 
     133    function lfGetCategoryList() { 
     134        $objDb = new SC_Helper_DB_Ex(); 
     135        // カテゴリ検索用選択リスト 
     136        $arrCategoryList = $objDb->sfGetCategoryList('', true, ' '); 
     137        if (is_array($arrCategoryList)) { 
     138            // 文字サイズを制限する 
     139            foreach($arrCategoryList as $key => $val) { 
     140                $truncate_str = SC_Utils_Ex::sfCutString($val, SEARCH_CATEGORY_LEN, false); 
     141                $arrCategoryList[$key] = preg_replace('/ /', "&nbsp;&nbsp;", $truncate_str); 
     142            } 
     143        } 
     144        return $arrCategoryList; 
     145    } 
     146 
     147    /** 
     148     * メーカー検索用選択リストを取得する 
     149     * 
     150     * @return array $arrMakerList メーカー検索用選択リスト 
     151     */ 
     152    function lfGetMakerList() { 
     153        $objDb = new SC_Helper_DB_Ex(); 
     154        // メーカー検索用選択リスト 
     155        $arrMakerList = $objDb->sfGetMakerList('', true); 
     156        if (is_array($arrMakerList)) { 
     157            // 文字サイズを制限する 
     158            foreach($arrMakerList as $key => $val) { 
     159                $arrMakerList[$key] = SC_Utils_Ex::sfCutString($val, SEARCH_CATEGORY_LEN); 
     160            } 
     161        } 
     162        return $arrMakerList; 
     163    } 
     164 
    102165} 
    103166?> 
Note: See TracChangeset for help on using the changeset viewer.