/** Akcia pre editaciu informacii o dokumente * @param int $id Id dokumentu na editaciu */ public function actionEdit($id) { if (($this->dokument = $this->dokumenty->find($id)) === FALSE) { return $this->error(sprintf("Pre zadané id som nenašiel prílohu! id=' %s'!", $id)); } $this["dokumentEditForm"]->setDefaults($this->dokument); }
/** Render funkcia pre vypisanie odkazu na clanok * @see Nette\Application\Control#render() */ public function render() { $this->template->setFile(__DIR__ . "/PrilohyClanok.latte"); $this->template->prilohy = $this->prilohy->getViditelnePrilohy($this->id_article); $this->template->texty = $this->texty; $this->template->avatar_path = $this->avatar_path; $this->template->render(); }
/** 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; }
public function handleShowInText($id) { $priloha = $this->dokumenty->find($id); $priloha->update(['zobraz_v_texte' => 1 - $priloha->zobraz_v_texte]); if (!$this->presenter->isAjax()) { $this->redirect('this'); } else { $this->redrawControl(''); } }
{ $values = $button->getForm()->getValues(); //Nacitanie hodnot formulara try { $uloz = ['id_hlavne_menu' => $values->id_hlavne_menu, 'id_user_profiles' => $this->id_user_profiles, 'id_registracia' => $values->id_registracia, 'popis' => isset($values->popis) && strlen($values->popis) > 2 ? $values->popis : NULL, 'zmena' => StrFTime("%Y-%m-%d %H:%M:%S", Time())]; $nazov = isset($values->nazov) ? $values->nazov : ""; if ($values->priloha && $values->priloha->name != "") { $priloha_info = $this->_uploadPriloha($values); $uloz = array_merge($uloz, ['nazov' => strlen($nazov) > 2 ? $nazov : $priloha_info['finalFileName'], 'spec_nazov' => Strings::webalize($priloha_info['finalFileName']), 'pripona' => $priloha_info['pripona'], 'subor' => $this->prilohy_adresar . $priloha_info['finalFileName'], 'thumb' => $priloha_info['thumb']]); } else { $uloz = array_merge($uloz, ['nazov' => strlen($nazov) > 2 ? $nazov : ""]); } $vysledok = $this->dokumenty->uloz($uloz, $values->id); if (!empty($vysledok) && isset($priloha_info['is_image']) && $priloha_info['is_image']) { $this->dokumenty->oprav($vysledok['id'], ['znacka' => '#I-' . $vysledok['id'] . '#']); } } catch (Database\DriverException $e) { $button->addError($e->getMessage()); } } /** * Upload prilohy * @param \Nette\Http\FileUpload $values * @return array */ private function _uploadPriloha($values) { $pr = $this->dokumenty->find($values->id); //Zmazanie starej prílohy if ($pr !== FALSE) { if (is_file($pr->subor)) { unlink($this->wwwDir . "/" . $pr->subor); } if (in_array(strtolower($pr->pripona), ['png', 'gif', 'jpg']) && is_file($pr->thumb)) { unlink($this->wwwDir . "/" . $pr->thumb); } } $fileName = $values->priloha->getSanitizedName(); $pi = pathinfo($fileName); $file = $pi['filename']; $ext = $pi['extension']; $additionalToken = 0; //Najdi meno suboru if (file_exists($this->prilohy_adresar . $fileName)) {
class AktualneClankyControl extends Nette\Application\UI\Control { /** @var Nette\Database\Table\Selection $aktualne_clanky Data zobrazovaneho clanku */ private $aktualne_clanky; /** @var string $avatar_path Cesta k titulnemu obrazku clanku */ private $avatar_path = ""; /** @var array $texts */