Esempio n. 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 indexAction()
 {
     $this->layout('layout/bags');
     $getuser = $this->forward()->dispatch('Admin\\Controller\\Index', array('action' => 'getuser'));
     $this->layout()->getuser = $getuser;
     if (!$getuser) {
         // notlogin
         $this->redirect()->toUrl(WEBPATH);
     }
     $this->layout()->getuser = $getuser;
     //$ProductTable = $this->getServiceLocator()->get('ProductTable');
     $allRecord = $this->getSlideTable()->countAll();
     //print_r($allRecord);die;
     $pageNull = new PageNull($allRecord);
     $itemsPerPage = 5;
     $pageRange = 3;
     $page = $this->params()->fromRoute('page', 1);
     $offset = ($page - 1) * $itemsPerPage;
     $paginator = new Paginator($pageNull);
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage($itemsPerPage);
     $paginator->setPageRange($pageRange);
     $listpr_tmp = $this->getSlideTable()->getList($offset, $itemsPerPage);
     //---------------------------------
     $fetch_slideshow = $this->getSlideTable()->getList($offset, $itemsPerPage);
     $this->layout()->fetch_slideshow = $fetch_slideshow;
     return new ViewModel(array('paginator' => $paginator, 'allRecord' => $allRecord, 'offset' => $offset, 'itemsPerPage' => $itemsPerPage));
 }
 public function dataAction()
 {
     $response = $this->getResponse();
     $grid = $this->grid('Application\\Index\\Index', array('-', 'id', 'title', 'category', 'username', 'created_at', '-'));
     if (isset($this->getSessionContainer()->parent_id)) {
         $grid['parent_id'] = $this->getSessionContainer()->parent_id;
     }
     $result = $this->getResourceTable()->fetchDataGrid($grid);
     $adapter = new ArrayAdapter($result);
     $paginator = new Paginator($adapter);
     $page = ceil(intval($grid['start']) / intval($grid['length'])) + 1;
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage(intval($grid['length']));
     $data = array();
     $data['data'] = array();
     foreach ($paginator as $row) {
         $category = array_key_exists('category', $row) ? $row['category'] : '-';
         $title = $row['node_type'] == \Application\Model\Resource::NODE_TYPE_CATEGORY ? '<a href="/admin/resource/parent_id/' . $row['id'] . '" title="' . strip_tags($row['description']) . '">' . strip_tags($row['title']) . '</a>' : '<i>' . strip_tags($row['title']) . '</i>';
         $actions = '';
         if ($row['url']) {
             $actions .= '<a class="btn btn-xs btn-outline blue-steel btn-view" href="' . $row['url'] . '" data-id="' . $row['id'] . '" target="_blank">View</a>&nbsp;';
         }
         $actions .= '<a class="btn btn-xs btn-outline red" href="/admin/resource/delete/id/' . $row['id'] . '" onclick="return confirm("Are you sure you wish to delete selected resources?");">Delete</a>';
         $data['data'][] = array('<input type="checkbox" name="id[' . $row['id'] . ']" value="' . $row['id'] . '" />', '<a class="btn btn-xs btn-outline blue-steel btn-view" href="/admin/resource/edit/id/' . $row['id'] . '/parent_id/' . $row['parent_id'] . '" title="' . $row['id'] . '">Edit: ' . $row['id'] . '</a>', $title, $category, $row['username'], date('F jS Y', strtotime($row['created_at'])), $actions);
     }
     $data['page'] = $page;
     $data['grid'] = $grid;
     $data['draw'] = intval($grid['draw']);
     $data['recordsTotal'] = $paginator->getTotalItemCount();
     $data['recordsFiltered'] = $paginator->getTotalItemCount();
     $response->setStatusCode(200);
     $response->setContent(Json::encode($data));
     return $response;
 }
Esempio n. 4
0
 public function indexAction()
 {
     $page = $this->params()->fromRoute("page", 1);
     $posts = new Paginator(new ArrayAdapter($this->getPostRepository()->findBy(array(), array("postDate" => "DESC"))));
     $posts->setCurrentPageNumber($page)->setItemCountPerPage(6);
     return new ViewModel(array("pageTitle" => "Latest News", "bodyClass" => "postsPage blackLayout", "posts" => $posts));
 }
Esempio n. 5
0
 public function getProfilesPaginator($iPage = 1, $iCount = null)
 {
     $oPaginator = new Paginator(new MongoCursor($this->mapper->fetchAllIds()));
     $oPaginator->setItemCountPerPage($iCount ? $iCount : $this->oOptions->getProfilesCountPerPage());
     $oPaginator->setCurrentPageNumber($iPage);
     return $oPaginator;
 }
 public function publicarAction()
 {
     $form = new FotosForm();
     $id = (int) $this->params()->fromRoute('id', 0);
     $fotosValidator = new FotosValidator();
     $request = $this->getRequest();
     $album = $this->getObjectManager()->find('Admin\\Model\\Galeria', $id);
     $collection = new ArrayCollection($this->getService('Admin\\Service\\Fotos')->fetchAll($id));
     $paginator = new Paginator(new Adapter($collection));
     $paginator->setCurrentPageNumber($this->params()->fromQuery('page', 1))->setItemCountPerPage(12);
     if (!$album) {
         $this->redirect()->toUrl('/admin/galeria-de-fotos');
         $this->flashMessenger()->addErrorMessage('Álbum não localizado');
     }
     if ($request->isPost()) {
         $form->setInputFilter($fotosValidator->getInputFilter());
         $form->setData(array_merge_recursive($this->getRequest()->getPost()->toArray(), $this->getRequest()->getFiles()->toArray()));
         if ($form->isValid()) {
             $dados = $form->getData();
             try {
                 $this->getService('Admin\\Service\\Fotos')->saveFotos($dados, $album);
                 $this->flashMessenger()->addSuccessMessage('Fotos Publicadas com Sucesso.');
             } catch (\Exception $e) {
                 $this->flashMessenger()->addErrorMessage('Erro ao publicar fotos, por favor tente novamente.');
             }
             return $this->redirect()->toUrl('/admin/galeria-de-fotos');
         }
     }
     return new ViewModel(array('form' => $form, 'fotos' => $collection));
 }
 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()];
 }
 public function indexAction()
 {
     /* 	$temp = $this->forward()->dispatch('Application/Controller/Album', array('action' => 'index'));
     		
     		echo '<pre>'; print_r($temp); echo '<pre>';die; */
     $auth = new AuthenticationService();
     if (!$auth->hasIdentity()) {
         return $this->redirect()->toRoute('home');
     }
     $select = new Select();
     $search = @$_REQUEST['search'];
     if (!empty($search)) {
         $select->where->like('name', '%' . $search . '%');
     }
     $order_by = $this->params()->fromRoute('order_by') ? $this->params()->fromRoute('order_by') : 'id';
     $order = $this->params()->fromRoute('order') ? $this->params()->fromRoute('order') : Select::ORDER_ASCENDING;
     $page = $this->params()->fromRoute('page') ? (int) $this->params()->fromRoute('page') : 1;
     $category = $this->getCategoryTable()->fetchAllCategory($select->order($order_by . ' ' . $order), $search);
     $itemPerPage = 2;
     $category->current();
     $paginator = new Paginator(new PaginatorIterator($category));
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage($itemPerPage);
     $paginator->setPageRange(10);
     return new ViewModel(array('order_by' => $order_by, 'order' => $order, 'page' => $page, 'paginator' => $paginator));
 }
Esempio n. 9
0
 /**
  * Get users
  *
  * @param integer $page
  * @param integer $perPage
  * @param string $orderBy
  * @param string $orderType
  * @param array $filters
  *      string nickname
  *      string email
  *      string status
  *      integer role
  * @return object
  */
 public function getUsers($page = 1, $perPage = 0, $orderBy = null, $orderType = null, array $filters = [])
 {
     $orderFields = ['id', 'nickname', 'email', 'registered', 'status'];
     $orderType = !$orderType || $orderType == 'desc' ? 'desc' : 'asc';
     $orderBy = $orderBy && in_array($orderBy, $orderFields) ? $orderBy : 'id';
     $select = $this->select();
     $select->from(['a' => 'user_list'])->columns(['id' => 'user_id', 'nickname' => 'nick_name', 'email', 'status', 'registered', 'role_id' => 'role'])->join(['b' => 'acl_role'], 'a.role = b.id', ['role' => 'name'])->order($orderBy . ' ' . $orderType);
     // filter by nickname
     if (!empty($filters['nickname'])) {
         $select->where([new LikePredicate('nick_name', $filters['nickname'] . '%')]);
     }
     // filter by email
     if (!empty($filters['email'])) {
         $select->where(['email' => $filters['email']]);
     }
     // filter by status
     if (!empty($filters['status'])) {
         $select->where(['status' => $filters['status']]);
     }
     // filter by role
     if (!empty($filters['role'])) {
         $select->where(['role' => $filters['role']]);
     }
     $paginator = new Paginator(new DbSelectPaginator($select, $this->adapter));
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage(PaginationUtility::processPerPage($perPage));
     $paginator->setPageRange(SettingService::getSetting('application_page_range'));
     return $paginator;
 }
Esempio n. 10
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()];
 }
Esempio n. 11
0
 public function indexAction()
 {
     /* $service1=new \Lib\Service1\Custom();
     		echo $service1->demo(); die; */
     /* $plugin=$this->CustomPlugin();
     		print_r($plugin->doSomthing()); die; */
     /* $facebook = new \Facebook(array(
     				'appId'  => 'xxx',
     				'secret' => 'xxx',
     			));
     			print_r($facebook); die; */
     $auth = new AuthenticationService();
     if (!$auth->hasIdentity()) {
         return $this->redirect()->toRoute('home');
     }
     $select = new Select();
     $search = @$_REQUEST['search'];
     if (!empty($search)) {
         $select->where->like('name', '%' . $search . '%')->or->like('email', '%' . $search . '%')->or->like('mob', '%' . $search . '%')->or->like('title', '%' . $search . '%');
     }
     $order_by = $this->params()->fromRoute('order_by') ? $this->params()->fromRoute('order_by') : 'id';
     $order = $this->params()->fromRoute('order') ? $this->params()->fromRoute('order') : Select::ORDER_ASCENDING;
     $page = $this->params()->fromRoute('page') ? (int) $this->params()->fromRoute('page') : 1;
     $album = $this->getAdminTable()->fetchAll($select->order($order_by . ' ' . $order), $search);
     $itemPerPage = 2;
     $album->current();
     $paginator = new Paginator(new PaginatorIterator($album));
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage($itemPerPage);
     $paginator->setPageRange(10);
     //print_r($paginator); die;
     return new ViewModel(array('order_by' => $order_by, 'order' => $order, 'page' => $page, 'paginator' => $paginator));
 }
 public function indexAction()
 {
     $id = (int) $this->getEvent()->getRouteMatch()->getParam('id');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $post = $request->getPost();
         if ($post->numerotombo != '') {
             $query = $this->getEntityManager()->createQuery("SELECT u FROM\n                        Equipamento\\Entity\\Equipamento u WHERE u.ntombo LIKE :data");
             $query->setParameters(array('data' => '%' . $post->numerotombo . '%'));
             $dados = $query->getResult();
             $qb = $this->getEntityManager()->createQueryBuilder()->select('u')->from('Equipamento\\Entity\\Equipamento', 'u')->innerJoin('Equipamento\\Entity\\Tombo', 't', 'WITH', 'u.idequipamento = t.tomboequipamento')->where('t.numeroTombo LIKE :data')->setParameter('data', '%' . $post->numerotombo . '%')->getQuery();
             $dados = $dados + $qb->getResult();
             if ($dados) {
                 $page = (int) $this->getEvent()->getRouteMatch()->getParam('page');
                 $paginator = new Paginator(new ArrayAdapter($dados));
                 $paginator->setCurrentPageNumber($page)->setDefaultItemCountPerPage(8);
                 return new ViewModel(array('data' => $paginator, 'page' => $page));
             }
         }
     }
     if (!$id) {
         $equipamentos = $this->getEntityManager()->getRepository('Equipamento\\Entity\\Equipamento')->findBy(array(), array('ntombo' => 'ASC'));
         $page = (int) $this->getEvent()->getRouteMatch()->getParam('page');
         $paginator = new Paginator(new ArrayAdapter($equipamentos));
         $paginator->setCurrentPageNumber($page)->setDefaultItemCountPerPage(8);
         return new ViewModel(array('data' => $paginator, 'page' => $page));
     }
     $equipamentos = $this->findEquipamentoByTombo($id);
     return new ViewModel(array('equipamentos' => $equipamentos));
 }
Esempio n. 13
0
 public function testToJson()
 {
     $this->paginator->setCurrentPageNumber(1);
     $json = $this->paginator->toJson();
     $expected = '"0":1,"1":2,"2":3,"3":4,"4":5,"5":6,"6":7,"7":8,"8":9,"9":10';
     $this->assertContains($expected, $json);
 }
 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;
 }
Esempio n. 15
0
 public function testNoPagesBeforeSecondLastPageEqualsPageRangeMinTwo()
 {
     $this->paginator->setPageRange(3);
     $this->paginator->setCurrentPageNumber(19);
     $pages = $this->paginator->getPages('Elastic');
     $this->assertEquals(5, count($pages->pagesInRange));
 }
 public function indexAction()
 {
     $id = (int) $this->getEvent()->getRouteMatch()->getParam('id');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $post = $request->getPost();
         if ($post->nomeVisitante != '') {
             $query = $this->getEntityManager()->createQuery("SELECT u FROM\n                        Visitante\\Entity\\Visitante u WHERE u.nomeVisitante LIKE :data");
             $query->setParameters(array('data' => '%' . $post->nomeVisitante . '%'));
             $dados = $query->getResult();
             if ($dados) {
                 $page = (int) $this->getEvent()->getRouteMatch()->getParam('page');
                 $paginator = new Paginator(new ArrayAdapter($dados));
                 $paginator->setCurrentPageNumber($page)->setDefaultItemCountPerPage(8);
                 return new ViewModel(array('data' => $paginator, 'page' => $page));
             }
         }
     }
     if (!$id) {
         $visitantes = $this->getEntityManager()->getRepository('Visitante\\Entity\\Visitante')->findBy(array(), array('nomeVisitante' => 'ASC'));
         $page = (int) $this->getEvent()->getRouteMatch()->getParam('page');
         $paginator = new Paginator(new ArrayAdapter($visitantes));
         $paginator->setCurrentPageNumber($page)->setDefaultItemCountPerPage(8);
         return new ViewModel(array('data' => $paginator, 'page' => $page));
     }
     $visitantes = $this->findVisitanteByNome($id);
     return new ViewModel(array('visitantes' => $visitantes));
 }
 private function getPaginator($query, $page)
 {
     $doc_paginator = new DoctrinePaginator(new ORMPaginator($query));
     $paginator = new Paginator($doc_paginator);
     $paginator->setCurrentPageNumber($page)->setItemCountPerPage(20);
     return $paginator;
 }
 public function indexAction()
 {
     $searchform = new AlbumSearchForm();
     $searchform->get('submit')->setValue('Search');
     $select = new Select();
     $order_by = $this->params()->fromRoute('order_by') ? $this->params()->fromRoute('order_by') : 'id';
     $order = $this->params()->fromRoute('order') ? $this->params()->fromRoute('order') : Select::ORDER_ASCENDING;
     $page = $this->params()->fromRoute('page') ? (int) $this->params()->fromRoute('page') : 1;
     $select->order($order_by . ' ' . $order);
     $search_by = $this->params()->fromRoute('search_by') ? $this->params()->fromRoute('search_by') : '';
     $where = new \Zend\Db\Sql\Where();
     $formdata = array();
     if (!empty($search_by)) {
         $formdata = (array) json_decode($search_by);
         if (!empty($formdata['artist'])) {
             $where->addPredicate(new \Zend\Db\Sql\Predicate\Like('artist', '%' . $formdata['artist'] . '%'));
         }
         if (!empty($formdata['title'])) {
             $where->addPredicate(new \Zend\Db\Sql\Predicate\Like('title', '%' . $formdata['title'] . '%'));
         }
     }
     if (!empty($where)) {
         $select->where($where);
     }
     $album = $this->getAlbumTable()->fetchAll($select);
     $totalRecord = $album->count();
     $itemsPerPage = 2;
     $album->current();
     $paginator = new Paginator(new paginatorIterator($album));
     $paginator->setCurrentPageNumber($page)->setItemCountPerPage($itemsPerPage)->setPageRange(7);
     $searchform->setData($formdata);
     return new ViewModel(array('search_by' => $search_by, 'order_by' => $order_by, 'order' => $order, 'page' => $page, 'paginator' => $paginator, 'pageAction' => 'album', 'form' => $searchform, 'totalRecord' => $totalRecord));
 }
Esempio n. 19
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];
 }
Esempio n. 20
0
 /**
  * Creates a paginator
  *
  * @return Paginator Zend Paginator
  */
 public function newPaginator(array $images = array(), $currentPage = 1, $perPage = 25)
 {
     $paginator = new Paginator(new ArrayAdapter($images));
     $paginator->setItemCountPerPage($perPage);
     $paginator->setCurrentPageNumber($currentPage);
     return $paginator;
 }
Esempio n. 21
0
 public function indexAction()
 {
     $this->layout()->setVariable('skipWelcome', false);
     $paginator = new Paginator(new ArrayAdapter($this->modulesList));
     $paginator->setCurrentPageNumber((int) $this->params()->fromQuery('page', 1));
     $paginator->setItemCountPerPage(10);
     return new ViewModel(['paginator' => $paginator]);
 }
Esempio n. 22
0
 public function indexAction()
 {
     /** @var QueryBuilder $qb */
     $qb = $this->getObjectManager()->createQueryBuilder();
     $qb->select('w')->from(Word::class, 'w');
     $form = new WordSearchForm();
     $form->setData($this->params()->fromQuery());
     $form->setInputFilter(new WordSearchInputFilter());
     // it doesn't matter if the form is not valid, as we would fill in default values anyway. This is just to avoid the default error messages
     $form->isValid();
     // set query, direction and order for the querybuilder
     $direction = strtolower($form->getData()['d']);
     $direction = $direction == 'desc' ? 'desc' : 'asc';
     $orderBy = strtolower($form->getData()['o']);
     switch ($orderBy) {
         case 'created':
             $order = 'createdAt';
             break;
         case 'updated':
             $order = 'updatedAt';
             break;
         default:
             $orderBy = $order = 'word';
             break;
     }
     $qb->orderBy('w.' . $order, $direction);
     // no need to avoid SQL injection, as doctrine does this for us
     $query = $form->getData()['q'];
     $qb->where('w.word LIKE :query')->setParameter('query', '%' . $query . '%');
     $itemsPerPage = 50;
     // set up the paginator
     $adapter = new DoctrineAdapter(new ORMPaginator($qb->getQuery()));
     $paginator = new Paginator($adapter);
     $paginator->setDefaultItemCountPerPage(50);
     $page = (int) $this->params()->fromQuery('p');
     if ($page != null) {
         $paginator->setCurrentPageNumber($page);
     } else {
         $paginator->setCurrentPageNumber(1);
     }
     $pages = $paginator->getTotalItemCount() / $itemsPerPage;
     $paginator->setPageRange($pages);
     $viewModel = new ViewModel();
     $viewModel->setVariables(['words' => $paginator->getCurrentItems(), 'pageCount' => $paginator->getPageRange() + 1, 'currentPage' => $paginator->getCurrentPageNumber(), 'orderBy' => $orderBy, 'direction' => $direction, 'query' => $query, 'form' => $form]);
     return $viewModel;
 }
 /**
  * 1 - Listar registros
  */
 public function indexAction()
 {
     $list = $this->getEm()->getRepository($this->entity)->findAll();
     $page = $this->params()->fromRoute('page');
     $paginator = new Paginator(new ArrayAdapter($list));
     $paginator->setCurrentPageNumber($page)->setDefaultItemCountPerPage(10);
     return new ViewModel(array('data' => $paginator, 'page' => $page));
 }
Esempio n. 24
0
 public function _set_paginator($array, $item_per_page)
 {
     $doctrine_collection = new ArrayCollection($array);
     $adapter = new CollectionAdapter($doctrine_collection);
     $paginator = new Paginator($adapter);
     $paginator->setCurrentPageNumber($this->params()->fromRoute('page'))->setItemCountPerPage($item_per_page);
     return $paginator;
 }
 public function listarTodosAction()
 {
     $controles = $this->getEntityManager()->getRepository('Controle\\Entity\\Controle')->findAll();
     $page = (int) $this->getEvent()->getRouteMatch()->getParam('page');
     $paginator = new Paginator(new ArrayAdapter($controles));
     $paginator->setCurrentPageNumber($page)->setDefaultItemCountPerPage(8);
     return new ViewModel(array('data' => $paginator, 'page' => $page));
 }
Esempio n. 26
0
 public function indexAction()
 {
     $page = $this->params()->fromRoute('page') ? (int) $this->params()->fromRoute('page') : 1;
     $apps = $this->getAppTable()->fetchAll();
     $paginator = new Paginator(new PaginatorIterator($apps));
     $paginator->setCurrentPageNumber($page)->setItemCountPerPage($this->config['pagination']['itempage'])->setPageRange($this->config['pagination']['pagerange']);
     return new ViewModel(array('apps' => $paginator, 'config' => $this->config));
 }
Esempio n. 27
0
 /**
  * Returns a paginator instance from Doctrine query
  *
  * @param mixed {Doctrine\ORM\Query, Doctrine\ORM\QueryBuilder}
  * @param int $page
  * @param int $items_per_page
  * @return Zend\Paginator\Paginator
  **/
 public static function create($qb, $page = 1, $items_per_page = 10)
 {
     $dPaginator = new DoctrinePaginator($qb);
     $adapter = new DoctrinePaginatorAdapter($dPaginator);
     $zfPaginator = new ZendPaginator($adapter);
     $zfPaginator->setCurrentPageNumber($page);
     $zfPaginator->setItemCountPerPage($items_per_page);
     return $zfPaginator;
 }
Esempio n. 28
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);
 }
Esempio n. 29
0
 public function getPagination($iPageNumber = 0, $iCountPerPage = 0, $aOptions = array())
 {
     $paginatorAdapter = new DbSelect($this->mAuthorityTb->getSql()->select()->where($aOptions), $this->mAuthorityTb->getAdapter(), $this->mAuthorityTb->getResultSetPrototype());
     $paginator = new Paginator($paginatorAdapter);
     $paginator->setCurrentPageNumber($iPageNumber)->setItemCountPerPage($iCountPerPage);
     $iTotal = $paginator->getTotalItemCount();
     $aRows = $this->mCore->IteratorToArray($paginator->getCurrentItems());
     return json_encode(array('rows' => $aRows, 'total' => $iTotal));
 }
Esempio n. 30
0
 /**
  * Sets the current page number.
  *
  * @param  int $pageNumber Page number
  * @return Paginator $this
  */
 public function setCurrentPageNumber($pageNumber)
 {
     $adapter = $this->getAdapter();
     if ($adapter instanceof PaginatorAdapterInterface) {
         $offset = $this->getItemCountPerPage() * ($pageNumber - 1);
         $adapter->setOffset($offset);
     }
     return parent::setCurrentPageNumber($pageNumber);
 }