Esempio n. 1
0
 /**
  * Add a submit button to the button bar. The button added is an instance
  * of the SubmitButton class.
  * 
  * @param type $label
  * @return ButtonBar
  */
 public function addSubmitButton($label)
 {
     $button = new SubmitButton($label);
     $button->addAttribute('name', $this->barName);
     $this->buttons[] = $button;
     return $this;
 }
Esempio n. 2
0
 public function saveClicked(SubmitButton $button)
 {
     $array = $button->getForm()->getValues();
     $array = $this->convertNumberToClass($array);
     $array['authorUrl'] = Model::createAuthorUri($array['name'], $array['surname'], $array['class'], $array['authorId']);
     Model::save($array, 'authorId', 'authors');
     $this->flashMessage('Změny pro autora:' . $array['name'] . " " . $array['surname'] . ' byly uloženy.');
     $this->presenter->redirect(":Admin:Default:authors");
 }
 public function deleteClicked(SubmitButton $button)
 {
     $arr = $button->getForm()->getValues();
     $files[] = $arr['file'][0];
     $miniature = WWW_DIR . "/attachments/mini/" . basename($files[0]);
     if (is_file($miniature)) {
         $files[] = $miniature;
     }
     $this->fileModel->deleteFiles($files);
     $this->arr = $files;
 }
Esempio n. 4
0
 public function saveClicked(SubmitButton $button)
 {
     $array = $button->getForm()->getValues();
     if ($array['id'] != '') {
         Model::save($array, 'id', 'options');
     } else {
         $array['name'] = 'home';
         Model::add($array, 'options');
     }
     $this->flashMessage('Text uložen.', 'info');
     $this->presenter->redirect("this");
 }
Esempio n. 5
0
 public function saveClicked(SubmitButton $button)
 {
     $array = $button->getForm()->getValues();
     unset($array['authorId']);
     try {
         $array['url'] = Model::createUri($array['title'], $array['author'], $array['workId']);
     } catch (Exception $e) {
         $this->flashMessage('U tohoto autora byla již vložena práce se stejným jménem', 'error');
         return;
     }
     $array = $this->fixValues($array);
     Model::save($array, 'workId', 'works');
     $this->flashMessage('Práce uložena.', 'info');
     $this->presenter->redirect(":Admin:Default:works");
 }
Esempio n. 6
0
 /**
  * @param  string  URI of the image
  * @param  string  alternate text for the image
  */
 public function __construct($src, $alt)
 {
     parent::__construct(NULL);
     $this->control->type = 'image';
     $this->control->src = $src;
     $this->control->alt = $alt;
 }
 public function init()
 {
     if (empty($this->buttons)) {
         $this->buttons = [CloseButton::className(), SubmitButton::className()];
     }
     parent::init();
 }
Esempio n. 8
0
 /**
  * FormHandler::submitButton()
  *
  * Create a submitButton on the form
  *
  * @param string $caption: The caption of the button
  * @param string $name: The name of the button
  * @param string $extra: CSS, Javascript or other which are inserted into the HTML tag
  * @param boolean $disableOnSubmit: Disable the button when it is pressed
  * @return void
  * @access public
  * @author Teye Heimans
  */
 function submitButton($caption = null, $name = null, $extra = null, $disableOnSubmit = null)
 {
     require_once FH_INCLUDE_DIR . 'buttons/class.SubmitButton.php';
     // get new button name if none is given
     if (empty($name)) {
         $name = $this->_getNewButtonName();
     }
     // create new submitbutton
     $btn = new SubmitButton($this, $name);
     if (!empty($caption)) {
         $btn->setCaption($caption);
     }
     if (!empty($extra)) {
         $btn->setExtra($extra);
     }
     if (!is_null($disableOnSubmit)) {
         $btn->disableOnSubmit($disableOnSubmit);
     }
     // register the button
     $this->_registerField($name, $btn);
 }
Esempio n. 9
0
 /**
  * Returns HTML name of control.
  * @return string
  */
 public function getHtmlName()
 {
     return parent::getHtmlName() . '[]';
 }
 /**
  * Handler which is called when form is submmited by button of this control
  * @param SubmitButton $button
  */
 public function submitButtonHandler($button)
 {
     $form = $button->getForm();
     foreach ($this->onSubmit as $onSubmitItem) {
         list($callback, $params) = $onSubmitItem;
         $callback->invokeArgs($params);
     }
     if ($this->hasAnyParentEmptyValue()) {
         return;
     }
     if (self::$disableChilds) {
         $this->addEmptyHeaderItem();
         $this->disableAllChilds();
     } else {
         $this->setFirstItemSelected();
         $this->selectFirstItemForAllChilds();
     }
 }
Esempio n. 11
0
 function getHtmlName()
 {
     $name = parent::getHtmlName();
     return strpos($name, '[') === FALSE ? $name : $name . '[]';
 }
 /**
  * Custom group operations handler.
  * @param  SubmitButton
  * @return void
  */
 public function gridOperationHandler(SubmitButton $button)
 {
     // how to findout which checkboxes in checker was checked?  $values['checker']['ID'] => bool(TRUE)
     $form = $button->getParent();
     $grid = $this->getComponent('ordersGrid');
     // was submitted?
     if ($form->isSubmitted() && $form->isValid()) {
         $values = $form->getValues();
         if ($button->getName() === 'operationSubmit') {
             $operation = $values['operations'];
         } else {
             throw new InvalidArgumentException("Unknown submit button '" . $button->getName() . "'.");
         }
         $rows = array();
         foreach ($values['checker'] as $k => $v) {
             if ($v) {
                 $rows[] = $k;
             }
         }
         if (count($rows) > 0) {
             $msg = $grid->translate('Operation %2$s over row %3$s succesfully done.', count($rows), $grid->translate($operation), implode(', ', $rows));
             $grid->flashMessage($msg, 'success');
             $msg = $grid->translate('This is demo application only, changes will not be done.');
             $grid->flashMessage($msg, 'info');
         } else {
             $msg = $grid->translate('No rows selected.');
             $grid->flashMessage($msg, 'warning');
         }
     }
     $grid->invalidateControl();
     if (!$this->presenter->isAjax()) {
         $this->presenter->redirect('this');
     }
 }