예제 #1
0
 public function indexAction(Request $req)
 {
     if (!$this->userHasAccess($this->app)) {
         return $this->redirectTo('login');
     }
     $admin_user_id = $this->app['sentry']->getUser()->getId();
     $options = ['order_by' => $req->get('order_by'), 'sort' => $req->get('sort')];
     $pager_formatted_talks = $this->getFilteredTalks($req->get('filter'), $admin_user_id, $options);
     $per_page = (int) $req->get('per_page') ?: 20;
     // Set up our page stuff
     $adapter = new \Pagerfanta\Adapter\ArrayAdapter($pager_formatted_talks);
     $pagerfanta = new \Pagerfanta\Pagerfanta($adapter);
     $pagerfanta->setMaxPerPage($per_page);
     $pagerfanta->getNbResults();
     if ($req->get('page') !== null) {
         $pagerfanta->setCurrentPage($req->get('page'));
     }
     $queryParams = $req->query->all();
     // Create our default view for the navigation options
     $routeGenerator = function ($page) use($queryParams) {
         $queryParams['page'] = $page;
         return '/admin/talks?' . http_build_query($queryParams);
     };
     $view = new TwitterBootstrap3View();
     $pagination = $view->render($pagerfanta, $routeGenerator, array('proximity' => 3));
     $templateData = ['pagination' => $pagination, 'talks' => $pagerfanta, 'page' => $pagerfanta->getCurrentPage(), 'current_page' => $req->getRequestUri(), 'totalRecords' => count($pager_formatted_talks), 'filter' => $req->get('filter'), 'per_page' => $per_page, 'sort' => $req->get('sort'), 'order_by' => $req->get('order_by')];
     return $this->render('admin/talks/index.twig', $templateData);
 }
예제 #2
0
 public function indexAction(Request $req, Application $app)
 {
     // Check if user is an logged in and an Admin
     if (!$this->userHasAccess($app)) {
         return $app->redirect($app['url'] . '/dashboard');
     }
     $admin_user_id = $app['sentry']->getUser()->getId();
     $mapper = $app['spot']->mapper('OpenCFP\\Entity\\Talk');
     $pager_formatted_talks = $mapper->getAllPagerFormatted($admin_user_id);
     // Set up our page stuff
     $adapter = new \Pagerfanta\Adapter\ArrayAdapter($pager_formatted_talks);
     $pagerfanta = new \Pagerfanta\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/talks?page=' . $page;
     };
     $view = new TwitterBootstrap3View();
     $pagination = $view->render($pagerfanta, $routeGenerator, array('proximity' => 3));
     $template = $app['twig']->loadTemplate('admin/talks/index.twig');
     $templateData = array('pagination' => $pagination, 'talks' => $pagerfanta, 'page' => $pagerfanta->getCurrentPage(), 'current_page' => $req->getRequestUri(), 'totalRecords' => count($pager_formatted_talks));
     return $template->render($templateData);
 }
예제 #3
0
 private function indexAction(Request $req)
 {
     $user = $this->app['sentry']->getUser();
     // How many admins make for a majority?
     $mapper = $this->app['spot']->mapper('OpenCFP\\Domain\\Entity\\User');
     $admin_count = $mapper->all()->where(['permissions' => '{"admin":1}'])->count();
     $admin_majority = (int) ($admin_count * 0.501) + 1;
     // Get list of talks where majority of admins 'favorited' them
     $mapper = $this->app['spot']->mapper('OpenCFP\\Domain\\Entity\\Talk');
     $favorite_talks = $mapper->getAdminFavorites($user->id, $admin_majority);
     // Set up our page stuff
     $adapter = new \Pagerfanta\Adapter\ArrayAdapter($favorite_talks);
     $pagerfanta = new \Pagerfanta\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/review?page=' . $page;
     };
     $view = new TwitterBootstrap3View();
     $pagination = $view->render($pagerfanta, $routeGenerator, array('proximity' => 3));
     $template_data = ['pagination' => $pagination, 'talks' => $pagerfanta, 'page' => $pagerfanta->getCurrentPage(), 'totalRecords' => count($favorite_talks)];
     return $this->render('admin/review/index.twig', $template_data);
 }
예제 #4
0
 public function indexAction(Request $req)
 {
     if (!$this->userHasAccess()) {
         return $this->redirectTo('dashboard');
     }
     /* @var Sentry $sentry */
     $sentry = $this->service('sentry');
     $user = $sentry->getUser();
     /* @var Locator $spot */
     $spot = $this->service('spot');
     // Get list of talks where majority of admins 'favorited' them
     $mapper = $spot->mapper(\OpenCFP\Domain\Entity\Talk::class);
     $options = ['order_by' => $req->get('order_by'), 'sort' => $req->get('sort')];
     $per_page = (int) $req->get('per_page') ?: 20;
     $talks = $mapper->getTopRatedByUserId($user->getId(), $options);
     // Set up our page stuff
     $adapter = new \Pagerfanta\Adapter\ArrayAdapter($talks);
     $pagerfanta = new \Pagerfanta\Pagerfanta($adapter);
     $pagerfanta->setMaxPerPage($per_page);
     $pagerfanta->getNbResults();
     if ($req->get('page') !== null) {
         $pagerfanta->setCurrentPage($req->get('page'));
     }
     $queryParams = $req->query->all();
     // Create our default view for the navigation options
     $routeGenerator = function ($page) use($queryParams) {
         $queryParams['page'] = $page;
         return '/admin/review?' . http_build_query($queryParams);
     };
     $view = new TwitterBootstrap3View();
     $pagination = $view->render($pagerfanta, $routeGenerator, ['proximity' => 3]);
     $template_data = ['pagination' => $pagination, 'talks' => $pagerfanta, 'page' => $pagerfanta->getCurrentPage(), 'totalRecords' => count($talks), 'per_page' => $per_page, 'filter' => $req->get('filter'), 'sort' => $req->get('sort'), 'order_by' => $req->get('order_by')];
     return $this->render('admin/review/index.twig', $template_data);
 }
예제 #5
0
 public function indexAction(Request $req, Application $app)
 {
     // Check if user is an logged in and an Admin
     if (!$this->userHasAccess($app)) {
         return $app->redirect($app['url'] . '/dashboard');
     }
     $rawSpeakers = $app['spot']->mapper('\\OpenCFP\\Entity\\User')->all()->order(['last_name' => 'ASC'])->toArray();
     // Set up our page stuff
     $adapter = new \Pagerfanta\Adapter\ArrayAdapter($rawSpeakers);
     $pagerfanta = new \Pagerfanta\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, array('proximity' => 3));
     $template = $app['twig']->loadTemplate('admin/speaker/index.twig');
     $templateData = array('airport' => $app['confAirport'], 'arrival' => $app['arrival'], 'departure' => $app['departure'], 'pagination' => $pagination, 'speakers' => $pagerfanta, 'page' => $pagerfanta->getCurrentPage());
     return $template->render($templateData);
 }
예제 #6
0
 public function indexAction(Request $req)
 {
     if (!$this->userHasAccess()) {
         return $this->redirectTo('dashboard');
     }
     /* @var Sentry $sentry */
     $sentry = $this->service('sentry');
     $adminGroup = $sentry->getGroupProvider()->findByName('Admin');
     $adminUsers = $sentry->findAllUsersInGroup($adminGroup);
     // Set up our page stuff
     $adapter = new \Pagerfanta\Adapter\ArrayAdapter($adminUsers->toArray());
     $pagerfanta = new \Pagerfanta\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/admins?page=' . $page;
     };
     $view = new TwitterBootstrap3View();
     $pagination = $view->render($pagerfanta, $routeGenerator, ['proximity' => 3]);
     $templateData = ['pagination' => $pagination, 'speakers' => $pagerfanta, 'page' => $pagerfanta->getCurrentPage()];
     return $this->render('admin/admins/index.twig', $templateData);
 }
예제 #7
0
 public function indexAction(Request $req, Application $app)
 {
     // Check if user is an logged in and an Admin
     if (!$this->userHasAccess($app)) {
         return $app->redirect($app['url'] . '/dashboard');
     }
     $adminGroup = $app['sentry']->getGroupProvider()->findByName('admin');
     $adminUsers = $app['sentry']->findAllUsersInGroup($adminGroup);
     // Set up our page stuff
     $adapter = new \Pagerfanta\Adapter\ArrayAdapter($adminUsers->toArray());
     $pagerfanta = new \Pagerfanta\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/admins?page=' . $page;
     };
     $view = new TwitterBootstrap3View();
     $pagination = $view->render($pagerfanta, $routeGenerator, array('proximity' => 3));
     $template = $app['twig']->loadTemplate('admin/admins/index.twig');
     $templateData = array('pagination' => $pagination, 'speakers' => $pagerfanta, 'page' => $pagerfanta->getCurrentPage());
     return $template->render($templateData);
 }
예제 #8
0
 /**
  * @Route("/admin/user", name="cuteflow_admin_user")
  * @Template()
  *
  * @return array
  */
 public function listAction()
 {
     $em = $this->getDoctrine()->getEntityManager();
     $filter = $this->getRequest()->getSession()->get('user.filter', new UserFilter());
     //        $filter->setGroup($em->merge($filter->getGroup()));     // needed to reattach the deserialized session entity
     $filterForm = $this->createForm(new UserFilterType(), $filter);
     $filterForm->bindRequest($this->getRequest());
     $this->getRequest()->getSession()->set('user.filter', $filter);
     $query = $em->getRepository('CuteFlowCoreBundle:User')->getFindByFilterQuery($filter);
     $paginator = new \Pagerfanta\Pagerfanta(new \Pagerfanta\Adapter\DoctrineORMAdapter($query));
     $paginator->setMaxPerPage($this->container->getParameter('cuteflow.pagesize.default'));
     $paginator->setCurrentPage($this->get('request')->query->get('page', 1), false, true);
     return array('filterForm' => $filterForm->createView(), 'paginator' => $paginator);
 }
예제 #9
0
 /**
  * Paginates the list of data.
  *
  * @param  array   $data
  * @param  integer $itemsPerPage
  * @return array
  */
 function paginate($data, $itemsPerPage = 20)
 {
     $get = request()->getQueryParams();
     $view = new Pagerfanta\View\TwitterBootstrap3View();
     $adapter = new Pagerfanta\Adapter\ArrayAdapter($data);
     $currentPage = isset($get['page']) ? $get['page'] : 1;
     $pagerfanta = new Pagerfanta\Pagerfanta($adapter);
     $pagerfanta->setMaxPerPage($itemsPerPage);
     $pagerfanta->setCurrentPage($currentPage);
     $route = function ($page) {
         $path = request()->getUri()->getPath();
         return $path . '?page=' . $page;
     };
     return [$pagerfanta, $view->render($pagerfanta, $route)];
 }
예제 #10
0
 public function indexAction(Request $req)
 {
     if (!$this->userHasAccess($this->app)) {
         return $this->redirectTo('login');
     }
     $sort = ["created_at" => "DESC"];
     if ($req->get('sort') !== null) {
         switch ($req->get('sort')) {
             case "title":
                 $sort = ["title" => "ASC"];
                 break;
             case "category":
                 $sort = ["category" => "ASC", "title" => "ASC"];
                 break;
             case "type":
                 $sort = ["type" => "ASC", "category" => "ASC", "title" => "ASC"];
                 break;
         }
     }
     $admin_user_id = $this->app['sentry']->getUser()->getId();
     $mapper = $this->app['spot']->mapper('OpenCFP\\Domain\\Entity\\Talk');
     $pager_formatted_talks = $mapper->getAllPagerFormatted($admin_user_id, $sort);
     // Set up our page stuff
     $adapter = new \Pagerfanta\Adapter\ArrayAdapter($pager_formatted_talks);
     $pagerfanta = new \Pagerfanta\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) use($req) {
         $uri = '/admin/talks?page=' . $page;
         if ($req->get('sort') !== null) {
             $uri .= '&sort=' . $req->get('sort');
         }
         return $uri;
     };
     $view = new TwitterBootstrap3View();
     $pagination = $view->render($pagerfanta, $routeGenerator, array('proximity' => 3));
     $templateData = array('pagination' => $pagination, 'talks' => $pagerfanta, 'page' => $pagerfanta->getCurrentPage(), 'current_page' => $req->getRequestUri(), 'totalRecords' => count($pager_formatted_talks));
     return $this->render('admin/talks/index.twig', $templateData);
 }
예제 #11
0
 private function indexAction(Request $req)
 {
     $adminGroup = $this->app['sentry']->getGroupProvider()->findByName('Admin');
     $adminUsers = $this->app['sentry']->findAllUsersInGroup($adminGroup);
     // Set up our page stuff
     $adapter = new \Pagerfanta\Adapter\ArrayAdapter($adminUsers->toArray());
     $pagerfanta = new \Pagerfanta\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/admins?page=' . $page;
     };
     $view = new TwitterBootstrap3View();
     $pagination = $view->render($pagerfanta, $routeGenerator, array('proximity' => 3));
     $templateData = array('pagination' => $pagination, 'speakers' => $pagerfanta, 'page' => $pagerfanta->getCurrentPage());
     return $this->render('admin/admins/index.twig', $templateData);
 }
     $q_members->setParameter(':pvid', $_GET['province_id']);
 }
 if (isset($_GET['city_id']) && !empty($_GET['city_id'])) {
     $q_members->andWhere('m.city_id = :ctid');
     $q_members->setParameter(':ctid', $_GET['city_id']);
 }
 if (isset($_GET['area']) && !empty($_GET['area'])) {
     $q_members->andWhere('m.area LIKE :area');
     $q_members->setParameter(':area', "%" . $_GET['area'] . "%");
 }
 // Paging handling
 $countQueryBuilderModifier = function ($q_members) {
     $q_members->select('COUNT(DISTINCT u.user_id) AS total_results')->setMaxResults(1);
 };
 $pagerAdapter = new \Pagerfanta\Adapter\DoctrineDbalAdapter($q_members, $countQueryBuilderModifier);
 $pagerfanta = new \Pagerfanta\Pagerfanta($pagerAdapter);
 $pagerfanta->setMaxPerPage(20);
 $pagerfanta->setCurrentPage(isset($_GET['page']) ? $_GET['page'] : 1);
 $viewPager = new \Pagerfanta\View\TwitterBootstrapView();
 $routerGen = function ($page) use($request) {
     $uri_page = 'membership?page=' . $page;
     $count_get_req = count($_GET);
     if ($count_get_req > 0) {
         $_GET['page'] = $page;
         $uri_page = 'membership?' . http_build_query($_GET);
     }
     return $uri_page;
 };
 $html_view_pager = $viewPager->render($pagerfanta, $routerGen, array('proximity' => 3, 'prev_message' => 'Prev', 'next_message' => 'Next'));
 $members = $pagerfanta->getCurrentPageResults();
 // --- End of paging handling
예제 #13
0
파일: index.php 프로젝트: akleiber/search
try {
    $user = $sm->find('Doctrine\\Tests\\Models\\Comments\\User', 'unknownid');
} catch (Doctrine\Search\Exception\NoResultException $exception) {
    print_r($exception->getMessage());
    echo PHP_EOL;
}
//Search for comments with parent user. Because of the way ES returns
//results, you have to explicitly ask for the _parent or _routing field if required.
//On single document query e.g. find() the _parent field is returned by ES anyway.
echo PHP_EOL . "*** Comments with parent user ***" . PHP_EOL;
$query = new Elastica\Query();
$query->setFilter(new Elastica\Filter\HasParent(new Elastica\Filter\Term(array('username' => 'mrhash')), 'users'));
$query->setFields(array('_source', '_parent'));
$comments = $sm->getRepository('Doctrine\\Tests\\Models\\Comments\\Comment')->search($query);
foreach ($comments as $comment) {
    print_r($comment);
}
//Paginated response with Pagerfanta library. In this case the Doctrine\Search\Query
//wrapper provides a mechanism for specifying the query but it should be possible to
//pass an Elastica query directly into a modified pagination adapter.
echo PHP_EOL . "*** Pagerfanta paginated results ***" . PHP_EOL;
$query = $sm->createQuery()->from('Doctrine\\Tests\\Models\\Comments\\Comment')->searchWith(new Elastica\Query())->setQuery(new Elastica\Query\MatchAll())->setFields(['_source', '_parent'])->setHydrationMode(Doctrine\Search\Query::HYDRATE_INTERNAL);
$pager = new Pagerfanta\Pagerfanta(new PagerfantaAdapter($query));
$pager->setAllowOutOfRangePages(true);
$pager->setMaxPerPage(1);
$pager->setCurrentPage(2);
$comments = $pager->getCurrentPageResults();
foreach ($comments as $comment) {
    print_r($comment);
}
echo "Total comments found by query: " . $pager->getNbResults() . PHP_EOL;
예제 #14
0
 /**
  * Retourne le PagerFanta pour la méthode findBy().
  *
  * @param array $conditions Conditions de la recherche
  * @param array|NULL $orderBy Tri des résultats
  * @param integer $nombreResultatsParPage Nombre de résultats par page
  * @param integer $currentPage Page à afficher
  * @return \Pagerfanta\Pagerfanta Pagerfanta
  */
 public function getPagerFantaFindBy(array $conditions, array $orderBy = null, $nombreResultatsParPage = 20, $currentPage = 1, array $extras = array())
 {
     $adapter = new \Pagerfanta\Adapter\DoctrineORMAdapter($this->getQueryBuilderFindBy($conditions, $orderBy, null, null, $extras), false);
     $pagerFanta = new \Pagerfanta\Pagerfanta($adapter);
     if (null !== $nombreResultatsParPage) {
         $pagerFanta->setMaxPerPage($nombreResultatsParPage);
     }
     $pagerFanta->setCurrentPage($currentPage);
     return $pagerFanta;
 }