当前位置: 首页>>代码示例>>PHP>>正文


PHP Pagerfanta\Pagerfanta类代码示例

本文整理汇总了PHP中Pagerfanta\Pagerfanta的典型用法代码示例。如果您正苦于以下问题:PHP Pagerfanta类的具体用法?PHP Pagerfanta怎么用?PHP Pagerfanta使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Pagerfanta类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: indexAction

 public function indexAction(Request $request, $page = 1)
 {
     $getTypes = $request->query->get('type_filters');
     $getSubjects = $request->query->get('subject_filters');
     $getPublishers = $request->query->get('publisher_filters');
     $typeFilters = !empty($getTypes) ? explode(',', $getTypes) : [];
     $subjectFilters = !empty($getSubjects) ? explode(',', $getSubjects) : [];
     $publisherFilters = !empty($getPublishers) ? explode(',', $getPublishers) : [];
     $journalSearcher = $this->get('fos_elastica.index.search.journal');
     $boolQuery = new Query\Bool();
     $match = new Query\Match();
     $match->setField('status', 1);
     $boolQuery->addMust($match);
     $match = new Query\Match();
     $match->setField('published', true);
     $boolQuery->addMust($match);
     if (!empty($typeFilters) || !empty($subjectFilters) || !empty($publisherFilters)) {
         foreach ($typeFilters as $type) {
             $match = new Query\Match();
             $match->setField('publisher.publisher_type.name', $type);
             $boolQuery->addMust($match);
         }
         foreach ($subjectFilters as $subject) {
             $match = new Query\Match();
             $match->setField('subjects.subject', $subject);
             $boolQuery->addMust($match);
         }
         foreach ($publisherFilters as $publisher) {
             $match = new Query\Match();
             $match->setField('publisher.name', $publisher);
             $boolQuery->addMust($match);
         }
     }
     $journalQuery = new Query($boolQuery);
     $typeAgg = new Aggregation\Terms('types');
     $typeAgg->setField('publisher.publisher_type.name');
     $typeAgg->setOrder('_term', 'asc');
     $typeAgg->setSize(0);
     $journalQuery->addAggregation($typeAgg);
     $subjectAgg = new Aggregation\Terms('subjects');
     $subjectAgg->setField('subjects.subject');
     $subjectAgg->setOrder('_term', 'asc');
     $subjectAgg->setSize(0);
     $journalQuery->addAggregation($subjectAgg);
     $publisherAgg = new Aggregation\Terms('publishers');
     $publisherAgg->setField('publisher.name');
     $publisherAgg->setOrder('_term', 'asc');
     $publisherAgg->setSize(0);
     $journalQuery->addAggregation($publisherAgg);
     $adapter = new ElasticaAdapter($journalSearcher, $journalQuery);
     $pagerfanta = new Pagerfanta($adapter);
     $pagerfanta->setMaxPerPage(21);
     $pagerfanta->setCurrentPage($page);
     $journals = $pagerfanta->getCurrentPageResults();
     $types = $adapter->getResultSet()->getAggregation('types')['buckets'];
     $subjects = $adapter->getResultSet()->getAggregation('subjects')['buckets'];
     $publishers = $adapter->getResultSet()->getAggregation('publishers')['buckets'];
     $data = ['types' => $types, 'subjects' => $subjects, 'publishers' => $publishers, 'type_filters' => $typeFilters, 'subject_filters' => $subjectFilters, 'publisher_filters' => $publisherFilters, 'journals' => $journals, 'pagerfanta' => $pagerfanta, 'page' => 'explore'];
     return $this->render('OjsSiteBundle:Explore:index.html.twig', $data);
 }
开发者ID:hasantayyar,项目名称:ojs,代码行数:60,代码来源:ExploreController.php

示例2: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var SolrIndexer $indexer */
     $indexer = $this->getContainer()->get('knp_bundles.indexer.solr');
     /** @var EntityManager $em */
     $em = $this->getContainer()->get('doctrine')->getManager();
     /** @var \Solarium_Client $solarium */
     $solarium = $this->getContainer()->get('solarium.client');
     /** @var EntityRepository $repository */
     $repository = $em->getRepository('KnpBundlesBundle:Bundle');
     $query = $solarium->createSelect();
     $query->setFields(array('name', 'ownerName'));
     try {
         $hasMoreResults = true;
         $page = 1;
         while ($hasMoreResults) {
             $paginator = new Pagerfanta(new SolariumAdapter($solarium, $query));
             $paginator->setMaxPerPage(50)->setCurrentPage($page, false, true);
             foreach ($paginator as $bundle) {
                 $entity = $repository->findOneBy(array('name' => $bundle['name']));
                 if (!$entity) {
                     $entity = new Bundle();
                     $entity->setName($bundle['name']);
                     $entity->setOwnerName($bundle['ownerName']);
                     $indexer->deleteBundlesIndexes($entity);
                     $output->writeln(sprintf('The bundle "%s" was deleted from solr index.', $entity->getFullName()));
                 }
             }
             $hasMoreResults = $paginator->getNbResults() == 50;
             $page++;
         }
     } catch (\Solarium_Client_HttpException $e) {
         throw new \Exception('Seems that our search engine is currently offline. Please check later.');
     }
 }
开发者ID:KnpLabs,项目名称:KnpBundles,代码行数:35,代码来源:KbSolrRemoveFromIndexCommand.php

示例3: createOrmPaginator

 /**
  * Creates a Doctrine ORM paginator for the given query builder.
  *
  * @param DoctrineQuery|DoctrineQueryBuilder $queryBuilder
  * @param int                                $page
  * @param int                                $maxPerPage
  *
  * @return Pagerfanta
  */
 public function createOrmPaginator($queryBuilder, $page = 1, $maxPerPage = self::MAX_ITEMS)
 {
     $paginator = new Pagerfanta(new DoctrineORMAdapter($queryBuilder, true, false));
     $paginator->setMaxPerPage($maxPerPage);
     $paginator->setCurrentPage($page);
     return $paginator;
 }
开发者ID:maldoinc,项目名称:EasyAdminBundle,代码行数:16,代码来源:Paginator.php

示例4: indexAction

 /**
  * @Route("/opencast/mediapackage", name="pumukitopencast")
  * @Template()
  */
 public function indexAction(Request $request)
 {
     if (!$this->has('pumukit_opencast.client')) {
         throw $this->createNotFoundException('PumukitOpencastBundle not configured.');
     }
     $opencastClient = $this->get('pumukit_opencast.client');
     $repository_multimediaobjects = $this->get('doctrine_mongodb')->getRepository('PumukitSchemaBundle:MultimediaObject');
     $limit = 10;
     $page = $request->get("page", 1);
     $criteria = $this->getCriteria($request);
     try {
         list($total, $mediaPackages) = $opencastClient->getMediaPackages(isset($criteria["name"]) ? $criteria["name"]->regex : "", $limit, ($page - 1) * $limit);
     } catch (\Exception $e) {
         return new Response($this->render('PumukitOpencastBundle:MediaPackage:error.html.twig', array('message' => $e->getMessage())), 400);
     }
     $currentPageOpencastIds = array();
     foreach ($mediaPackages as $mediaPackage) {
         $currentPageOpencastIds[] = $mediaPackage["id"];
     }
     $adapter = new FixedAdapter($total, $mediaPackages);
     $pagerfanta = new Pagerfanta($adapter);
     $pagerfanta->setMaxPerPage($limit);
     $pagerfanta->setCurrentPage($page);
     $repo = $repository_multimediaobjects->createQueryBuilder()->field("properties.opencast")->exists(true)->field("properties.opencast")->in($currentPageOpencastIds)->getQuery()->execute();
     return array('mediaPackages' => $pagerfanta, 'multimediaObjects' => $repo, 'player' => $opencastClient->getPlayerUrl());
 }
开发者ID:bmartinezteltek,项目名称:PuMuKIT2,代码行数:30,代码来源:MediaPackageController.php

示例5: indexAction

 public function indexAction(Request $req)
 {
     $rawSpeakers = $this->app['spot']->mapper(\OpenCFP\Domain\Entity\User::class)->all()->order(['first_name' => 'ASC'])->toArray();
     $airports = $this->service(AirportInformationDatabase::class);
     $rawSpeakers = array_map(function ($speaker) use($airports) {
         try {
             $airport = $airports->withCode($speaker['airport']);
             $speaker['airport'] = ['code' => $airport->code, 'name' => $airport->name, 'country' => $airport->country];
         } catch (\Exception $e) {
             $speaker['airport'] = ['code' => null, 'name' => null, 'country' => null];
         }
         return $speaker;
     }, $rawSpeakers);
     // Set up our page stuff
     $adapter = new ArrayAdapter($rawSpeakers);
     $pagerfanta = new Pagerfanta($adapter);
     $pagerfanta->setMaxPerPage(20);
     $pagerfanta->getNbResults();
     if ($req->get('page') !== null) {
         $pagerfanta->setCurrentPage($req->get('page'));
     }
     // Create our default view for the navigation options
     $routeGenerator = function ($page) {
         return '/admin/speakers?page=' . $page;
     };
     $view = new TwitterBootstrap3View();
     $pagination = $view->render($pagerfanta, $routeGenerator, ['proximity' => 3]);
     $templateData = ['airport' => $this->app->config('application.airport'), 'arrival' => date('Y-m-d', $this->app->config('application.arrival')), 'departure' => date('Y-m-d', $this->app->config('application.departure')), 'pagination' => $pagination, 'speakers' => $pagerfanta, 'page' => $pagerfanta->getCurrentPage()];
     return $this->render('admin/speaker/index.twig', $templateData);
 }
开发者ID:intfrr,项目名称:opencfp,代码行数:30,代码来源:SpeakersController.php

示例6: renderTag

 /**
  * Renders the tag.
  *
  * @param \Netgen\TagsBundle\API\Repository\Values\Tags\Tag $tag
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 protected function renderTag(Tag $tag, Request $request)
 {
     $configResolver = $this->getConfigResolver();
     if ($this->adapter instanceof TagAdapterInterface) {
         $this->adapter->setTag($tag);
     }
     $pager = new Pagerfanta($this->adapter);
     $pager->setMaxPerPage($configResolver->getParameter('tag_view.related_content_list.limit', 'eztags'));
     $pager->setCurrentPage($request->get('page', 1));
     $response = new Response();
     $response->headers->set('X-Tag-Id', $tag->id);
     if ($configResolver->getParameter('tag_view.cache', 'eztags') === true) {
         $response->setPublic();
         if ($configResolver->getParameter('tag_view.ttl_cache', 'eztags') === true) {
             $response->setSharedMaxAge($configResolver->getParameter('tag_view.default_ttl', 'eztags'));
         }
         // Make the response vary against X-User-Hash header ensures that an HTTP
         // reverse proxy caches the different possible variations of the
         // response as it can depend on user role for instance.
         if ($request->headers->has('X-User-Hash')) {
             $response->setVary('X-User-Hash');
         }
         $response->setLastModified($tag->modificationDate);
     }
     return $this->render($configResolver->getParameter('tag_view.template', 'eztags'), array('tag' => $tag, 'pager' => $pager), $response);
 }
开发者ID:umanit,项目名称:TagsBundle,代码行数:34,代码来源:TagViewController.php

示例7: getPagerfantaRepresentation

 /**
  * Construct a pagerfanta representation from the current request
  *
  * @param AdapterInterface $adapter - The adapter to use
  * @return QueryablePaginatedRepresentation
  */
 protected function getPagerfantaRepresentation(Request $request, AdapterInterface $adapter)
 {
     $pagerfanta = new Pagerfanta($adapter);
     $limit = $request->query->get('limit');
     $zeroLimit = false;
     if (!$limit && ($limit === 0 || $limit === '0')) {
         $limit = $pagerfanta->count();
         $zeroLimit = true;
     }
     if (!$limit) {
         $limit = 10;
     }
     $pagerfanta->setMaxPerPage($limit);
     $page = $request->query->get('page');
     $nbPages = $pagerfanta->getNbPages();
     if (!$page) {
         $page = 1;
     }
     // Avoid errors: redirect to max page
     if ($page > $nbPages) {
         $page = $nbPages;
     }
     $pagerfanta->setCurrentPage($page);
     $route = new Route($request->get('_route'), $request->attributes->get('_route_params'), false);
     return new QueryablePaginatedRepresentation(new CollectionRepresentation($pagerfanta->getCurrentPageResults()), $route->getName(), $route->getParameters(), $pagerfanta->getCurrentPage(), $zeroLimit ? 0 : $pagerfanta->getMaxPerPage(), $nbPages, $pagerfanta->count(), null, null, $route->isAbsolute(), $request->query->get('where'), $request->query->get('search'), $request->query->get('order'), null, null, null);
 }
开发者ID:uebb,项目名称:hateoas-bundle,代码行数:32,代码来源:ResourceCollectionView.php

示例8: findLatest

 /**
  * @param int $page
  *
  * @return Pagerfanta
  */
 public function findLatest($page = 1)
 {
     $paginator = new Pagerfanta(new DoctrineORMAdapter($this->queryLatest(), false));
     $paginator->setMaxPerPage(Post::NUM_ITEMS);
     $paginator->setCurrentPage($page);
     return $paginator;
 }
开发者ID:rakutentech,项目名称:php-buildpack,代码行数:12,代码来源:PostRepository.php

示例9: createPager

 private function createPager($objects, $page, $limit = 5)
 {
     $adapter = new DoctrineODMMongoDBAdapter($objects);
     $pagerfanta = new Pagerfanta($adapter);
     $pagerfanta->setMaxPerPage($limit)->setNormalizeOutOfRangePages(true)->setCurrentPage($page);
     return $pagerfanta;
 }
开发者ID:bmartinezteltek,项目名称:PuMuKIT2,代码行数:7,代码来源:InfoController.php

示例10: searchAction

 /**
  * Perform a search and return a JSON response.
  *
  * @param Request $request
  *
  * @return JsonResponse
  */
 public function searchAction(Request $request)
 {
     $queryString = $request->query->get('q');
     $category = $request->query->get('category', null);
     $locale = $request->query->get('locale', null);
     $page = $this->listRestHelper->getPage();
     $limit = $this->listRestHelper->getLimit();
     $aggregateHits = [];
     $startTime = microtime(true);
     $categories = $category ? [$category] : $this->searchManager->getCategoryNames();
     foreach ($categories as $category) {
         $query = $this->searchManager->createSearch($queryString);
         if ($locale) {
             $query->locale($locale);
         }
         if ($category) {
             $query->category($category);
         }
         foreach ($query->execute() as $hit) {
             $aggregateHits[] = $hit;
         }
     }
     $time = microtime(true) - $startTime;
     $adapter = new ArrayAdapter($aggregateHits);
     $pager = new Pagerfanta($adapter);
     $pager->setMaxPerPage($limit);
     $pager->setCurrentPage($page);
     $representation = new SearchResultRepresentation(new CollectionRepresentation($pager->getCurrentPageResults(), 'result'), 'sulu_search_search', ['locale' => $locale, 'query' => $query, 'category' => $category], (int) $page, (int) $limit, $pager->getNbPages(), 'page', 'limit', false, count($aggregateHits), $this->getCategoryTotals($aggregateHits), number_format($time, 8));
     $view = View::create($representation);
     $context = SerializationContext::create();
     $context->enableMaxDepthChecks();
     $context->setSerializeNull(true);
     $view->setSerializationContext($context);
     return $this->viewHandler->handle($view);
 }
开发者ID:kriswillis,项目名称:sulu,代码行数:42,代码来源:SearchController.php

示例11: listAction

 /**
  * @param int $page
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function listAction($page)
 {
     $pagerfanta = new Pagerfanta($this->galleryManager->createPagerfantaAdapter());
     $pagerfanta->setMaxPerPage($this->galleriesPerPage);
     $pagerfanta->setCurrentPage($page);
     return $this->templating->renderResponse('FSiGalleryBundle:Gallery:list.html.twig', array('galleries' => $pagerfanta, 'preview_photos_count' => $this->previewPhotosCount));
 }
开发者ID:BenDiouf,项目名称:gallery-bundle,代码行数:11,代码来源:GalleryController.php

示例12: renderPagination

 /**
  * @return string
  */
 public function renderPagination(Page $page, Twig_Environment $environment)
 {
     $pagerfanta = new Pagerfanta(new PorpaginasAdapter($page));
     $pagerfanta->setCurrentPage($page->getCurrentPage());
     $pagerfanta->setMaxPerPage($page->getCurrentLimit());
     return $environment->getExtension('pagerfanta')->renderPagerfanta($pagerfanta, $this->viewName, $this->options);
 }
开发者ID:moufmouf,项目名称:porpaginas,代码行数:10,代码来源:PagerfantaRenderingAdapter.php

示例13: indexAction

 public function indexAction(Request $request, $page)
 {
     $querystring = $request->query->get('query');
     $finder = $this->get('fos_elastica.finder.videocollection');
     $language = $this->get('bestophe_video_collection.movieManager')->getLanguage();
     $query = $this->getElasticaResults($querystring, $language);
     $results = $finder->find($query);
     $totalHits = count($results);
     $adapter = new ArrayAdapter($results);
     $pager = new Pagerfanta($adapter);
     $maxPerPage = $this->getPagerFantaMaxPerPage();
     $pager->setMaxPerPage($maxPerPage);
     $pager->setCurrentPage($page);
     //            if ($querystring != null && $querystring != '') {
     //                $query = new \Elastica\Query\Match();
     //                $query->setFieldQuery('title_fr', $querystring);
     //                //  $query->setFieldFuzziness('title_fr', 0.7);
     //                //  $query->setFieldMinimumShouldMatch('title_fr', '80%');
     //            //
     //        } else {
     //                $query = new \Elastica\Query\MatchAll();
     //            }
     //
     //            $results = $finder->find($query);
     //
     //            $totalHits = count($results);
     return $this->render('bestopheVideoCollectionBundle:MovieSection:SearchView.html.twig', array('listMovies' => $pager->getCurrentPageResults(), 'pager' => $pager, 'query' => $querystring, 'totalHits' => $totalHits));
 }
开发者ID:ChristWood,项目名称:videoCollection,代码行数:28,代码来源:SearchController.php

示例14: listBlogPostsAction

 /**
  * Displays the list of blog_post
  * Note: This is a fully customized controller action, it will generate the response and call
  *       the view. Since it is not calling the ViewControler we don't need to match a specific
  *       method signature.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Location $location containing blog posts
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function listBlogPostsAction(Location $location, Request $request)
 {
     $response = new Response();
     // Setting default cache configuration (you can override it in you siteaccess config)
     $response->setSharedMaxAge($this->getConfigResolver()->getParameter('content.default_ttl'));
     // Make the response location cache aware for the reverse proxy
     $response->headers->set('X-Location-Id', $location->id);
     $response->setVary('X-User-Hash');
     $viewParameters = $request->attributes->get('viewParameters');
     // Getting location and content from ezpublish dedicated services
     $repository = $this->getRepository();
     if ($location->invisible) {
         throw new NotFoundHttpException("Location #{$location->id} cannot be displayed as it is flagged as invisible.");
     }
     $content = $repository->getContentService()->loadContentByContentInfo($location->getContentInfo());
     // Getting language for the current siteaccess
     $languages = $this->getConfigResolver()->getParameter('languages');
     // Using the criteria helper (a demobundle custom service) to generate our query's criteria.
     // This is a good practice in order to have less code in your controller.
     $criteria = $this->get('ezdemo.criteria_helper')->generateListBlogPostCriterion($location, $viewParameters, $languages);
     // Generating query
     $query = new Query();
     $query->query = $criteria;
     $query->sortClauses = array(new SortClause\Field('blog_post', 'publication_date', Query::SORT_DESC, $languages[0]));
     // Initialize pagination.
     $pager = new Pagerfanta(new ContentSearchAdapter($query, $this->getRepository()->getSearchService()));
     $pager->setMaxPerPage($this->container->getParameter('ezdemo.blog.blog_post_list.limit'));
     $pager->setCurrentPage($request->get('page', 1));
     return $this->render('eZDemoBundle:full:blog.html.twig', array('location' => $location, 'content' => $content, 'pagerBlog' => $pager), $response);
 }
开发者ID:vidarl,项目名称:DemoBundle,代码行数:39,代码来源:DemoController.php

示例15: getPostsAction

 /**
  * @QueryParam(name="page", requirements="\d+", default="1", description="Page of the overview")
  * @QueryParam(name="limit", requirements="\d+", default="10", description="Size of the page")
  * @QueryParam(name="sort", requirements="[a-z]+", description="Sort parameter")
  * @QueryParam(name="sort_order", requirements="(asc|desc)", allowBlank=false, default="asc", description="Sort direction")
  * @QueryParam(name="search", requirements="[a-zA-Z0-9]+", description="Search")
  * @QueryParam(name="status", requirements="(pending|publish|draft|auto-draft|future|private|inherit|trash)",  default="", nullable=true, description="Status of the posts")
  * @QueryParam(name="by_author", requirements="[a-zA-Z]+", description="By author's username", incompatibles={"search"})
  * @QueryParam(name="by_category", requirements="[a-zA-Z]+", description="By category", incompatibles={"search"})
  * @QueryParam(name="by_keywords", requirements="[a-zA-Z]+", description="By keywords", incompatibles={"search"})
  * @QueryParam(name="format", requirements="[a-z]+", default="lite", description="Format of request")
  * @Rest\View()
  */
 public function getPostsAction(ParamFetcher $paramFetcher)
 {
     $page = $paramFetcher->get("page");
     $limit = $paramFetcher->get("limit");
     $sort = $paramFetcher->get("sort");
     $sort_order = $paramFetcher->get("sort_order");
     $search = $paramFetcher->get("search");
     $status = $paramFetcher->get("status");
     $by_author = $paramFetcher->get("by_author");
     $by_category = $paramFetcher->get("by_category");
     $by_keywords = $paramFetcher->get("by_keywords");
     $format = $paramFetcher->get("format");
     $repo = $this->getDoctrine()->getManager()->getRepository('ESGISGabonPostBundle:CorporatePost');
     $posts = $repo->getPosts($format);
     $adapter = new ArrayAdapter($posts);
     $pager = new Pagerfanta($adapter);
     $pager->setMaxPerPage($limit);
     try {
         $pager->setCurrentPage($page);
     } catch (NotValidCurrentPageException $e) {
         throw new NotFoundHttpException();
     }
     $pagerfantaFactory = new PagerfantaFactory();
     $paginatedCollection = $pagerfantaFactory->createRepresentation($pager, new Route('api_get_posts', array('page' => $page, 'limit' => $limit, 'sort' => $sort, 'sort_order' => $sort_order)), new CollectionRepresentation($pager->getCurrentPageResults(), 'posts', 'posts'));
     return $paginatedCollection;
 }
开发者ID:bface007,项目名称:esgis_gabon,代码行数:39,代码来源:PostRestController.php


注:本文中的Pagerfanta\Pagerfanta类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。