Created
March 15, 2013 19:09
-
-
Save anonymous/5172274 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * @author: David | |
| * @date: 27.2.13 | |
| * @version: 0.1 | |
| */ | |
| use Nette\Application\UI\Control; | |
| class Modaler extends Control | |
| { | |
| public $presenter; | |
| public $name; | |
| /** | |
| * @persistent | |
| */ | |
| public $content; | |
| /** | |
| * @persistent | |
| */ | |
| public $title; | |
| /** | |
| * @persistent | |
| */ | |
| public $toggle = FALSE; | |
| /** | |
| * @persistent | |
| */ | |
| public $size = 'medium'; | |
| /** | |
| * @persistent | |
| */ | |
| public $form; | |
| /** @var array */ | |
| public $defaultData; | |
| /** | |
| * Konstruktor | |
| * | |
| * @param Nette\ComponentModel\IContainer $presenter | |
| * @param null $name | |
| */ | |
| public function __construct($presenter, $name) | |
| { | |
| parent::__construct(); | |
| $this->presenter = $presenter; | |
| $this->name = $name; | |
| if ($this->presenter->isAjax()) | |
| { | |
| $this->reload(); | |
| } | |
| } | |
| /** | |
| * Render | |
| */ | |
| public function render() | |
| { | |
| $template = $this->template; | |
| $template->content = $this->getContent(); | |
| $template->title = $this->getTitle(); | |
| $template->toggle = $this->getToggle(); | |
| $template->size = $this->getSize(); | |
| $template->form = $this->getForm(); | |
| $template->setFile(__DIR__ . '/default.latte'); | |
| $template->render(); | |
| } | |
| /** | |
| * Refresh wrapper. | |
| * @return void | |
| */ | |
| public function reload() | |
| { | |
| if ($this->presenter->isAjax()) { | |
| $this->setToggle(TRUE); | |
| $this->invalidateControl('modal'); | |
| } else { | |
| $this->presenter->redirect('this'); | |
| } | |
| } | |
| /** | |
| * @return mixed | |
| */ | |
| public function createComponentForm() | |
| { | |
| if (!empty($this->form)) | |
| { | |
| $data = new $this->form; | |
| if ($this->getDefaultData()) | |
| { | |
| $data->setDefaultData($this->getDefaultData()); | |
| } | |
| return $data; | |
| } else { | |
| return NULL; | |
| } | |
| } | |
| public function getContent() | |
| { | |
| return $this->content; | |
| } | |
| public function setContent($content) | |
| { | |
| $this->content = $content; | |
| } | |
| public function getTitle() | |
| { | |
| return $this->title; | |
| } | |
| public function setTitle($title) | |
| { | |
| $this->title = $title; | |
| } | |
| public function getToggle() | |
| { | |
| return $this->toggle; | |
| } | |
| public function setToggle($toggle) | |
| { | |
| $this->toggle = $toggle; | |
| } | |
| public function getSize() | |
| { | |
| return $this->size; | |
| } | |
| public function setSize($size) | |
| { | |
| $this->size = $size; | |
| } | |
| public function getForm() | |
| { | |
| return $this->form; | |
| } | |
| public function setForm($form) | |
| { | |
| $this->form = $form; | |
| } | |
| public function getDefaultData() | |
| { | |
| return $this->defaultData; | |
| } | |
| public function setDefaultData($defaultDataToForm) | |
| { | |
| $this->defaultData = $defaultDataToForm; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment