Esempio n. 1
0
 public function render()
 {
     $comments = $this->article->getComments();
     $this->template->comments = $comments->slice($this->paginator->getOffset(), $this->paginator->getLength());
     $this->template->setFile(__DIR__ . '/templates/comments.latte');
     $total = count($this->article->getComments());
     $this->paginator->setItemCount($total);
     $this->template->paginator = $this->paginator;
     $this->template->render();
 }
Esempio n. 2
0
 /**
  * @param IQueryable $repository
  * @return array
  */
 public function fetch(IQueryable $repository)
 {
     $query = $this->getQuery($repository);
     if ($this->paginator) {
         $query = Paginate::getPaginateQuery($query, $this->paginator->getOffset(), $this->paginator->getLength());
         // Step 2 and 3
     } else {
         $query = $query->setMaxResults(NULL)->setFirstResult(NULL);
     }
     $this->lastQuery = $query;
     return $query->getResult();
 }
Esempio n. 3
0
 public function renderDefault()
 {
     $this->template->paginator = $this->paginator;
     $this->template->paginatorDel = $this->paginatorDel;
     if ($this->moderate) {
         $this->template->news = $this->newsManager->getNewsList($this->paginator->getLength(), $this->paginator->getOffset(), 0);
         $this->template->newsDel = $this->newsManager->getNewsList($this->paginatorDel->getLength(), $this->paginatorDel->getOffset(), 1);
     } else {
         $this->template->news = $this->newsManager->getNewsList($this->paginator->getLength(), $this->paginator->getOffset(), 0, $this->user->getId());
         $this->template->newsDel = $this->newsManager->getNewsList($this->paginatorDel->getLength(), $this->paginatorDel->getOffset(), 1, $this->user->getId());
     }
 }
 public function renderDefault($page = 1)
 {
     $empty = FALSE;
     $this->page = $page;
     $paginator = new Paginator();
     $paginator->setItemsPerPage(10);
     $paginator->setPage($this->page);
     if (!$this->user->isAllowed('Article', 'editAll')) {
         $count = $this->articleManager->getCount($this->user->id);
     } else {
         $count = $this->articleManager->getCount();
     }
     $paginator->setItemCount($count);
     if (Strings::length($this->q) >= 3) {
         $this->fulltextQuery = $this->q;
     }
     if ($this->fulltextQuery) {
         if (!$this->user->isAllowed('Article', 'editAll')) {
             $fulltextArticles = $this->articleManager->findFulltext($this->fulltextQuery)->fetchAll();
         } else {
             $fulltextArticles = $this->articleManager->findFulltext($this->fulltextQuery)->where('article.user_id', $this->user->id)->fetchAll();
         }
         if (!empty($fulltextArticles)) {
             $paginator->setItemCount(count($fulltextArticles));
             $fulltextPages = array_chunk($fulltextArticles, $paginator->itemsPerPage, true);
             $this->template->listOfArticles = $fulltextPages[$paginator->page - 1];
         } else {
             $paginator->setItemCount(0);
             $this->template->listOfArticles = array();
         }
     } else {
         if (!$this->user->isAllowed('Article', 'editAll')) {
             $this->template->listOfArticles = $this->articleManager->findAll()->where('article.user_id', $this->user->id)->limit($paginator->getLength(), $paginator->getOffset())->fetchAll();
         } else {
             $this->template->listOfArticles = $this->articleManager->findAll()->limit($paginator->getLength(), $paginator->getOffset())->fetchAll();
         }
         if (empty($this->template->listOfArticles)) {
             $empty = TRUE;
         }
     }
     $this->template->fulltextQuery = $this->q;
     $this->template->page = $this->page;
     $this->template->empty = $empty;
     if ($count > $paginator->itemsPerPage && !$paginator->last) {
         $this->template->showMoreButton = TRUE;
     }
     if ($this->ajax) {
         $this->redrawControl('datalistResult');
     }
 }
Esempio n. 5
0
 public function actionDefault($page = 1)
 {
     if ($page < 1) {
         $this->redirect('this', ['page' => 1]);
     }
     $this->paginator = new Paginator();
     $this->paginator->setItemsPerPage(self::ORDERS_PER_PAGE);
     $this->paginator->setPage($page);
     $orders = $this->orderService->getAll($this->paginator->getItemsPerPage(), $this->paginator->getOffset());
     $this->paginator->setItemCount(count($orders));
     $orders = iterator_to_array($orders);
     if (count($orders) === 0 && $page > 1) {
         $this->redirect('this', ['page' => 1]);
     }
     $this->orders = $orders;
 }
 public function renderDefault($page = 1)
 {
     $paginator = new Paginator();
     $paginator->setItemsPerPage(10);
     $paginator->setPage($page);
     $count = $this->shortcutsManager->getCount();
     $paginator->setItemCount($count);
     $empty = FALSE;
     if ($this->fulltextQuery != '') {
         $this->template->listOfShortcuts = $this->shortcutsManager->findFulltext($this->fulltextQuery);
     } else {
         $this->template->listOfShortcuts = $this->shortcutsManager->findAll($paginator->getOffset(), $paginator->getLength());
         if (empty($this->template->listOfShortcuts)) {
             $empty = TRUE;
         }
     }
     $this->template->fulltextQuery = $this->fulltextQuery;
     $this->template->empty = $empty;
     $this->template->page = $page;
     if ($count > 10) {
         $this->template->showMoreButton = TRUE;
     }
     if ($this->ajax) {
         $this->redrawControl('datalistResult');
     }
 }
 /**
  * @return Form
  */
 public function create($kat = null, $page = null, $id_user = null)
 {
     // nastaveni paginatoru
     $paginator = new Nette\Utils\Paginator();
     $paginator->setItemsPerPage(6);
     // def počtu položek na stránce
     $paginator->setPage($page);
     // def stranky
     // selekce upozorneni
     $alerts = $this->database->findAll('alert')->where('id_user', $id_user);
     if ($kat == 'read') {
         // prectene
         $alerts = $alerts->where('visited', 1);
     } else {
         // neprectene
         $alerts = $alerts->where('visited', 0);
     }
     $alerts = $alerts->order('added DESC')->order('id DESC');
     // prideleni produktu na stranku
     $paginator->setItemCount($alerts->count('*'));
     $this->alerts = $alerts->limit($paginator->getLength(), $paginator->getOffset());
     $this->kat = $kat;
     // form
     $form = new Form();
     $form->getElementPrototype()->class('ajax form');
     foreach ($this->alerts as $alert) {
         $form->addCheckbox($alert->id);
     }
     $form->addSubmit('btndel', 'Smazat upozornění')->setAttribute('class', 'btn btn-primary');
     $form->addSubmit('btnvis', 'Označit jako přečtené')->setAttribute('class', 'btn btn-default');
     $form->onSuccess[] = array($this, 'formSucceeded');
     $form->onError[] = array($this, 'formNotSucceeded');
     return $form;
 }
Esempio n. 8
0
 /**
  * @return int
  */
 public function getOffset()
 {
     if ($this->limit === NULL) {
         return NULL;
     }
     $this->getSteps();
     return $this->paginator->getOffset();
 }
Esempio n. 9
0
 /**
  * @param Paginator
  * @param bool fills paginator "itemCount", if true, solr query will be executed immediately
  * @throws InvalidStateException
  */
 public function applyPaginator(Paginator $paginator, $fillItemCount = TRUE)
 {
     $this->applyPaging($paginator->getOffset(), $paginator->getLength());
     if ($fillItemCount) {
         $this->execute();
         $paginator->setItemCount($this->getTotalCount());
     }
 }
Esempio n. 10
0
 public function renderArticles()
 {
     /** @var Doctrine\Common\Collections\ArrayCollection */
     $articles = $this->objectWithArticles->getArticles();
     $total = $articles->count();
     $this->template->news = $articles->slice($this->paginator->getOffset(), $this->paginator->getLength());
     $this->paginator->setItemCount($total);
     $this->template->paginator = $this->paginator;
 }
Esempio n. 11
0
 /**
  * Render grid
  */
 public function render()
 {
     $this->paginator->setPage($this->page);
     $this->model->setLimit($this->paginator->getLength());
     $this->model->setOffset($this->paginator->getOffset());
     if ($this->sortColumn && $this["columns"]->getComponent($this->sortColumn)->isSortable()) {
         $this->model->setSorting($this->sortColumn, $this->sortType);
     }
     $this->template->render();
 }
Esempio n. 12
0
 /**
  * Render grid
  */
 public function render()
 {
     $this->model->setLimit($this->paginator->getLength());
     $this->model->setOffset($this->paginator->getOffset());
     if ($this->sortColumn && $this["columns"]->getComponent($this->sortColumn)->isSortable()) {
         $this->model->setSorting($this->sortColumn, $this->sortType);
     }
     $this['visualPaginator']->setClass(array('paginator', $this->ajaxClass));
     $this->template->render();
 }
Esempio n. 13
0
 public function renderDefault($page = 1, $filter = '%')
 {
     $paginator = new Nette\Utils\Paginator();
     $paginator->setItemsPerPage(5);
     $paginator->setPage($page);
     $results = count($this->database->table('users')->where('username LIKE ? OR email LIKE ?', $filter, $filter));
     $paginator->setItemCount($results);
     $this->template->totalPages = $paginator->getPageCount();
     $this->template->page = $paginator->page;
     $this->template->filter = $filter;
     $this->template->users = $this->database->table('users')->order('username')->where('username LIKE ? OR email LIKE ?', $filter, $filter)->limit($paginator->getLength(), $paginator->getOffset());
 }
Esempio n. 14
0
 public function renderDefault()
 {
     $this->template->categoryId = $this->template->settings['categories:id:contact'];
     $contactsDb = $this->database->table("contacts")->order("name");
     $paginator = new \Nette\Utils\Paginator();
     $paginator->setItemCount($contactsDb->count("*"));
     $paginator->setItemsPerPage(20);
     $paginator->setPage($this->getParameter("page"));
     $this->template->args = $this->getParameters();
     $this->template->paginator = $paginator;
     $this->template->contacts = $contactsDb->limit($paginator->getLength(), $paginator->getOffset());
     $this->template->menu = $this->database->table("categories")->where('parent_id', $this->template->settings['categories:id:contact']);
 }
Esempio n. 15
0
 public function renderDefault()
 {
     $cols = array("pages_types_id" => 6, "pages_id" => $this->getParameter("page_id"));
     $this->template->galleryId = $this->getParameter("id");
     $gallery = $this->database->table("pages")->where($cols);
     $paginator = new \Nette\Utils\Paginator();
     $paginator->setItemCount($gallery->count());
     $paginator->setItemsPerPage(20);
     $paginator->setPage($this->getParameter("page"));
     $this->template->paginator = $paginator;
     $this->template->galleries = $gallery->order("title")->limit($paginator->getLength(), $paginator->getOffset());
     $this->template->args = $this->getParameters(TRUE);
 }
Esempio n. 16
0
 public function renderDefault($page = 1, $filter = '%')
 {
     $paginator = new Nette\Utils\Paginator();
     $paginator->setItemsPerPage(3);
     // the number of records on page
     $paginator->setPage($page);
     //current page, default 1
     $users = $this->database->table('users')->where('login LIKE ? OR email LIKE ?', $filter, $filter)->limit($paginator->getLength(), $paginator->getOffset());
     $this->template->users = $users;
     $this->template->filter = $filter;
     $this->template->totalPosts = $this->database->table('users')->count();
     $paginator->setItemCount($this->template->totalPosts);
     $this->template->totalPages = $paginator->getPageCount();
     $this->template->page = $paginator->page;
     $this->template->pageCount = $paginator->getItemsPerPage();
 }
Esempio n. 17
0
 public function renderList($entryid = NULL, $page = 1)
 {
     $pag = new Nette\Utils\Paginator();
     $pag->setItemCount($this->entry->listAll()->count());
     $pag->setItemsPerPage(20);
     $pag->setPage($page);
     $this->template->entries = $this->entry->listAll()->order('lname')->limit($pag->getLength(), $pag->getOffset());
     if ($entryid) {
         $form = $this['entryForm'];
         $entry = $this->entry->load($entryid);
         if (!$entry) {
             $this->error('Záznam nenalezen!');
         }
         $form->setDefaults($entry);
     }
 }
Esempio n. 18
0
 /**
  * Render default view
  *
  * @param string $q
  */
 public function renderDefault($keyword, $page = 1)
 {
     // get all categories
     $categories = $this->categoryRepo->findAll();
     $this->template->categories = $categories;
     $paginator = new Nette\Utils\Paginator();
     $paginator->setItemsPerPage(self::PER_PAGE);
     // the number of records on page
     $paginator->setPage($page);
     // get products
     $products = $this->productsRepo->search($keyword, ['limit' => $paginator->getLength(), 'offset' => $paginator->getOffset()] + $this->getHttpRequest()->getQuery());
     $paginator->setItemCount($products['total']);
     // the total number of records (e.g., a number of products)
     $this->template->paginator = $paginator;
     $this->template->keyword = $keyword;
     $this->template->products = $products;
 }
Esempio n. 19
0
 /**
  * @return mixed array|Nette\Database\Table\Selection
  */
 public function getData()
 {
     if (empty($this->filteredData)) {
         $data = $this->data;
         if (!empty($this->filter) and $this->filterCallback !== NULL) {
             $data = $this->filterCallback->invokeArgs(array($data, $this->filter));
         }
         if ($this->isPaginatorEnabled()) {
             $this->paginator->setItemCount(count($data));
             $data = $this->paginatorCallback->invokeArgs(array($data, $this->paginator->getLength(), $this->paginator->getOffset()));
         }
         foreach ($data as $row) {
             $this->filteredData[] = $row;
         }
     }
     return $this->filteredData;
 }
Esempio n. 20
0
 public function renderDefault()
 {
     $this->template->helpdesk = $this->database->table("helpdesk");
     $this->template->templates = $this->database->table("helpdesk_emails")->where("helpdesk_id", $this->getParameter("id"));
     if (!$this->getParameter("id")) {
         $helpdeskId = null;
     } else {
         $helpdeskId = $this->getParameter('id');
     }
     $messages = $this->database->table("helpdesk_messages")->where(array("helpdesk_id" => $helpdeskId))->order("subject");
     $paginator = new \Nette\Utils\Paginator();
     $paginator->setItemCount($messages->count("*"));
     $paginator->setItemsPerPage(20);
     $paginator->setPage($this->getParameter("page"));
     $this->template->paginator = $paginator;
     $this->template->messages = $messages->limit($paginator->getLength(), $paginator->getOffset());
     $this->template->args = $this->getParameters();
 }
Esempio n. 21
0
 /**
  * Render grid
  */
 public function render()
 {
     $this->getModel()->setLimit($this->paginator->getLength());
     $this->getModel()->setOffset($this->paginator->getOffset());
     $sorting = $this->getSorting();
     if ($sorting) {
         $this->getModel()->setSorting($sorting);
     }
     if (!is_null($vp = $this->getComponent('visualPaginator', FALSE))) {
         $vp->setClass(array('paginator', $this->ajaxClass));
         $this->template->paginator = $vp;
     } else {
         $this->template->paginator = $this->getPaginator();
     }
     //for default check
     $this->template->defaultSorting = (array) $this->defaultSorting;
     $this->template->emptyResultText = $this->emptyResultText;
     $this->template->render();
 }
Esempio n. 22
0
 /**
  * Render default view
  *
  * @param string $categoryId
  */
 public function renderDefault($page = 1, $categoryId = null)
 {
     // get all categories
     $categories = $this->categoryRepo->findAll();
     $this->template->categories = $categories;
     $this->template->category = $categories[$categoryId];
     $paginator = new Nette\Utils\Paginator();
     $paginator->setItemsPerPage(self::PER_PAGE);
     // the number of records on page
     $paginator->setPage($page);
     // get products
     $products = $this->productsRepo->findByCategory($categoryId, ['limit' => $paginator->getLength(), 'offset' => $paginator->getOffset()] + $this->getHttpRequest()->getQuery());
     $paginator->setItemCount($products['total']);
     // the total number of records (e.g., a number of products)
     $this->template->products = $products;
     $userFilters = $this->getHttpRequest()->getQuery();
     unset($userFilters['page']);
     $this->template->userFilters = $userFilters;
     $this->template->paginator = $paginator;
 }
Esempio n. 23
0
 public function renderDefault($page = 1)
 {
     $empty = FALSE;
     $paginator = new Paginator();
     $paginator->setItemsPerPage($this->itemsPerPage);
     $paginator->setPage($page);
     $this->template->listOfObjects = $this->prepareListResource();
     // CALC COUNT
     $count = $this->template->listOfObjects->count();
     $paginator->setItemCount($count);
     $this->template->listOfObjects->limit($paginator->getLength(), $paginator->getOffset());
     if ($this->template->listOfObjects->count() == 0) {
         $empty = TRUE;
     }
     $this->template->empty = $empty;
     $this->template->page = $page;
     if ($count > $this->itemsPerPage && !$paginator->isLast()) {
         $this->template->showMoreButton = TRUE;
     }
     if ($this->ajax) {
         $this->redrawControl('datalist');
     }
 }
Esempio n. 24
0
 public function renderDefault()
 {
     $type = 1;
     if ($type == 1) {
         $events = $this->database->table("pages")->where("pages_types_id = 3");
     } else {
         $events = $this->database->table("pages")->select(":events.id, pages.id, pages.title, pages.pages_types_id, :events.date_event, :events.date_event_end, \n            :events.all_day, :events.contact, public, DATEDIFF(NOW(), \n            :events.date_event) AS diffDate")->where("pages_types_id = 3");
     }
     $paginator = new \Nette\Utils\Paginator();
     $paginator->setItemCount($events->count("*"));
     $paginator->setItemsPerPage(20);
     $paginator->setPage($this->getParameter("page"));
     $type = 1;
     if ($type == 0) {
         $order = "diffDate DESC";
     } else {
         $order = "title";
     }
     $this->template->events = $events->order($order)->limit($paginator->getLength(), $paginator->getOffset());
     $this->template->paginator = $paginator;
     $this->template->args = $this->getParameters();
     $this->template->viewtype = $this->context->httpRequest->getCookie('viewtype');
 }
Esempio n. 25
0
 public function getIterator() : IteratorAggregate
 {
     return new ArrayObject(array_slice(iterator_to_array($this->collection), $this->paginator->getOffset(), $this->paginator->getItemsPerPage(), TRUE));
 }
Esempio n. 26
0
 public function renderList($entryid = NULL, $page = 1)
 {
     $pag = new Nette\Utils\Paginator();
     $pag->setItemCount($this->entry->listAll()->count());
     $pag->setItemsPerPage(10);
     $pag->setPage($page);
     $this->template->pag = $pag;
     $this->template->raceid = $this->raceid;
     $this->template->entries = $this->entry->listAll()->order('lname')->limit($pag->getLength(), $pag->getOffset());
     $this->template->addFilter('startopt', function ($s) {
         return self::$start_options[$s];
     });
     if ($entryid) {
         $form = $this['entryForm'];
         $entry = $this->entry->load($entryid);
         if (!$entry) {
             $this->error('Záznam nenalezen!');
         }
         $form->setDefaults($entry);
     }
 }
Esempio n. 27
0
 public function renderDetail()
 {
     $this->template->contacts = $this->database->table("contacts")->where("categories_id", 22);
     $this->template->hours = array("00" => "00", "01" => "01", "02" => "02", "03" => "03", "04" => "04", "05" => "05", "06" => "06", "07" => "07", "08" => "08", "09" => "09", "10" => "10", "11" => "11", "12" => "12", "13" => "13", "14" => "14", "15" => "15", "16" => "16", "17" => "17", "18" => "18", "19" => "19", "20" => "20", "21" => "21", "22" => "22", "23" => "23");
     $this->template->minutes = array("00" => "00", "05" => "05", "10" => "10", "15" => "15", "20" => "20", "25" => "25", "30" => "30", "40" => "40", "45" => "45", "50" => "50", "55" => "55");
     $this->template->page = $this->database->table("pages")->get($this->getParameter("id"));
     $events = $this->database->table("events")->where("pages_id = ?", $this->getParameter("id"));
     $paginator = new \Nette\Utils\Paginator();
     $paginator->setItemCount($events->count("*"));
     $paginator->setItemsPerPage(20);
     $paginator->setPage($this->getParameter("page"));
     $this->template->database = $this->database;
     $this->template->events = $events->order("date_event")->limit($paginator->getLength(), $paginator->getOffset());
     $this->template->paginator = $paginator;
     $this->template->args = $this->getParameters();
 }
Esempio n. 28
0
 /**
  * Get next page URL
  * @param Paginator $paginator
  * @return Link
  */
 private function getNextPageUrl(Paginator $paginator)
 {
     $url = clone $this->request->getUrl();
     parse_str($url->getQuery(), $query);
     $paginator->setPage($paginator->getPage() + 1);
     $query['offset'] = $paginator->getOffset();
     $query['limit'] = $paginator->getItemsPerPage();
     $url->appendQuery($query);
     return new Link($url, Link::NEXT);
 }
Esempio n. 29
0
 public function renderSimple($page = 1)
 {
     $empty = FALSE;
     $itemsPerPage = 10;
     $paginator = new Paginator();
     $paginator->setItemsPerPage($itemsPerPage);
     $paginator->setPage($page);
     // BASE QUERY
     $this->template->listOfObjects = $this->database->table('image');
     // CALC COUNT
     $count = $this->template->listOfObjects->count();
     $paginator->setItemCount($count);
     $this->template->listOfObjects->limit($paginator->getLength(), $paginator->getOffset());
     if ($this->template->listOfObjects->count() == 0) {
         $empty = TRUE;
     }
     $this->template->empty = $empty;
     $this->template->page = $page;
     if ($count > $itemsPerPage && !$paginator->isLast()) {
         $this->template->showMoreButton = TRUE;
     }
     if ($this->ajax) {
         $this->redrawControl('datalist');
     }
 }
Esempio n. 30
0
 /**
  * @param \Nette\Utils\Paginator
  * @param int
  * @return ResultSet
  */
 public function applyPaginator(UIPaginator $paginator, $itemsPerPage = NULL)
 {
     if ($itemsPerPage !== NULL) {
         $paginator->setItemsPerPage($itemsPerPage);
     }
     $paginator->setItemCount($this->getTotalCount());
     $this->applyPaging($paginator->getOffset(), $paginator->getLength());
     return $this;
 }