예제 #1
0
 /** Signal prepinania jazykov
  * @param string $language skratka noveho jazyka
  */
 public function handleSetLang($language)
 {
     if ($this->language != $language) {
         //Cokolvek rob len ak sa meni
         //Najdi v DB pozadovany jazyk
         $la_tmp = $this->lang->findOneBy(['skratka' => $language]);
         //Ak existuje tak akceptuj
         if (isset($la_tmp->skratka) && $la_tmp->skratka == $language) {
             $this->language = $language;
         }
     }
     $this->redirect('this');
 }
예제 #2
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);
     $m = $modul_presenter[0];
     //Modul
     if ($m == "Mapa") {
         //Ak mám modul "Mapa" tak ostatne neporebujem
         $this->language = 'sk';
         $this->language_id = 1;
         return;
     }
     // 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(array('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 = array();
     //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(array("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(array("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(array('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 = array('g' => 1 << 30, 'm' => 1 << 20, 'k' => 1 << 10);
     $this->upload_size = intval($ini_v) * ($s[strtolower(substr($ini_v, -1))] ?: 1);
 }