public function renderInzerat($id = NULL, $user_id = NULL)
 {
     // priprava pro praci s formularem
     $form = $this['inzerat'];
     if ($id == 0) {
         // nový inzerát
         $inzerat = (object) array('id' => 0, 'id_user' => $user_id, 'id_kategorie' => 1, 'title' => '', 'body' => '', 'added' => '', 'expire' => '', 'value' => '');
         $form['id_inzerat']->value = $id;
         // novy inzerat ($id == 0)
         $this->template->inzerat = $inzerat;
         $this->template->autor_id = 0;
         $this->template->autor_nickname = NULL;
         $this->template->comments = NULL;
         $this->template->any_pictures = 0;
     } else {
         // prohlizeni/ editace inzeratu
         $this->template->inzerat = $this->database->findById('poster', $id);
         if (!$this->template->inzerat) {
             $this->flashMessage('Je nám líto, ale hledaný inzerát v naší databázi není.');
             $this->redirect('Homepage:default');
         }
         // jedna se o editaci, nahraji tedy do formu data editovaneho inzeratu
         $form['id_inzerat']->value = $id;
         $form->setDefaults($this->template->inzerat);
         // (1) $this->template->nazevKategorie = $this->database->findById('kategorie', $this->template->inzerat->id_kategorie)->nazev; <- fuj (Roman)
         $this->template->nazevKategorie = $this->template->inzerat->kategorie->nazev;
         // lepsi verze zapisu nahore, vyuziti elegance FK a ORM db
         $this->template->autor_id = $this->template->inzerat->id_user;
         // (2) $this->template->autor_nickname = $this->database->findById('user', $this->template->inzerat->id_user)->nickname;
         $this->template->autor_nickname = $this->template->inzerat->user->nickname;
         // 1 a 2 netreba ukladat zvlast do promennych, v template k nim lze pristupovat stejne jako jsem naznacil u obou promennych o radek nize
         $this->template->comments = $this->database->find('komenty', 'id_poster', $id);
         $this->template->pictures = $this->database->find('image', 'id_poster', $id);
         $this->template->any_pictures = count($this->template->pictures);
     }
 }