mirror of
https://github.com/Karaka-Management/oms-Media.git
synced 2026-02-04 19:48:42 +00:00
update
This commit is contained in:
parent
cf2796ea49
commit
d93565fec8
|
|
@ -44,11 +44,9 @@ use phpOMS\Localization\BaseStringL11n;
|
|||
use phpOMS\Message\Http\HttpRequest;
|
||||
use phpOMS\Message\Http\HttpResponse;
|
||||
use phpOMS\Message\Http\RequestStatusCode;
|
||||
use phpOMS\Message\NotificationLevel;
|
||||
use phpOMS\Message\RequestAbstract;
|
||||
use phpOMS\Message\ResponseAbstract;
|
||||
use phpOMS\Model\Html\Head;
|
||||
use phpOMS\Model\Message\FormValidation;
|
||||
use phpOMS\Security\Guard;
|
||||
use phpOMS\System\File\FileUtils;
|
||||
use phpOMS\System\File\Local\Directory;
|
||||
|
|
@ -531,6 +529,8 @@ final class ApiController extends Controller
|
|||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function normalizeDbPath(string $path) : string
|
||||
|
|
@ -957,6 +957,8 @@ final class ApiController extends Controller
|
|||
*
|
||||
* @api
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiMediaCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
|
||||
|
|
@ -1072,8 +1074,8 @@ final class ApiController extends Controller
|
|||
$media->id
|
||||
)
|
||||
) {
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::HIDDEN, '', '', []);
|
||||
$response->header->status = RequestStatusCode::R_403;
|
||||
$this->createInvalidReturnResponse($request, $response, $media);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -1087,8 +1089,8 @@ final class ApiController extends Controller
|
|||
}
|
||||
} else {
|
||||
if (empty($data) || !isset($data['guard'])) {
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::HIDDEN, '', '', []);
|
||||
$response->header->status = RequestStatusCode::R_403;
|
||||
$this->createInvalidReturnResponse($request, $response, $media);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1111,16 +1113,16 @@ final class ApiController extends Controller
|
|||
$media = $this->prepareEncryptedMedia($media, $request);
|
||||
|
||||
if ($media->id === 0) {
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::ERROR, 'Media', 'Media could not be exported. Please try again.', []);
|
||||
$response->header->status = RequestStatusCode::R_500;
|
||||
$this->createInvalidReturnResponse($request, $response, $media);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!\is_file($media->getAbsolutePath())) {
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::ERROR, 'Media', 'Media could not be exported. Please try again.', []);
|
||||
if ($media->extension !== 'collection' && !\is_file($media->getAbsolutePath())) {
|
||||
$response->header->status = RequestStatusCode::R_500;
|
||||
$this->createInvalidReturnResponse($request, $response, $media);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -1227,11 +1229,15 @@ final class ApiController extends Controller
|
|||
case 'php':
|
||||
case 'js':
|
||||
case 'css':
|
||||
case 'csv':
|
||||
case 'rs':
|
||||
case 'py':
|
||||
case 'r':
|
||||
$view->setTemplate('/Modules/Media/Theme/Backend/Components/Media/text_raw');
|
||||
break;
|
||||
case 'json':
|
||||
$view->setTemplate('/Modules/Media/Theme/Backend/Components/Media/json_raw');
|
||||
break;
|
||||
case 'txt':
|
||||
case 'cfg':
|
||||
case 'log':
|
||||
|
|
@ -1255,6 +1261,9 @@ final class ApiController extends Controller
|
|||
case 'mpeg':
|
||||
$view->setTemplate('/Modules/Media/Theme/Backend/Components/Media/video_raw');
|
||||
break;
|
||||
case 'collection':
|
||||
$view->setTemplate('/Modules/Media/Theme/Backend/Components/Media/collection_raw');
|
||||
break;
|
||||
default:
|
||||
$view->setTemplate('/Modules/Media/Theme/Backend/Components/Media/default');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ final class BackendController extends Controller
|
|||
$view = new View($this->app->l11nManager, $request, $response);
|
||||
$view->setTemplate('/Modules/Media/Theme/Backend/media-list');
|
||||
|
||||
$path = \str_replace('+', ' ', (string) ($request->getData('path') ?? '/'));
|
||||
$path = \str_replace('+', ' ', $request->getDataString('path') ?? '/');
|
||||
|
||||
$hasPermission = $this->app->accountManager->get($request->header->account)
|
||||
->hasPermission(
|
||||
|
|
|
|||
|
|
@ -380,7 +380,7 @@ class Media implements \JsonSerializable
|
|||
*/
|
||||
public function setPath(string $path) : void
|
||||
{
|
||||
$this->path = \str_replace('\\', '/', $path);
|
||||
$this->path = \strtr($path, '\\', '/');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -392,7 +392,7 @@ class Media implements \JsonSerializable
|
|||
*/
|
||||
public function setVirtualPath(string $path) : void
|
||||
{
|
||||
$this->virtualPath = \str_replace('\\', '/', $path);
|
||||
$this->virtualPath = \strtr($path, '\\', '/');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ declare(strict_types=1);
|
|||
use phpOMS\Uri\UriFactory;
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<style>html, body, iframe { margin: 0; padding: 0; border: 0; }</style>
|
||||
<audio width="100%" controls>
|
||||
<source src="<?= UriFactory::build('{/api}media/export?id=' . $this->media->id); ?>" type="audio/<?= $this->media->extension; ?>">
|
||||
|
|
|
|||
11
Theme/Backend/Components/Media/collection_raw.tpl.php
Normal file
11
Theme/Backend/Components/Media/collection_raw.tpl.php
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<style>html, body, iframe { margin: 0; padding: 0; border: 0; text-align: center; } svg { width: 90%; fill: #efefef; }</style>
|
||||
<body>
|
||||
<svg fill="#1C2033" version="1.1" id="lni_lni-folder" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px"
|
||||
y="0px" viewBox="0 0 64 64" style="enable-background:new 0 0 64 64;" xml:space="preserve">
|
||||
<path d="M61,19.6v-3.3c0-3.4-2.7-6.1-6.1-6.1H32.7l-0.3-0.8c-0.7-1.8-2.4-2.9-4.3-2.9H7.9c-3.4,0-6.1,2.7-6.1,6.1v38.9
|
||||
c0,3.4,2.7,6.1,6.1,6.1h48.3c3.4,0,6.1-2.7,6.1-6.1V22.7C62.3,21.5,61.8,20.4,61,19.6z M54.9,14.6c0.9,0,1.6,0.7,1.6,1.6v1.9H35.9
|
||||
l-1.4-3.5H54.9z M57.8,51.5c0,0.9-0.7,1.6-1.6,1.6H7.9c-0.9,0-1.6-0.7-1.6-1.6V12.5c0-0.9,0.7-1.6,1.6-1.6L28.2,11l4.1,10.2
|
||||
c0.3,0.9,1.2,1.4,2.1,1.4h23.3c0,0,0.1,0,0.1,0.1V51.5z"/>
|
||||
</svg>
|
||||
|
|
@ -15,6 +15,7 @@ declare(strict_types=1);
|
|||
use phpOMS\Uri\UriFactory;
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<style>html, body, iframe { margin: 0; padding: 0; border: 0; }</style>
|
||||
<img alt="<?= $this->printHtml($this->media->name); ?>" style="max-width: 100%" src="<?= $this->media->id !== 0
|
||||
? UriFactory::build('{/api}media/export?id=' . $this->media->id)
|
||||
|
|
|
|||
6
Theme/Backend/Components/Media/json_raw.tpl.php
Normal file
6
Theme/Backend/Components/Media/json_raw.tpl.php
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<style>html, body, iframe { margin: 0; padding: 0; border: 0; }</style>
|
||||
<pre><?php
|
||||
$json = $this->getFileContent(($this->media->isAbsolute ? '' : __DIR__ . '/../../../../../../') . $this->media->getPath());
|
||||
echo \json_encode(\json_decode($json), \JSON_PRETTY_PRINT);
|
||||
?></pre>
|
||||
|
|
@ -15,6 +15,7 @@ declare(strict_types=1);
|
|||
use phpOMS\Utils\Parser\Markdown\Markdown;
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<style>html, body, iframe { margin: 0; padding: 0; border: 0; }</style>
|
||||
<article><?= Markdown::parse(
|
||||
$this->getFileContent(($this->media->isAbsolute ? '' : __DIR__ . '/../../../../../../') . $this->media->getPath())
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ declare(strict_types=1);
|
|||
use \phpOMS\Uri\UriFactory;
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<style>html, body, iframe { margin: 0; padding: 0; border: 0; }</style>
|
||||
<iframe
|
||||
class="col-simple"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<style>html, body, iframe { margin: 0; padding: 0; border: 0; }</style>
|
||||
<pre class="textContent" data-tpl-text="/media/content" data-tpl-value="/media/content"><?= $this->printHtml(
|
||||
$this->getFileContent(($this->media->isAbsolute ? '' : __DIR__ . '/../../../../../../') . $this->media->getPath())
|
||||
); ?>
|
||||
); ?></pre>
|
||||
|
|
@ -15,6 +15,7 @@ declare(strict_types=1);
|
|||
use phpOMS\Uri\UriFactory;
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<style>html, body, iframe { margin: 0; padding: 0; border: 0; }</style>
|
||||
<video width="100%" controls>
|
||||
<source src="<?= UriFactory::build('{/api}media/export?id=' . $this->media->id); ?>" type="video/<?= $this->media->extension; ?>">
|
||||
|
|
|
|||
|
|
@ -69,7 +69,14 @@ use phpOMS\Uri\UriFactory;
|
|||
<td>
|
||||
<td><?= $this->getHtml('ID', '0', '0'); ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
|
||||
<td class="wf-100"><?= $this->getHtml('Name', 'Media', 'Backend'); ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
|
||||
<tbody id="iMediaInput-tags" class="tags" data-limit="0" data-active="true" data-form="<?= $this->form; ?>">
|
||||
<tbody
|
||||
id="iMediaInput-tags"
|
||||
class="tags"
|
||||
data-action='[{"listener": "change", "action": [{"key": 1, "type": "dom.set", "selector": "#iMediaFile", "value": "<?= UriFactory::build('{/api}media/export') . '?id={!#iFiles [name=media_file]:checked}&type=html'; ?>"}]}]'
|
||||
data-limit="0"
|
||||
data-active="true"
|
||||
data-form="<?= $this->form; ?>"
|
||||
>
|
||||
<template id="iMediaInput-tagTemplate">
|
||||
<tr data-tpl-value="/id" data-value="" data-uuid="" data-name="media-list">
|
||||
<td><label class="radio" for="iFile-0">
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class MediaView extends View
|
|||
{
|
||||
if (\is_file($media->getPath() . $sub)
|
||||
&& ($path = \realpath($media->getPath() . $sub)) !== false
|
||||
&& ($path = \str_replace('\\', '/', $path)) !== false
|
||||
&& ($path = \strtr($path, '\\', '/')) !== false
|
||||
&& StringUtils::startsWith($path, $media->getPath())
|
||||
) {
|
||||
return $media->getPath() . $sub;
|
||||
|
|
@ -68,7 +68,7 @@ class MediaView extends View
|
|||
{
|
||||
if (\is_dir($media->getPath() . $sub)
|
||||
&& ($path = \realpath($media->getPath() . $sub)) !== false
|
||||
&& ($path = \str_replace('\\', '/', $path)) !== false
|
||||
&& ($path = \strtr($path, '\\', '/')) !== false
|
||||
&& StringUtils::startsWith($path, $media->getPath())
|
||||
) {
|
||||
return $media->getPath() . $sub;
|
||||
|
|
|
|||
|
|
@ -71,14 +71,12 @@ final class Autoloader
|
|||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws AutoloadException Throws this exception if the class to autoload doesn't exist. This could also be related to a wrong namespace/file path correlation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function defaultAutoloader(string $class) : void
|
||||
{
|
||||
$class = \ltrim($class, '\\');
|
||||
$class = \str_replace(['_', '\\'], '/', $class);
|
||||
$class = \strtr($class, '_\\', '//');
|
||||
|
||||
foreach (self::$paths as $path) {
|
||||
$file = $path . $class . '.php';
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user