Ejemplo n.º 1
0
 /**
  * Getting array of errors.
  * @return Error[]
  */
 public function getErrors()
 {
     return $this->errorCollection->toArray();
 }
Ejemplo n.º 2
0
 function processActionHandleFile($hash, &$file, &$package, &$upload, &$error)
 {
     $errorCollection = new ErrorCollection();
     $storage = Driver::getInstance()->getStorageByUserId($this->getUser()->getId());
     if (!$storage) {
         $errorCollection->add(array(new Error(Loc::getMessage('DISK_UF_CONTROLLER_ERROR_COULD_NOT_FIND_USER_STORAGE'), self::ERROR_COULD_NOT_FIND_USER_STORAGE)));
         $error = implode(" ", $errorCollection->toArray());
         return false;
     }
     $folder = $storage->getFolderForUploadedFiles();
     if (!$folder) {
         $errorCollection->add(array(new Error(Loc::getMessage('DISK_UF_CONTROLLER_ERROR_COULD_NOT_FIND_FIND_FOLDER'), self::ERROR_COULD_NOT_FIND_FOLDER)));
         $error = implode(" ", $errorCollection->toArray());
         return false;
     }
     $urlManager = Driver::getInstance()->getUrlManager();
     if ($folder->canAdd($storage->getCurrentUserSecurityContext())) {
         $fileModel = $folder->uploadFile($file["files"]["default"], array('NAME' => $file['name'], 'CREATED_BY' => $this->getUser()->getId()), array(), true);
         if ($fileModel) {
             $name = $fileModel->getName();
             $id = FileUserType::NEW_FILE_PREFIX . $fileModel->getId();
             $file = array_merge($file, array('id' => $id, 'originalId' => $fileModel->getId(), 'name' => $name, 'label' => getFileNameWithoutExtension($name), 'ext' => $fileModel->getExtension(), 'size' => \CFile::formatSize($fileModel->getSize()), 'sizeInt' => $fileModel->getSize(), 'storage' => $storage->getProxyType()->getTitleForCurrentUser() . ' / ' . $folder->getName(), 'deleteUrl' => $urlManager->getUrlUfController('deleteFile', array('attachedId' => $id)), 'canChangeName' => true), TypeFile::isImage($name) ? array('previewUrl' => $urlManager->getUrlForShowFile($fileModel, array("width" => self::$previewParams["width"], "height" => self::$previewParams["height"]))) : array());
         } else {
             $error = is_array($folder->getErrors()) ? implode(" ", $folder->getErrors()) : 'The file has not been saved';
         }
     }
     return empty($error);
 }