Changeset 22796 for branches/version-2_12-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_News.php
- Timestamp:
- 2013/05/02 18:11:36 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_12-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_News.php
r22581 r22796 32 32 * @version $Id$ 33 33 */ 34 class LC_Page_FrontParts_Bloc_News extends LC_Page_FrontParts_Bloc_Ex 35 { 34 class LC_Page_FrontParts_Bloc_News extends LC_Page_FrontParts_Bloc_Ex { 36 35 37 36 // }}} … … 43 42 * @return void 44 43 */ 45 function init() 46 { 44 function init() { 47 45 parent::init(); 48 46 } … … 53 51 * @return void 54 52 */ 55 function process() 56 { 53 function process() { 57 54 $this->action(); 58 55 $this->sendResponse(); … … 64 61 * @return void 65 62 */ 66 function action() 67 { 68 69 $objNews = new SC_Helper_News_Ex(); 63 function action() { 64 70 65 $objFormParam = new SC_FormParam_Ex(); 71 66 switch ($this->getMode()) { … … 76 71 $this->arrErr = $objFormParam->checkError(false); 77 72 if (empty($this->arrErr)) { 78 $arrData = $objFormParam->getHashArray(); 79 $json = $this->lfGetNewsForJson($ arrData, $objNews);73 74 $json = $this->lfGetNewsForJson($objFormParam); 80 75 echo $json; 81 76 SC_Response_Ex::actionExit(); … … 91 86 $this->arrErr = $objFormParam->checkError(false); 92 87 if (empty($this->arrErr)) { 93 $arrData = $objFormParam->getHashArray(); 94 $json = $this->lfGetNewsDetailForJson($ arrData, $objNews);88 89 $json = $this->lfGetNewsDetailForJson($objFormParam); 95 90 echo $json; 96 91 SC_Response_Ex::actionExit(); … … 101 96 break; 102 97 default: 103 $this-> arrNews = $objNews->getList();104 $this-> newsCount = $objNews->getCount();98 $this->newsCount = $this->lfGetNewsCount(); 99 $this->arrNews = $this->lfGetNews(SC_Query_Ex::getSingletonInstance()); 105 100 break; 106 101 } … … 113 108 * @return void 114 109 */ 115 function destroy() 116 { 110 function destroy() { 117 111 parent::destroy(); 118 112 } … … 124 118 * @return void 125 119 */ 126 function lfInitNewsParam(&$objFormParam) 127 { 120 function lfInitNewsParam(&$objFormParam) { 128 121 $objFormParam->addParam('現在ページ', 'pageno', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'), '', false); 129 122 $objFormParam->addParam('表示件数', 'disp_number', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'), '', false); … … 136 129 * @return array $arrNewsList 新着情報の配列を返す 137 130 */ 138 function lfGetNews( $dispNumber, $pageNo, SC_Helper_News_Ex $objNews)139 {140 $arrNewsList = $obj News->getList($dispNumber, $pageNo);131 function lfGetNews(&$objQuery) { 132 $objQuery->setOrder('rank DESC '); 133 $arrNewsList = $objQuery->select('* , cast(news_date as date) as news_date_disp', 'dtb_news' ,'del_flg = 0'); 141 134 142 135 // モバイルサイトのセッション保持 (#797) … … 159 152 * (ページと表示件数を指定) 160 153 * 161 * @param array $arrData フォーム入力値 162 * @param object $objNews 154 * @param array $objFormParam フォームパラメータークラス 163 155 * @return String $json 新着情報のJSONを返す 164 156 */ 165 function lfGetNewsForJson($arrData, SC_Helper_News_Ex $objNews) 166 { 157 function lfGetNewsForJson(&$objFormParam) { 158 159 $objQuery =& SC_Query_Ex::getSingletonInstance(); 160 $arrData = $objFormParam->getHashArray(); 167 161 168 162 $dispNumber = $arrData['disp_number']; 169 163 $pageNo = $arrData['pageno']; 170 $arrNewsList = $this->lfGetNews($dispNumber, $pageNo, $objNews); 164 if (!empty($dispNumber) && !empty($pageNo)) { 165 $objQuery->setLimitOffset($dispNumber, (($pageNo - 1) * $dispNumber)); 166 } 167 168 $arrNewsList = $this->lfGetNews($objQuery); 171 169 172 170 //新着情報の最大ページ数をセット 173 $newsCount = $ objNews->getCount();171 $newsCount = $this->lfGetNewsCount(); 174 172 $arrNewsList['news_page_count'] = ceil($newsCount / 3); 175 173 … … 183 181 * (news_idを指定) 184 182 * 185 * @param array $arrData フォーム入力値 186 * @param object $objNews 183 * @param array $objFormParam フォームパラメータークラス 187 184 * @return String $json 新着情報1件分のJSONを返す 188 185 */ 189 function lfGetNewsDetailForJson($arrData, SC_Helper_News_Ex $objNews) 190 { 191 192 $arrNewsList = $objNews->get($arrData['news_id']); 186 function lfGetNewsDetailForJson(&$objFormParam) { 187 188 $objQuery = SC_Query_Ex::getSingletonInstance(); 189 $arrData = $objFormParam->getHashArray(); 190 $newsId = $arrData['news_id']; 191 $arrNewsList = $objQuery->select(' * , cast(news_date as date) as news_date_disp ',' dtb_news '," del_flg = '0' AND news_id = ? ", array($newsId)); 192 193 193 $json = SC_Utils_Ex::jsonEncode($arrNewsList); //JSON形式 194 194 195 195 return $json; 196 } 197 198 /** 199 * 新着情報の件数を取得する 200 * 201 * @return Integer $count 新着情報の件数を返す 202 */ 203 function lfGetNewsCount() { 204 205 $count = 0; 206 207 $objQuery = SC_Query_Ex::getSingletonInstance(); 208 $count = $objQuery->count('dtb_news', "del_flg = '0'"); 209 210 return $count; 196 211 } 197 212 … … 202 217 * @return string JSON 形式のエラーメッセージ 203 218 */ 204 function lfGetErrors($arrErr) 205 { 219 function lfGetErrors($arrErr) { 206 220 $messages = ''; 207 221 foreach ($arrErr as $val) {
Note: See TracChangeset
for help on using the changeset viewer.