diff --git a/Models/Media.php b/Models/Media.php index 86c5ef3..400f929 100755 --- a/Models/Media.php +++ b/Models/Media.php @@ -312,6 +312,11 @@ class Media implements \JsonSerializable return $this->isAbsolute ? $this->path : \ltrim($this->path, '\\/'); } + public function getAbsolutePath() : string + { + return $this->isAbsolute ? $this->path : __DIR__ . '/../../../' . \ltrim($this->path, '\\/'); + } + /** * @return string * diff --git a/Models/UploadFile.php b/Models/UploadFile.php index 8f193a7..86ac5af 100755 --- a/Models/UploadFile.php +++ b/Models/UploadFile.php @@ -119,6 +119,12 @@ class UploadFile foreach ($files as $key => $f) { ++$fCounter; + if (!\is_file($f['tmp_name'])) { + $result[$key]['status'] = UploadStatus::FILE_NOT_FOUND; + + return $result; + } + if ($path === '') { $path = File::dirpath($f['tmp_name']); } @@ -240,8 +246,9 @@ class UploadFile */ private function createFileName(string $path, string $tempName, string $extension) : string { - $rnd = ''; - $limit = -1; + $rnd = ''; + $limit = -1; + $fileName = ''; $nameWithoutExtension = empty($tempName) ? '' : \substr($tempName, 0, -\strlen($extension) - 1); @@ -311,6 +318,8 @@ class UploadFile */ private function findOutputDir() : string { + $rndPath = ''; + do { $rndPath = \str_pad(\dechex(\mt_rand(0, 65535)), 4, '0', \STR_PAD_LEFT); } while (\is_dir($this->outputDir . '/_' . $rndPath)); diff --git a/Models/UploadStatus.php b/Models/UploadStatus.php index a5887e7..9fab2af 100755 --- a/Models/UploadStatus.php +++ b/Models/UploadStatus.php @@ -47,4 +47,6 @@ abstract class UploadStatus extends Enum public const FAILED_HASHING = -9; public const NOT_ENCRYPTABLE = -10; + + public const FILE_NOT_FOUND = -11; } diff --git a/Theme/Backend/Components/Media/pdf.tpl.php b/Theme/Backend/Components/Media/pdf.tpl.php index 153fad0..dbe26cc 100755 --- a/Theme/Backend/Components/Media/pdf.tpl.php +++ b/Theme/Backend/Components/Media/pdf.tpl.php @@ -18,6 +18,6 @@ use \phpOMS\Uri\UriFactory;
- +
\ No newline at end of file diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php index 6e99eb4..c823cf3 100644 --- a/Theme/Backend/Lang/en.lang.php +++ b/Theme/Backend/Lang/en.lang.php @@ -42,8 +42,8 @@ return ['Media' => [ 'Select' => 'Select', 'Settings' => 'Settings', 'Size' => 'Size', - 'Tag' => '', - 'Tags' => '', + 'Tag' => 'Tag', + 'Tags' => 'Tags', 'Type' => 'Type', 'Upload' => 'Upload', 'VirtualPath' => 'Virtual Path',