autofixes

This commit is contained in:
Dennis Eichhorn 2020-08-30 20:13:11 +02:00
parent aaa4de2adc
commit 4ea01e2175
15 changed files with 76 additions and 62 deletions

View File

@ -28,7 +28,6 @@ use phpOMS\Message\ResponseAbstract;
*/
trait FileUploaderTrait
{
/**
* Setup file uploader.
*

View File

@ -340,7 +340,7 @@ class Media implements \JsonSerializable
return $this->isAbsolute ? $this->path : \ltrim($this->path, '\\/');
}
/**
/**
* @return string
*
* @since 1.0.0

View File

@ -27,6 +27,8 @@ use phpOMS\Stdlib\Base\Enum;
abstract class PathSettings extends Enum
{
public const FILE_PATH = 1;
public const RANDOM_PATH = 2;
public const COLLECTION_PATH = 3;
}

View File

@ -27,5 +27,6 @@ use phpOMS\Stdlib\Base\Enum;
abstract class PermissionState extends Enum
{
public const MEDIA = 1;
public const COLLECTION = 2;
}

View File

@ -27,14 +27,24 @@ use phpOMS\Stdlib\Base\Enum;
abstract class UploadStatus extends Enum
{
public const OK = 0;
public const WRONG_PARAMETERS = -1;
public const NOTHING_UPLOADED = -2;
public const UPLOAD_SIZE = -3;
public const UNKNOWN_ERROR = -4;
public const CONFIG_SIZE = -5;
public const WRONG_EXTENSION = -6;
public const NOT_UPLOADED = -7;
public const NOT_MOVABLE = -8;
public const FAILED_HASHING = -9;
public const NOT_ENCRYPTABLE = -10;
}

View File

@ -38,7 +38,7 @@
</div>
</span>
</div>
<div class="ipt-second"><button><?= $this->getHtml('Select', 'Media') ?></button></div>
<div class="ipt-second"><button><?= $this->getHtml('Select', 'Media'); ?></button></div>
</div>
<div class="box" id="<?= $this->printHtml($this->getId()); ?>-tags" data-limit="0" data-active="true">
<template id="<?= $this->printHtml($this->getId()); ?>-tagTemplate">

View File

@ -5,15 +5,15 @@ use phpOMS\Uri\UriFactory;
?>
<div class="portlet">
<div class="portlet-head"><?= $this->getHtml('Media', 'Media') ?><i class="fa fa-download floatRight download btn"></i></div>
<div class="portlet-head"><?= $this->getHtml('Media', 'Media'); ?><i class="fa fa-download floatRight download btn"></i></div>
<table class="default">
<thead>
<td>
<td class="wf-100"><?= $this->getHtml('Name', 'Media') ?>
<td><?= $this->getHtml('Type', 'Media') ?>
<td><?= $this->getHtml('Size', 'Media') ?>
<td><?= $this->getHtml('Creator', 'Media') ?>
<td><?= $this->getHtml('Created', 'Media') ?>
<td class="wf-100"><?= $this->getHtml('Name', 'Media'); ?>
<td><?= $this->getHtml('Type', 'Media'); ?>
<td><?= $this->getHtml('Size', 'Media'); ?>
<td><?= $this->getHtml('Creator', 'Media'); ?>
<td><?= $this->getHtml('Created', 'Media'); ?>
<tbody>
<?php $count = 0; foreach ($this->media as $key => $value) : ++$count;
$url = UriFactory::build('{/prefix}media/single?{?}&id=' . $value->getId());
@ -46,12 +46,12 @@ use phpOMS\Uri\UriFactory;
}
?>
<tr data-href="<?= $url; ?>">
<td data-label="<?= $this->getHtml('Type') ?>"><a href="<?= $url; ?>"><i class="fa fa-<?= $this->printHtml($icon); ?>"></i></a>
<td data-label="<?= $this->getHtml('Name') ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getName()); ?></a>
<td data-label="<?= $this->getHtml('Extension') ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getExtension()); ?></a>
<td data-label="<?= $this->getHtml('Size') ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getSize()); ?></a>
<td data-label="<?= $this->getHtml('Creator') ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getCreatedBy()->getName1()); ?></a>
<td data-label="<?= $this->getHtml('Created') ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getCreatedAt()->format('Y-m-d H:i:s')); ?></a>
<td data-label="<?= $this->getHtml('Type'); ?>"><a href="<?= $url; ?>"><i class="fa fa-<?= $this->printHtml($icon); ?>"></i></a>
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getName()); ?></a>
<td data-label="<?= $this->getHtml('Extension'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getExtension()); ?></a>
<td data-label="<?= $this->getHtml('Size'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getSize()); ?></a>
<td data-label="<?= $this->getHtml('Creator'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getCreatedBy()->getName1()); ?></a>
<td data-label="<?= $this->getHtml('Created'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getCreatedAt()->format('Y-m-d H:i:s')); ?></a>
<?php endforeach; ?>
<?php if ($count === 0) : ?>
<tr><td colspan="6" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>

View File

@ -8,7 +8,7 @@
<div class="portlet-body">
<table class="layout wf-100">
<tbody>
<tr><td><label for="iMedia"><?= $this->getHtml('Media') ?></label>
<tr><td><label for="iMedia"><?= $this->getHtml('Media'); ?></label>
<tr><td>
<div class="ipt-wrap">
<div class="ipt-first">
@ -37,9 +37,9 @@
</div>
</div>
</div>
<div class="ipt-second"><button><?= $this->getHtml('Select', 'Media') ?></button></div>
<div class="ipt-second"><button><?= $this->getHtml('Select', 'Media'); ?></button></div>
</div>
<tr><td><label for="iUpload"><?= $this->getHtml('Upload', 'Media') ?></label>
<tr><td><label for="iUpload"><?= $this->getHtml('Upload', 'Media'); ?></label>
<tr><td>
<input type="hidden" name="virtualPath" form="<?= $this->form; ?>" value="<?= $this->virtualPath; ?>">
<input type="file" id="iUpload" name="upload" form="<?= $this->form; ?>" multiple>

View File

@ -36,21 +36,21 @@ use phpOMS\Uri\UriFactory;
<div class="col-xs-12 col-md-6">
<form method="PUT" id="media-uploader" action="<?= UriFactory::build('{/api}media/collection'); ?>">
<div class="portlet">
<div class="portlet-head"><?= $this->getHtml('CreateCollection') ?></div>
<div class="portlet-head"><?= $this->getHtml('CreateCollection'); ?></div>
<div class="portlet-body">
<table class="layout wf-100">
<tr><td><label for="iVirtualPath"><?= $this->getHtml('VirtualPath') ?></label>
<tr><td><label for="iVirtualPath"><?= $this->getHtml('VirtualPath'); ?></label>
<tr><td><input type="text" id="iVirtualPath" name="virtualPath" value="<?= empty($this->request->getUri()->getQuery('path')) ? '/' : $this->request->getUri()->getQuery('path'); ?>" disabled>
<tr><td><label for="iPath"><?= $this->getHtml('Path') ?></label>
<tr><td><label for="iPath"><?= $this->getHtml('Path'); ?></label>
<tr><td><input type="text" id="iPath" name="path" value="<?= empty($this->request->getUri()->getQuery('path')) ? '/' : $this->request->getUri()->getQuery('path'); ?>">
<tr><td><label><?= $this->getHtml('Settings') ?></label>
<tr><td><label><?= $this->getHtml('Settings'); ?></label>
<tr><td>
<label class="checkbox" for="iAddCollection">
<input type="checkbox" id="iAddCollection" name="addcollection" checked>
<span class="checkmark"></span>
<?= $this->getHtml('AddToCollection') ?>
<?= $this->getHtml('AddToCollection'); ?>
</label>
<tr><td><label for="iName"><?= $this->getHtml('Name') ?></label>
<tr><td><label for="iName"><?= $this->getHtml('Name'); ?></label>
<tr><td><input type="text" id="iName" name="name" multiple>
</table>
</div>

View File

@ -47,21 +47,21 @@ use phpOMS\Uri\UriFactory;
<div class="portlet-head"><?= $this->getHtml('Settings'); ?></div>
<div class="portlet-body">
<table class="layout wf-100">
<tr><td><label for="iVirtualPath"><?= $this->getHtml('VirtualPath') ?></label>
<tr><td><label for="iVirtualPath"><?= $this->getHtml('VirtualPath'); ?></label>
<tr><td><input type="text" id="iVirtualPath" name="virtualPath" value="<?= empty($this->request->getUri()->getQuery('path')) ? '/' : $this->request->getUri()->getQuery('path'); ?>" disabled>
<tr><td><label for="iPath"><?= $this->getHtml('Path') ?></label>
<tr><td><label for="iPath"><?= $this->getHtml('Path'); ?></label>
<tr><td><input type="text" id="iPath" name="path" value="<?= empty($this->request->getUri()->getQuery('path')) ? '/' : $this->request->getUri()->getQuery('path'); ?>">
<tr><td><label><?= $this->getHtml('Settings') ?></label>
<tr><td><label><?= $this->getHtml('Settings'); ?></label>
<tr><td>
<label class="checkbox" for="iAddCollection">
<input type="checkbox" id="iAddCollection" name="addcollection" checked>
<span class="checkmark"></span>
<?= $this->getHtml('AddToCollection') ?>
<?= $this->getHtml('AddToCollection'); ?>
</label>
</table>
</div>
<div class="portlet-foot">
<input type="submit" value="<?= $this->getHtml('Save', '0', '0') ?>">
<input type="submit" value="<?= $this->getHtml('Save', '0', '0'); ?>">
</div>
</form>
</div>

View File

@ -61,7 +61,7 @@ $next = empty($media) ? '{/prefix}media/list' : '{/prefix}media/list?{?}&id=
$url = UriFactory::build('{/prefix}media/list?path=' . $subPath);
?>
<li data-href="<?= $url; ?>"<?= $i === $length - 1 ? 'class="active"' : '' ?>><a href="<?= $url; ?>"><?= $this->printHtml($paths[$i]); ?></a></li>
<li data-href="<?= $url; ?>"<?= $i === $length - 1 ? 'class="active"' : ''; ?>><a href="<?= $url; ?>"><?= $this->printHtml($paths[$i]); ?></a></li>
<?php endfor; ?>
</ul>
</div>
@ -71,16 +71,16 @@ $next = empty($media) ? '{/prefix}media/list' : '{/prefix}media/list?{?}&id=
<div class="row">
<div class="col-xs-12">
<div class="portlet">
<div class="portlet-head"><?= $this->getHtml('Media') ?><i class="fa fa-download floatRight download btn"></i></div>
<div class="portlet-head"><?= $this->getHtml('Media'); ?><i class="fa fa-download floatRight download btn"></i></div>
<table id="mediaList" class="default">
<thead>
<tr>
<td>
<td class="wf-100"><?= $this->getHtml('Name') ?>
<td><?= $this->getHtml('Type') ?>
<td><?= $this->getHtml('Size') ?>
<td><?= $this->getHtml('Creator') ?>
<td><?= $this->getHtml('Created') ?>
<td class="wf-100"><?= $this->getHtml('Name'); ?>
<td><?= $this->getHtml('Type'); ?>
<td><?= $this->getHtml('Size'); ?>
<td><?= $this->getHtml('Creator'); ?>
<td><?= $this->getHtml('Created'); ?>
<tbody>
<?php $count = 0;
foreach ($media as $key => $value) :
@ -99,18 +99,18 @@ $next = empty($media) ? '{/prefix}media/list' : '{/prefix}media/list?{?}&id=
$icon = $fileIconFunction(FileUtils::getExtensionType($value->getExtension()));
?>
<tr tabindex="0" data-href="<?= $url; ?>">
<td data-label="<?= $this->getHtml('Type') ?>"><a href="<?= $url; ?>"><i class="fa fa-<?= $this->printHtml($icon); ?>"></i></a>
<td data-label="<?= $this->getHtml('Name') ?>"><a href="<?= $url; ?>">
<td data-label="<?= $this->getHtml('Type'); ?>"><a href="<?= $url; ?>"><i class="fa fa-<?= $this->printHtml($icon); ?>"></i></a>
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>">
<?= $this->printHtml(
$value->getExtension() !== 'collection'
? $value->getName() . (
$value->getExtension() !== '' ? '.' . $value->getExtension() : ''
) : $value->getName()); ?>
</a>
<td data-label="<?= $this->getHtml('Extension') ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getExtension()); ?></a>
<td data-label="<?= $this->getHtml('Size') ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getSize()); ?></a>
<td data-label="<?= $this->getHtml('Creator') ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getCreatedBy()->getName1()); ?></a>
<td data-label="<?= $this->getHtml('Created') ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getCreatedAt()->format('Y-m-d H:i:s')); ?></a>
<td data-label="<?= $this->getHtml('Extension'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getExtension()); ?></a>
<td data-label="<?= $this->getHtml('Size'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getSize()); ?></a>
<td data-label="<?= $this->getHtml('Creator'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getCreatedBy()->getName1()); ?></a>
<td data-label="<?= $this->getHtml('Created'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getCreatedAt()->format('Y-m-d H:i:s')); ?></a>
<?php endforeach; ?>
<?php if ($count === 0) : ?>
<tr><td colspan="6" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>

View File

@ -43,11 +43,11 @@ echo $this->getData('nav')->render();
<div class="portlet-body">
<table class="list w-100">
<tbody>
<tr><td><?= $this->getHtml('Name') ?><td class="wf-100"><?= $this->printHtml($media->getName()); ?>
<tr><td><?= $this->getHtml('Size') ?><td class="wf-100"><?= $this->printHtml($media->getSize()); ?>
<tr><td><?= $this->getHtml('Created') ?><td><?= $this->printHtml($media->getCreatedAt()->format('Y-m-d')); ?>
<tr><td><?= $this->getHtml('Creator') ?><td><?= $this->printHtml($media->getCreatedBy()->getName1()); ?>
<tr><td colspan="2"><?= $this->getHtml('Description') ?>
<tr><td><?= $this->getHtml('Name'); ?><td class="wf-100"><?= $this->printHtml($media->getName()); ?>
<tr><td><?= $this->getHtml('Size'); ?><td class="wf-100"><?= $this->printHtml($media->getSize()); ?>
<tr><td><?= $this->getHtml('Created'); ?><td><?= $this->printHtml($media->getCreatedAt()->format('Y-m-d')); ?>
<tr><td><?= $this->getHtml('Creator'); ?><td><?= $this->printHtml($media->getCreatedBy()->getName1()); ?>
<tr><td colspan="2"><?= $this->getHtml('Description'); ?>
<tr><td colspan="2"><?= $media->getDescription(); ?>
</table>
</div>
@ -61,9 +61,9 @@ echo $this->getData('nav')->render();
data-tag="form"
data-method="POST"
data-uri="<?= UriFactory::build('{/api}media?{?}&csrf={$CSRF}'); ?>">
<button class="save hidden"><?= $this->getHtml('Save', '0', '0') ?></button>
<button class="cancel hidden"><?= $this->getHtml('Cancel', '0', '0') ?></button>
<button class="update"><?= $this->getHtml('Edit', '0', '0') ?></button>
<button class="save hidden"><?= $this->getHtml('Save', '0', '0'); ?></button>
<button class="cancel hidden"><?= $this->getHtml('Cancel', '0', '0'); ?></button>
<button class="update"><?= $this->getHtml('Edit', '0', '0'); ?></button>
</div>
<?php endif; ?>
</section>
@ -75,15 +75,15 @@ echo $this->getData('nav')->render();
<div class="col-xs-12">
<section class="portlet">
<table class="default">
<caption><?= $this->getHtml('Media') ?><i class="fa fa-download floatRight download btn"></i></caption>
<caption><?= $this->getHtml('Media'); ?><i class="fa fa-download floatRight download btn"></i></caption>
<thead>
<tr>
<td>
<td class="wf-100"><?= $this->getHtml('Name') ?>
<td><?= $this->getHtml('Type') ?>
<td><?= $this->getHtml('Size') ?>
<td><?= $this->getHtml('Creator') ?>
<td><?= $this->getHtml('Created') ?>
<td class="wf-100"><?= $this->getHtml('Name'); ?>
<td><?= $this->getHtml('Type'); ?>
<td><?= $this->getHtml('Size'); ?>
<td><?= $this->getHtml('Creator'); ?>
<td><?= $this->getHtml('Created'); ?>
<tbody>
<?php
if (!\is_dir($media->isAbsolute() ? $media->getPath() : __DIR__ . '/../../../../' . \ltrim($media->getPath(), '//'))

View File

@ -36,21 +36,21 @@ use phpOMS\Uri\UriFactory;
<div class="col-xs-12 col-md-6">
<form method="PUT" id="media-uploader" action="<?= UriFactory::build('{/api}media'); ?>">
<div class="portlet">
<div class="portlet-head"><?= $this->getHtml('Upload') ?></div>
<div class="portlet-head"><?= $this->getHtml('Upload'); ?></div>
<div class="portlet-body">
<table class="layout wf-100">
<tr><td><label for="iVirtualPath"><?= $this->getHtml('VirtualPath') ?></label>
<tr><td><label for="iVirtualPath"><?= $this->getHtml('VirtualPath'); ?></label>
<tr><td><input type="text" id="iVirtualPath" name="virtualPath" value="<?= empty($this->request->getUri()->getQuery('path')) ? '/' : $this->request->getUri()->getQuery('path'); ?>" disabled>
<tr><td><label for="iPath"><?= $this->getHtml('Path') ?></label>
<tr><td><label for="iPath"><?= $this->getHtml('Path'); ?></label>
<tr><td><input type="text" id="iPath" name="path" value="<?= empty($this->request->getUri()->getQuery('path')) ? '/' : $this->request->getUri()->getQuery('path'); ?>">
<tr><td><label><?= $this->getHtml('Settings') ?></label>
<tr><td><label><?= $this->getHtml('Settings'); ?></label>
<tr><td>
<label class="checkbox" for="iAddCollection">
<input type="checkbox" id="iAddCollection" name="addcollection" checked>
<span class="checkmark"></span>
<?= $this->getHtml('AddToCollection') ?>
<?= $this->getHtml('AddToCollection'); ?>
</label>
<tr><td><label for="iFiles"><?= $this->getHtml('Files') ?></label>
<tr><td><label for="iFiles"><?= $this->getHtml('Files'); ?></label>
<tr><td><input type="file" id="iFiles" name="files" multiple>
</table>
</div>

View File

@ -20,6 +20,7 @@ namespace Modules\Media\tests\Admin;
class AdminTest extends \PHPUnit\Framework\TestCase
{
protected const MODULE_NAME = 'Media';
protected const URI_LOAD = 'http://127.0.0.1/en/backend/media';
use \Modules\tests\ModuleTestTrait;

View File

@ -30,6 +30,7 @@ use phpOMS\Router\WebRouter;
class ApiControllerTest extends \PHPUnit\Framework\TestCase
{
protected $app = null;
protected $module = null;
protected function setUp() : void