Example #1
0
 /**
  * 
  * @return unknown|\Onion\View\Model\ViewModel
  */
 public function viewAction()
 {
     $lnId = $this->request('id', null);
     $this->_sWindowType = $this->request('w', 'default');
     if ($lnId === null) {
         return $this->redirect()->toRoute($this->_sRoute);
     }
     $loEntity = $this->getEntityManager()->find($this->_sEntityExtended, $lnId);
     $loView = new ViewModel();
     if ($this->isXmlHttpRequest()) {
         $lsView = $this->renderView(array('', '', '', $loEntity->getFormatedData()), true);
     } else {
         $lsView = $this->renderView(array($this->request('back', 'index'), $this->_sTitleS, $this->_sRoute, $loEntity->getFormatedData()));
     }
     $loView->setVariables(array('lsTitle' => $this->_sTitleS, 'lsBack' => $this->request('back', 'index'), 'lsRoute' => $this->_sRoute, 'laData' => $loEntity->getFormatedData(), 'lsView' => $lsView), true);
     return $this->setResponseType($loView, $lsView);
 }
Example #2
0
 /**
  * 
  * @param int $pnStatus
  * @param bool $pbActive
  * @param string $psBack
  * @param string $psFolderTitle
  * @return string|\Onion\View\Model\ViewModel
  */
 public function gridx($pnStatus = 0, $pbActive = 1, $psBack = 'index', $psFolderTitle = null)
 {
     $loGrid = Application::factory('User\\Grid\\UserGrid');
     $lnPage = $this->request('p', 0);
     $lnRows = $this->request('rows', $loGrid->get('numRows'));
     $lsOrder = $this->request('ord', $loGrid->get('order'));
     $lsOrderCol = $this->request('col', $loGrid->get('orderCol'));
     $lsQuery = $this->request('q', '');
     $lsField = $this->request('f', '');
     $lsField = $loGrid->isSearchField($lsField) ? $lsField : $loGrid->get('searchFieldDefault');
     $lsWhere = '';
     if ($loGrid->get('showSearch') && !empty($lsQuery)) {
         $loSearch = new Search();
         $loSearch->set('sSearchFields', $lsField);
         $lsWhere .= $loSearch->createRLikeQuery('"' . $lsQuery . '"', 'r');
     }
     $laParams = array('status' => $pnStatus, 'active' => $pbActive, 'rows' => $lnRows, 'page' => $lnPage, 'col' => $lsOrderCol, 'ord' => $lsOrder, 'q' => $lsQuery, 'where' => $lsWhere);
     if (method_exists($this, 'gridBeforeSelect')) {
         $laParams = $this->gridBeforeSelect($laParams);
     }
     $laResult = $this->getEntityManager()->getRepository($this->_sEntityExtended)->getList($laParams, $lbCache = false);
     if (method_exists($this, 'gridAfterSelect')) {
         $laResult = $this->gridAfterSelect($laResult);
     }
     $laMessages = $this->flashMessenger()->getMessages();
     $loGrid->setData($laResult['resultSet'])->setTotalResults($laResult['totalCount'])->setBackTo($psBack)->setMessages($laMessages)->setNumRows($lnRows)->setSearchFieldDefault($lsField)->setSearchQuery($lsQuery)->setOrder($lsOrder)->setOrderCol($lsOrderCol)->setCurrentPage($lnPage);
     $lsGrid = $loGrid->render($this->_sRoute, $psFolderTitle);
     if (method_exists($this, 'gridAfterRender')) {
         $lsGrid = $this->gridAfterRender($lsGrid);
     }
     $loView = new ViewModel();
     if ($this->isXmlHttpRequest()) {
         $loView->setTerminal(true);
         // desabilita o layout
         $loResponse = $this->getResponse();
         $loResponse->setStatusCode(200);
         $loResponse->setContent($lsGrid);
         return $loResponse;
     } else {
         $loView->setVariables(array('lsGrid' => $lsGrid, 'lsFolder' => '', 'lsTitleP' => ''), true);
     }
     return $loView;
 }