mirror of
https://github.com/Karaka-Management/oms-Media.git
synced 2026-01-24 06:48:41 +00:00
php cs fixer
This commit is contained in:
parent
6926c00775
commit
3d65a24d33
|
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
use Modules\Media\Controller\ApiController;
|
||||
use Modules\Media\Models\PermissionState;
|
||||
|
|
@ -18,7 +18,7 @@ return [
|
|||
'data' => [
|
||||
'field_name' => [
|
||||
'type' => 'string', 'default' => 'Hello', 'validation' => '[\\w]*', 'required' => false,'annotation' => [],
|
||||
]
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
use Modules\Media\Controller\BackendController;
|
||||
use Modules\Media\Models\PermissionState;
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@ namespace Modules\Media\Controller;
|
|||
|
||||
use Modules\Media\Models\Media;
|
||||
use Modules\Media\Models\MediaMapper;
|
||||
use Modules\Media\Models\Collection;
|
||||
use Modules\Media\Models\CollectionMapper;
|
||||
use Modules\Media\Models\UploadFile;
|
||||
use Modules\Media\Models\UploadStatus;
|
||||
use phpOMS\Message\NotificationLevel;
|
||||
|
|
@ -128,7 +126,7 @@ final class ApiController extends Controller
|
|||
*/
|
||||
public static function createMediaPath(string $basePath = 'Modules/Media/Files') : string
|
||||
{
|
||||
$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);
|
||||
return $basePath . '/' . $rndPath[0] . $rndPath[1] . '/' . $rndPath[2] . $rndPath[3];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ class UploadFile
|
|||
{
|
||||
$result = [];
|
||||
|
||||
if (\count($files) === \count($files, COUNT_RECURSIVE)) {
|
||||
if (\count($files) === \count($files, \COUNT_RECURSIVE)) {
|
||||
$files = [$files];
|
||||
}
|
||||
|
||||
|
|
@ -120,7 +120,7 @@ class UploadFile
|
|||
$result[$key]['status'] = UploadStatus::WRONG_PARAMETERS;
|
||||
|
||||
return $result;
|
||||
} elseif ($f['error'] !== UPLOAD_ERR_OK) {
|
||||
} elseif ($f['error'] !== \UPLOAD_ERR_OK) {
|
||||
$result[$key]['status'] = $this->getUploadError($f['error']);
|
||||
|
||||
return $result;
|
||||
|
|
@ -223,7 +223,7 @@ class UploadFile
|
|||
$sha .= '.' . $extension;
|
||||
$fileName = $sha;
|
||||
$rnd = \mt_rand();
|
||||
$limit++;
|
||||
++$limit;
|
||||
} while (\file_exists($path . '/' . $fileName) && $limit < self::PATH_GENERATION_LIMIT);
|
||||
|
||||
if ($limit >= self::PATH_GENERATION_LIMIT) {
|
||||
|
|
@ -282,7 +282,7 @@ class UploadFile
|
|||
private function findOutputDir(array $files) : string
|
||||
{
|
||||
do {
|
||||
$rndPath = \str_pad(\dechex(\rand(0, 65535)), 4, '0', STR_PAD_LEFT);
|
||||
$rndPath = \str_pad(\dechex(\mt_rand(0, 65535)), 4, '0', \STR_PAD_LEFT);
|
||||
} while (\file_exists($this->outputDir . '/' . $rndPath));
|
||||
|
||||
return $this->outputDir . '/' . $rndPath;
|
||||
|
|
@ -300,11 +300,11 @@ class UploadFile
|
|||
private function getUploadError($error) : int
|
||||
{
|
||||
switch ($error) {
|
||||
case UPLOAD_ERR_NO_FILE:
|
||||
case \UPLOAD_ERR_NO_FILE:
|
||||
// TODO: no file sent
|
||||
return UploadStatus::NOTHING_UPLOADED;
|
||||
case UPLOAD_ERR_INI_SIZE:
|
||||
case UPLOAD_ERR_FORM_SIZE:
|
||||
case \UPLOAD_ERR_INI_SIZE:
|
||||
case \UPLOAD_ERR_FORM_SIZE:
|
||||
return UploadStatus::UPLOAD_SIZE;
|
||||
default:
|
||||
return UploadStatus::UNKNOWN_ERROR;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
|
|
@ -19,7 +19,7 @@ include __DIR__ . '/template-functions.php';
|
|||
|
||||
/**
|
||||
* @var \phpOMS\Views\View $this
|
||||
* @var $media \Modules\Media\Models\Media
|
||||
* @var $media \Modules\Media\Models\Media
|
||||
*/
|
||||
$media = $this->getData('media');
|
||||
echo $this->getData('nav')->render();
|
||||
|
|
|
|||
|
|
@ -1,30 +1,30 @@
|
|||
<?php
|
||||
|
||||
use \phpOMS\System\File\ExtensionType;
|
||||
|
||||
$fileIconFunction = function (int $extensionType) : string
|
||||
{
|
||||
if ($extensionType === ExtensionType::CODE) {
|
||||
return 'file-code-o';
|
||||
} elseif ($extensionType === ExtensionType::TEXT) {
|
||||
return 'file-text-o';
|
||||
} elseif ($extensionType === ExtensionType::PRESENTATION) {
|
||||
return 'file-powerpoint-o';
|
||||
} elseif ($extensionType === ExtensionType::PDF) {
|
||||
return 'file-pdf-o';
|
||||
} elseif ($extensionType === ExtensionType::ARCHIVE) {
|
||||
return 'file-zip-o';
|
||||
} elseif ($extensionType === ExtensionType::AUDIO) {
|
||||
return 'file-audio-o';
|
||||
} elseif ($extensionType === ExtensionType::VIDEO) {
|
||||
return 'file-video-o';
|
||||
} elseif ($extensionType === ExtensionType::IMAGE) {
|
||||
return 'file-image-o';
|
||||
} elseif ($extensionType === ExtensionType::SPREADSHEET) {
|
||||
return 'file-excel-o';
|
||||
} elseif ($extensionType === 'collection') {
|
||||
return 'folder-open-o';
|
||||
}
|
||||
|
||||
return 'file-o';
|
||||
};
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
use \phpOMS\System\File\ExtensionType;
|
||||
|
||||
$fileIconFunction = function (int $extensionType) : string
|
||||
{
|
||||
if ($extensionType === ExtensionType::CODE) {
|
||||
return 'file-code-o';
|
||||
} elseif ($extensionType === ExtensionType::TEXT) {
|
||||
return 'file-text-o';
|
||||
} elseif ($extensionType === ExtensionType::PRESENTATION) {
|
||||
return 'file-powerpoint-o';
|
||||
} elseif ($extensionType === ExtensionType::PDF) {
|
||||
return 'file-pdf-o';
|
||||
} elseif ($extensionType === ExtensionType::ARCHIVE) {
|
||||
return 'file-zip-o';
|
||||
} elseif ($extensionType === ExtensionType::AUDIO) {
|
||||
return 'file-audio-o';
|
||||
} elseif ($extensionType === ExtensionType::VIDEO) {
|
||||
return 'file-video-o';
|
||||
} elseif ($extensionType === ExtensionType::IMAGE) {
|
||||
return 'file-image-o';
|
||||
} elseif ($extensionType === ExtensionType::SPREADSHEET) {
|
||||
return 'file-excel-o';
|
||||
} elseif ($extensionType === 'collection') {
|
||||
return 'folder-open-o';
|
||||
}
|
||||
|
||||
return 'file-o';
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,85 +1,85 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.2
|
||||
*
|
||||
* @package Modules\Media\Views
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://website.orange-management.de
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Media\Views;
|
||||
|
||||
use Modules\Media\Models\Media;
|
||||
use phpOMS\System\File\ExtensionType;
|
||||
use phpOMS\System\File\FileUtils;
|
||||
use phpOMS\System\File\Local\File;
|
||||
use phpOMS\Utils\StringUtils;
|
||||
|
||||
use phpOMS\Views\View;
|
||||
|
||||
/**
|
||||
* Media view.
|
||||
*
|
||||
* @package Modules\Media\Views
|
||||
* @license OMS License 1.0
|
||||
* @link http://website.orange-management.de
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class MediaView extends View
|
||||
{
|
||||
protected function filePathFunction(Media $media, string $sub) : string
|
||||
{
|
||||
if (\is_file($media->getPath() . $sub)
|
||||
&& StringUtils::startsWith(
|
||||
\str_replace('\\', '/', \realpath($media->getPath() . $sub)),
|
||||
$media->getPath()
|
||||
)
|
||||
) {
|
||||
return $media->getPath() . $sub;
|
||||
}
|
||||
|
||||
return $media->getPath();
|
||||
}
|
||||
|
||||
protected function dirPathFunction(Media $media, string $sub) : string
|
||||
{
|
||||
if (\is_dir($media->getPath() . $sub)
|
||||
&& StringUtils::startsWith(
|
||||
\str_replace('\\', '/', \realpath($media->getPath() . $sub)),
|
||||
$media->getPath()
|
||||
)
|
||||
) {
|
||||
return $media->getPath() . $sub;
|
||||
}
|
||||
|
||||
return $media->getPath();
|
||||
}
|
||||
|
||||
protected function isCollectionFunction(Media $media, string $sub) : bool
|
||||
{
|
||||
return ($media->getExtension() === 'collection'
|
||||
&& !\is_file($media->getPath() . $sub))
|
||||
|| (\is_dir($media->getPath())
|
||||
&& ($sub === null || \is_dir($media->getPath() . $sub))
|
||||
);
|
||||
}
|
||||
|
||||
protected function lineContentFunction(string $path) : array
|
||||
{
|
||||
$output = \file_get_contents($path);
|
||||
$output = \str_replace(["\r\n", "\r"], "\n", $output);
|
||||
|
||||
return \explode("\n", $output);
|
||||
}
|
||||
|
||||
protected function isImageFunction(Media $media, string $path) : bool
|
||||
{
|
||||
return FileUtils::getExtensionType($media->getExtension()) === ExtensionType::IMAGE
|
||||
|| FileUtils::getExtensionType(File::extension($path)) === ExtensionType::IMAGE;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.2
|
||||
*
|
||||
* @package Modules\Media\Views
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://website.orange-management.de
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Media\Views;
|
||||
|
||||
use Modules\Media\Models\Media;
|
||||
use phpOMS\System\File\ExtensionType;
|
||||
use phpOMS\System\File\FileUtils;
|
||||
use phpOMS\System\File\Local\File;
|
||||
use phpOMS\Utils\StringUtils;
|
||||
|
||||
use phpOMS\Views\View;
|
||||
|
||||
/**
|
||||
* Media view.
|
||||
*
|
||||
* @package Modules\Media\Views
|
||||
* @license OMS License 1.0
|
||||
* @link http://website.orange-management.de
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class MediaView extends View
|
||||
{
|
||||
protected function filePathFunction(Media $media, string $sub) : string
|
||||
{
|
||||
if (\is_file($media->getPath() . $sub)
|
||||
&& StringUtils::startsWith(
|
||||
\str_replace('\\', '/', \realpath($media->getPath() . $sub)),
|
||||
$media->getPath()
|
||||
)
|
||||
) {
|
||||
return $media->getPath() . $sub;
|
||||
}
|
||||
|
||||
return $media->getPath();
|
||||
}
|
||||
|
||||
protected function dirPathFunction(Media $media, string $sub) : string
|
||||
{
|
||||
if (\is_dir($media->getPath() . $sub)
|
||||
&& StringUtils::startsWith(
|
||||
\str_replace('\\', '/', \realpath($media->getPath() . $sub)),
|
||||
$media->getPath()
|
||||
)
|
||||
) {
|
||||
return $media->getPath() . $sub;
|
||||
}
|
||||
|
||||
return $media->getPath();
|
||||
}
|
||||
|
||||
protected function isCollectionFunction(Media $media, string $sub) : bool
|
||||
{
|
||||
return ($media->getExtension() === 'collection'
|
||||
&& !\is_file($media->getPath() . $sub))
|
||||
|| (\is_dir($media->getPath())
|
||||
&& ($sub === null || \is_dir($media->getPath() . $sub))
|
||||
);
|
||||
}
|
||||
|
||||
protected function lineContentFunction(string $path) : array
|
||||
{
|
||||
$output = \file_get_contents($path);
|
||||
$output = \str_replace(["\r\n", "\r"], "\n", $output);
|
||||
|
||||
return \explode("\n", $output);
|
||||
}
|
||||
|
||||
protected function isImageFunction(Media $media, string $path) : bool
|
||||
{
|
||||
return FileUtils::getExtensionType($media->getExtension()) === ExtensionType::IMAGE
|
||||
|| FileUtils::getExtensionType(File::extension($path)) === ExtensionType::IMAGE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user