getValue(); } $destination = $this->getTransferAdapter()->getDestination($this->getName()); if (is_array($destination)) { $destination = reset($destination); } $fullFileName = $destination . '/' . rawurlencode($value); $downloadUrl = str_replace(WWW_PATH, BASE_URL, $fullFileName); return $downloadUrl; } public function getValue() { if (!is_null($this->_value)) { return $this->_value; } if (!$this->isValid(null)) { return $this->_oldValue; } if (!$this->receive()) { return null; } $content = $this->getTransferAdapter()->getFileName($this->getName()); if (empty($content)) { return null; } $filenames = $this->getFileName(); if (count($filenames) == 1) { $this->_value = $this->_oldValue; $this->_value[] = basename($filenames); return $this->_value; } $this->_value = $this->_oldValue; foreach ($filenames as $filename) { $this->_value[] = basename($filename); } return $this->_value; } protected function _initOldValue($context) { if (array_key_exists($this->getName(), $context)) { $this->_oldValue = $context[$this->getName()]; } return $this; } public function isValid($value, $context = null) { if (null !== $context) { $this->_initOldValue($context); } if (!$this->getTransferAdapter()->getUploadedCount($this->getName())) { if ($this->isRequired()) { if (empty($this->_oldValue)) { $this->getTransferAdapter()->addError('File is required'); $this->_value = $this->_oldValue; return false; } else { $this->_value = $this->_oldValue; return true; } } else { $this->_value = $this->_oldValue; return true; } } return Zend_Form_Element_File::isValid($value, $context); } public function loadDefaultDecorators() { if ($this->loadDefaultDecoratorsIsDisabled()) { return; } $decorators = $this->getDecorators(); if (empty($decorators)) { $this->addDecorator('MultiFile') ->addDecorator('Errors') ->addDecorator('Description') ->addDecorator('HtmlTag', ['tag' => 'dd', 'id' => $this->getName() . '-element']) ->addDecorator('Label', ['tag' => 'dt']); } } }