render fixes, minor bug fixes

This commit is contained in:
Dennis Eichhorn 2022-03-05 17:03:46 +01:00
parent 51b8a2a315
commit 2e067f63f0
5 changed files with 21 additions and 5 deletions

View File

@ -312,6 +312,11 @@ class Media implements \JsonSerializable
return $this->isAbsolute ? $this->path : \ltrim($this->path, '\\/'); return $this->isAbsolute ? $this->path : \ltrim($this->path, '\\/');
} }
public function getAbsolutePath() : string
{
return $this->isAbsolute ? $this->path : __DIR__ . '/../../../' . \ltrim($this->path, '\\/');
}
/** /**
* @return string * @return string
* *

View File

@ -119,6 +119,12 @@ class UploadFile
foreach ($files as $key => $f) { foreach ($files as $key => $f) {
++$fCounter; ++$fCounter;
if (!\is_file($f['tmp_name'])) {
$result[$key]['status'] = UploadStatus::FILE_NOT_FOUND;
return $result;
}
if ($path === '') { if ($path === '') {
$path = File::dirpath($f['tmp_name']); $path = File::dirpath($f['tmp_name']);
} }
@ -240,8 +246,9 @@ class UploadFile
*/ */
private function createFileName(string $path, string $tempName, string $extension) : string private function createFileName(string $path, string $tempName, string $extension) : string
{ {
$rnd = ''; $rnd = '';
$limit = -1; $limit = -1;
$fileName = '';
$nameWithoutExtension = empty($tempName) ? '' : \substr($tempName, 0, -\strlen($extension) - 1); $nameWithoutExtension = empty($tempName) ? '' : \substr($tempName, 0, -\strlen($extension) - 1);
@ -311,6 +318,8 @@ class UploadFile
*/ */
private function findOutputDir() : string private function findOutputDir() : string
{ {
$rndPath = '';
do { do {
$rndPath = \str_pad(\dechex(\mt_rand(0, 65535)), 4, '0', \STR_PAD_LEFT); $rndPath = \str_pad(\dechex(\mt_rand(0, 65535)), 4, '0', \STR_PAD_LEFT);
} while (\is_dir($this->outputDir . '/_' . $rndPath)); } while (\is_dir($this->outputDir . '/_' . $rndPath));

View File

@ -47,4 +47,6 @@ abstract class UploadStatus extends Enum
public const FAILED_HASHING = -9; public const FAILED_HASHING = -9;
public const NOT_ENCRYPTABLE = -10; public const NOT_ENCRYPTABLE = -10;
public const FILE_NOT_FOUND = -11;
} }

View File

@ -18,6 +18,6 @@ use \phpOMS\Uri\UriFactory;
<section id="mediaFile" class="portlet"> <section id="mediaFile" class="portlet">
<div class="portlet-body"> <div class="portlet-body">
<iframe style="min-height: 600px;" data-form="iUiSettings" data-name="iframeHelper" id="iHelperFrame" src="<?= UriFactory::build('{/backend}Resources/mozilla/Pdf/web/viewer.html?{?}&file=' . ($this->media->isAbsolute ? '' : '/../../../../') . $this->media->getPath()); ?>" allowfullscreen></iframe> <iframe style="min-height: 600px;" data-form="iUiSettings" data-name="iframeHelper" id="iHelperFrame" src="<?= UriFactory::build('{/backend}Resources/mozilla/Pdf/web/viewer.html?{?}&file=' . \urlencode(($this->media->isAbsolute ? '' : '/../../../../') . $this->media->getPath())); ?>" allowfullscreen></iframe>
</div> </div>
</section> </section>

View File

@ -42,8 +42,8 @@ return ['Media' => [
'Select' => 'Select', 'Select' => 'Select',
'Settings' => 'Settings', 'Settings' => 'Settings',
'Size' => 'Size', 'Size' => 'Size',
'Tag' => '', 'Tag' => 'Tag',
'Tags' => '', 'Tags' => 'Tags',
'Type' => 'Type', 'Type' => 'Type',
'Upload' => 'Upload', 'Upload' => 'Upload',
'VirtualPath' => 'Virtual Path', 'VirtualPath' => 'Virtual Path',