Esempio n. 1
0
 public function __construct(\Nette\ComponentModel\IContainer $parent = null, $name = null)
 {
     parent::__construct($parent, $name);
     $this->addComponent(new Container(), "toolbar");
     $this->addComponent(new Container(), "actions");
     $this->addComponent(new Container(), "columns");
     $this->paginator = new Paginator();
     $this->paginator->setItemsPerPage($this->defaultItemsPerPage);
 }
Esempio n. 2
0
 /**
  * @param Article $article Clanek, ktery se komentuje
  * @param \Nette\Http\Session $session Session pro ulozeni hodnot pri nahledu komentare
  * @param \Kdyby\Translation\Translator $translator Prekladac
  * @param \App\Model\Repository\ArticleRepository $repository 
  */
 public function __construct(Article $article, \Nette\Http\Session $session, \Kdyby\Translation\Translator $translator, \App\Model\Repository\ArticleRepository $repository)
 {
     $this->article = $article;
     $this->commentSession = $session->getSection('comments');
     $this->translator = $translator;
     $this->articleRepository = $repository;
     $this->paginator = new \Nette\Utils\Paginator();
     $this->paginator->setItemsPerPage(self::COMMENT_PER_PAGE);
     $this->paginator->setPage(1);
 }
Esempio n. 3
0
 public function __construct(\Nette\ComponentModel\IContainer $parent = null, $name = null)
 {
     parent::__construct($parent, $name);
     $this->addComponent(new Container(), "toolbar");
     $this->addComponent(new Container(), "actions");
     $this->addComponent(new Container(), "columns");
     $this->addComponent(new \VisualPaginator(), 'visualPaginator');
     $this['visualPaginator']->onChange[] = callback($this, 'invalidateControl');
     $this->paginator = $this['visualPaginator']->getPaginator();
     $this->paginator->setItemsPerPage($this->defaultItemsPerPage);
 }
Esempio n. 4
0
 /**
  * @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);
 }
Esempio n. 5
0
 public function actionDefault()
 {
     $this->moderate = $this->user->isAllowed(self::RES, 'moderate');
     if (!$this->moderate && !$this->user->isAllowed(self::RES, 'add')) {
         throw new Nette\Application\ForbiddenRequestException();
     }
     $this->paginator = new Paginator();
     $this->paginator->setItemCount($this->newsManager->getNewsCount(false, $this->moderate ? false : $this->user->getId()));
     $this->paginator->setItemsPerPage(5);
     $this->paginatorDel = new Paginator();
     $this->paginatorDel->setItemCount($this->newsManager->getNewsCount(true, $this->moderate ? false : $this->user->getId()));
     $this->paginatorDel->setItemsPerPage(5);
 }
Esempio n. 6
0
 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();
 }
Esempio n. 7
0
 public function __construct(User $user, CommentsManager $commentsManager, ResourceAuthorizator $resourceAuthorizator, CaptchaManager $captchaManager, IRatingControlFactory $rating, $forWhat, $forId)
 {
     $this->user = $user;
     $this->paginator = new Paginator();
     $this->commentsManager = $commentsManager;
     $this->resourceAuthorizator = $resourceAuthorizator;
     $this->captchaManager = $captchaManager;
     $this->rating = $rating;
     $this->commentsManager->setComments($forWhat, $forId, $this->user->isLoggedIn() ? $this->user->id : null);
     $this->paginator->setItemCount($this->commentsManager->countComments());
     $this->paginator->setItemsPerPage(8);
     $this->paginator->setPage(1);
     $this->page = $this->paginator->getPage();
     $this->lastPage = $this->paginator->getLastPage();
 }
 /**
  * @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. 9
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');
     }
 }
Esempio n. 11
0
 protected function createPaginator()
 {
     $paginator = new Nette\Utils\Paginator();
     $paginator->setItemsPerPage($this->itemsPerPage);
     $paginator->setPage((int) $this->page);
     return $paginator;
 }
Esempio n. 12
0
 /**
  * Sets paginator
  * @param \Nette\Utils\Paginator $paginator
  * @return Grid
  */
 public function setPaginator(Paginator $paginator)
 {
     $this->paginator = $paginator;
     $this->paginator->setItemsPerPage($this->defaultItemsPerPage);
     //sets default values
     return $this;
 }
Esempio n. 13
0
 public function setPagination($rowsPerPage = 20, $rowsCount = null)
 {
     $paginator = new Paginator();
     $paginator->setItemsPerPage($rowsPerPage);
     if ($rowsCount) {
         $paginator->setItemCount($rowsCount);
     }
     $this->renderer->setPaginator($paginator);
 }
Esempio n. 14
0
 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());
 }
Esempio n. 15
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. 16
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. 17
0
 public function actionDefault($section, $subsection)
 {
     if (!$this->session->started) {
         $this->session->start();
     }
     $this->template->editorial = $this->textManager->getText(TextManager::EDITORIAL);
     $get = $this->getRequest()->parameters;
     if (isset($get['log']) && $get['log'] == 'in' && !$this->session->started) {
         $this->template->customFlashMessage = 'Nemáte zapnuté soubory cookies, pro přihlášení musí být povoleny.';
     }
     if (!$subsection && !$section) {
         $this->paginator = new Paginator();
         $this->paginator->setItemCount($this->articleManager->countNewArticleList());
         $this->paginator->setItemsPerPage(8);
         $this->template->articles = $this->articleManager->getNewArticleList($this->paginator);
         return;
     }
     $this->template->setFile(__DIR__ . '/templates/Article/section.latte');
     if ($section && !$subsection) {
         $sectionDat = $this->articleManager->getSectionByUrl($section);
         if (!$sectionDat) {
             throw new Nette\Application\BadRequestException();
         }
         $this->template->section = $sectionDat;
         $this->template->subSections = $this->articleManager->getSubSectionFor($sectionDat->id);
         $this->template->articles = $this->articleManager->getArticleNotSubsection($sectionDat);
         $this->template->serials = $this->articleManager->getSerialForSection($sectionDat->id);
     }
     if ($subsection) {
         $subSectionDat = $this->articleManager->getSectionByUrl($subsection, 'subSectionDat');
         if (!$subSectionDat) {
             throw new Nette\Application\BadRequestException();
         }
         $this->template->section = $subSectionDat;
         $this->template->subSections = null;
         $this->template->articles = $this->articleManager->getArticleBySubSection($subSectionDat);
         $this->template->serials = $this->articleManager->getSerialForSubSection($subSectionDat->id);
     }
 }
Esempio n. 18
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. 19
0
 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');
     }
 }
Esempio n. 21
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. 22
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. 23
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. 24
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. 25
0
 /**
  * @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;
 }
Esempio n. 26
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. 27
0
 /**
  * @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');
 }
Esempio n. 28
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. 29
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. 30
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);
     }
 }