Example #1
0
 /**
  * @constuctor
  *
  * @param	string	$absolutename absolutename
  * @param	string	$name name
  * @param	array	$configuration configuration
  * @param	\Ameos\AmeosForm\Form $form form
  */
 public function __construct($absolutename, $name, $configuration = [], $form)
 {
     parent::__construct($absolutename, $name, $configuration, $form);
     $this->configuration['encrypt'] = isset($configuration['encrypt']) ? (bool) $configuration['encrypt'] : false;
     $this->configuration['fill_value'] = isset($configuration['fill_value']) ? (bool) $configuration['fill_value'] : false;
     $this->configuration['fill_value_iferror'] = isset($configuration['fill_value']) ? (bool) $configuration['fill_value_iferror'] : true;
 }
Example #2
0
 /**
  * return rendering information
  *
  * @return	array rendering information
  */
 public function getRenderingInformation()
 {
     $data = parent::getRenderingInformation();
     $data['captcha'] = $this->renderCaptchaPicture();
     $data['refresh'] = $this->renderCaptchaRefresh();
     $data['input'] = $this->renderCaptchaInput();
     return $data;
 }
Example #3
0
 /**
  * return where clause
  *
  * @return	bool|array FALSE if no search. Else array with search type and value
  */
 public function getClause()
 {
     $values = $this->getValue();
     if (!empty($values)) {
         if ($this->overrideClause !== false) {
             return parent::getClause();
         } else {
             $clauses = [];
             if (is_array($values)) {
                 foreach ($values as $value) {
                     $clauses[] = ['field' => $this->getSearchField(), 'type' => 'contains', 'value' => $value];
                 }
             }
             return ['elementname' => $this->getName(), 'elementvalue' => $this->getValue(), 'field' => $this->getSearchField(), 'type' => 'logicalOr', 'clauses' => $clauses];
         }
     }
     return false;
 }
Example #4
0
    /**
     * set the value
     * 
     * @param	string	$value value
     * @return 	\Ameos\AmeosForm\Elements\ElementAbstract this
     */
    public function setValue($value)
    {
        if ($value == 0) {
            $value = '';
        }
        parent::setValue($value);
        if ($value != '') {
            $this->pageRenderer->addJsFooterInlineCode('setvalue-datepicker-' . $this->getName() . '-' . $value, '
				if(document.getElementById("' . $this->getHtmlId() . '-datepicker")) {
					document.getElementById("' . $this->getHtmlId() . '-datepicker").value = moment(' . $value . ', "X").format("' . $this->configuration['format'] . '");
				}
			');
        } else {
            $this->pageRenderer->addJsFooterInlineCode('setvalue-datepicker-' . $this->getName() . '-' . $value, '
				if(document.getElementById("' . $this->getHtmlId() . '-datepicker")) {
					document.getElementById("' . $this->getHtmlId() . '-datepicker").value = "";
				}
			');
        }
        return $this;
    }
Example #5
0
 /**
  * set the value
  *
  * @todo : fal mode
  * @param	string	$value value
  * @return 	\Ameos\AmeosForm\Elements\ElementAbstract this
  */
 public function setValue($value)
 {
     if (is_array($value)) {
         if (isset($value['upload']) && is_array($value['upload']) && $value['upload'][0]['name'] != '') {
             $this->value = $value;
             $this->determineErrors();
             $currentValue = [];
             if ($this->isValid()) {
                 foreach ($value['upload'] as $uploadFile) {
                     $directory = $this->getUploadDirectory();
                     $filename = $this->getUploadFilename($uploadFile['name']);
                     $temporaryFilepath = $this->getTemporaryUpdateFilepath($uploadFile['name']);
                     GeneralUtility::upload_copy_move($uploadFile['tmp_name'], $temporaryFilepath);
                     Events::getInstance($this->form->getIdentifier())->registerEvent('form_is_valid', [$this, 'moveTemporaryUploadedFile'], ['destinationFilepath' => $directory . $filename, 'temporaryFilepath' => $temporaryFilepath]);
                     $this->uploadState = 'temporary-upload';
                     $currentValue[] = basename($temporaryFilepath);
                 }
                 parent::setValue($currentValue);
             } else {
                 $this->value = null;
             }
         } elseif (isset($value['temporary'])) {
             $currentValue = [];
             foreach ($value['temporary'] as $uploadFile) {
                 $directory = $this->getUploadDirectory();
                 $filename = $this->getUploadFilename($value['temporary']);
                 Events::getInstance($this->form->getIdentifier())->registerEvent('form_is_valid', [$this, 'moveTemporaryUploadedFile'], ['destinationFilepath' => $directory . $filename, 'temporaryFilepath' => PATH_site . 'typo3temp/ameos_form/tempupload/' . $value['temporary']]);
                 $this->uploadState = 'temporary-upload';
                 $currentValue[] = basename($temporaryFilepath);
             }
             parent::setValue($currentValue);
         }
     } else {
         if (is_string($this->value) && $this->value != '') {
             $value = $this->value . ',' . $value;
         }
         parent::setValue($value);
     }
     return $this;
 }