Ejemplo n.º 1
0
 public function renderDetail($code)
 {
     $items = $this->items->fetchVisible()->fetchAll();
     $item = clone $this->items;
     $this->template->item = $item->where('code', $code)->fetch();
     $id = $this->template->item->id;
     $i = 0;
     foreach ($items as $key => $value) {
         $v[$i] = $value;
         if ($key == $id) {
             $this->template->next_id = $i + 1;
             $this->template->prev_id = $i - 1;
         }
         $i++;
     }
     $this->template->items = $v;
 }
Ejemplo n.º 2
0
 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());
     }
 }