phpcs fixes

This commit is contained in:
Dennis Eichhorn 2019-10-06 17:50:12 +02:00
parent a429af8002
commit 5700c30859
15 changed files with 159 additions and 18 deletions

View File

@ -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__ . '/../../../');

View File

@ -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

View File

@ -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
{

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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);
}

View File

@ -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',

View File

@ -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.',
];

View File

@ -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',

View File

@ -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
*/

View File

@ -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';

View File

@ -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;

View 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;

View File

@ -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());