Example #1
0
 public function handleSave(Form $form)
 {
     if ($form->isSubmitted() !== $form->getSaveButton()) {
         return;
     }
     $data = array('toolbar' => array());
     $i = TRUE;
     foreach ($form['toolbar']->values as $items) {
         if ($i) {
             $i = FALSE;
         } else {
             $data['toolbar'][] = '/';
         }
         $r = array();
         $i = TRUE;
         foreach ($items['line'] as $value) {
             if ($i) {
                 $i = FALSE;
             } else {
                 $data['toolbar'][] = array('items' => $r);
                 $r = array();
             }
             foreach ($value['items'] as $item) {
                 $r[] = $item;
             }
         }
         $data['toolbar'][] = array('items' => $r);
     }
     file_put_contents($this->ckeditorDir . '/backend.json', json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
 }
Example #2
0
 public function formSuccess(Form $form)
 {
     if ($form->isSubmitted() !== $form->getSaveButton()) {
         return;
     }
     $values = $form->values;
     $data = array('code' => 'K0ntrolaH3slem', 'jmeno' => $values['person'] == 'fyzicka' ? $values['fyzicka']['name'] : $values['pravnicka']['name'] . ' / ' . $values['pravnicka']['person'], 'narozeni' => $values['person'] == 'fyzicka' ? $values['fyzicka']['bornDate'] : $values['pravnicka']['IC'], 'ulice' => $values['street'], 'obec' => $values['city'], 'psc' => $values['psc'], 'email' => $values['email'], 'castka' => $values['money'] == 'other' ? $values['moneyOther'] : $values['money'], 'ip' => $this->httpRequest->remoteAddress);
     $params = '';
     foreach ($data as $key => $val) {
         $params .= '&' . $key . '=' . urlencode($val);
     }
     $params = ltrim($params, '&');
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, 'http://s-dary.zvara.cz/inject.php');
     curl_setopt($ch, CURLOPT_POST, count($data));
     curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     $result = curl_exec($ch);
     $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     curl_close($ch);
     if ($status == 200) {
         $this->flashMessage('Děkujeme, částku prosím uhraďte na náš transparentní účet s variabilním symbolem ' . $result, 'success');
     } elseif ($status == 403) {
         $this->flashMessage('Server nemá povolení k provedení akce. Prosím kontaktujte administrátora. ', 'warning');
     } else {
         $this->flashMessage('Nastala chyba při ukládání, zopakujte prosím akci později', 'warning');
     }
     $this->redirect('this');
 }
 public function formSuccess(Form $form)
 {
     if ($form->isSubmitted() === $form->getSaveButton()) {
         $x = $this->newsletterManager->sendNewsletter($form->data);
         $this->presenter->flashMessage('Newsletter byl odeslán na ' . $x . ' kontaktů.');
         $this->redirect('this');
     }
 }
Example #4
0
 public function formSuccess(Form $form)
 {
     if ($form->isSubmitted() !== $form->getSaveButton()) {
         return;
     }
     $this->getImporter()->run($form);
     $this->flashMessage($this->translator->translate('Process has been finished'), 'success');
     $this->redirect('this');
 }
Example #5
0
 public function formSuccess(Form $form)
 {
     if ($form->isSubmitted() !== $form->getSaveButton()) {
         return;
     }
     $this->flashMessage($this->translator->translate('Configuration has been saved.'), 'success');
     if (!$this->isAjax()) {
         $this->redirect('this');
     }
 }
Example #6
0
 public function handleSave(Form $form)
 {
     if ($form->hasSaveButton() && $form->isSubmitted() === $form->getSaveButton()) {
         try {
             $this->mapper->entityManager->getRepository(get_class($form->data))->save($form->data);
         } catch (\Exception $e) {
             $ok = true;
             if (is_array($this->onCatchError) || $this->onCatchError instanceof \Traversable) {
                 foreach ($this->onCatchError as $handler) {
                     if (\Nette\Callback::create($handler)->invokeArgs(array($form, $e))) {
                         $ok = false;
                         break;
                     }
                 }
             } elseif ($this->onCatchError !== NULL) {
                 $class = get_class($this);
                 throw new \Nette\UnexpectedValueException("Property {$class}::onCatchError must be array or NULL, " . gettype($this->onCatchError) . " given.");
             }
             if ($ok) {
                 throw $e;
             }
         }
     }
 }
Example #7
0
 public function overloadFormSuccess(Form $form)
 {
     if ($form->isSubmitted() === $form->getSaveButton() && !$form->errors) {
         $this->redirect('default');
     }
 }
Example #8
0
 public function actionFormSuccess(VForm $form)
 {
     $this->invalidateControl('actionForm');
     if ($form->hasSaveButton() && $form->isSubmitted() === $form->getSaveButton()) {
         $this->id = NULL;
         $this->formName = NULL;
         if (!$this->presenter->isAjax()) {
             $this->redirect('this', array('formName' => NULL, 'id' => NULL, 'mode' => NULL));
         }
         $this->invalidateControl('table');
         if ($this->mode === $this::MODE_PLACE) {
             $this->invalidateControl('navbarFormContainer');
             $this->invalidateControl('actionFormContainer');
         }
         $this->presenter->payload->url = $this->link('this', array('formName' => NULL, 'id' => NULL, 'mode' => NULL));
     }
 }
Example #9
0
 public function formSuccess(Form $form)
 {
     $values = $form->getValues();
     $button = $form->isSubmitted();
     if ($values->remember) {
         $form->presenter->user->setExpiration('+ 14 days', FALSE);
     } else {
         $form->presenter->user->setExpiration('+ 20 minutes', TRUE);
     }
     if ($button === $form->getSaveButton()) {
         try {
             $form->presenter->user->login($values->username, $values->password);
         } catch (AuthenticationException $e) {
             $this->onError($this, $e->getMessage());
         }
     } else {
         $this->redirect('login!', str_replace('_', ' ', $button->name));
     }
     $this->onSuccess($this);
     $this->redirect('this');
 }
Example #10
0
 public function handleSuccess(Form $form)
 {
     if ($form->isSubmitted() === $form->getSaveButton()) {
         $values = $form->values;
         if ($values['type'] == 'component') {
             $file = $this->getFileByClass($values['component']);
             $baseName = $file->getBasename('.php') . '.latte';
             $template = $file->getPath() . '/' . $baseName;
             $target = $this->moduleHelpers->expandPath('@' . $values['target'] . 'Module', 'Resources/layouts');
             if ($values['layout']) {
                 $target .= '/' . $values['layout'];
             }
             $target .= '/' . $baseName;
         } else {
             $presenter = explode(':', $values['presenter']);
             $module = lcfirst($presenter[0]);
             $page = lcfirst($presenter[2]);
             $presenter = lcfirst($presenter[3]);
             $template = $this->moduleHelpers->expandPath('@' . $module . 'Module/@' . $page . '.' . $presenter . '.latte', 'Resources/layouts');
             $target = $this->moduleHelpers->expandPath('@' . $values['target'] . 'Module/' . ($values['layout'] ? $values['layout'] . '/' : '') . '@' . $page . '.' . $presenter . '.latte', 'Resources/layouts');
         }
         if (!copy($template, $target)) {
             $form->addError("Unable to copy file '{$template}' to '{$target}'.");
         }
     }
 }
Example #11
0
 public function formCreateSuccess(\Venne\Forms\Form $form)
 {
     if ($form->hasSaveButton() && $form->isSubmitted() === $form->getSaveButton()) {
         if (!$this->presenter->isAjax()) {
             $this->redirect('create!', array('createForm' => NULL));
         }
         $this->getPresenter()->invalidateControl('content');
         $this->presenter->payload->url = $this->link('create!', array('createForm' => NULL));
         $this->createForm = NULL;
         $this->handleCreate();
     } else {
         $this->invalidateControl('createForm');
     }
 }