$this->hlavne_menu_lang = $hlavne_menu_lang; } /** Nastavenie komponenty * @param int $id_hlavne_menu * @param boolean $zobraz_anotaciu */ public function setZobraz($id_hlavne_menu, $zobraz_anotaciu = FALSE) { $this->id_hlavne_menu = $id_hlavne_menu;
/** Vytvorenie ponuky * @return array */ private function _addpolmenu() { if ($this->id < 0) { //Zaporne id je pre cast $ponuka = $this->druh->findBy(array("povolene" => 1)); $this->id = -1 * $this->id; if (($cast = $this->hlavne_menu_cast->find($this->id)) !== FALSE && count($cast)) { $out["nadpis"] = $cast->nazov; } else { $this->chyba = "Chybne zadané id = " . $this->id; return; } $uroven = 0; } else { //Kladne id je pre polozku $ponuka = $this->druh->findBy(array("povolene" => 1, "je_spec_naz > 0")); if (($cast = $this->hlavne_menu_lang->findOneBy(array("id_hlavne_menu" => $this->id, "id_lang" => 1))) !== FALSE && count($cast)) { $out["nadpis"] = $cast->nazov; } else { $this->chyba = "Chybne zadané id = " . $this->id; return; } $uroven = $cast->hlavne_menu->uroven + 1; } foreach ($ponuka as $g) { $out["ponuka"][] = array("link" => $g->presenter . ":add", "id" => $this->id, "uroven" => $uroven, "presenter" => $g->presenter, "popis" => $g->popis); } return $out; }
/** * Render funkcia pre vypisanie odkazu na clanok * @param array $p Parametre: id_hlavne_menu - id odkazovaneho clanku, template - pouzita sablona * @see Nette\Application\Control#render() */ public function render($p = []) { if (isset($p["id_hlavne_menu"]) && (int) $p["id_hlavne_menu"]) { //Mam id_clanok $pom_hlm = $this->hlavne_menu_lang->findOneBy(["id_lang" => $this->language_id, "id_hlavne_menu" => $p["id_hlavne_menu"]]); if ($pom_hlm === FALSE) { $chyba = "hlavne_menu_lang = " . $p["id_hlavne_menu"]; } } else { //Nemam id_clanok $chyba = "id_hlavne_menu"; } if (isset($chyba)) { //Je nejaka chyba $this->template->setFile(__DIR__ . '/OdkazNaClanky_error.latte'); $this->template->text = sprintf($this->texty['not_found'], $chyba); } else { //Vsetko je OK $p_hlm = $pom_hlm->hlavne_menu; //Pre skratenie zapisu $this->template->setFile(__DIR__ . "/OdkazNaClanky" . (isset($p["template"]) && strlen($p["template"]) ? "_" . $p["template"] : "default") . ".latte"); $this->template->nazov = $pom_hlm->nazov; $this->template->datum_platnosti = $p_hlm->datum_platnosti; $this->template->avatar = $p_hlm->avatar; $this->template->anotacia = isset($pom_hlm->id_clanok_lang) ? $pom_hlm->clanok_lang->anotacia : NULL; $this->template->texty = $this->texty; $this->template->link_presenter = $p_hlm->druh->presenter == "Menu" ? "Clanky:" : $p_hlm->druh->presenter . ":"; $this->template->id_hlavne_menu = $p["id_hlavne_menu"]; $this->template->absolutna = $p_hlm->absolutna; } $this->template->render(); }
/** Nastavenie jazyka * @param int $language_id texty */ public function setLanguage_id($language_id) { $this->language_id = $language_id; return $this; } /** Nastavenie hlavicky clanku
/** * Render * @param array $params Parametre komponenty - [admin_links]*/ public function render($params) { $this->template->setFile(__DIR__ . '/TitleArticle.latte'); $this->template->clanok = $this->clanok; $this->template->por_podclanky = $this->hlavne_menu_lang->findBy(["hlavne_menu.id_nadradenej" => $this->clanok->id_hlavne_menu]); $this->template->odkaz = ":" . $this->odkaz . ":zmenVlastnika"; $this->template->vlastnik = $params['admin_links']['vlastnik']; $this->template->admin_links = $params['admin_links']; $this->template->komentare_enabled = $this->komentare; $this->template->nadradeny = $this->clanok->hlavne_menu->id_nadradenej !== NULL ? $this->hlavne_menu_nadradeny->hlavne_menu : NULL; $this->template->aktualny_projekt_enabled = $this->aktualny_projekt_enabled; $this->template->zobraz_anotaciu = $this->zobraz_anotaciu; $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; }
protected function startup() { parent::startup(); // Sprava uzivatela $user = $this->getUser(); //Nacitanie uzivatela // Kontrola prihlasenia a nacitania urovne registracie $this->id_reg = $user->isLoggedIn() ? $user->getIdentity()->id_registracia : 0; // Nastavenie z config-u $this->nastavenie = $this->context->parameters; $modul_presenter = explode(":", $this->name); // Skontroluj ci je nastaveny jazyk a ci pozadovany jazyk existuje ak ano akceptuj if (!isset($this->language)) { //Prednastavim hodnotu jazyka $lang_temp = $this->lang->find(1); $this->language = $lang_temp->skratka; $this->language_id = $lang_temp->id; } if (isset($this->params['language'])) { $lang_temp = $this->lang->findOneBy(['skratka' => $this->params['language']]); if (isset($lang_temp->skratka) && $lang_temp->skratka == $this->params['language']) { $this->language = $this->params['language']; $this->language_id = $lang_temp->id; } else { //Inak nastav Slovencinu $this->language = 'sk'; $this->language_id = 1; } } //Nacitanie a spracovanie hlavnych udajov webu $this->udaje_webu = $this->udaje->findAll()->fetchPairs('nazov', 'text'); $vysledok = []; //Nacitanie len tych premennych, ktore platia pre danu jazykovu mutaciu foreach ($this->udaje_webu as $key => $value) { $kluc = explode("-", $key); if (count($kluc) == 2 && $kluc[1] == $this->language) { $vysledok[substr($key, 0, strlen($key) - strlen($this->language) - 1)] = $value; } if (count($kluc) == 1) { $vysledok[$key] = $value; } } $this->udaje_webu = $vysledok; // Nacitanie pomocnych premennych $this->udaje_webu['meno_presentera'] = strtolower($modul_presenter[1]); //Meno aktualneho presentera $httpR = $this->httpRequest->getUrl(); $this->nazov_stranky = $httpR->host . $httpR->scriptPath; // Nazov stranky v tvare www.nieco.sk $this->nazov_stranky = substr($this->nazov_stranky, 0, strlen($this->nazov_stranky) - 1); // Priradenie hlavnych parametrov a udajov $this->max_id_reg = $this->registracia->findAll()->max('id'); //Najdi max. ur. reg. //Najdi info o druhu $tmp_druh = $this->druh->findBy(["druh.presenter" => ucfirst($this->udaje_webu['meno_presentera'])])->where("druh.modul IS NULL OR druh.modul = ?", $modul_presenter[0])->limit(1)->fetch(); if ($tmp_druh !== FALSE) { if ($tmp_druh->je_spec_naz) { //Ak je spec_nazov pozadovany a mam id $hl_udaje = $this->hlavne_menu->hladaj_id(isset($this->params['id']) ? (int) trim($this->params['id']) : 0, $this->id_reg); } else { //Ak nie je spec_nazov pozadovany $hl_udaje = $this->hlavne_menu->findOneBy(["id_druh" => $tmp_druh->id]); } } else { $hl_udaje = FALSE; } if ($hl_udaje !== FALSE) { //Ak sa hl. udaje nasli //Nacitanie textov hl_udaje pre dany jazyk $lang_hl_udaje = $this->hlavne_menu_lang->findOneBy(['id_lang' => $this->language_id, 'id_hlavne_menu' => $hl_udaje->id]); if ($lang_hl_udaje !== FALSE) { //Nasiel som udaje a tak aktualizujem $this->udaje_webu["nazov"] = $lang_hl_udaje->nazov; $this->udaje_webu["h1part2"] = $lang_hl_udaje->h1part2; $this->udaje_webu["description"] = $lang_hl_udaje->description; } else { //Len preto aby tam nieco bolo $this->udaje_webu["nazov"] = "Error nazov"; $this->udaje_webu["h1part2"] = "Error h1part2"; $this->udaje_webu["description"] = "Error description"; } $this->udaje_webu['hl_udaje'] = $hl_udaje->toArray(); } else { //Len preto aby tam nieco bolo $this->udaje_webu["description"] = "Nenájdená stránka"; $this->udaje_webu['hl_udaje'] = FALSE; } //Vypocet max. velkosti suboru pre upload $ini_v = trim(ini_get("upload_max_filesize")); $s = ['g' => 1 << 30, 'm' => 1 << 20, 'k' => 1 << 10]; $this->upload_size = intval($ini_v) * ($s[strtolower(substr($ini_v, -1))] ?: 1); // -- Povodny: $this->texty_presentera->setLanguage($this->language); //Nastavenie textov podla jazyka }
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 */