Example #1
0
 /** 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;
 }
Example #2
0
 /** 
  * 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();
 }
Example #3
0
 /** Nastavenie komponenty
  * @param Nette\Database\Table\ActiveRow $clanok
  * @param string $odkaz
  * @param boolean $komentare Povolenie komentarov
  * @param boolean $aktualny_projekt_enabled Povolenie aktualneho projektu
  * @param boolean $zobraz_anotaciu Zobrazenie anotacie polozky
  * @return \App\AdminModule\Components\Article\TitleArticleControl */
 public function setTitle(Nette\Database\Table\ActiveRow $clanok, $odkaz, $komentare = FALSE, $aktualny_projekt_enabled = FALSE, $zobraz_anotaciu = FALSE)
 {
     $this->clanok = $clanok;
     $this->odkaz = $odkaz;
     $this->komentare = $komentare;
     $this->aktualny_projekt_enabled = $aktualny_projekt_enabled;
     $this->zobraz_anotaciu = $zobraz_anotaciu;
     $this->hlavne_menu_nadradeny = $this->hlavne_menu_lang->findOneBy(["id_hlavne_menu" => $this->clanok->hlavne_menu->id_nadradenej]);
     return $this;
 }
Example #4
0
 /** Funkcia pre spracovanie signálu vymazavania
  * @param int $id Id polozky v hlavnom menu
  * @param string $druh Blizsia specifikacia, kde je to potrebne
  */
 function confirmedDelete($id, $druh = "")
 {
     //Vstupna kontrola
     if (!(isset($id) && $id)) {
         $this->error("Id položky nie je nastavené!");
     }
     if ($druh != 'priloha') {
         $hl_m = $this->hlavne_menu_lang->findOneBy(["id_hlavne_menu" => $id, "id_lang" => 1]);
         if ($hl_m === FALSE) {
             $this->error("Položka s id = " . $id . " sa nenašla!");
         }
         $presenter = $hl_m->hlavne_menu->druh->presenter;
     }
     if ($druh == 'avatar') {
         $hl = $this->hlavne_menu->find($id);
         $this->vymazSubor("www/" . $this->avatar_path . $hl->avatar);
         $uloz = $this->hlavne_menu->uloz(["avatar" => NULL], $id);
         $this->_ifMessage($uloz !== FALSE ? TRUE : FALSE, 'Titulný obrázok bol vymazaný!', 'Došlo k chybe a titulný obrázok nebol vymazaný!');
         $this->redirect($presenter . ':', $id);
     } elseif ($druh == 'priloha') {
         //Poziadavka na zmazanie prilohy
         $pr = $this->dokumenty->find($id);
         //najdenie prislusnej polozky menu, ku ktorej priloha patri
         if ($pr !== FALSE) {
             $id_nadradenej = $pr->id_hlavne_menu;
             //Nechcem smerovat na nadradeny clanok, len na seba
             $vysledok = $this->vymazSubor($pr->subor) ? in_array(strtolower($pr->pripona), ['png', 'gif', 'jpg']) ? $this->vymazSubor($pr->thumb) : TRUE : FALSE;
             $this->_ifMessage($vysledok ? $pr->delete() : FALSE, 'Príloha bola vymazaná!', 'Došlo k chybe a príloha nebola vymazaná!');
         } else {
             $this->flashRedirect("Homepage:", 'Došlo k chybe a príloha nebola vymazaná!', 'danger');
         }
     } elseif ($druh == "") {
         $id_nadradenej = $hl_m->hlavne_menu->id_nadradenej == NULL ? -1 * $hl_m->hlavne_menu->id_hlavne_menu_cast : $hl_m->hlavne_menu->id_nadradenej;
         if ($presenter == "Clanky") {
             //Mazanie clanku
             $this->_ifMessage($this->_delClanok($id), 'Článok bol úspešne vymazaný!', 'Došlo k chybe a článok nebol vymazaný!');
             //Poziadavka na zmazanie clanku
         } elseif ($presenter == "Menu") {
             $this->_ifMessage($id_nadradenej = $this->_delHlMenu($id), 'Položka menu bola úspešne vymazaná!', 'Došlo k chybe a položka menu nebola vymazaná!');
         }
         if ($id_nadradenej < 0) {
             $this->redirect('Homepage:', ["id" => $id_nadradenej]);
         } else {
             if (($nadr = $this->hlavne_menu->find($id_nadradenej)) !== FALSE) {
                 $this->redirect($nadr->druh->presenter . ':', $nadr->id);
             }
         }
     }
 }
Example #5
0
 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
 }