* Nastavenie slider-u * @param array $nastavenie * @return \App\FrontModule\Components\Slider\SliderControl */ public function setNastavenie($nastavenie) { $this->nastavenie = $nastavenie; return $this; } /** * Pre vyhodnotenie zobrazenia * @param mix $z zobrazenie polozky * @param string $p nazov presentera * @param int $i id pre zobrazenie * @return boolean */ private function _zisti($z, $p, $i) { return $z == NULL ? TRUE : ($z == 0 && $p == 'Homepage' ? TRUE : ($z > 0 && $z == $i ? TRUE : FALSE)); } /** Render */ public function render() { $this->template->setFile(__DIR__ . '/Slider_' . $this->nastavenie["varianta"] . '.latte'); $p_name = explode(":", $this->presenter->name); if ($this->nastavenie["varianta"] > 0) { $slider = $this->slider->getSlider(); $slider_zobrazenie = $slider->fetchPairs("id", "zobrazenie"); $id_pre_zobrazenie = $p_name[1] == "Clanky" ? isset($this->presenter->params['id']) ? $this->presenter->params['id'] : 0 : 0; $vysa = []; foreach ($slider_zobrazenie as $k => $v) { $vy[$k] = strpos($v, " ") !== FALSE ? explode(" ", $v) : $v; $vysledok = FALSE; if (is_array($vy[$k])) { foreach ($vy[$k] as $ke => $z) { $vysledok = $this->_zisti($z, $p_name[1], $id_pre_zobrazenie) == TRUE ? TRUE : $vysledok;
$this->template->sucasny = Html::el('img', array('width' => '90', 'alt' => 'obrazok'))->src('http://' . $this->nazov_stranky . '/www/' . (is_file('www/files/slider/' . $pol_slider->subor) ? 'files/slider/' . $pol_slider->subor : 'images/otaznik.png')); $this["sliderEditForm"]->setDefaults($pol_slider); $this["sliderEditForm"]->setDefaults(array('zobrazenie_null' => $pol_slider->zobrazenie == NULL ? 1 : 0)); } } /** Edit Slider form component factory for admin. * @return Nette\Application\UI\Form */ public function createComponentSliderEditForm() {
$form->addSubmit('cancel', 'Cancel')->setAttribute('class', 'btn btn-default')->setValidationScope(FALSE); return $form; } /** Spracovanie vstupov z formulara * @param Nette\Forms\Controls\SubmitButton $button Data formulara */ public function editSliderFormSubmitted($button) { $values = $button->getForm()->getValues(); $data = $this->slider->find($values->id); //Nacitanie editovanej polozky if ($values->zobrazenie_null) { $values->zobrazenie = NULL; } unset($values->zobrazenie_null); if ($this->slider_i['odkaz']) { $values->id_hlavne_menu = (int) $values->id_hlavne_menu > 0 ? (int) $values->id_hlavne_menu : NULL; if ($values->id_hlavne_menu !== NULL) { //Kontrola exzistencie id_hlavne_menu if ($this->hlavne_menu->find($values->id_hlavne_menu) == FALSE) { $button->addError('Zadali ste nesprávne číslo článku. Skúste znovu!'); return; } } } if ($values->subor && $values->subor->name != "") { if ($values->subor->isImage()) { $slider_dir = $this->wwwDir . "/www/files/slider/"; $finalFileName = $this->_imageFileName($slider_dir, $values->subor->getSanitizedName()); $image_name = $slider_dir . $finalFileName; $values->subor->move($image_name); $image = Image::fromFile($image_name); $image->resize($this->slider_i['x'], $this->slider_i['y'], Image::SHRINK_ONLY | Image::EXACT); $image->save($image_name, 80); if (is_file('www/files/slider/' . $data['subor'])) { unlink($slider_dir . $data['subor']); } $values->subor = $finalFileName; } else { $button->addError('Zadali ste nesprávne číslo článku. Skúste znovu!'); unset($values->subor); return; } } else { unset($values->subor); } try {