mirror of
https://github.com/Karaka-Management/oms-Media.git
synced 2026-02-16 01:08:41 +00:00
Went through todos
This commit is contained in:
parent
6a6580c470
commit
84f9e33f3f
|
|
@ -65,6 +65,22 @@ use phpOMS\Views\View;
|
||||||
* @license OMS License 2.0
|
* @license OMS License 2.0
|
||||||
* @link https://jingga.app
|
* @link https://jingga.app
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
*
|
||||||
|
* @feature Allow PDF modification (allow notes on PDF, approval stamps)
|
||||||
|
* This requires a JS live preview for adding this at a specific position (maybe PDFJSAnnotate, maybe customize PDF.js)
|
||||||
|
* https://github.com/Karaka-Management/oms-Billing/issues/11
|
||||||
|
*
|
||||||
|
* @feature Job/Schedule which checks unhandled invoices
|
||||||
|
* https://github.com/Karaka-Management/oms-Billing/issues/10
|
||||||
|
*
|
||||||
|
* @feature Allow to index a local file if it is not in the database
|
||||||
|
* E.g. button with text "Add to Application"
|
||||||
|
* Un-indexed files cannot be changed/moved/deleted.
|
||||||
|
* https://github.com/Karaka-Management/oms-Media/issues/18
|
||||||
|
*
|
||||||
|
* @feature Create preview option for images
|
||||||
|
* E.g. ctrl+mouse hover or a different "list-view" like in explorer
|
||||||
|
* https://github.com/Karaka-Management/oms-Media/issues/19
|
||||||
*/
|
*/
|
||||||
final class ApiController extends Controller
|
final class ApiController extends Controller
|
||||||
{
|
{
|
||||||
|
|
@ -358,6 +374,10 @@ final class ApiController extends Controller
|
||||||
|
|
||||||
$created = [];
|
$created = [];
|
||||||
foreach ($status as &$stat) {
|
foreach ($status as &$stat) {
|
||||||
|
if (!Guard::isSafeFile($stat['path'] . '/' . $stat['filename'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
++$nCounter;
|
++$nCounter;
|
||||||
|
|
||||||
// Possible: name != filename (name = database media name, filename = name on the file system)
|
// Possible: name != filename (name = database media name, filename = name on the file system)
|
||||||
|
|
@ -387,6 +407,10 @@ final class ApiController extends Controller
|
||||||
$created[] = $media;
|
$created[] = $media;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($created)) {
|
||||||
|
return new NullCollection();
|
||||||
|
}
|
||||||
|
|
||||||
if (!$createCollection) {
|
if (!$createCollection) {
|
||||||
$collection = new NullCollection();
|
$collection = new NullCollection();
|
||||||
$collection->sources = $created;
|
$collection->sources = $created;
|
||||||
|
|
|
||||||
|
|
@ -236,7 +236,11 @@ class Media implements \JsonSerializable
|
||||||
*/
|
*/
|
||||||
public function encrypt(string $key, ?string $outputPath = null) : bool
|
public function encrypt(string $key, ?string $outputPath = null) : bool
|
||||||
{
|
{
|
||||||
return EncryptionHelper::encryptFile($this->getAbsolutePath(), $outputPath ?? $this->getAbsolutePath(), $key);
|
return EncryptionHelper::encryptFile(
|
||||||
|
$this->getAbsolutePath(),
|
||||||
|
$outputPath ?? $this->getAbsolutePath(),
|
||||||
|
$key
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -251,7 +255,11 @@ class Media implements \JsonSerializable
|
||||||
*/
|
*/
|
||||||
public function decrypt(string $key, ?string $outputPath = null) : bool
|
public function decrypt(string $key, ?string $outputPath = null) : bool
|
||||||
{
|
{
|
||||||
return EncryptionHelper::decryptFile($this->getAbsolutePath(), $outputPath ?? $this->getAbsolutePath(), $key);
|
return EncryptionHelper::decryptFile(
|
||||||
|
$this->getAbsolutePath(),
|
||||||
|
$outputPath ?? $this->getAbsolutePath(),
|
||||||
|
$key
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,7 @@ class UploadFile
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!\is_dir($path) && !Directory::create($path, 0755, true)) {
|
if (!\is_dir($path) && !Directory::create($path, 0755, true)) {
|
||||||
FileLogger::getInstance()->error('Couldn\t upload media file. There maybe is a problem with your permission or uploaded file.');
|
FileLogger::getInstance()->error('Couldn\'t upload media file. There maybe is a problem with your permission or uploaded file.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!\rename($f['tmp_name'], $dest = $path . '/' . $result[$key]['filename'])) {
|
if (!\rename($f['tmp_name'], $dest = $path . '/' . $result[$key]['filename'])) {
|
||||||
|
|
@ -199,6 +199,11 @@ class UploadFile
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure uploaded file is not executable
|
||||||
|
$currentPermissions = \fileperms($dest);
|
||||||
|
$newPermissions = $currentPermissions & ~0100;
|
||||||
|
\chmod($dest, $newPermissions);
|
||||||
|
|
||||||
if ($encryptionKey !== '') {
|
if ($encryptionKey !== '') {
|
||||||
$isEncrypted = EncryptionHelper::encryptFile($dest, $dest, $encryptionKey);
|
$isEncrypted = EncryptionHelper::encryptFile($dest, $dest, $encryptionKey);
|
||||||
|
|
||||||
|
|
@ -218,6 +223,8 @@ class UploadFile
|
||||||
/*
|
/*
|
||||||
if ($encoding !== '') {
|
if ($encoding !== '') {
|
||||||
// changing encoding bugs out image files
|
// changing encoding bugs out image files
|
||||||
|
// @todo Automatically change the file encoding of text files
|
||||||
|
// https://github.com/Karaka-Management/oms-Media/issues/21
|
||||||
//FileUtils::changeFileEncoding($dest, $encoding);
|
//FileUtils::changeFileEncoding($dest, $encoding);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
*/
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use phpOMS\System\File\ExtensionType;
|
||||||
use phpOMS\System\File\FileUtils;
|
use phpOMS\System\File\FileUtils;
|
||||||
use phpOMS\Uri\UriFactory;
|
use phpOMS\Uri\UriFactory;
|
||||||
|
|
||||||
|
|
@ -44,7 +45,8 @@ $next = empty($this->media)
|
||||||
$extensionType = FileUtils::getExtensionType($value->extension);
|
$extensionType = FileUtils::getExtensionType($value->extension);
|
||||||
$icon = $fileIconFunction($extensionType);
|
$icon = $fileIconFunction($extensionType);
|
||||||
?>
|
?>
|
||||||
<tr data-href="<?= $url; ?>">
|
<tr data-href="<?= $url; ?>"
|
||||||
|
<?= \in_array($extensionType, [ExtensionType::IMAGE, ExtensionType::PDF]) ? 'data-preview="' . UriFactory::build('{/api}media/export?id=' . $value->id . '&type=html&csrf={$CSRF}') . '"' : ''; ?>>
|
||||||
<td data-label="<?= $this->getHtml('Type'); ?>"><a href="<?= $url; ?>"><i class="g-icon"><?= $this->printHtml($icon); ?></i></a>
|
<td data-label="<?= $this->getHtml('Type'); ?>"><a href="<?= $url; ?>"><i class="g-icon"><?= $this->printHtml($icon); ?></i></a>
|
||||||
<td data-label="<?= $this->getHtml('Path'); ?>"><a class="content" href="<?= UriFactory::build('{/base}/media/list?{?}&path=' . $value->getVirtualPath()); ?>"><?= $this->printHtml($value->getVirtualPath()); ?></a>
|
<td data-label="<?= $this->getHtml('Path'); ?>"><a class="content" href="<?= UriFactory::build('{/base}/media/list?{?}&path=' . $value->getVirtualPath()); ?>"><?= $this->printHtml($value->getVirtualPath()); ?></a>
|
||||||
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->name); ?></a>
|
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->name); ?></a>
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
*/
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use phpOMS\System\File\ExtensionType;
|
||||||
use phpOMS\System\File\FileUtils;
|
use phpOMS\System\File\FileUtils;
|
||||||
use phpOMS\Uri\UriFactory;
|
use phpOMS\Uri\UriFactory;
|
||||||
use phpOMS\Utils\Converter\FileSizeType;
|
use phpOMS\Utils\Converter\FileSizeType;
|
||||||
|
|
@ -184,22 +185,24 @@ $next = empty($media) ? '{/base}/media/list' : '{/base}/media/list?{?}&offse
|
||||||
<td>
|
<td>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php $count = 0;
|
<?php $count = 0;
|
||||||
foreach ($media as $key => $value) :
|
foreach ($media as $key => $value) :
|
||||||
++$count;
|
++$count;
|
||||||
|
|
||||||
$url = $value->extension === 'collection'
|
$url = $value->extension === 'collection'
|
||||||
? UriFactory::build('{/base}/media/list?path=' . \rtrim($value->getVirtualPath(), '/') . '/' . $value->name)
|
? UriFactory::build('{/base}/media/list?path=' . \rtrim($value->getVirtualPath(), '/') . '/' . $value->name)
|
||||||
: UriFactory::build('{/base}/media/view?id=' . $value->id
|
: UriFactory::build('{/base}/media/view?id=' . $value->id
|
||||||
. '&path={?path}' . (
|
. '&path={?path}' . (
|
||||||
$value->id === 0
|
$value->id === 0
|
||||||
? '/' . $value->name
|
? '/' . $value->name
|
||||||
: ''
|
: ''
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$icon = $fileIconFunction(FileUtils::getExtensionType($value->extension));
|
$icon = $fileIconFunction($extensionType = FileUtils::getExtensionType($value->extension));
|
||||||
?>
|
?>
|
||||||
<tr tabindex="0" data-href="<?= $url; ?>">
|
<tr tabindex="0"
|
||||||
|
data-href="<?= $url; ?>"
|
||||||
|
<?= \in_array($extensionType, [ExtensionType::IMAGE, ExtensionType::PDF]) ? 'data-preview="' . UriFactory::build('{/api}media/export?id=' . $value->id . '&type=html&csrf={$CSRF}') . '"' : ''; ?>>
|
||||||
<td><label class="checkbox" for="iMediaSelect-<?= $key; ?>">
|
<td><label class="checkbox" for="iMediaSelect-<?= $key; ?>">
|
||||||
<input type="checkbox" id="iMediaSelect-<?= $key; ?>" name="mediaselect">
|
<input type="checkbox" id="iMediaSelect-<?= $key; ?>" name="mediaselect">
|
||||||
<span class="checkmark"></span>
|
<span class="checkmark"></span>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user