/** * Spracovanie formulara pre pridanie komentara * @param Nette\Application\UI\Form $form */ public function onZapisKomentar(Nette\Application\UI\Form $form) { $this->clanok_komentar->uloz($form->getValues()); if (!$this->presenter->isAjax()) { $this->redirect('this'); } else { $this->redrawControl('koment'); } }
/** Vymaze clanok so vsetkym co k tomu patri * @param int $id Id mazaqneho clanku * @return boolean */ protected function _delClanok($id) { $dokumenty = $this->dokumenty->findBy(["id_hlavne_menu" => $id]); $komponenty = $this->clanok_komponenty->findBy(["id_hlavne_menu" => $id]); $komentar = $this->clanok_komentar->findBy(["id_hlavne_menu" => $id]); $hl_m_m = $this->hlavne_menu_lang->findBy(["id_hlavne_menu" => $id])->fetchPairs("id", "id_clanok_lang"); if ($dokumenty !== FALSE && ($pocita = count($dokumenty))) { $do = 0; foreach ($dokumenty as $pr) { $do = $do + ($this->vymazSubor($pr->subor) ? $pr->znacka !== NULL ? $this->vymazSubor($pr->thumb) : 1 : 0); } $out = $do == $pocita ? $dokumenty->delete() == $pocita ? TRUE : FALSE : FALSE; } else { $out = TRUE; } $out_k = $komponenty !== FALSE && ($pocita = count($komponenty)) ? $komponenty->delete() == $pocita ? TRUE : FALSE : TRUE; $out_d = $komentar !== FALSE && ($pocita = count($komentar)) ? $komentar->delete() == $pocita ? TRUE : FALSE : TRUE; $pocita = 0; $this->hlavne_menu_lang->findBy(["id_hlavne_menu" => $id])->update(["id_clanok_lang" => NULL]); foreach ($hl_m_m as $k => $v) { if ($v == NULL) { $pocita++; } else { $pocita = $pocita + $this->clanok_lang->find(['id' => $v])->delete(); } } $out_c = count($hl_m_m) == $pocita; $out_h = $this->_delHlMenu($id); return $out_k and $out_d and $out_c and $out_h; }