/** * @author : PhongTX * @name : ajaxlistvideoAction * @copyright : FPT Online * @todo : ajaxlistvideo Action * @return : Json */ public function ajaxlistvideoAction() { //set cache $this->_request->setParam('cache_file', 1); // Disable render layout $this->_helper->layout->disableLayout(true); // Set not render view $this->_helper->viewRenderer->setNoRender(true); // Default response $response = array('error' => 0, 'msg' => 'Success', 'html' => NULL); // Get cate id $intCateId = intval($this->_request->getParam('cateId', 0)); //Get curr page $currPage = intval($this->_request->getParam('currPage', 1)); //Get str Ex $strEx = $this->_request->getParam('strEx', ''); $arrEx = explode(',', $strEx); // Get total new $intTotalNew = intval($this->_request->getParam('totalNew', 0)); // if hasn't cate => load by id if ($intCateId) { //New object $objNews = new Thethao_Model_News(); //Init params $arrParams = array('category_id' => $intCateId, 'limit' => LIMIT_LIST_VIDEO + count($arrEx), 'offset' => ($currPage - 1) * (LIMIT_LIST_VIDEO + $intTotalNew)); //get all article by rule 2 $arrData = $objNews->getListArticleIdsByRule2($arrParams); $arrListVideoTemp = array_slice($arrData['data'], 0, LIMIT_LIST_VIDEO); $arrPush = array(); $i = 0; foreach ($arrEx as $idEx) { if (in_array($idEx, $arrListVideoTemp)) { $i++; } if (in_array($idEx, $arrData['data'])) { array_push($arrPush, $idEx); } } $arrData['data'] = array_slice(array_values(array_diff($arrData['data'], $arrPush)), 0, LIMIT_LIST_VIDEO); //Set lai total $arrData['total'] = $arrData['total'] - $intTotalNew - $i; //Valid data if (!empty($arrData['data'])) { //set obj get Article $this->view->objArticle->setIdBasic($arrData['data']); } //Get total page $totalPage = $arrData['total'] ? intval(ceil($arrData['total'] / LIMIT_LIST_VIDEO)) : 0; //InitParam Paging $arrParamPaging = array('total' => $arrData['total'], 'page' => $currPage, 'perpage' => LIMIT_LIST_VIDEO, 'classPagination' => 'pagination_news right'); // Assign to view $this->view->assign(array('arrData' => $arrData, 'arrParamPaging' => $arrParamPaging, 'totalPage' => $totalPage, 'currPage' => $currPage, 'cateId' => $intCateId)); //Render view $response['html'] = $this->view->render('video/box/list_video.phtml'); } //Return Json echo Zend_Json::encode($response); }