Ejemplo n.º 1
0
 public function getControl()
 {
     $container = Html::el();
     $container->add($this->wrappedControl->getControl());
     $container->add($this->applyButton->getControl($this->caption));
     return $container;
 }
 public function processEntireForm(SubmitButton $button)
 {
     $form = $button->getForm();
     $values = $form->getValues(TRUE);
     foreach ($values["rows"] as $containerId => $containerValues) {
         $this->saveMeta($this->targetList[$containerId], $containerValues);
     }
     $this->onProcessEntireForm($form);
 }
Ejemplo n.º 3
0
 public function processFilter(SubmitButton $buttonControl)
 {
     $values = $buttonControl->getForm()->getValues();
     foreach ($values as $k => $v) {
         if ($v === '') {
             $values[$k] = null;
         }
     }
     $this->presenter->redirect('this', ['name' => $values['name'], 'extension' => $values['extension'], 'maxWidth' => $values['maxWidth'], 'maxHeight' => $values['maxHeight']]);
 }
Ejemplo n.º 4
0
 public function processFilter(SubmitButton $button)
 {
     $values = $button->getForm()->getValues();
     $this->localities = $this->localityFacade->findLocalities($values['search'], self::VISIBLE_LOCALITIES);
     $this->search = $values['search'];
     if ($this->isAjax()) {
         $this->redrawControl('localitiesList');
     } else {
         $this->redirect('Locality:itemAutocomplete');
     }
 }
 public function generatePdf(SubmitButton $button)
 {
     $values = $button->getForm()->getValues(true);
     $items = $this->listingItemsReader->findListingsItems([$this->listingResult->getListingId()]);
     $listing = $this->listingResult->getListing();
     $listingData = ['l_id' => $listing->id, 'l_year' => $listing->year, 'l_month' => $listing->month, 'l_description' => $listing->description, 'l_hourlyWage' => $listing->hourlyWage, 'u_id' => $listing->user->id, 'u_name' => $listing->user->name, 'worked_days' => $this->listingResult->getWorkedDays(), 'worked_hours' => $this->listingResult->getWorkedHours(), 'total_worked_hours_in_sec' => $this->listingResult->getTotalWorkedHours()->toSeconds(), 'lunch_hours' => $this->listingResult->getLunchHours(), 'other_hours' => $this->listingResult->getOtherHours()];
     /** @var IListingPdfFile $pdf */
     $pdf = $this->listingPDFGenerator->generate($listingData, $items, $values);
     $response = new Nette\Application\Responses\FileResponse($pdf->getStoragePath(), $pdf->getFileName());
     $this->presenter->sendResponse($response);
 }
 /**
  * @secured
  */
 public function generatePdf(SubmitButton $button)
 {
     $values = $button->getForm()->getHttpData(Form::DATA_TEXT);
     if (!empty($values['listingsSettings'])) {
         array_walk($values['listingsSettings'], function (&$value) {
             $value = (bool) $value;
         });
     }
     $zipPath = $this->PDFGenerator->generate($values['year'], $this->user, $values);
     $this->presenter->sendResponse(new FileResponse($zipPath));
 }
Ejemplo n.º 7
0
 /**
  * @param \Nette\ComponentModel\Container $obj
  */
 protected function attached($obj)
 {
     parent::attached($obj);
     if ($obj instanceof Nette\Application\UI\Presenter) {
         $this->payPal->setReturnAddress($this->link('return'), $this->link('cancel'));
     }
 }
Ejemplo n.º 8
0
 public function processDeleteMessages(SubmitButton $button)
 {
     $messagesIDs = $button->getForm()->getHttpData(Form::DATA_TEXT, 'msg[]');
     if (!empty($messagesIDs)) {
         try {
             $this->loader->removeMessages($messagesIDs);
             $this->flashMessage('Vybrané zprávy byli úspěšně smazány.', 'success');
         } catch (\DibiException $e) {
             $this->flashMessage('Při pokusu o hromadné smazání zpráv došlo k chybě.
                  Zkuste akci opakovat později.', 'error');
         }
         if ($this->presenter->isAjax()) {
             $this->redrawControl();
         } else {
             $this->redirect('this');
         }
     }
 }
Ejemplo n.º 9
0
 /**
  * Když není RequestButton požadavek, tak se tento button nezobrazuje.
  *
  * @param IPresenter
  */
 protected function attached($parent)
 {
     if ($parent instanceof \Nette\Application\IPresenter) {
         $backlinkId = $this->form->presenter->getParam(RequestButton::BACKLINK_KEY);
         if (!$backlinkId or !RequestButtonStorage::is($backlinkId)) {
             $this->setDisabled(true);
             $this->getParent()->removeComponent($this);
         }
     }
     parent::attached($parent);
 }
Ejemplo n.º 10
0
 public function getControl($caption = NULL)
 {
     $control = parent::getControl($caption);
     $control->setText("");
     // Delete content
     if ($this->icon) {
         $control->class[] = "hasIcon";
         $this->icon->alt = $this->caption;
         $control->add($this->icon);
     }
     if ($this->showCaption) {
         $control->class[] = "hasCaption";
         $control->add(Html::el("span class=caption")->setHtml($this->caption));
     }
     // CSS classes:
     if ($this->icon and !$this->showCaption) {
         $control->class[] = "hasIconAndNoCaption";
     } elseif (!$this->icon and $this->showCaption) {
         $control->class[] = "hasCaptionAndNoIcon";
     } elseif ($this->icon and $this->showCaption) {
         $control->class[] = "hasCaptionAndIcon";
     }
     return $control;
 }
Ejemplo n.º 11
0
 /**
  * @param string $methodName
  * @return void
  */
 public static function register($methodName = 'addDynamic')
 {
     if (self::$registered) {
         Nette\Forms\Container::extensionMethod(self::$registered, function () {
             throw new Nette\MemberAccessException();
         });
     }
     Nette\Forms\Container::extensionMethod($methodName, function (Nette\Forms\Container $_this, $name, $factory, $createDefault = 0, $forceDefault = FALSE) {
         $control = new Container($factory, $createDefault, $forceDefault);
         $control->currentGroup = $_this->currentGroup;
         return $_this[$name] = $control;
     });
     if (self::$registered) {
         return;
     }
     SubmitButton::extensionMethod('addRemoveOnClick', function (SubmitButton $_this, $callback = NULL) {
         $_this->setValidationScope(FALSE);
         $_this->onClick[] = function (SubmitButton $button) use($callback) {
             $replicator = $button->lookup(__NAMESPACE__ . '\\Container');
             /** @var Container $replicator */
             if (is_callable($callback)) {
                 Callback::invoke($callback, $replicator, $button->parent);
             }
             if ($form = $button->getForm(FALSE)) {
                 $form->onSuccess = array();
             }
             $replicator->remove($button->parent);
         };
         return $_this;
     });
     SubmitButton::extensionMethod('addCreateOnClick', function (SubmitButton $_this, $allowEmpty = FALSE, $callback = NULL) {
         $_this->onClick[] = function (SubmitButton $button) use($allowEmpty, $callback) {
             $replicator = $button->lookup(__NAMESPACE__ . '\\Container');
             /** @var Container $replicator */
             if (!is_bool($allowEmpty)) {
                 $callback = Callback::closure($allowEmpty);
                 $allowEmpty = FALSE;
             }
             if ($allowEmpty === TRUE || $replicator->isAllFilled() === TRUE) {
                 $newContainer = $replicator->createOne();
                 if (is_callable($callback)) {
                     Callback::invoke($callback, $replicator, $newContainer);
                 }
             }
             $button->getForm()->onSuccess = array();
         };
         return $_this;
     });
     self::$registered = $methodName;
 }
Ejemplo n.º 12
0
 /**
  * @param \Nette\Forms\Controls\SubmitButton $button
  * @internal
  */
 public function handleOperations(\Nette\Forms\Controls\SubmitButton $button)
 {
     $this->grid->onRegistered && $this->grid->onRegistered($this->grid);
     $form = $button->getForm();
     $this->addCheckers($form[self::ID]);
     $values = $form[self::ID]->values;
     if (empty($values[self::ID])) {
         $httpData = $form->getHttpData();
         if (!empty($httpData[self::ID][self::ID]) && ($operation = $httpData[self::ID][self::ID])) {
             trigger_error("Operation with name '{$operation}' does not exist.", E_USER_NOTICE);
         }
         $this->grid->reload();
     }
     $ids = array();
     $operation = $values[self::ID];
     unset($values[self::ID]);
     foreach ($values as $key => $val) {
         if ($val) {
             $ids[] = $key;
         }
     }
     $this->onSubmit($operation, $ids);
 }
Ejemplo n.º 13
0
 /**
  * Confirm NO clicked
  *
  * @param Forms\Controls\SubmitButton $button
  */
 public function cancelClicked(Forms\Controls\SubmitButton $button)
 {
     // Get submitted values from form
     $values = $button->getForm(TRUE)->getValues();
     // Get token from post
     $token = $values->secureToken;
     if ($this->getConfirmerValues($token)) {
         $this->sessionStorage->clear($token);
     }
     $this->getDialog()->resetConfirmer();
     // Check if request is done via ajax...
     if ($this->getPresenter() instanceof Application\UI\Presenter && !$this->getPresenter()->isAjax()) {
         // ...if not redirect to actual page
         $this->getPresenter()->redirect('this');
     }
 }
Ejemplo n.º 14
0
 /**
  * Kontroluje jestli je formulář upraven pro potřeby RequestButtonu.
  * Tedy že je použit RequestButtonReceiver, nebo zavolán RequestButtonHelper::prepareForm()
  *
  * @see RequestButtonReceiver
  * @see RequestButtonHelper::prepareForm()
  * @param string
  * @return Html
  */
 public function getControl($caption = NULL)
 {
     if (!$this->formIsPrepared) {
         throw new \Nette\InvalidStateException('Use RequestButtonReceiver instead AppForm , or call method `RequestButtonHelper::prepareForm($form);` after added all FormControls.');
     }
     return parent::getControl();
 }
Ejemplo n.º 15
0
 /**
  * @param string $caption
  * @param int $copyCount
  */
 public function __construct($caption, $copyCount = 1)
 {
     parent::__construct($caption);
     $this->copyCount = $copyCount;
 }
Ejemplo n.º 16
0
 public function register(array $messages = [])
 {
     if ($this->registered) {
         return;
     }
     // Default error messages for custom validators
     foreach ($messages as $validator => $message) {
         Nette\Forms\Rules::$defaultMessages[$validator] = $message;
     }
     // addLinkSubmit
     Container::extensionMethod('addLinkSubmit', function (Container $container, $name, $label = NULL, $icon = NULL, $destination = NULL) {
         $control = new Zax\Forms\Controls\LinkSubmitButton($label);
         $proto = $control->getControlPrototype();
         $proto->href($destination);
         $proto->setHtml($this->makeLabel($this->translate($label), $icon));
         return $container[$name] = $control;
     });
     // addButtonSubmit
     Container::extensionMethod('addButtonSubmit', function (Container $container, $name, $label = NULL, $icon = NULL, $data = []) {
         $control = new Nette\Forms\Controls\SubmitButton($label);
         $proto = $control->getControlPrototype();
         $proto->setName('button');
         $proto->setType('submit');
         foreach ($data as $key => $value) {
             $proto->setData($key, $value);
         }
         $label = $this->makeLabel($this->translate($label), $icon);
         $proto->setHtml($label);
         return $container[$name] = $control;
     });
     // addTexyArea
     Container::extensionMethod('addTexyArea', function (Container $container, $name, $label = NULL) {
         $control = new Zax\Forms\Controls\TexyAreaInput($label);
         $control->injectIcons($this->icons);
         return $container[$name] = $control;
     });
     // addFileUpload
     Container::extensionMethod('addFileUpload', function (Container $container, $name, $label = NULL, $multiple = FALSE) {
         $upload = new Nette\Forms\Controls\UploadControl($label, $multiple);
         $upload->getControlPrototype()->setData(['buttonText' => $this->translate('common.button.chooseFile' . ($multiple ? 's' : '')), 'input' => $multiple ? 'false' : 'true', 'maxFiles' => $multiple ? Zax\Utils\HttpHelpers::getMaxFileUploads() : 1]);
         $upload->addRule(Zax\Application\UI\Form::MAX_FILE_SIZE, NULL, Zax\Utils\HttpHelpers::getMaxUploadSize() * 1024 * 1024);
         return $container[$name] = $upload;
     });
     // addEmail
     Container::extensionMethod('addEmail', function (Container $container, $name, $label = NULL, $cols = NULL, $maxLength = NULL) {
         $text = $container->addText($name, $label, $cols, $maxLength);
         $text->setType('email');
         $text->addCondition(Nette\Forms\Form::FILLED)->addRule(Nette\Forms\Form::EMAIL);
         return $text;
     });
     // addArrayTextArea
     Container::extensionMethod('addArrayTextArea', function (Container $container, $name, $label = NULL, $keyValDelimiter = NULL) {
         $control = new Zax\Forms\Controls\ArrayTextAreaControl($label, $keyValDelimiter);
         return $container[$name] = $control;
     });
     // addNeonTextArea
     Container::extensionMethod('addNeonTextArea', function (Container $container, $name, $label = NULL) {
         $control = new Zax\Forms\Controls\NeonTextAreaControl($label);
         return $container[$name] = $control;
     });
     // addStatic
     Container::extensionMethod('addStatic', function (Container $container, $name, $label = NULL) {
         $control = new Zax\Forms\Controls\StaticControl($label);
         return $container[$name] = $control;
     });
     // addAutoComplete
     Container::extensionMethod('addAutoComplete', function (Container $container, $name, $label = NULL, $autocomplete = []) {
         $control = $container->addText($name, $label);
         $control->getControlPrototype()->addClass('jqueryui_autocomplete')->setData('autocomplete', $autocomplete);
         return $control;
     });
     // addMultiAutoComplete
     Container::extensionMethod('addMultiAutoComplete', function (Container $container, $name, $label = NULL, $autocomplete = []) {
         $control = $container->addText($name, $label);
         $control->getControlPrototype()->addClass('jqueryui_multiautocomplete')->setData('autocomplete', $autocomplete);
         return $control;
     });
     $this->registered = TRUE;
 }
Ejemplo n.º 17
0
 /**
  * @param SubmitButton $button
  */
 public function submitStep(SubmitButton $button)
 {
     $form = $button->getForm();
     $submitName = $button->getName();
     if ($submitName === self::PREV_SUBMIT_NAME) {
         $currentStep = $this->getCurrentStep();
         $this->getSection()->currentStep = $currentStep - 1;
     } else {
         if ($submitName === self::NEXT_SUBMIT_NAME && $form->isValid()) {
             $this->merge($form->getValues(TRUE));
             $this->getSection()->lastStep = $this->getSection()->currentStep = $this->getCurrentStep() + 1;
         } else {
             if ($submitName === self::FINISH_SUBMIT_NAME && $form->isValid() && $this->getSection()->values !== NULL) {
                 $this->merge($form->getValues(TRUE));
                 $this->isSuccess = TRUE;
                 $this->finish();
                 foreach ($this->onSuccess as $callback) {
                     $callback($this);
                 }
                 $this->resetSection();
             }
         }
     }
 }
Ejemplo n.º 18
0
 /**
  * @param SubmitButton $submitter
  * @internal
  */
 public function onRemoveSubmit(SubmitButton $submitter)
 {
     $this->getForm()->onSuccess = [];
     $this->getForm()->onError = [];
     $this->getForm()->onSubmit = [];
     if ($this->minCopies === NULL || iterator_count($this->getContainers()) > $this->minCopies) {
         $this->removeComponent($submitter->getParent());
         $this->totalCopies--;
         $this->checkSubmitButtons();
     }
 }
Ejemplo n.º 19
0
 /**
  * @param \Nette\Forms\Controls\SubmitButton $button
  * @internal
  */
 public function handleOperations(\Nette\Forms\Controls\SubmitButton $button)
 {
     $grid = $this->getGrid();
     !empty($grid->onRegistered) && $grid->onRegistered($grid);
     $form = $button->getForm();
     $this->addCheckers($form[self::ID]);
     $values = $form[self::ID]->values;
     if (empty($values[self::ID])) {
         $httpData = $form->getHttpData();
         if (!empty($httpData[self::ID][self::ID]) && ($operation = $httpData[self::ID][self::ID])) {
             $grid->__triggerUserNotice("Operation with name '{$operation}' does not exist.");
         }
         $grid->reload();
     }
     $ids = [];
     $operation = $values[self::ID];
     unset($values[self::ID]);
     foreach ($values as $key => $val) {
         if ($val) {
             $ids[] = $key;
         }
     }
     $this->onSubmit($operation, $ids);
     $grid->page = 1;
     if ($this->presenter->isAjax()) {
         $grid['form'][self::ID][self::ID]->setValue(NULL);
         $grid->getData(TRUE, FALSE);
     }
     $grid->reload();
 }
Ejemplo n.º 20
0
__construct($src=NULL,$alt=NULL){parent::__construct();$this->control->type='image';$this->control->src=$src;$this->control->alt=$alt;}function
getHtmlName(){$name=parent::getHtmlName();return
strpos($name,'[')===FALSE?$name:$name.'[]';}function
Ejemplo n.º 21
0
 /**
  * Returns HTML name of control.
  *
  * @return string
  */
 public function getHtmlName()
 {
     $name = parent::getHtmlName();
     return strpos($name, '[') === false ? $name : $name . '[]';
 }
Ejemplo n.º 22
0
 /**
  * @param  string
  * @param  string|NULL
  */
 public function __construct($channel, $caption = NULL)
 {
     parent::__construct($caption);
     $this->channel = $channel;
 }
Ejemplo n.º 23
0
 public function processPageSavingAsDraft(SubmitButton $buttonControl)
 {
     $this->pageSaving($buttonControl->getForm(), true);
 }
Ejemplo n.º 24
0
 /**
  * Returns HTML name of control.
  * @return string
  */
 public function getHtmlName()
 {
     return parent::getHtmlName() . '[]';
 }
Ejemplo n.º 25
0
 function getHtmlName()
 {
     $name = parent::getHtmlName();
     return strpos($name, '[') === FALSE ? $name : $name . '[]';
 }
Ejemplo n.º 26
0
 /**
  * Confirm NO clicked
  * @param Nette\Forms\Controls\SubmitButton $button
  */
 public function cancelClicked($button)
 {
     $form = $button->getForm(TRUE);
     $values = $form->getValues();
     if (isset($this->session->{$values['token']})) {
         unset($this->session->{$values['token']});
     }
     $this->visible = FALSE;
     $this->invalidateControl();
     if (!$this->presenter->isAjax()) {
         $this->presenter->redirect('this');
     }
 }
Ejemplo n.º 27
0
 public function filter(Nette\Forms\Controls\SubmitButton $button)
 {
     $this->filter = $this->prepareFilterValues($button->getForm()->getValues(TRUE));
     $this->redirect('this');
 }
Ejemplo n.º 28
0
 public function generatePdf(SubmitButton $button)
 {
     $values = $button->getForm()->getValues();
     $template = $this->createTemplate()->setFile(__DIR__ . '/../templates/Listing/pdf.latte');
     $template->itemsCollection = $this->itemFacade->generateEntireTable($this->listing);
     $template->listing = $this->listing;
     $template->username = $values['name'] == null ?: $values['name'];
     $template->employer = $values['employer'];
     $template->employeeName = $values['name'];
     $template->wage = $values['wage'];
     $template->otherHours = $values['otherHours'];
     $template->workedHours = $values['workedHours'];
     $template->lunchHours = $values['lunch'];
     $pdf = new \PdfResponse\PdfResponse($template);
     $this->presenter->sendResponse($pdf);
 }
Ejemplo n.º 29
0
 /**
  * Has been button pressed?
  * @return bool
  */
 public static function validateSubmitted(Controls\SubmitButton $control)
 {
     return $control->isSubmittedBy();
 }
Ejemplo n.º 30
0
 /**
  * @param SubmitButton $button
  * @return void
  */
 public function filterFormReset(SubmitButton $button)
 {
     $values = $button->getForm()->getValues();
     foreach ($values as $key => $value) {
         $this->{$key} = NULL;
     }
     $this->resetPaginator();
     $this->redirect('this');
 }