mirror of
https://github.com/Karaka-Management/oms-Media.git
synced 2026-05-20 03:48:41 +00:00
phpcs fixes
This commit is contained in:
parent
a429af8002
commit
5700c30859
|
|
@ -175,6 +175,17 @@ final class ApiController extends Controller
|
|||
return $mediaCreated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create db entry for uploaded file
|
||||
*
|
||||
* @param array $status Files
|
||||
* @param int $account Uploader
|
||||
* @param string $virtualPath Virtual path (not on the hard-drive)
|
||||
*
|
||||
* @return null|Media
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function createDbEntry(array $status, int $account, string $virtualPath = '/') : ?Media
|
||||
{
|
||||
$media = null;
|
||||
|
|
@ -195,6 +206,15 @@ final class ApiController extends Controller
|
|||
return $media;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize the file path
|
||||
*
|
||||
* @param string $path Path to the file
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static function normalizeDbPath(string $path) : string
|
||||
{
|
||||
$realpath = \realpath(__DIR__ . '/../../../');
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
|
|
@ -9,4 +9,6 @@
|
|||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/ // TODO: implement file storage interface
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
// TODO: implement file storage interface
|
||||
|
|
|
|||
|
|
@ -21,8 +21,10 @@ use phpOMS\Message\ResponseAbstract;
|
|||
/**
|
||||
* Options trait.
|
||||
*
|
||||
* @package Modules\Media\Models
|
||||
* @since 1.0.0
|
||||
* @package Modules\Media\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
trait FileUploaderTrait
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
|
|
@ -9,4 +9,6 @@
|
|||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/ // TODO: implement filestorage on remote ftp server
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
// TODO: implement filestorage on remote ftp server
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
|
|
@ -9,4 +9,6 @@
|
|||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/ // TODO: implement local file storage
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
// TODO: implement local file storage
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ class Media implements \JsonSerializable
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected string $description = '';
|
||||
protected string $description = '';
|
||||
|
||||
/**
|
||||
* Media Description.
|
||||
|
|
@ -149,11 +149,31 @@ class Media implements \JsonSerializable
|
|||
return $this->id;
|
||||
}
|
||||
|
||||
public function encrypt(string $password, string $outputPath) : void
|
||||
/**
|
||||
* Encrypt the media file
|
||||
*
|
||||
* @param string $password Password to encrypt the file with
|
||||
* @param null|string $outputPath Output path of the encryption (null = replace file)
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function encrypt(string $password, string $outputPath = null) : void
|
||||
{
|
||||
// todo: implement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypt the media file
|
||||
*
|
||||
* @param string $password Password to encrypt the file with
|
||||
* @param null|string $outputPath Output path of the encryption (null = replace file)
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function decrypt(string $password, string $outputPath) : string
|
||||
{
|
||||
// todo: implement;
|
||||
|
|
|
|||
|
|
@ -179,6 +179,7 @@ class UploadFile
|
|||
return $result;
|
||||
}
|
||||
|
||||
/*
|
||||
if ($this->isInterlaced && \in_array($extension, FileUtils::IMAGE_EXTENSION)) {
|
||||
// todo: interlacing somehow messes up some images (tested with logo.png from assets)
|
||||
//$this->interlace($extension, $dest);
|
||||
|
|
@ -187,7 +188,7 @@ class UploadFile
|
|||
if ($encoding !== '') {
|
||||
// changing encoding bugs out image files
|
||||
//FileUtils::changeFileEncoding($dest, $encoding);
|
||||
}
|
||||
}*/
|
||||
|
||||
$result[$key]['path'] = \realpath($this->outputDir);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
|
|
@ -10,6 +10,8 @@
|
|||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
return ['Navigation' => [
|
||||
'Create' => 'Create',
|
||||
'List' => 'List',
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
|
|
@ -10,6 +10,8 @@
|
|||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
$MODLANG[1] = [
|
||||
'i:ModuleInstalled' => 'Installation of the module {$1} was successful.',
|
||||
];
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
|
|
@ -10,6 +10,8 @@
|
|||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
return ['Media' => [
|
||||
'Account' => 'Account',
|
||||
'Author' => 'Author',
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
|
|
@ -10,6 +10,8 @@
|
|||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @var \phpOMS\Views\View $this
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
|
|
@ -10,6 +10,8 @@
|
|||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
include __DIR__ . '/template-functions.php';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
|
|
@ -10,6 +10,8 @@
|
|||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
use \phpOMS\System\File\FileUtils;
|
||||
use \phpOMS\System\File\Local\File;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,16 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.4
|
||||
*
|
||||
* @package Modules\HumanResourceManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use \phpOMS\System\File\ExtensionType;
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,16 @@ use phpOMS\Views\View;
|
|||
*/
|
||||
class MediaView extends View
|
||||
{
|
||||
/**
|
||||
* Get file path
|
||||
*
|
||||
* @param Media $media Media file
|
||||
* @param string $sub Sub path
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected function filePathFunction(Media $media, string $sub) : string
|
||||
{
|
||||
if (\is_file($media->getPath() . $sub)
|
||||
|
|
@ -46,6 +56,16 @@ class MediaView extends View
|
|||
return $media->getPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get directory path
|
||||
*
|
||||
* @param Media $media Media file
|
||||
* @param string $sub Sub path
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected function dirPathFunction(Media $media, string $sub) : string
|
||||
{
|
||||
if (\is_dir($media->getPath() . $sub)
|
||||
|
|
@ -60,6 +80,16 @@ class MediaView extends View
|
|||
return $media->getPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if media file is a collection
|
||||
*
|
||||
* @param Media $media Media file
|
||||
* @param string $sub Sub path
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected function isCollectionFunction(Media $media, string $sub) : bool
|
||||
{
|
||||
return ($media->getExtension() === 'collection'
|
||||
|
|
@ -69,6 +99,15 @@ class MediaView extends View
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file content
|
||||
*
|
||||
* @param string $path File path
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected function getFileContent(string $path) : string
|
||||
{
|
||||
$output = \file_get_contents($path);
|
||||
|
|
@ -77,6 +116,15 @@ class MediaView extends View
|
|||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file content
|
||||
*
|
||||
* @param string $path File path
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected function lineContentFunction(string $path) : array
|
||||
{
|
||||
$output = \file_get_contents($path);
|
||||
|
|
@ -85,12 +133,32 @@ class MediaView extends View
|
|||
return \explode("\n", $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if media file is image file
|
||||
*
|
||||
* @param Media $media Media file
|
||||
* @param string $path File path
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected function isImageFile(Media $media, string $path) : bool
|
||||
{
|
||||
return FileUtils::getExtensionType($media->getExtension()) === ExtensionType::IMAGE
|
||||
|| FileUtils::getExtensionType(File::extension($path)) === ExtensionType::IMAGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if media file is text file
|
||||
*
|
||||
* @param Media $media Media file
|
||||
* @param string $path File path
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected function isTextFile(Media $media, string $path) : bool
|
||||
{
|
||||
$mediaExtension = FileUtils::getExtensionType($media->getExtension());
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user