コード例 #1
0
ファイル: ControllerAction.php プロジェクト: m3uzz/onionfw
 /**
  * 
  * @return unknown
  */
 public function searchSelectAction()
 {
     $lnPage = $this->request('p', 0);
     $lnRows = $this->request('rows', $this->_nSearchGridNumRows);
     $lsOrder = $this->request('ord', $this->_sSearchGridOrder);
     $lsOrderCol = $this->request('col', $this->_sSearchGridOrderCol);
     $lsQuery = $this->request('q', '');
     $lsField = $this->request('f', '');
     $lsField = isset($this->_aSearchFields[$lsField]) ? $lsField : $this->_sSearchFieldDefault;
     $lsMark = $this->request('st', 'radio');
     $lsWindow = $this->request('w', 'default');
     $lsFilter = $this->request('filter', '');
     $laFilter = json_decode(base64_decode($lsFilter), true);
     $lsWhere = isset($laFilter['where']) ? $laFilter['where'] : "";
     if ($this->_bSearch && !empty($lsQuery)) {
         $loSearch = new Search();
         $loSearch->set('sSearchFields', $lsField);
         $lsWhere .= $loSearch->createRLikeQuery('"' . $lsQuery . '"', 'r');
     }
     $laParams = array('status' => isset($laFilter['status']) ? $laFilter['status'] : 0, 'active' => isset($laFilter['active']) ? $laFilter['active'] : 1, 'rows' => $this->_nSearchGridNumRows, 'page' => $lnPage, 'col' => $lsOrderCol, 'ord' => $lsOrder, 'q' => $lsQuery, 'where' => $lsWhere);
     if (method_exists($this, 'searchBeforeSelect')) {
         $laParams = $this->searchBeforeSelect($laParams);
     }
     if (method_exists($this, 'searchList')) {
         $laResult = $this->searchList($laParams);
     } else {
         $laResult = $this->getEntityManager()->getRepository($this->_sEntityExtended)->getList($laParams, $lbCache = false);
     }
     if (method_exists($this, 'searchAfterSelect')) {
         $laResult = $this->searchAfterSelect($laResult);
     }
     $loPagination = new Pagination();
     $loPagination->set('sUri', "/" . $this->_sRoute . '/search-select/?');
     $loPagination->set('nResPerPage', $lnRows);
     $loPagination->setPaginator($laResult['totalCount'], $lnPage);
     //Debug::displayd($laResult['resultSet']);
     $lsGrid = $this->renderSelectGrid(array($laResult['resultSet'], $loPagination, $lnRows, $lsQuery, $lsField, array('ord' => $lsOrder, 'col' => $lsOrderCol), '/' . $this->_sRoute . '/search-select', $this->_sSearchLabelField, $lsWindow, $lsFilter), $lsMark);
     if (method_exists($this, 'searchAfterRender')) {
         $lsGrid = $this->searchAfterRender($lsGrid);
     }
     $loView = new ViewModel();
     return $this->setResponseType($loView, $lsGrid);
 }
コード例 #2
0
ファイル: Grid.php プロジェクト: m3uzz/onionfw
 /**
  *
  * @param object $poPagination Onion\Paginator\Pagination
  * @throws Exception
  * @return Onion\Paginator\Pagination
  */
 public function setPagination($poPagination = null)
 {
     if ($poPagination instanceof Pagination) {
         $this->_pagination = $poPagination;
     } elseif ($poPagination !== null) {
         throw new Exception('The value of "pagination" property need to be an instance of Onion\\Paginator\\Pagination!');
     } else {
         $loPagination = new Pagination();
         $loPagination->set('nResPerPage', $this->get('numRows'));
         $loPagination->setPaginator($this->get('totalResults'), $this->get('currentPage'));
         $this->_pagination = $loPagination;
     }
     return $this->_pagination;
 }