public function render() { $template = $this->getTemplate(); $template->setFile($this->templateDir . '/' . $this->templateFile); $template->setTranslator($this->getPresenter()->translator); //upravim model if (!is_null($this->order)) { $this->model->order($this->order . ' ' . $this->orderDir); } elseif (!is_null($this->orderDefault)) { if (is_null($this->orderDirDefault)) { $orderDir = 'ASC'; } else { $orderDir = $this->orderDirDefault; } $this->model->order($this->orderDefault . ' ' . $orderDir); } //strankovani $this->visualPaginator->getPaginator()->setItemsPerPage($this->itemsToPage); $this->visualPaginator->getPaginator()->setItemCount($this->model->count('*')); $this->model->limit($this->visualPaginator->getPaginator()->getLength(), $this->visualPaginator->getPaginator()->getOffset()); $template->columns = $this->columns; $template->model = $this->model; $template->menu = $this->menu; $template->uniquete = $this->uniquete; $template->emptyText = is_null($this->emptyText) ? $this->getPresenter()->translator->translate('admin.grid.noItemFound') : $this->emptyText; $template->visualPaginator = $this->visualPaginator; $template->order = $this->order; $template->orderDir = $this->orderDir; $template->ordering = $this->ordering; $template->render(); }
public function renderDefault() { $this->items->fetchVisible(); $this->template->page = $this->page; $this->offset = $this->limit * ($this->page - 1); // omezeni na lokalitu $this->template->locality = false; if ($this->locality) { //$this->items->where('(locality.code = ? OR scope_all = 1)',$this->locality); $this->items->where('(locality.code = ?)', $this->locality); if ($this->shire === null) { $this->template->locality = true; } } // omezeni na kraje if ($this->shire) { $this->items->where('(locality.shire.code = ? OR locality.shire.id = 99 OR scope_all = 1)', $this->shire); $this->template->shire = $this->context->createServiceShires()->where('code', $this->shire)->fetch(); } //omezeni na kategorie if ($this->category || count($this->categories) > 0) { $this->items->where(':subject_x_category.category_id', array_keys($this->categories)); if (count($this->categories) == 1) { $this->template->category = $this->context->createService('categories')->get(key($this->categories)); } else { $this->template->categories = $this->context->createService('categories'); } } else { // $this['categories']['categories']['all']->setValue(1); } //omezeni na deti if ($this->kids) { $this->items->kids($this->kids); } // omezeni na kocarek if ($this->stroller) { $this->items->where('subject.stroller', $this->stroller); } // omezeni na kocarek if ($this->nonsmoking) { $this->items->where('subject.nonsmoking', $this->nonsmoking); } // omezeni na kocarek if ($this->wheelchair_access) { $this->items->where('subject.wheelchair_access', $this->wheelchair_access); } //nastavi razeni a pripadna dalsi omezeni switch ($this->order) { case 'likes': $res = $this->context->database->table('subject_rating')->select('subject_id, sum(thumb_up) thumb_up, sum(thumb_down) thumb_down')->order('thumb_up DESC, thumb_down')->group('subject_id'); $ids = array(); foreach ($res as $key => $row) { $ids[] = $row['subject_id']; } $this->items->where('subject.id', $ids); $this->items->order('FIND_IN_SET(subject.id,"' . implode(",", $ids) . '")'); break; case 'recommended': $this->items->fetchAd(null, true)->order('created DESC'); break; default: $this->items->order($this->order); break; } // pocet polozek s omezenimi $items = clone $this->items; $count = $items->count(); $this->template->count = $count; // strankovani $this->pagerPlaces->itemCount = $count; if ($this->page * $this->limit > $count - $this->limit) { //zkontroluje, zda se jedna o posledni stranku vypisu $this->limit = 99; // nastavi limit na hodne velky cislo, aby se vypsalo vse zbyvajici } elseif (($this->page + 1) * $this->limit > $count - $this->limit) { // zkontroluje, zda se jedna o predposledni stranku vypisu $this->limit = 99; } $this->template->limit = $this->limit; $this->pagerPlaces->itemsPerPage = $this->limit; $this->template->page = $this->page; if ($this->isAjax()) { $this->template->newEntry = $this->items->limit($this->pagerPlaces->getLimit(), $this->pagerPlaces->getOffset()); $this->redrawControl('paging'); } else { $this->template->subjects = $this->items->limit($this->pagerPlaces->getLimit(), $this->pagerPlaces->getOffset()); } }
public function renderDefault() { $this->template->albums = $this->albums->order('artist')->order('title'); }