Changeset 21045


Ignore:
Timestamp:
2011/07/27 13:34:06 (13 years ago)
Author:
468
Message:

#1413 スマートフォン版新着情報ブロック用処理(Ajax通信用データ返信)追加

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_11-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_News.php

    r20810 r21045  
    6262     */ 
    6363    function action() { 
    64         $this->arrNews = $this->lfGetNews(); 
     64 
     65        $objFormParam = new SC_FormParam_Ex(); 
     66        switch($this->getMode()){ 
     67            case "getList": 
     68                $this->lfInitNewsParam($objFormParam); 
     69                $objFormParam->setParam($_POST); 
     70                $objFormParam->convParam(); 
     71                $this->arrErr = $this->lfCheckError($objFormParam); 
     72                if(empty($this->arrEr)){ 
     73                     $json = $this->lfGetNewsForJson($objFormParam); 
     74                     echo $json; 
     75                     exit; 
     76                } 
     77                break; 
     78            case "getDetail": 
     79                $this->lfInitNewsParam($objFormParam); 
     80                $objFormParam->setParam($_GET); 
     81                $objFormParam->convParam(); 
     82                $this->arrErr = $this->lfCheckError($objFormParam); 
     83                if(empty($this->arrEr)){ 
     84                     $json = $this->lfGetNewsDetailForJson($objFormParam); 
     85                     echo $json; 
     86                     exit; 
     87                } 
     88                break; 
     89            default: 
     90                $this->newsCount = $this->lfGetNewsCount(); 
     91                $this->arrNews = $this->lfGetNews(); 
     92                break; 
     93        } 
    6594    } 
    6695 
     
    72101    function destroy() { 
    73102        parent::destroy(); 
     103    } 
     104 
     105   /** 
     106     * 新着情報パラメーター初期化 
     107     * 
     108     * @param array $objFormParam フォームパラメータークラス 
     109     * @return void 
     110     */ 
     111    function lfInitNewsParam(&$objFormParam) { 
     112        $objFormParam->addParam("現在ページ", "pageno", INT_LEN, 'n', array("NUM_CHECK", "MAX_LENGTH_CHECK"), "", false); 
     113        $objFormParam->addParam("表示件数", "disp_number", INT_LEN, 'n', array("NUM_CHECK", "MAX_LENGTH_CHECK"), "", false); 
     114        $objFormParam->addParam("新着ID", "news_id", INT_LEN, 'n', array("NUM_CHECK", "MAX_LENGTH_CHECK"), "", false); 
     115    } 
     116 
     117      /** 
     118     * フォーム入力パラメーターエラーチェック 
     119     * 
     120     * @param array $objFormParam フォームパラメータークラス 
     121     * @return array エラー配列 
     122     */ 
     123    function lfCheckError(&$objFormParam) { 
     124        $arrErr = SC_Helper_Customer_Ex::sfCustomerMypageErrorCheck($objFormParam, true); 
     125        return $arrErr; 
    74126    } 
    75127 
     
    95147        return $arrNewsList; 
    96148    } 
     149 
     150    /** 
     151     * 新着情報をJSON形式で取得する 
     152     * (ページと表示件数を指定) 
     153     * 
     154     * @param array $objFormParam フォームパラメータークラス 
     155     * @return String $json 新着情報のJSONを返す 
     156     */ 
     157    function lfGetNewsForJson(&$objFormParam){ 
     158 
     159        $objQuery = SC_Query_Ex::getSingletonInstance(); 
     160        $arrData = $objFormParam->getHashArray(); 
     161         
     162        $dispNumber = $arrData['disp_number']; 
     163        $pageNo = $arrData['pageno']; 
     164        if(!empty($dispNumber) && !empty($pageNo)){ 
     165             $objQuery->setLimitOffset($dispNumber, (($pageNo - 1) * $dispNumber)); 
     166        } 
     167 
     168        $objQuery->setOrder("rank DESC "); 
     169        $arrNewsList = $objQuery->select(" * , cast(news_date as date) as news_date_disp "," dtb_news "," del_flg = '0' "); 
     170 
     171        //新着情報の最大ページ数をセット 
     172        $newsCount = $this->lfGetNewsCount(); 
     173        $arrNewsList["news_page_count"] = ceil($newsCount / 3); 
     174 
     175        $json =  SC_Utils_Ex::jsonEncode($arrNewsList);    //JSON形式 
     176 
     177        return $json; 
     178    } 
     179 
     180    /** 
     181     * 新着情報1件分をJSON形式で取得する 
     182     * (news_idを指定) 
     183     * 
     184     * @param array $objFormParam フォームパラメータークラス 
     185     * @return String $json 新着情報1件分のJSONを返す 
     186     */ 
     187    function lfGetNewsDetailForJson(&$objFormParam){ 
     188 
     189        $objQuery = SC_Query_Ex::getSingletonInstance(); 
     190        $arrData = $objFormParam->getHashArray(); 
     191        $newsId = $arrData['news_id']; 
     192        $arrNewsList = $objQuery->select(" * , cast(news_date as date) as news_date_disp "," dtb_news "," del_flg = '0' AND news_id = ? ", array($newsId)); 
     193 
     194        $json =  SC_Utils_Ex::jsonEncode($arrNewsList);    //JSON形式 
     195 
     196        return $json; 
     197    } 
     198     
     199    /** 
     200     * 新着情報の件数を取得する 
     201     * 
     202     * @return Integer $count 新着情報の件数を返す 
     203     */ 
     204    function lfGetNewsCount(){ 
     205 
     206        $count = 0; 
     207         
     208        $objQuery = SC_Query_Ex::getSingletonInstance(); 
     209        $count = $objQuery->count("dtb_news", "del_flg = '0'"); 
     210 
     211        return $count; 
     212    } 
    97213} 
    98214?> 
Note: See TracChangeset for help on using the changeset viewer.