public function handlePage($stranka = '') { if (!$stranka || !is_numeric($stranka)) { throw new \Nette\Application\BadRequestException(); } $this->paginator->setPage($stranka); $this->stranka = $stranka; $this->template->articles = $this->articleManager->getNewArticleList($this->paginator); }
private function setPage($page = 1, $new = false) { if ($new) { $this->paginator->itemCount++; } $this->paginator->setPage($page); $this->page = $page; $this->template->lastPage = $this->lastPage; $this->template->comments = $this->commentsManager->getComments($this->paginator); }
/** * @param int $total_count * @param int $limit */ public function setCounts($total_count, $limit) { $this->paginator->setItemCount($total_count); $this->paginator->setItemsPerPage($limit); if (!isset($this->settings['page'])) { $this->settings['page'] = 1; } if ($this->settings['page'] > $this->paginator->getPageCount()) { $this->settings['page'] = $this->paginator->getPageCount(); } $this->paginator->setPage(isset($this->settings['page']) ? $this->settings['page'] : 1); }
public function handlePage($page = '', $for = 'pub') { if (!$page) { throw new \Nette\Application\BadRequestException(); } if ($for == 'pub') { $this->paginator->setPage($page); } else { $this->paginatorDel->setPage($page); } $this->redrawAjax('pubNews'); $this->redrawAjax('delNews'); }
public function getData() { $this->paginator->setItemsPerPage($this->itemsPerPage); $this->paginator->setItemCount($this->dataset->getCount()); $this->paginator->setPage($this->page); $this->page = $this->paginator->getPage(); $this->dataset->setLimit($this->paginator->length, $this->paginator->offset); // TODO: IDataSource::setOrderBy() is optional if (empty($this->orderColumn) && !empty($this->defaultOrderColumn)) { $this->dataset->setOrderBy($this->defaultOrderColumn, $this->defaultOrderDir === self::ASC); } elseif (!empty($this->orderColumn)) { $this->dataset->setOrderBy($this->orderColumn, $this->orderDir === self::ASC); } return $this->dataset->getData(); }
/** * @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; }
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'); } }
protected function createPaginator() { $paginator = new Nette\Utils\Paginator(); $paginator->setItemsPerPage($this->itemsPerPage); $paginator->setPage((int) $this->page); return $paginator; }
public function handleSetPage($page) { $this->paginator->setPage($page); if ($this->presenter->isAjax()) { $this->invalidateControl("datagrid"); } }
private function startPaginator(HttpService $httpService, array $rows) { $this->paginator->setPage($httpService->getPaginatorPage()); if (is_null($this->paginator->getItemCount())) { $this->paginator->setItemCount(count($rows)); } return array_slice($rows, $this->paginator->offset, $this->paginator->itemsPerPage); }
/** * 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(); }
public function renderDefault($rPage = 1) { $rPaginator = new Paginator(); $rPaginator->setItemCount(count($this->reservationManager->getReservations())); $rPaginator->setItemsPerPage(15); $rPaginator->setPage($rPage); $this->template->rPaginator = $rPaginator; $this->template->rButtons = $this->reservationManager->getPaginatorsButtons($rPaginator); $this->template->reservations = $this->reservationManager->getReservationsForPaginator($rPaginator->getLength(), $rPaginator->getOffset()); }
/** * Nastavuje stranku paginatoru pro zobrazeni komentaru * @param int $page */ public function handleSetCommentPage($page = NULL) { if ($page === NULL) { $page = $this->paginator->getPage() + 1; } if ($this->paginator->getPage() != $page) { $this->paginator->setPage($page); $this->redrawControl('comments'); $this->redrawControl('pagin'); } }
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()); }
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); }
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']); }
public function renderDetail($id, $page = 1) { $allProducts = $this->productService->getProductsInCategory(self::BASE_LANG, $id); $paginator = new Paginator(); $paginator->setItemsPerPage(self::ITEMS_PER_PAGE); $paginator->setItemCount(count($allProducts)); $paginator->setPage((int) $page); $products = array_slice($allProducts, self::ITEMS_PER_PAGE * $paginator->getPage() - 1, $paginator->getItemsPerPage()); if (!$products && 0 === count($allProducts)) { throw new BadRequestException(); } $this->template->paginator = $paginator; $this->template->products = $products; }
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'); } }
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); } }
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(); }
public function renderDefault($page) { // initial dao object $dao = $this->em->getRepository(Search::getClassName()); $searchQuery = new SearchQuery(); // initial paginator $paginator = new Nette\Utils\Paginator(); $paginator->setPage($page); $searchs = $dao->fetch($searchQuery)->applySorting(array('Search.date' => 'DESC'))->applyPaginator($paginator, self::ROWSONPAGE); $numberRows = $searchs->getTotalCount(); $paginator->setItemCount($numberRows); // push data to template $this->template->search = $searchs; $this->template->paginator = $paginator; $this->template->page = $page; }
/** * @param \Nette\ComponentModel\IComponent $component */ protected function attached($component) { parent::attached($component); if (!$component instanceof Presenter) { return; } $this->configure($component); // sorting validation $directions = [self::SORT_ASC, self::SORT_DESC]; foreach ($this->sortBy as $column => $direction) { if (!isset($this->columns[$column]) || !$this->columns[$column]->isSortable() || !in_array($direction, $directions)) { unset($this->sortBy[$column]); continue; } } $this->paginator->setPage($this->page)->setItemsPerPage($this->perPage); }
/** * 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; }
/** * Výpis uživatelů * @param int */ public function renderDefault($page = 1) { $paginator = new Paginator(); $pocet = $this->uzivateleModel->pocet(); $paginator->setPage($page)->setItemsPerPage(self::POLOZEK_NA_STRANKU)->setItemCount($pocet); if ($paginator->getPage() != $page) { // je li page nastavena na neexistující, je přesměrována $this->redirect('this', array('page' => $paginator->getPage())); } $data = FALSE; if ($pocet) { $data = $this->uzivateleModel->vypis($paginator); } $this->template->data = $data; $this->template->pocetDat = $pocet; $this->template->paginator = $paginator; $this->template->opravneni = $this->opravneni; }
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(); }
/** * @return array */ public function getSteps() { if (!$this->steps) { $this->paginator->setPage($this->page); $this->paginator->setItemsPerPage($this->limit); $this->paginator->setItemCount($this->settings->getItemCount()); $this->paginator->setPage($this->page); $paginator = $this->paginator; $arr = range(max($paginator->getFirstPage(), $paginator->getPage() - 2), min($paginator->getLastPage(), $paginator->getPage() + 2)); $count = 2; $quotient = ($paginator->getPageCount() - 1) / $count; for ($i = 0; $i <= $count; $i++) { $arr[] = (int) (round($quotient * $i) + $paginator->getFirstPage()); } sort($arr); $this->steps = array_values(array_unique($arr)); } return $this->steps; }
/** * 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; }
/** * @param string $id Web title tagu */ public function actionTag($id) { list($webId, $webTitle) = Model\Entities\Tag::parseWebId($id); /** @var Model\Entities\Tag $this->objectWithArticles */ $this->objectWithArticles = $this->tagRepository->getById($webId); if (!is_object($this->objectWithArticles)) { $this->flashMessage($this->translator->translate('system.tagNF'), self::MESSAGE_DANGER); $this->redirect('default'); } $this->template->bgImage = "home-bg.jpg"; $this->template->title = $this->objectWithArticles->getTitle(); $this->template->description = $this->translator->translate('system.tag', 1); //nastaveni zajimavych clanku sekce $this->template->dPosts = $this->articleRepository->getMostDiscussedArticles(); $this->template->rPosts = $this->articleRepository->getMostReadedArticles(); $this->template->nPosts = $this->articleRepository->getRandArticles(); //nastaveni strankovani $this->paginator = new \Nette\Utils\Paginator(); $this->paginator->setItemsPerPage(self::POST_PER_PAGE); $this->paginator->setPage(1); $this->setView('articles'); }
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'); }