Get the list of accepted images format for upload

@return array

@throws StatusException
426069
public function getAcceptedFormats()
    {
        try {
            $ret    = array();
            $result = $this->getSoapClient()->GetImageImportFormats();
            if ( isset($result->GetImageImportFormatsResult->string) ) {
                $ret = $result->GetImageImportFormatsResult->string;
                $ret = array_map('strtolower' , $ret);
            }

            return $ret;
        } catch ( SoapException $ex ) {
            throw new StatusException('Error while obtaining the list of accepted image formats' , $ex);
        }
    }
1063307
private function mapImage(): array
    {
        $previewUri = $this->resourceManager->getPublicPersistentResourceUri($this->image->getResource());

        return [
            'previewUri' => $previewUri,
            'width' => $this->image->getWidth(),
            'height' => $this->image->getHeight(),
            'persistenceIdentifier' => $this->persistenceManager->getIdentifierByObject($this->image)
        ];
    }
903042
protected function getFileValidationRules()
    {
        $rules = array_get($this->field->options, 'validation', []);

        // If the 'image' rule is not set, make sure it is added.
        if (is_string($rules)) {
            if (empty($rules)) {
                $rules = 'image';
            } elseif ( ! preg_match('#(^|\|)image($|\|)#', $rules)) {
                $rules .= '|image';
            }
        } elseif ( ! in_array('image', $rules)) {
            array_unshift($rules, 'image');
        }

        return $rules;
    }
1090249
protected function defaultUploadedFiles()
    {
        $files = [];
        foreach ($_FILES as $class => $info) {
            $files[$class] = [];
            $this->populateUploadedFileRecursive($files[$class], $info['name'], $info['tmp_name'], $info['type'], $info['size'], $info['error']);
        }

        return $files;
    }
125404
public function getFilterFormats() {
    $options = [];
    $formats = filter_formats($this->currentUser);
    foreach ($formats as $format) {
      $options[$format->id()] = $format->label();
    }
    return $options;
  }
450590
public function values() {
		$res = [];
		foreach($this->fields as $name=>$field) {
			$value = $field->getValue();
			if($value === null)
				continue;
			if(($field->getType() == 'image' || $field->getType() == 'submit') && $name !== $this->submit)
				continue;

			$path = $this->getPath($name);

			$arr =& $res;
			$key = array_pop($path);

			foreach($path as $parent)
				$arr =& $arr[$parent];
			if(!$key)
				$arr[] = $value;
			else
				$arr[$key] = $value;
		}
		return $res;
	}
1358016
public function actionImages(): Response
    {
        $result = [];

        foreach (AttachmentModel::find()->each() as $attachment) {
            $result[] = [
                'id' => $attachment->id,
                'url' => $attachment->getFileUrl('origin'),
                'thumb' => $attachment->getFileUrl('thumbnail'),
            ];
        }

        return $this->asJson($result);
    }
1228531
public function listAll()
    {
        try {
            $return = [ ];
            $result = $this->getSoapClient()->ListImages();
            if ( isset($result->ListImagesResult) ) {
                $return = $this->getSoapClient()->backendListArrayToMultiAssocArray($result->ListImagesResult);
            }

            return $return;
        } catch ( SoapException $ex ) {
            throw new StatusException('Error while obtaining the list of all images' , $ex);
        }
    }
145620
protected function getIncomingFiles()
    {
        $fh = $this->app->make('helper/validation/file');
        $nh = $this->app->make('helper/number');
        $incoming = $this->app->make(Incoming::class);
        $files = $incoming->getIncomingFilesystem()->listContents($incoming->getIncomingPath());
        foreach (array_keys($files) as $index) {
            $files[$index]['allowed'] = $fh->extension($files[$index]['basename']);
            $files[$index]['thumbnail'] = FileTypeList::getType($files[$index]['extension'])->getThumbnail();
            $files[$index]['displaySize'] = $nh->formatSize($files[$index]['size'], 'KB');
        }

        return $files;
    }
908480
private function validateImageMimeType()
    {
        $imageType = exif_imagetype($this->uploadFile->getTemporaryFilename());
        $mime = image_type_to_mime_type($imageType);
        if (!$imageType || !in_array($mime, parent::getAllowedMimeTypes())) {
            throw new \Exception("Uploaded image appears to be corrupt"); // @codeCoverageIgnore
        }
    }
355618
public function getFilesArray()
    {
        if ($this->_filesArray === null) {
            $this->_filesArray = $this->getQueryCacheHelper((new Query())->from('{{%admin_storage_file}}')->select(['id', 'is_hidden', 'is_deleted', 'folder_id', 'name_original', 'name_new', 'name_new_compound', 'mime_type', 'extension', 'hash_name', 'hash_file', 'upload_timestamp', 'file_size', 'upload_user_id', 'caption'])->indexBy('id'), self::CACHE_KEY_FILE);
        }

        return $this->_filesArray;
    }
793926
protected function validateImages()
    {
        $field = 'images';
        $images = $this->getSubmitted($field);

        if (empty($images) || !is_array($images)) {
            $this->unsetSubmitted($field);
            return null;
        }

        foreach ($images as &$image) {

            if (isset($image['title'])) {
                $image['title'] = mb_strimwidth($image['title'], 0, 255, '');
            }

            if (isset($image['description'])) {
                $image['description'] = mb_strimwidth($image['description'], 0, 255, '');
            }

            if (empty($image['translation'])) {
                continue;
            }

            foreach ($image['translation'] as $lang => &$translation) {
                foreach ($translation as $key => &$value) {
                    if ($value === '') {
                        unset($image['translation'][$lang][$key]);
                        continue;
                    }
                    $value = mb_strimwidth($value, 0, 255, '');
                }

                if (empty($image['translation'][$lang])) {
                    unset($image['translation'][$lang]);
                    continue;
                }
            }
        }

        $this->setSubmitted($field, $images);
        return true;
    }
1296816
public function actionFilesUpload()
    {
        $this->checkRouteAccess(self::PERMISSION_ROUTE);
        
        foreach ($_FILES as $k => $file) {
            if ($file['error'] !== UPLOAD_ERR_OK) {
                Yii::$app->response->setStatusCode(422, 'Data Validation Failed.');
                return ['upload' => false, 'message' => Storage::getUploadErrorMessage($file['error']), 'file' => null];
            }
            try {
                $response = Yii::$app->storage->addFile($file['tmp_name'], $file['name'], Yii::$app->request->post('folderId', 0), Yii::$app->request->post('isHidden', false));
                if ($response) {
                    return ['upload' => true, 'message' => Module::t('api_storage_file_upload_succes'), 'file' => $response];
                } else {
                    Yii::$app->response->setStatusCode(422, 'Data Validation Failed.');
                    return ['upload' => false, 'message' => Module::t('api_storage_file_upload_folder_error'), 'file' => null];
                }
            } catch (Exception $err) {
                Yii::$app->response->setStatusCode(422, 'Data Validation Failed.');
                return ['upload' => false, 'message' => Module::t('api_sotrage_file_upload_error', ['error' => $err->getMessage()]), 'file' => null];
            }
        }
    
        // If the files array is empty, this is an indicator for exceeding the upload_max_filesize from php ini or a wrong upload defintion.
        Yii::$app->response->setStatusCode(422, 'Data Validation Failed.');
        return ['upload' => false, 'message' => Storage::getUploadErrorMessage(UPLOAD_ERR_NO_FILE), 'file' => null];
    }
236935
public function getAllowedUploadableExtension()
    {
        $config = $this->getServiceLocator()->get('MelisCoreConfig');
        $path   = $config->getItem('meliscore/interface/meliscore_leftmenu/interface/meliscore_toolstree_section/interface/meliscore_tool_system_config/interface/meliscore_tool_platform_scheme');
        $ext    = null;


        if($path) {
            $ext = isset($path['datas']['allowed_file_extension']) ? $path['datas']['allowed_file_extension'] : 'jpeg,jpg,png,svg,ico,gif';
        }

        return $ext;
    }
382262
public function uploadImage()
    {
        $image = $this->getTempImage();
        $file = $_FILES['Filedata'];
        $uploadError = Nip_File_System::instance()->getUploadError($file, $image->extensions);

        if (!$uploadError) {
            $image->setResourceFromUpload($file);
            if ($image->validate()) {
                $image->resize();
                $image->save();

                $imageCrop = $this->getTempImage();
                $imageCrop->copyResource($image);

                $ratio = $imageCrop->getRatio();
                $max_width = $imageCrop->minWidth > 600 ? $imageCrop->minWidth : 600;
                $heightCalculated = round($max_width / $ratio);
                if ($heightCalculated < $imageCrop->minHeight) {
                    $max_width = round($imageCrop->minHeight * $ratio);
                }

                $imageCrop->max_width = $max_width;
                $imageCrop->setName('crop-' . $image->name);
                $imageCrop->resize();
                $imageCrop->save();

                return $imageCrop;
            } else {
                $this->errors['upload'] = 'Eroare dimensiuni.';
            }
        } else {
            $this->errors['upload'] = $uploadError;
        }


        return false;
    }
1022491
public function getUploadedFiles()
    {
        $files = [];

        foreach (self::normailizeUploadedFiles($this->files) as $key => $file) {
            if (isset($file['name'])) {
                $files[$key] = new UploadedFile($file);
            } else {
                foreach ($file as $f) {
                    if ('' === $f['name']) {
                        continue;
                    }

                    $files[$key][] = new UploadedFile($f);
                }
            }
        }

        return $files;
    }
391442
final public static function normalizeUploads(): Array
	{
		$files = [];

		foreach($_FILES as $name => $value) {
			$file_post = $_FILES[$name];
			if (
				array_key_exists('name', $file_post)
				and is_array($file_post['name'])
			) {
				$file_count = count($file_post['name']);
				$file_keys = array_keys($file_post);

				for ($i = 0; $i < $file_count; $i++) {
					foreach ($file_keys as $key) {
						$files[$name][$i][$key] = $file_post[$key][$i];
					}
				}
			} else {
				$files[$name] = [$value];
			}
		}

		return $files;
	}