* @package tao */ class tao_helpers_form_elements_xhtml_AsyncFile extends tao_helpers_form_elements_AsyncFile { use XhtmlRenderingTrait; /** * Short description of method feed * * @access public * @author Joel Bout, */ public function feed() { common_Logger::t('Evaluating AsyncFile ' . $this->getName(), [ 'TAO']); if (isset($_POST[$this->name])) { $struct = json_decode($_POST[$this->name], true); if ($struct !== false) { $this->setValue($struct); } else { common_Logger::w('Could not unserialise AsyncFile field ' . $this->getName(), [ 'TAO']); } } } /** * Short description of method render * * @access public * @author Joel Bout, * @return string */ public function render() { $widgetName = 'Uploader_' . md5($this->name); $returnValue = $this->renderLabel(); $returnValue .= ""; $returnValue .= "
"; // get the upload max size $fileSize = SystemHelper::getFileUploadLimit(); $mimetypes = []; // add a client validation foreach ($this->validators as $validator) { // get the valid file extensions if ($validator instanceof tao_helpers_form_validators_FileMimeType) { $options = $validator->getOptions(); if (isset($options['mimetype'])) { $mimetypes = $options['mimetype']; } } // get the max file size if ($validator instanceof tao_helpers_form_validators_FileSize) { $options = $validator->getOptions(); if (isset($options['max'])) { $validatorMax = (int) $options['max']; if ($validatorMax > 0 && $validatorMax < $fileSize) { $fileSize = $validatorMax; } } } } // default value for 'auto' is 'true': $auto = 'true'; if (isset($this->attributes['auto'])) { if (! $this->attributes['auto'] || $this->attributes['auto'] === 'false') { $auto = 'false'; } unset($this->attributes['auto']); } // initialize the Uploader Js component $returnValue .= ''; $returnValue .= "
"; return (string) $returnValue; } /** * Short description of method getEvaluatedValue * * @access public * @author Joel Bout, * @return mixed */ public function getEvaluatedValue() { return $this->getRawValue(); } }