This commit is contained in:
Dennis Eichhorn 2023-10-09 22:06:38 +00:00
parent 79720c2e0b
commit 54aa5729ab
29 changed files with 139 additions and 58 deletions

19
Admin/Hooks/Cli.php Normal file
View File

@ -0,0 +1,19 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\Media
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
return [
'Module:Admin-encryption-change' => [
'callback' => ['\Modules\Media\Controller\CliController:runEncryptionChangeFromHook'],
],
];

View File

@ -183,7 +183,7 @@ final class Installer extends InstallerAbstract
$module->apiReferenceCreate($request, $response); $module->apiReferenceCreate($request, $response);
$responseData = $response->get(''); $responseData = $response->getData('');
if (!\is_array($responseData)) { if (!\is_array($responseData)) {
return []; return [];
} }
@ -221,7 +221,7 @@ final class Installer extends InstallerAbstract
$module->apiCollectionCreate($request, $response); $module->apiCollectionCreate($request, $response);
$responseData = $response->get(''); $responseData = $response->getData('');
if (!\is_array($responseData)) { if (!\is_array($responseData)) {
return []; return [];
} }
@ -259,7 +259,7 @@ final class Installer extends InstallerAbstract
$module->apiMediaTypeCreate($request, $response); $module->apiMediaTypeCreate($request, $response);
$responseData = $response->get(''); $responseData = $response->getData('');
if (!\is_array($responseData)) { if (!\is_array($responseData)) {
return []; return [];
} }
@ -375,7 +375,7 @@ final class Installer extends InstallerAbstract
$module->apiCollectionCreate($request, $response); $module->apiCollectionCreate($request, $response);
} }
$responseData = $response->get(''); $responseData = $response->getData('');
if (!\is_array($responseData)) { if (!\is_array($responseData)) {
return []; return [];
} }

View File

@ -1,11 +1,12 @@
import { jsOMS } from '../../jsOMS/Utils/oLib.js';
import { Autoloader } from '../../jsOMS/Autoloader.js'; import { Autoloader } from '../../jsOMS/Autoloader.js';
import { NotificationMessage } from '../../jsOMS/Message/Notification/NotificationMessage.js'; import { NotificationMessage } from '../../jsOMS/Message/Notification/NotificationMessage.js';
import { NotificationType } from '../../jsOMS/Message/Notification/NotificationType.js'; import { NotificationType } from '../../jsOMS/Message/Notification/NotificationType.js';
import { Upload } from './Models/Upload.js'; import { Upload } from './Models/Upload.js';
Autoloader.defineNamespace('jsOMS.Modules'); Autoloader.defineNamespace('omsApp.Modules');
jsOMS.Modules.Media = class { omsApp.Modules.Media = class {
/** /**
* @constructor * @constructor
* *

View File

@ -111,7 +111,7 @@ final class ApiController extends Controller
$internalResponse = new HttpResponse(); $internalResponse = new HttpResponse();
$this->apiMediaTypeCreate($request, $internalResponse); $this->apiMediaTypeCreate($request, $internalResponse);
if (!\is_array($data = $internalResponse->get($request->uri->__toString()))) { if (!\is_array($data = $internalResponse->getDataArray($request->uri->__toString()))) {
continue; continue;
} }
@ -144,7 +144,7 @@ final class ApiController extends Controller
$internalResponse = new HttpResponse(); $internalResponse = new HttpResponse();
$this->app->moduleManager->get('Tag')->apiTagCreate($request, $internalResponse); $this->app->moduleManager->get('Tag')->apiTagCreate($request, $internalResponse);
if (!\is_array($data = $internalResponse->get($request->uri->__toString()))) { if (!\is_array($data = $internalResponse->getDataArray($request->uri->__toString()))) {
continue; continue;
} }

View File

@ -0,0 +1,61 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\Media
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\Media\Controller;
use Model\SettingMapper;
use Modules\Media\Models\MediaMapper;
use phpOMS\Contract\RenderableInterface;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
use phpOMS\Security\EncryptionHelper;
use phpOMS\Views\View;
/**
* Media controller class.
*
* @package Modules\Media
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
final class CliController extends Controller
{
/**
* Api method to make a call to the cli app
*
* @param mixed ...$data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function runEncryptionChangeFromHook(mixed ...$data) : void
{
$mapper = MediaMapper::yield()
->where('isEncrypted', true);
foreach ($mapper->execute() as $media) {
if (!empty($data['old'])) {
$media->decrypt($data['old']);
}
if (!empty($data['new'])) {
$media->encrypt($data['new']);
}
}
}
}

View File

@ -16,7 +16,7 @@ use \phpOMS\Uri\UriFactory;
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<style>html, body, iframe { margin: 0; padding: 0; border: 0; }</style> <style>html, body, iframe { margin: 0; padding: 0; border: 0; width: 100%; height: 100%; overflow: hidden; }</style>
<iframe <iframe
class="col-simple" class="col-simple"
id="iMediaFrame" id="iMediaFrame"

View File

@ -44,8 +44,8 @@ return ['Media' => [
'Select' => 'يختار', 'Select' => 'يختار',
'Settings' => 'إعدادات', 'Settings' => 'إعدادات',
'Size' => 'بحجم', 'Size' => 'بحجم',
'Tag' => '#VALUE!', 'Tag' => '',
'Tags' => '#VALUE!', 'Tags' => '',
'Type' => 'نوع', 'Type' => 'نوع',
'Upload' => 'تحميل', 'Upload' => 'تحميل',
'VirtualPath' => 'المسار الافتراضي', 'VirtualPath' => 'المسار الافتراضي',

View File

@ -44,8 +44,8 @@ return ['Media' => [
'Select' => 'Vybrat', 'Select' => 'Vybrat',
'Settings' => 'Nastavení', 'Settings' => 'Nastavení',
'Size' => 'Velikost', 'Size' => 'Velikost',
'Tag' => '#VALUE!', 'Tag' => '',
'Tags' => '#VALUE!', 'Tags' => '',
'Type' => 'Typ', 'Type' => 'Typ',
'Upload' => 'nahrát', 'Upload' => 'nahrát',
'VirtualPath' => 'Virtuální cesta', 'VirtualPath' => 'Virtuální cesta',

View File

@ -44,8 +44,8 @@ return ['Media' => [
'Select' => 'Vælg', 'Select' => 'Vælg',
'Settings' => 'Indstillinger.', 'Settings' => 'Indstillinger.',
'Size' => 'Størrelse', 'Size' => 'Størrelse',
'Tag' => '#VALUE!', 'Tag' => '',
'Tags' => '#VALUE!', 'Tags' => '',
'Type' => 'Type', 'Type' => 'Type',
'Upload' => 'Upload', 'Upload' => 'Upload',
'VirtualPath' => 'Virtual Path.', 'VirtualPath' => 'Virtual Path.',

View File

@ -44,8 +44,8 @@ return ['Media' => [
'Select' => 'Wählen', 'Select' => 'Wählen',
'Settings' => 'Einstellungen', 'Settings' => 'Einstellungen',
'Size' => 'Größe', 'Size' => 'Größe',
'Tag' => '#VALUE!', 'Tag' => '',
'Tags' => '#VALUE!', 'Tags' => '',
'Type' => 'Typ', 'Type' => 'Typ',
'Upload' => 'Hochladen', 'Upload' => 'Hochladen',
'VirtualPath' => 'Virtueller Pfad', 'VirtualPath' => 'Virtueller Pfad',

View File

@ -44,8 +44,8 @@ return ['Media' => [
'Select' => 'Επιλέγω', 'Select' => 'Επιλέγω',
'Settings' => 'Ρυθμίσεις', 'Settings' => 'Ρυθμίσεις',
'Size' => 'Μέγεθος', 'Size' => 'Μέγεθος',
'Tag' => '#VALUE!', 'Tag' => '',
'Tags' => '#VALUE!', 'Tags' => '',
'Type' => 'Τύπος', 'Type' => 'Τύπος',
'Upload' => 'Μεταφόρτω', 'Upload' => 'Μεταφόρτω',
'VirtualPath' => 'Εικονική διαδρομή', 'VirtualPath' => 'Εικονική διαδρομή',

View File

@ -44,8 +44,8 @@ return ['Media' => [
'Select' => 'Seleccione', 'Select' => 'Seleccione',
'Settings' => 'Ajustes', 'Settings' => 'Ajustes',
'Size' => 'Tamaño', 'Size' => 'Tamaño',
'Tag' => '#VALUE!', 'Tag' => '',
'Tags' => '#VALUE!', 'Tags' => '',
'Type' => 'Escribe', 'Type' => 'Escribe',
'Upload' => 'Subir', 'Upload' => 'Subir',
'VirtualPath' => 'Camino virtual', 'VirtualPath' => 'Camino virtual',

View File

@ -44,8 +44,8 @@ return ['Media' => [
'Select' => 'Valitse', 'Select' => 'Valitse',
'Settings' => 'asetukset', 'Settings' => 'asetukset',
'Size' => 'Koko', 'Size' => 'Koko',
'Tag' => '#VALUE!', 'Tag' => '',
'Tags' => '#VALUE!', 'Tags' => '',
'Type' => 'Tyyppi', 'Type' => 'Tyyppi',
'Upload' => 'Ladata', 'Upload' => 'Ladata',
'VirtualPath' => 'Virtuaalinen polku', 'VirtualPath' => 'Virtuaalinen polku',

View File

@ -44,8 +44,8 @@ return ['Media' => [
'Select' => 'Sélectionner', 'Select' => 'Sélectionner',
'Settings' => 'Réglages', 'Settings' => 'Réglages',
'Size' => 'Taille', 'Size' => 'Taille',
'Tag' => '#VALUE!', 'Tag' => '',
'Tags' => '#VALUE!', 'Tags' => '',
'Type' => 'Taper', 'Type' => 'Taper',
'Upload' => 'Télécharger', 'Upload' => 'Télécharger',
'VirtualPath' => 'Voie virtuelle', 'VirtualPath' => 'Voie virtuelle',

View File

@ -44,8 +44,8 @@ return ['Media' => [
'Select' => 'Kiválaszt', 'Select' => 'Kiválaszt',
'Settings' => 'Beállítások', 'Settings' => 'Beállítások',
'Size' => 'Méret', 'Size' => 'Méret',
'Tag' => '#VALUE!', 'Tag' => '',
'Tags' => '#VALUE!', 'Tags' => '',
'Type' => 'típus', 'Type' => 'típus',
'Upload' => 'Feltöltés', 'Upload' => 'Feltöltés',
'VirtualPath' => 'Virtuális út', 'VirtualPath' => 'Virtuális út',

View File

@ -44,8 +44,8 @@ return ['Media' => [
'Select' => 'Selezionare', 'Select' => 'Selezionare',
'Settings' => 'Impostazioni', 'Settings' => 'Impostazioni',
'Size' => 'Misurare', 'Size' => 'Misurare',
'Tag' => '#VALUE!', 'Tag' => '',
'Tags' => '#VALUE!', 'Tags' => '',
'Type' => 'Tipo', 'Type' => 'Tipo',
'Upload' => 'Caricamento', 'Upload' => 'Caricamento',
'VirtualPath' => 'Percorso virtuale', 'VirtualPath' => 'Percorso virtuale',

View File

@ -44,8 +44,8 @@ return ['Media' => [
'Select' => '選択する', 'Select' => '選択する',
'Settings' => '設定', 'Settings' => '設定',
'Size' => 'サイズ', 'Size' => 'サイズ',
'Tag' => '#VALUE!', 'Tag' => '',
'Tags' => '#VALUE!', 'Tags' => '',
'Type' => 'タイプ', 'Type' => 'タイプ',
'Upload' => 'アップロード', 'Upload' => 'アップロード',
'VirtualPath' => '仮想パス', 'VirtualPath' => '仮想パス',

View File

@ -44,8 +44,8 @@ return ['Media' => [
'Select' => '선택하다', 'Select' => '선택하다',
'Settings' => '설정', 'Settings' => '설정',
'Size' => '크기', 'Size' => '크기',
'Tag' => '#VALUE!', 'Tag' => '',
'Tags' => '#VALUE!', 'Tags' => '',
'Type' => '유형', 'Type' => '유형',
'Upload' => '업로드', 'Upload' => '업로드',
'VirtualPath' => '가상 경로', 'VirtualPath' => '가상 경로',

View File

@ -44,8 +44,8 @@ return ['Media' => [
'Select' => 'Plukke ut', 'Select' => 'Plukke ut',
'Settings' => 'Innstillinger', 'Settings' => 'Innstillinger',
'Size' => 'Størrelse', 'Size' => 'Størrelse',
'Tag' => '#VALUE!', 'Tag' => '',
'Tags' => '#VALUE!', 'Tags' => '',
'Type' => 'Type', 'Type' => 'Type',
'Upload' => 'Laste opp', 'Upload' => 'Laste opp',
'VirtualPath' => 'Virtual Path.', 'VirtualPath' => 'Virtual Path.',

View File

@ -44,8 +44,8 @@ return ['Media' => [
'Select' => 'Wybierać', 'Select' => 'Wybierać',
'Settings' => 'Ustawienia', 'Settings' => 'Ustawienia',
'Size' => 'Rozmiar', 'Size' => 'Rozmiar',
'Tag' => '#VALUE!', 'Tag' => '',
'Tags' => '#VALUE!', 'Tags' => '',
'Type' => 'Rodzaj', 'Type' => 'Rodzaj',
'Upload' => 'Wgrywać', 'Upload' => 'Wgrywać',
'VirtualPath' => 'Wirtualna ścieżka', 'VirtualPath' => 'Wirtualna ścieżka',

View File

@ -44,8 +44,8 @@ return ['Media' => [
'Select' => 'Selecione.', 'Select' => 'Selecione.',
'Settings' => 'Configurações', 'Settings' => 'Configurações',
'Size' => 'Tamanho', 'Size' => 'Tamanho',
'Tag' => '#VALUE!', 'Tag' => '',
'Tags' => '#VALUE!', 'Tags' => '',
'Type' => 'Modelo', 'Type' => 'Modelo',
'Upload' => 'Envio', 'Upload' => 'Envio',
'VirtualPath' => 'Caminho virtual', 'VirtualPath' => 'Caminho virtual',

View File

@ -44,8 +44,8 @@ return ['Media' => [
'Select' => 'Выбирать', 'Select' => 'Выбирать',
'Settings' => 'Настройки', 'Settings' => 'Настройки',
'Size' => 'Размер', 'Size' => 'Размер',
'Tag' => '#VALUE!', 'Tag' => '',
'Tags' => '#VALUE!', 'Tags' => '',
'Type' => 'Тип', 'Type' => 'Тип',
'Upload' => 'Загрузить', 'Upload' => 'Загрузить',
'VirtualPath' => 'Виртуальный путь', 'VirtualPath' => 'Виртуальный путь',

View File

@ -44,8 +44,8 @@ return ['Media' => [
'Select' => 'Välj', 'Select' => 'Välj',
'Settings' => 'inställningar', 'Settings' => 'inställningar',
'Size' => 'Storlek', 'Size' => 'Storlek',
'Tag' => '#VALUE!', 'Tag' => '',
'Tags' => '#VALUE!', 'Tags' => '',
'Type' => 'Typ', 'Type' => 'Typ',
'Upload' => 'Ladda upp', 'Upload' => 'Ladda upp',
'VirtualPath' => 'Virtuell väg', 'VirtualPath' => 'Virtuell väg',

View File

@ -44,8 +44,8 @@ return ['Media' => [
'Select' => 'เลือก', 'Select' => 'เลือก',
'Settings' => 'การตั้งค่า', 'Settings' => 'การตั้งค่า',
'Size' => 'ขนาด', 'Size' => 'ขนาด',
'Tag' => '#VALUE!', 'Tag' => '',
'Tags' => '#VALUE!', 'Tags' => '',
'Type' => 'พิมพ์', 'Type' => 'พิมพ์',
'Upload' => 'ที่อัพโหลด', 'Upload' => 'ที่อัพโหลด',
'VirtualPath' => 'เส้นทางเสมือน', 'VirtualPath' => 'เส้นทางเสมือน',

View File

@ -44,8 +44,8 @@ return ['Media' => [
'Select' => 'Seçme', 'Select' => 'Seçme',
'Settings' => 'Ayarlar', 'Settings' => 'Ayarlar',
'Size' => 'Boyut', 'Size' => 'Boyut',
'Tag' => '#VALUE!', 'Tag' => '',
'Tags' => '#VALUE!', 'Tags' => '',
'Type' => 'Tip', 'Type' => 'Tip',
'Upload' => 'Yüklemek', 'Upload' => 'Yüklemek',
'VirtualPath' => 'Sanal yol', 'VirtualPath' => 'Sanal yol',

View File

@ -44,8 +44,8 @@ return ['Media' => [
'Select' => 'Вибирати', 'Select' => 'Вибирати',
'Settings' => 'Налаштування', 'Settings' => 'Налаштування',
'Size' => 'Розмір', 'Size' => 'Розмір',
'Tag' => '#VALUE!', 'Tag' => '',
'Tags' => '#VALUE!', 'Tags' => '',
'Type' => 'Тип', 'Type' => 'Тип',
'Upload' => 'Завантажувати', 'Upload' => 'Завантажувати',
'VirtualPath' => 'Віртуальний шлях', 'VirtualPath' => 'Віртуальний шлях',

View File

@ -44,8 +44,8 @@ return ['Media' => [
'Select' => '选择', 'Select' => '选择',
'Settings' => '设置', 'Settings' => '设置',
'Size' => '尺寸', 'Size' => '尺寸',
'Tag' => '#VALUE!', 'Tag' => '',
'Tags' => '#VALUE!', 'Tags' => '',
'Type' => '类型', 'Type' => '类型',
'Upload' => '上传', 'Upload' => '上传',
'VirtualPath' => '虚拟路径', 'VirtualPath' => '虚拟路径',

View File

@ -72,7 +72,7 @@ trait ApiControllerCollectionTrait
} }
$media = []; $media = [];
$createdMedia = $response->get('')['response']; $createdMedia = $response->getDataArray('')['response'];
foreach ($createdMedia as $file) { foreach ($createdMedia as $file) {
$media[] = $file; $media[] = $file;
} }
@ -87,7 +87,7 @@ trait ApiControllerCollectionTrait
$this->module->apiCollectionCreate($request, $response); $this->module->apiCollectionCreate($request, $response);
$collection = $response->get('')['response']; $collection = $response->getDataArray('')['response'];
self::assertEquals('Test Collection', $collection->name); self::assertEquals('Test Collection', $collection->name);
self::assertCount(2, $collection->getSources()); self::assertCount(2, $collection->getSources());
} }
@ -123,7 +123,7 @@ trait ApiControllerCollectionTrait
$this->module->apiCollectionCreate($request, $response); $this->module->apiCollectionCreate($request, $response);
$collection = $response->get('')['response']; $collection = $response->getDataArray('')['response'];
self::assertTrue(\is_dir(__DIR__ . '/../../../Files/test/path')); self::assertTrue(\is_dir(__DIR__ . '/../../../Files/test/path'));
Directory::delete(__DIR__ . '/../../../Files/test/path'); Directory::delete(__DIR__ . '/../../../Files/test/path');

View File

@ -120,7 +120,7 @@ trait ApiControllerMediaTrait
Directory::delete(__DIR__ . '/temp'); Directory::delete(__DIR__ . '/temp');
} }
$media = $response->get('')['response']; $media = $response->getDataArray('')['response'];
self::assertCount(2, $media); self::assertCount(2, $media);
} }
@ -171,7 +171,7 @@ trait ApiControllerMediaTrait
Directory::delete(__DIR__ . '/temp'); Directory::delete(__DIR__ . '/temp');
} }
$media = $response->get('')['response']; $media = $response->getDataArray('')['response'];
self::assertTrue(\is_file(__DIR__ . '/../test/path/testFile1.txt')); self::assertTrue(\is_file(__DIR__ . '/../test/path/testFile1.txt'));
self::assertTrue(\is_file(__DIR__ . '/../test/path/testFile2.txt')); self::assertTrue(\is_file(__DIR__ . '/../test/path/testFile2.txt'));
@ -238,7 +238,7 @@ trait ApiControllerMediaTrait
TestUtils::setMember($request, 'files', $files); TestUtils::setMember($request, 'files', $files);
$this->module->apiMediaUpload($request, $response); $this->module->apiMediaUpload($request, $response);
$id = \reset($response->get('')['response']); $id = \reset($response->getDataArray('')['response']);
$response = new HttpResponse(); $response = new HttpResponse();
$request = new HttpRequest(new HttpUri('')); $request = new HttpRequest(new HttpUri(''));
@ -278,7 +278,7 @@ trait ApiControllerMediaTrait
$this->module->apiMediaCreate($request, $response); $this->module->apiMediaCreate($request, $response);
self::assertCount(1, $response->get('')['response']); self::assertCount(1, $response->getDataArray('')['response']);
self::assertTrue(\is_file(__DIR__ . '/../test/path/created.md')); self::assertTrue(\is_file(__DIR__ . '/../test/path/created.md'));
Directory::delete(__DIR__ . '/../test'); Directory::delete(__DIR__ . '/../test');