Пример #1
0
 /**
  * @return void
  */
 public function initialize()
 {
     $this->criteria = $this->getVariable('validCriteria', []);
     $this->currentPage = isset($this->criteria['page']) ? $this->criteria['page'] : 1;
     $this->itemsCountPerPage = isset($this->criteria['limit']) ? $this->criteria['limit'] : 20;
     $criteria = $this->repository->createCriteria($this->criteria);
     $this->count = $this->repository->count($criteria);
     $this->zendPaginator = new ZendPaginator(new NullFill($this->count));
     $this->zendPaginator->setCurrentPageNumber($this->currentPage);
     $this->zendPaginator->setDefaultItemCountPerPage($this->itemsCountPerPage);
     $this->zendPaginator->setPageRange(5);
 }
 public function __invoke($page, $entity)
 {
     $auditModuleOptions = $this->getServiceLocator()->getServiceLocator()->get('auditModuleOptions');
     $entityManager = $auditModuleOptions->getEntityManager();
     $auditService = $this->getServiceLocator()->getServiceLocator()->get('auditService');
     if (gettype($entity) != 'string' and in_array(get_class($entity), array_keys($auditModuleOptions->getAuditedClassNames()))) {
         $auditEntityClass = 'ZF\\Doctrine\\Audit\\Entity\\' . str_replace('\\', '_', get_class($entity));
         $identifiers = $auditService->getEntityIdentifierValues($entity);
     } elseif ($entity instanceof AbstractAudit) {
         $auditEntityClass = get_class($entity);
         $identifiers = $auditService->getEntityIdentifierValues($entity, true);
     } else {
         $auditEntityClass = 'ZF\\Doctrine\\Audit\\Entity\\' . str_replace('\\', '_', $entity);
     }
     $search = array('auditEntityClass' => $auditEntityClass);
     if (isset($identifiers)) {
         $search['entityKeys'] = serialize($identifiers);
     }
     $queryBuilder = $entityManager->getRepository('ZF\\Doctrine\\Audit\\Entity\\RevisionEntity')->createQueryBuilder('rev');
     $queryBuilder->orderBy('rev.id', 'DESC');
     $i = 0;
     foreach ($search as $key => $val) {
         $i++;
         $queryBuilder->andWhere("rev.{$key} = ?{$i}");
         $queryBuilder->setParameter($i, $val);
     }
     $adapter = new DoctrineAdapter(new ORMPaginator($queryBuilder));
     $paginator = new Paginator($adapter);
     $paginator->setDefaultItemCountPerPage($auditModuleOptions->getPaginatorLimit());
     $paginator->setCurrentPageNumber($page);
     return $paginator;
 }
Пример #3
0
 public function listAction()
 {
     $pagerAction = $this->handlePager();
     $limit = $this->getLimit($this->defaultPageSize);
     $limit = 100;
     $page = $this->getRequest()->getQuery('page', 0);
     $sort = $this->getRequest()->getQuery('sort', $this->defaultSort);
     $order = $this->getRequest()->getQuery('order', $this->defaultOrder);
     if (empty($sort)) {
         $sort = $this->defaultSort;
     }
     $offset = $limit * $page - $limit;
     if ($offset < 0) {
         $offset = 0;
     }
     /* @var $qb \Doctrine\ORM\QueryBuilder */
     $qb = $this->getEntityManager()->createQueryBuilder();
     $qb->select(['e.referrer', 'COUNT(e.id) AS refcount'])->from($this->getEntityClass(), 'e')->setFirstResult($offset)->setMaxResults($limit)->groupBy('e.referrer')->orderBy('e.' . $sort, $order);
     $qb = $this->handleSearch($qb);
     $pager = $this->getPagerForm($limit);
     $q = $qb->getQuery();
     $q->setMaxResults($limit);
     $q->setFirstResult($offset);
     $results = $this->getSources($q->getArrayResult());
     $paginator = new Paginator(new ArrayAdapter($results));
     $paginator->setCacheEnabled(true);
     $paginator->setDefaultItemCountPerPage($limit);
     $paginator->setCurrentPageNumber($page);
     $paginator->setPageRange($this->paginatorRange);
     $ui = ['table' => ["source" => ["col" => 3, "label" => "Source", "sort" => false], "referrers" => ["col" => 6, "label" => "Referrers", "sort" => false], "count" => ["col" => 1, "label" => "# Leads", "sort" => false]]];
     return ['paginator' => $paginator, 'sort' => $sort, 'order' => $order, 'page' => $page, 'pager' => $pager, 'query' => $this->params()->fromQuery(), 'ui' => $ui, 'isAdmin' => $this->isAdmin(), 'history' => $this->setHistory()];
 }
Пример #4
0
 public function listAction()
 {
     $pagerAction = $this->handlePager();
     $limit = $this->getLimit($this->defaultPageSize);
     // $limit = $this->getRequest()->getQuery('limit',
     // $this->defaultPageSize);
     $page = $this->getRequest()->getQuery('page', 0);
     $sort = $this->getRequest()->getQuery('sort', $this->defaultSort);
     $order = $this->getRequest()->getQuery('order', $this->defaultOrder);
     if (empty($sort)) {
         $sort = $this->defaultSort;
     }
     $offset = $limit * $page - $limit;
     if ($offset < 0) {
         $offset = 0;
     }
     /* @var $qb \Doctrine\ORM\QueryBuilder */
     $qb = $this->getEntityManager()->createQueryBuilder();
     $qb->add('select', 'e')->add('from', $this->getEntityClass() . ' e')->orderBy('e.' . $sort, $order)->setFirstResult($offset)->setMaxResults($limit);
     $qb = $this->handleSearch($qb);
     $pager = $this->getPagerForm($limit);
     $paginator = new Paginator(new DoctrinePaginator(new ORMPaginator($qb->getQuery(), true)));
     $paginator->setDefaultItemCountPerPage($limit);
     $paginator->setCurrentPageNumber($page);
     $paginator->setPageRange($this->paginatorRange);
     $ui = ['table' => ["occurred" => ["col" => 2, "label" => "Date", "sort" => true], "event" => ["col" => 2, "label" => "Event", "sort" => false], "account" => ["col" => 3, "label" => "Account", "sort" => false], "message" => ["col" => 5, "label" => "Info", "sort" => false]]];
     $filters = $this->getFilterForm($this->params()->fromQuery());
     $post = $this->params()->fromPost();
     $redirectUrl = $this->url()->fromRoute($this->getActionRoute(), [], true);
     return ['paginator' => $paginator, 'sort' => $sort, 'order' => $order, 'page' => $page, 'pager' => $pager, 'query' => $this->params()->fromQuery(), 'filters' => $filters, 'ui' => $ui, 'history' => $this->setHistory()];
 }
Пример #5
0
 public function listAction()
 {
     $page = $this->getRequest()->getQuery('page', 0);
     $limit = $this->getRequest()->getQuery('limit', $this->defaultPageSize);
     $sort = $this->getRequest()->getQuery('sort', $this->defaultSort);
     $order = $this->getRequest()->getQuery('order', $this->defaultOrder);
     $id = $this->getEvent()->getRouteMatch()->getParam('id', 0);
     if (empty($sort)) {
         $sort = $this->defaultSort;
     }
     $offset = $limit * $page - $limit;
     if ($offset < 0) {
         $offset = 0;
     }
     /* @var $qb \Doctrine\ORM\QueryBuilder */
     $qb = $this->getEntityManager()->createQueryBuilder();
     $qb->add('select', 'e')->add('from', '\\Lead\\Entity\\Lead e')->innerJoin('e.account', 'a')->andWhere('a.id = :id')->orderBy('e.' . $sort, $order)->setFirstResult($offset)->setMaxResults($limit)->setParameter('id', $id);
     $qb = $this->handleSearch($qb);
     $paginator = new Paginator(new DoctrinePaginator(new LosPaginator($qb, false)));
     $paginator->setDefaultItemCountPerPage($limit);
     $paginator->setCurrentPageNumber($page);
     $paginator->setPageRange($this->paginatorRange);
     $ui = ['table' => ["referrer" => ["col" => 6, "label" => "Source", "sort" => true], "lastsubmitted" => ["col" => 4, "label" => "Submitted", "sort" => true]]];
     $filters = $this->getFilterForm($this->params()->fromQuery())->remove('account');
     return ['id' => $id, 'paginator' => $paginator, 'sort' => $sort, 'order' => $order, 'page' => $page, 'query' => $this->params()->fromQuery(), 'filters' => $filters, 'ui' => $ui];
 }
Пример #6
0
 protected function getPaginator($conditions)
 {
     $select = $this->buildSelect($conditions);
     //vo($select->getSqlString());exit;
     $pagerAdapter = new DbSelect($select, $this->getAdapter());
     Paginator::setDefaultItemCountPerPage(50);
     return new Paginator($pagerAdapter);
 }
Пример #7
0
 public function listAction()
 {
     $pagerAction = $this->handlePager();
     $limit = $this->getLimit($this->defaultPageSize);
     // $limit = $this->getRequest()->getQuery('limit',
     // $this->defaultPageSize);
     $page = $this->getRequest()->getQuery('page', 0);
     $sort = $this->getRequest()->getQuery('sort', $this->defaultSort);
     $order = $this->getRequest()->getQuery('order', $this->defaultOrder);
     if (empty($sort)) {
         $sort = $this->defaultSort;
     }
     $offset = $limit * $page - $limit;
     if ($offset < 0) {
         $offset = 0;
     }
     /* @var $qb \Doctrine\ORM\QueryBuilder */
     $qb = $this->getEntityManager()->createQueryBuilder();
     $qb->add('select', 'e')->add('from', $this->getEntityClass() . ' e')->innerJoin('e.account', 'account')->leftJoin('account.apis', 'apis')->where('apis.name = :email')->orderBy('e.' . $sort, $order)->setFirstResult($offset)->setMaxResults($limit)->setParameter('email', 'Email');
     $qb = $this->handleSearch($qb);
     $pager = $this->getPagerForm($limit);
     $paginator = new Paginator(new DoctrinePaginator(new LosPaginator($qb, false)));
     $paginator->setDefaultItemCountPerPage($limit);
     $paginator->setCurrentPageNumber($page);
     $paginator->setPageRange($this->paginatorRange);
     $ui = ['table' => ["description" => ["col" => 3, "label" => "Name", "sort" => false], "event" => ["col" => 3, "label" => "Latest Email Event", "sort" => false], "account" => ["col" => 2, "label" => "Account", "sort" => false], "timecreated" => ["col" => 2, "label" => "Date", "sort" => true]]];
     $filters = $this->getFilterForm($this->params()->fromQuery());
     $post = $this->params()->fromPost();
     $redirectUrl = $this->url()->fromRoute('services/email', ['action' => 'list'], true);
     if (!$pagerAction) {
         $prg = $this->prg($redirectUrl, true);
     } else {
         $prg = false;
     }
     if ($prg instanceof Response) {
         return $prg;
     } elseif ($prg === false) {
         $form = $this->getListForm($paginator);
         return ['paginator' => $paginator, 'sort' => $sort, 'order' => $order, 'page' => $page, 'pager' => $pager, 'query' => $this->params()->fromQuery(), 'form' => $form, 'filters' => $filters, 'ui' => $ui, 'history' => $this->setHistory()];
     }
     $form = $this->getListForm($paginator, $prg);
     if ($prg && isset($prg['sel'])) {
         $res = true;
         foreach ($prg['sel'] as $lead_id => $one) {
             if ($one) {
                 $response = $this->submit($lead_id);
                 $res = $response ? $res : false;
             }
         }
         if ($res) {
             $this->flashMessenger()->addSuccessMessage($this->getServiceLocator()->get('translator')->translate($this->successSubmitMessage));
         } else {
             $this->flashMessenger()->addErrorMessage($this->getServiceLocator()->get('translator')->translate($this->errorSubmitMessage));
         }
     }
     return $this->redirect()->toRoute('services/email', ['action' => 'list'], true);
 }
Пример #8
0
 public function indexAction()
 {
     $list = $this->getEm()->getRepository($this->entity)->findBy(array(), array('nome' => 'asc'));
     $page = $this->params()->fromRoute('page');
     $paginator = new Paginator(new ArrayAdapter($list));
     $paginator->setCurrentPageNumber($page);
     $paginator->setDefaultItemCountPerPage(20);
     return new ViewModel(array('data' => $paginator, 'page' => $page));
 }
 public function indexAction()
 {
     $especies = $this->getRepository()->findAll();
     $page = (int) $this->getRequest()->getQuery('page', '1');
     $paginator = new Paginator(new ArrayAdapter($especies));
     $paginator->setCurrentPageNumber($page);
     $paginator->setDefaultItemCountPerPage(20);
     return array('data' => $paginator, 'page' => $page);
 }
Пример #10
0
 public function indexAction()
 {
     $list = $this->getEm()->getRepository('Seerc\\Entity\\Cidade')->findAll();
     $page = $this->params()->fromRoute('page');
     $paginator = new Paginator(new ArrayAdapter($list));
     $paginator->setCurrentPageNumber($page);
     $paginator->setDefaultItemCountPerPage(2);
     return new ViewModel(array('data' => $paginator, 'page' => $page));
 }
Пример #11
0
 /**
  * list
  *
  * @return ViewModel
  */
 public function IndexAction()
 {
     $list = $this->getEm()->getRepository($this->entity)->findAll();
     $page = $this->params()->fromRoute('page');
     $pagination = new Paginator(new ArrayAdapter($list));
     $pagination->setCurrentPageNumber($page);
     $pagination->setDefaultItemCountPerPage(10);
     return new ViewModel(['data' => $pagination, 'page' => $page]);
 }
 public function paginator($data, $currentPage = null, $countPerPage = 30)
 {
     if ($currentPage == null) {
         $currentPage = $this->params()->fromRoute('page');
     }
     $paginator = new Paginator(new ArrayAdapter($data));
     $paginator->setCurrentPageNumber($currentPage);
     $paginator->setDefaultItemCountPerPage($countPerPage);
     return $paginator;
 }
Пример #13
0
 /**
  * @param int $page
  * @return \PServerCore\Entity\News[]|Paginator
  */
 public function getActiveNews($page = 1)
 {
     $queryBuilder = $this->getNewsQueryBuilder();
     $queryBuilder->where('p.active = :active')->setParameter('active', 1);
     $adapter = new DoctrineAdapter(new ORMPaginator($queryBuilder));
     $paginator = new Paginator($adapter);
     $paginator->setDefaultItemCountPerPage($this->collectionOptions->getConfig()['news']['limit']);
     $paginator->setCurrentPageNumber($page);
     return $paginator;
 }
Пример #14
0
 /**
  * @return \Zend\View\Model\ViewModel
  */
 public function listAction()
 {
     $page = $this->params('page');
     $templateQuery = $this->getGeneralService()->findFiltered(WebInfo::class, []);
     $paginator = new Paginator(new PaginatorAdapter(new ORMPaginator($templateQuery, false)));
     $paginator->setDefaultItemCountPerPage($page === 'all' ? PHP_INT_MAX : 15);
     $paginator->setCurrentPageNumber($page);
     $paginator->setPageRange(ceil($paginator->getTotalItemCount() / $paginator->getDefaultItemCountPerPage()));
     return new ViewModel(['paginator' => $paginator]);
 }
 /**
  * @return ViewModel
  */
 public function missingAction()
 {
     $affiliation = $this->getAffiliationService()->findAffiliationWithMissingLoi();
     $page = $this->params('page');
     $paginator = new Paginator(new PaginatorAdapter(new ORMPaginator($affiliation, false)));
     $paginator->setDefaultItemCountPerPage($page === 'all' ? PHP_INT_MAX : 15);
     $paginator->setCurrentPageNumber($page);
     $paginator->setPageRange(ceil($paginator->getTotalItemCount() / $paginator->getDefaultItemCountPerPage()));
     return new ViewModel(['paginator' => $paginator]);
 }
Пример #16
0
 /**
  * View all previous polls
  */
 public function historyAction()
 {
     $adapter = $this->getPollService()->getPaginatorAdapter();
     $paginator = new Paginator($adapter);
     $paginator->setDefaultItemCountPerPage(10);
     $page = $this->params()->fromRoute('page');
     if ($page) {
         $paginator->setCurrentPageNumber($page);
     }
     return new ViewModel(['paginator' => $paginator]);
 }
Пример #17
0
 public function indexAction()
 {
     $query = $this->allAlbums($id, $column, $order);
     $paginator = new ZendPaginator(new PaginatorAdapter(new ORMPaginator($query)));
     $paginator->setDefaultItemCountPerPage(10);
     $page = (int) $this->params()->fromQuery('page');
     if ($page) {
         $paginator->setCurrentPageNumber($page);
     }
     return new ViewModel(array('paginator' => $paginator));
 }
Пример #18
0
 public function indexAction()
 {
     $currentPage = $this->params()->fromRoute('page', null);
     $adapter = $this->jobTable->getAdapter();
     $select = $this->jobTable->getAll();
     $paginator = new Paginator(new \Zend\Paginator\Adapter\DbSelect($select, $adapter));
     $paginator->setCurrentPageNumber($currentPage);
     $paginator->setDefaultItemCountPerPage($this->config['admin_element_pagination']);
     $jobs = $paginator->getCurrentItems();
     return new ViewModel(array('jobs' => $jobs, 'paginator' => $paginator));
 }
Пример #19
0
 /**
  * @return array
  */
 public function indexAction()
 {
     $search = $this->params()->fromQuery('q');
     $page = (int) $this->params()->fromQuery('page', 1);
     $sort = $this->params()->fromQuery('sort');
     $queryBuilder = $this->getDatagrid()->createSearchQueryBuilder($search, $sort);
     $paginator = new Paginator(new DoctrineAdapter(new ORMPaginator($queryBuilder)));
     $paginator->setDefaultItemCountPerPage(10);
     $paginator->setCurrentPageNumber($page);
     return array('singular' => $this->getDatagrid()->getSingularName(), 'plural' => $this->getDatagrid()->getPluralName(), 'columns' => $this->getDatagrid()->getHeaderColumns(), 'form' => new Search(), 'result' => $paginator, 'search' => $search, 'page' => $page, 'sort' => $sort);
 }
Пример #20
0
 public function indexAction()
 {
     $em = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager');
     $repo = $em->getRepository('Advocacia\\Entity\\Cadastro');
     $cadastro = $repo->findAll();
     //Paginação
     $page = $this->params()->fromRoute('page');
     $paginator = new Paginator(new ArrayAdapter($cadastro));
     $paginator->setCurrentPageNumber($page);
     $paginator->setDefaultItemCountPerPage(4);
     return new ViewModel(['cadastro' => $paginator, 'page' => $page]);
 }
 /**
  * @return ViewModel
  */
 public function overviewAction()
 {
     $which = $this->params('which', CalendarService::WHICH_UPCOMING);
     $page = $this->params('page', 1);
     $calendarItems = $this->getCalendarService()->findCalendarItems($which, $this->zfcUserAuthentication()->getIdentity());
     $paginator = new Paginator(new PaginatorAdapter(new ORMPaginator($calendarItems)));
     $paginator->setDefaultItemCountPerPage($page === 'all' ? PHP_INT_MAX : 15);
     $paginator->setCurrentPageNumber($page);
     $paginator->setPageRange(ceil($paginator->getTotalItemCount() / $paginator->getDefaultItemCountPerPage()));
     $whichValues = $this->getCalendarService()->getWhichValues();
     return new ViewModel(['enableCalendarContact' => $this->getModuleOptions()->getCommunityCalendarContactEnabled(), 'which' => $which, 'paginator' => $paginator, 'whichValues' => $whichValues]);
 }
Пример #22
0
 /**
  * @return \Zend\View\Model\ViewModel
  */
 public function listAction()
 {
     $page = $this->params()->fromRoute('page', 1);
     $filterPlugin = $this->getGeneralFilter();
     $contactQuery = $this->getGeneralService()->findEntitiesFiltered('gender', $filterPlugin->getFilter());
     $paginator = new Paginator(new PaginatorAdapter(new ORMPaginator($contactQuery, false)));
     $paginator->setDefaultItemCountPerPage($page === 'all' ? PHP_INT_MAX : 20);
     $paginator->setCurrentPageNumber($page);
     $paginator->setPageRange(ceil($paginator->getTotalItemCount() / $paginator->getDefaultItemCountPerPage()));
     $form = new GenderFilter($this->getGeneralService());
     $form->setData(['filter' => $filterPlugin->getFilter()]);
     return new ViewModel(['paginator' => $paginator, 'form' => $form, 'encodedFilter' => urlencode($filterPlugin->getHash()), 'order' => $filterPlugin->getOrder(), 'direction' => $filterPlugin->getDirection()]);
 }
Пример #23
0
 /**
  * List all approved and unapproved polls
  */
 public function listAction()
 {
     $pollService = $this->getPollService();
     $adapter = $pollService->getPaginatorAdapter();
     $paginator = new Paginator($adapter);
     $paginator->setDefaultItemCountPerPage(15);
     $page = $this->params()->fromRoute('page');
     if ($page) {
         $paginator->setCurrentPageNumber($page);
     }
     $unapprovedPolls = $pollService->getUnapprovedPolls();
     $approvalForm = $pollService->getPollApprovalForm();
     return new ViewModel(['unapprovedPolls' => $unapprovedPolls, 'paginator' => $paginator, 'approvalForm' => $approvalForm]);
 }
Пример #24
0
 public function filtroAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $filtro = $request->getPost()->toArray();
         $repo = $this->getEm()->getRepository($this->entity);
         $list = $repo->createQueryBuilder('d')->where('d.nome LIKE :nome')->setParameter('nome', '%' . $filtro[busca] . '%')->getQuery()->execute();
         $page = $this->params()->fromRoute('page');
         $paginator = new Paginator(new ArrayAdapter($list));
         $paginator->setCurrentPageNumber($page);
         $paginator->setDefaultItemCountPerPage(20);
         return new ViewModel(array('data' => $paginator, 'page' => $page));
     }
 }
 public function listPaginate($page = 1, $items_per_page = 10, $fieldSort = null, $orderSort = 'asc')
 {
     $repository = $this->entityManager->getRepository($this->getRepository());
     if (!is_null($fieldSort)) {
         $queryBuilder = $repository->createQueryBuilder('query')->orderBy('query.' . $fieldSort, $orderSort);
     } else {
         $queryBuilder = $repository->createQueryBuilder('query');
     }
     $adapter = new DoctrineAdapter(new ORMPaginator($queryBuilder));
     $paginator = new Paginator($adapter);
     $paginator->setDefaultItemCountPerPage($items_per_page);
     $paginator->setCurrentPageNumber($page);
     return $paginator;
 }
 public function __invoke($page, $revisionEntity, $joinTable, $mappedBy)
 {
     $auditModuleOptions = $this->getServiceLocator()->getServiceLocator()->get('auditModuleOptions');
     $entityManager = $auditModuleOptions->getEntityManager();
     $auditService = $this->getServiceLocator()->getServiceLocator()->get('auditService');
     $entityClassName = 'ZF\\Doctrine\\Audit\\Entity\\' . str_replace('\\', '_', $joinTable);
     $query = $entityManager->createQuery("\r\n            SELECT e\r\n            FROM ZF\\Doctrine\\Audit\\Entity\\RevisionEntity e\r\n            JOIN e.revision r\r\n            WHERE e.id IN (\r\n                SELECT re.id\r\n                FROM {$entityClassName} s\r\n                JOIN s.revisionEntity re\r\n                WHERE s.{$mappedBy} = :var\r\n            )\r\n            ORDER BY r.timestamp DESC\r\n        ");
     $query->setParameter('var', $revisionEntity->getTargetEntity());
     $adapter = new DoctrineAdapter(new ORMPaginator($query));
     $paginator = new Paginator($adapter);
     $paginator->setDefaultItemCountPerPage($auditModuleOptions->getPaginatorLimit());
     $paginator->setCurrentPageNumber($page);
     return $paginator;
 }
Пример #27
0
 public function onBootstrap(MvcEvent $e)
 {
     Paginator::setDefaultItemCountPerPage(30);
     ini_set('html_errors', 'Off');
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $sm = $e->getApplication()->getServiceManager();
     $em = $sm->get('doctrine.entitymanager.orm_default');
     $auth = $sm->get('Zend\\Authentication\\AuthenticationService');
     if (Cons::isConsole()) {
         $locale = locale_get_default();
     } else {
         /* @var $al \Zend\Http\Header\Accept */
         $al = $e->getRequest()->getHeaders('accept-language');
         if ($al) {
             $locales = $al->getPrioritized();
             $locale = reset($locales)->getTypeString();
             \Locale::acceptFromHttp($locale);
         } else {
             $locale = locale_get_default();
         }
     }
     /** @var Translator $translator */
     $translator = $sm->get('MvcTranslator');
     $translator->setLocale(mb_substr($locale, 0, 2));
     //        $translator->getEventManager()->attach('missingTranslation', array($this, 'translationListener'));
     AbstractValidator::setDefaultTranslator($translator);
     //
     // Narediti session tako, da se virtual hosti ne bodo med seboj mešali
     // da se avtentikacija ne prenaša med vhosti
     // poskrbim za identiteto uporabnika
     if ($e->getRequest() instanceof Request) {
         // handling autorizacij preko konzole
         $this->setIdentity('*****@*****.**', $auth, $em);
     } else {
         /* @var $request Request2 */
         $request = $e->getRequest();
         $header = $request->getHeader('Authorization');
         if ($header instanceof Authorization && strlen($header->getFieldValue()) > 10) {
             $this->tryHttpAuth($auth, $em, $e);
         }
     }
     $identity = $auth->getIdentity();
     $evm = $em->getEventManager();
     $evm->addEventSubscriber(new RevisionsListener($sm, $identity));
     $config = $sm->get('entity.metadata.factory')->getAllEntityConfig();
     $evm->addEventSubscriber(new PrePersistListener($config));
 }
 /**
  * @return ViewModel
  */
 public function viewAction()
 {
     $organisationService = $this->getOrganisationService()->setOrganisationId($this->params('id'));
     $page = $this->params()->fromRoute('page', 1);
     $filterPlugin = $this->getInvoiceFilter();
     $invoiceQuery = $this->getInvoiceService()->findEntitiesFiltered('invoice', array_merge($filterPlugin->getFilter(), ['organisation' => [$organisationService->getOrganisation()->getId()]]));
     $paginator = new Paginator(new PaginatorAdapter(new ORMPaginator($invoiceQuery, false)));
     $paginator->setDefaultItemCountPerPage($page === 'all' ? PHP_INT_MAX : 15);
     $paginator->setCurrentPageNumber($page);
     $paginator->setPageRange(ceil($paginator->getTotalItemCount() / $paginator->getDefaultItemCountPerPage()));
     $form = new InvoiceFilter($this->getInvoiceService());
     $form->setData(['filter' => $filterPlugin->getFilter()]);
     $projects = $this->getProjectService()->findProjectByOrganisation($organisationService->getOrganisation(), ProjectService::WHICH_ALL);
     return new ViewModel(['paginator' => $paginator, 'form' => $form, 'encodedFilter' => urlencode($filterPlugin->getHash()), 'order' => $filterPlugin->getOrder(), 'direction' => $filterPlugin->getDirection(), 'organisationService' => $organisationService, 'organisationDoa' => $this->getDoaService()->findDoaByOrganisation($organisationService->getOrganisation()), 'organisationLoi' => $this->getLoiService()->findLoiByOrganisation($organisationService->getOrganisation()), 'projects' => $projects, 'projectService' => $this->getProjectService()]);
 }
Пример #29
0
 /**
  * @return ViewModel
  */
 public function listAction()
 {
     if (!is_null($this->params('call'))) {
         $this->getCallService()->setCallId($this->params('call'));
     }
     if (!is_null($this->params('program'))) {
         $this->getProgramService()->setProgramId($this->params('program'));
     }
     $page = $this->params('page');
     $projects = $this->getProjectService()->findProjectByContactByProgramOrCall($this->zfcUserAuthentication()->getIdentity(), ProjectService::WHICH_ALL, !$this->getProgramService()->isEmpty() ? $this->getProgramService()->getProgram() : null, !$this->getCallService()->isEmpty() ? $this->getCallService()->getCall() : null, null, $this->params()->fromQuery('q'));
     $paginator = new Paginator(new PaginatorAdapter(new ORMPaginator($projects, false)));
     $paginator->setDefaultItemCountPerPage($page === 'all' ? PHP_INT_MAX : 15);
     $paginator->setCurrentPageNumber($page);
     $paginator->setPageRange(ceil($paginator->getTotalItemCount() / $paginator->getDefaultItemCountPerPage()));
     return new ViewModel(['paginator' => $paginator, 'search' => $this->params()->fromQuery('q'), 'calls' => $this->getCallService()->findNonEmptyCalls(), 'callId' => $this->getCallService()->isEmpty() ? null : $this->getCallService()->getCall()->getId(), 'selectedProgramId' => $this->getProgramService()->isEmpty() ? null : $this->getProgramService()->getProgram()->getId()]);
 }
Пример #30
0
 /**
  * Renders a paginated list of revisions.
  *
  * @return \Zend\View\Model\ViewModel
  */
 public function indexAction()
 {
     /**
      * @var integer $page
      */
     $sm = $this->getServiceLocator();
     $auditReader = $sm->get('auditReader');
     $config = $sm->get("Config");
     $ZF2AuditConfig = $config["zf2-entity-audit"];
     $page = (int) $this->params()->fromRoute('page');
     $limit = $ZF2AuditConfig['ui']['page.limit'];
     $paginator = new Paginator(new DbalAdapter($auditReader->paginateRevisionsQuery()));
     $paginator->setDefaultItemCountPerPage($limit);
     $paginator->setCurrentPageNumber($page);
     return new ViewModel(array('paginator' => $paginator, 'auditReader' => $auditReader));
 }