mirror of
https://github.com/Karaka-Management/oms-Media.git
synced 2026-02-11 23:18:39 +00:00
bug fixes
This commit is contained in:
parent
84f9e33f3f
commit
55f4846f54
2
.github/workflows/greetings.yml
vendored
2
.github/workflows/greetings.yml
vendored
|
|
@ -9,5 +9,5 @@ jobs:
|
|||
- uses: actions/first-interaction@v1
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
issue-message: 'Thank you for createing this issue. We will check it as soon as possible.'
|
||||
issue-message: 'Thank you for creating this issue. We will check it as soon as possible.'
|
||||
pr-message: 'Thank you for your pull request. We will check it as soon as possible.'
|
||||
|
|
|
|||
|
|
@ -1,114 +0,0 @@
|
|||
[
|
||||
{
|
||||
"type": "type",
|
||||
"name": "contract",
|
||||
"l11n": [
|
||||
{
|
||||
"title": "Contract",
|
||||
"lang": "en"
|
||||
},
|
||||
{
|
||||
"title": "Vertrag",
|
||||
"lang": "de"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "type",
|
||||
"name": "nda",
|
||||
"l11n": [
|
||||
{
|
||||
"title": "NDA",
|
||||
"lang": "en"
|
||||
},
|
||||
{
|
||||
"title": "NDA",
|
||||
"lang": "de"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "type",
|
||||
"name": "receipt",
|
||||
"l11n": [
|
||||
{
|
||||
"title": "Receipt",
|
||||
"lang": "en"
|
||||
},
|
||||
{
|
||||
"title": "Quittung",
|
||||
"lang": "de"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "type",
|
||||
"name": "invoice",
|
||||
"l11n": [
|
||||
{
|
||||
"title": "Invoice",
|
||||
"lang": "en"
|
||||
},
|
||||
{
|
||||
"title": "Rechnung",
|
||||
"lang": "de"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "type",
|
||||
"name": "letter",
|
||||
"l11n": [
|
||||
{
|
||||
"title": "Letter",
|
||||
"lang": "en"
|
||||
},
|
||||
{
|
||||
"title": "Brief",
|
||||
"lang": "de"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "type",
|
||||
"name": "minutes",
|
||||
"l11n": [
|
||||
{
|
||||
"title": "Minutes",
|
||||
"lang": "en"
|
||||
},
|
||||
{
|
||||
"title": "Protokoll",
|
||||
"lang": "de"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "type",
|
||||
"name": "leasing",
|
||||
"l11n": [
|
||||
{
|
||||
"title": "Leasing",
|
||||
"lang": "en"
|
||||
},
|
||||
{
|
||||
"title": "Leasing",
|
||||
"lang": "de"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "type",
|
||||
"name": "insurance",
|
||||
"l11n": [
|
||||
{
|
||||
"title": "Insurance",
|
||||
"lang": "en"
|
||||
},
|
||||
{
|
||||
"title": "Versicherung",
|
||||
"lang": "de"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
@ -23,6 +23,7 @@ return [
|
|||
'dest' => '\Modules\Media\Controller\SearchController:searchGeneral',
|
||||
'verb' => RouteVerb::ANY,
|
||||
'active' => true,
|
||||
'order' => 3,
|
||||
'permission' => [
|
||||
'module' => SearchController::NAME,
|
||||
'type' => PermissionType::READ,
|
||||
|
|
|
|||
37
Admin/Install/Tag.install.json
Normal file
37
Admin/Install/Tag.install.json
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
[
|
||||
{
|
||||
"name": "nda",
|
||||
"l11n": {
|
||||
"en": "NDA",
|
||||
"de": "NDA"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "receipt",
|
||||
"l11n": {
|
||||
"en": "Receipt",
|
||||
"de": "Quittung"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "invoice",
|
||||
"l11n": {
|
||||
"en": "Invoice",
|
||||
"de": "Rechnung"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "letter",
|
||||
"l11n": {
|
||||
"en": "Letter",
|
||||
"de": "Brief"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "minutes",
|
||||
"l11n": {
|
||||
"en": "Minutes",
|
||||
"de": "Protokoll"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -17,14 +17,14 @@ namespace Modules\Media\Admin\Install;
|
|||
use phpOMS\Application\ApplicationAbstract;
|
||||
|
||||
/**
|
||||
* Media class.
|
||||
* Tag class.
|
||||
*
|
||||
* @package Modules\Media\Admin\Install
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Media
|
||||
class Tag
|
||||
{
|
||||
/**
|
||||
* Install media providing
|
||||
|
|
@ -38,6 +38,6 @@ class Media
|
|||
*/
|
||||
public static function install(ApplicationAbstract $app, string $path) : void
|
||||
{
|
||||
\Modules\Media\Admin\Installer::installExternal($app, ['path' => __DIR__ . '/Media.install.json']);
|
||||
\Modules\Tag\Admin\Installer::installExternal($app, ['path' => __DIR__ . '/Tag.install.json']);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,58 +1,4 @@
|
|||
{
|
||||
"media_type": {
|
||||
"name": "media_type",
|
||||
"fields": {
|
||||
"media_type_id": {
|
||||
"name": "media_type_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"media_type_name": {
|
||||
"name": "media_type_name",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"media_type_isvisible": {
|
||||
"name": "media_type_isvisible",
|
||||
"type": "TINYINT(1)",
|
||||
"null": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"media_type_l11n": {
|
||||
"name": "media_type_l11n",
|
||||
"fields": {
|
||||
"media_type_l11n_id": {
|
||||
"name": "media_type_l11n_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"media_type_l11n_title": {
|
||||
"name": "media_type_l11n_title",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"media_type_l11n_type": {
|
||||
"name": "media_type_l11n_type",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "media_type",
|
||||
"foreignKey": "media_type_id"
|
||||
},
|
||||
"media_type_l11n_language": {
|
||||
"name": "media_type_l11n_language",
|
||||
"type": "VARCHAR(2)",
|
||||
"default": null,
|
||||
"null": true,
|
||||
"foreignTable": "language",
|
||||
"foreignKey": "language_639_1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"media_parsed": {
|
||||
"name": "media_parsed",
|
||||
"fields": {
|
||||
|
|
@ -256,31 +202,5 @@
|
|||
"foreignKey": "tag_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"media_type_rel": {
|
||||
"name": "media_type_rel",
|
||||
"fields": {
|
||||
"media_type_rel_id": {
|
||||
"name": "media_type_rel_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"media_type_rel_src": {
|
||||
"name": "media_type_rel_src",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "media",
|
||||
"foreignKey": "media_id"
|
||||
},
|
||||
"media_type_rel_dst": {
|
||||
"name": "media_type_rel_dst",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "media_type",
|
||||
"foreignKey": "media_type_id"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -144,9 +144,6 @@ final class Installer extends InstallerAbstract
|
|||
case 'upload':
|
||||
$result['upload'][] = self::uploadMedia($apiApp, $media);
|
||||
break;
|
||||
case 'type':
|
||||
$result['type'][] = self::createType($apiApp, $media);
|
||||
break;
|
||||
case 'reference':
|
||||
$result['reference'][] = self::createReference($apiApp, $media);
|
||||
break;
|
||||
|
|
@ -230,65 +227,6 @@ final class Installer extends InstallerAbstract
|
|||
: $responseData['response']->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create type.
|
||||
*
|
||||
* @param ApplicationAbstract $app Application
|
||||
* @param array $data Media info
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static function createType(ApplicationAbstract $app, array $data) : array
|
||||
{
|
||||
/** @var \Modules\Media\Controller\ApiController $module */
|
||||
$module = $app->moduleManager->get('Media');
|
||||
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest();
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('name', $data['name'] ?? '');
|
||||
|
||||
if (!empty($data['l11n'])) {
|
||||
$request->setData('title', \reset($data['l11n'])['title']);
|
||||
$request->setData('lang', \reset($data['l11n'])['lang']);
|
||||
}
|
||||
|
||||
$module->apiMediaTypeCreate($request, $response);
|
||||
|
||||
$responseData = $response->getData('');
|
||||
if (!\is_array($responseData)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$type = $responseData['response'];
|
||||
$id = $type->id;
|
||||
|
||||
$isFirst = true;
|
||||
foreach ($data['l11n'] as $l11n) {
|
||||
if ($isFirst) {
|
||||
$isFirst = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest();
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('title', $l11n['title'] ?? '');
|
||||
$request->setData('lang', $l11n['lang'] ?? null);
|
||||
$request->setData('type', $id);
|
||||
|
||||
$module->apiMediaTypeL11nCreate($request, $response);
|
||||
}
|
||||
|
||||
return \is_array($type)
|
||||
? $type
|
||||
: $type->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload media.
|
||||
*
|
||||
|
|
@ -316,7 +254,7 @@ final class Installer extends InstallerAbstract
|
|||
: ($data['virtualPath'] ?? '/')
|
||||
)
|
||||
);
|
||||
$request->setData('type', $data['media_type'] ?? null); // = identifier for modules
|
||||
$request->setData('type', $data['tag'] ?? null); // = identifier for modules
|
||||
$request->setData('pathsettings', $data['path_setting'] ?? PathSettings::FILE_PATH);
|
||||
|
||||
$tempPath = __DIR__ . '/../../../temp/';
|
||||
|
|
|
|||
|
|
@ -18,18 +18,6 @@ use phpOMS\Account\PermissionType;
|
|||
use phpOMS\Router\RouteVerb;
|
||||
|
||||
return [
|
||||
'^/admin/module/settings\?id=Media&type=.*?$' => [
|
||||
[
|
||||
'dest' => '\Modules\Media\Controller\BackendController:viewMediaTypeSettings',
|
||||
'verb' => RouteVerb::GET,
|
||||
'active' => true,
|
||||
'permission' => [
|
||||
'module' => BackendController::NAME,
|
||||
'type' => PermissionType::READ,
|
||||
'state' => \Modules\Admin\Models\PermissionCategory::MODULE,
|
||||
],
|
||||
],
|
||||
],
|
||||
'^/media/list(\?.*$|$)' => [
|
||||
[
|
||||
'dest' => '\Modules\Media\Controller\BackendController:viewMediaList',
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ echo $this->data['nav']->render(); ?>
|
|||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="portlet">
|
||||
<section class="portlet">
|
||||
<div class="portlet-head"><?= $this->getHtml('Types'); ?><i class="g-icon download btn end-xs">download</i></div>
|
||||
<div class="slider">
|
||||
<table id="typeList" class="default sticky">
|
||||
|
|
@ -80,6 +80,6 @@ echo $this->data['nav']->render(); ?>
|
|||
<?php endif; ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -23,12 +23,8 @@ use Modules\Media\Models\MediaClass;
|
|||
use Modules\Media\Models\MediaContent;
|
||||
use Modules\Media\Models\MediaContentMapper;
|
||||
use Modules\Media\Models\MediaMapper;
|
||||
use Modules\Media\Models\MediaType;
|
||||
use Modules\Media\Models\MediaTypeL11nMapper;
|
||||
use Modules\Media\Models\MediaTypeMapper;
|
||||
use Modules\Media\Models\NullCollection;
|
||||
use Modules\Media\Models\NullMedia;
|
||||
use Modules\Media\Models\NullMediaType;
|
||||
use Modules\Media\Models\PathSettings;
|
||||
use Modules\Media\Models\PermissionCategory;
|
||||
use Modules\Media\Models\Reference;
|
||||
|
|
@ -37,13 +33,12 @@ use Modules\Media\Models\UploadFile;
|
|||
use Modules\Media\Models\UploadStatus;
|
||||
use Modules\Media\Theme\Backend\Components\Media\ElementView;
|
||||
use Modules\Messages\Models\EmailMapper;
|
||||
use Modules\Tag\Models\NullTag;
|
||||
use phpOMS\Account\PermissionType;
|
||||
use phpOMS\Ai\Ocr\Tesseract\TesseractOcr;
|
||||
use phpOMS\Application\ApplicationAbstract;
|
||||
use phpOMS\Asset\AssetType;
|
||||
use phpOMS\Autoloader;
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
use phpOMS\Message\Http\HttpResponse;
|
||||
use phpOMS\Message\Http\RequestStatusCode;
|
||||
use phpOMS\Message\RequestAbstract;
|
||||
|
|
@ -179,51 +174,26 @@ final class ApiController extends Controller
|
|||
foreach ($uploads as $file) {
|
||||
$ids[] = $file->id;
|
||||
|
||||
// add media types
|
||||
if (!empty($types = $request->getDataJson('types'))) {
|
||||
foreach ($types as $type) {
|
||||
if (!isset($type['id'])) {
|
||||
$request->setData('name', $type['name'], true);
|
||||
$request->setData('title', $type['title'], true);
|
||||
$request->setData('lang', $type['lang'] ?? null, true);
|
||||
|
||||
$internalResponse = new HttpResponse();
|
||||
$this->apiMediaTypeCreate($request, $internalResponse);
|
||||
|
||||
if (!\is_array($data = $internalResponse->getDataArray($request->uri->__toString()))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$file->addMediaType($tId = $data['response']);
|
||||
} else {
|
||||
$file->addMediaType(new NullMediaType($tId = (int) $type['id']));
|
||||
// add media tags
|
||||
if (!empty($tags = $request->getDataJson('tags'))) {
|
||||
foreach ($tags as $tag) {
|
||||
if (!isset($tag['id'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$file->tags[] = new NullTag($tId = (int) $tag['id']);
|
||||
|
||||
$this->createModelRelation(
|
||||
$request->header->account,
|
||||
$file->id,
|
||||
$tId,
|
||||
MediaMapper::class,
|
||||
'types',
|
||||
'tags',
|
||||
'',
|
||||
$request->getOrigin()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->hasData('tags')) {
|
||||
$file->tags = $this->app->moduleManager->get('Tag', 'Api')->createTagsFromRequest($request);
|
||||
}
|
||||
|
||||
$this->createModelRelation(
|
||||
$request->header->account,
|
||||
$file->id,
|
||||
\array_map(function (\Modules\Tag\Models\Tag $tag) { return $tag->id; }, $file->tags),
|
||||
MediaMapper::class,
|
||||
'tags',
|
||||
'',
|
||||
$request->getOrigin()
|
||||
);
|
||||
}
|
||||
|
||||
$this->createStandardAddResponse($request, $response, $ids);
|
||||
|
|
@ -337,7 +307,7 @@ final class ApiController extends Controller
|
|||
bool $readContent = false,
|
||||
?int $unit = null,
|
||||
bool $createCollection = true,
|
||||
?int $type = null,
|
||||
?int $tag = null,
|
||||
?int $rel = null,
|
||||
string $mapper = '',
|
||||
string $field = ''
|
||||
|
|
@ -394,9 +364,9 @@ final class ApiController extends Controller
|
|||
isEncrypted: !empty($encryptionKey)
|
||||
);
|
||||
|
||||
// Create relation to type
|
||||
if (!empty($type)) {
|
||||
$this->createModelRelation($account, $media->id, $type, MediaMapper::class, 'types', '', '127.0.0.1');
|
||||
// Create relation to tag
|
||||
if (!empty($tag)) {
|
||||
$this->createModelRelation($account, $media->id, $tag, MediaMapper::class, 'tags', '', '127.0.0.1');
|
||||
}
|
||||
|
||||
// Create relation to model
|
||||
|
|
@ -1125,6 +1095,10 @@ final class ApiController extends Controller
|
|||
string $collectionPath = ''
|
||||
) : void
|
||||
{
|
||||
if (empty($files)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var \Modules\Media\Models\Media[] $mediaFiles */
|
||||
$mediaFiles = MediaMapper::getAll()
|
||||
->where('id', $files)
|
||||
|
|
@ -1601,144 +1575,6 @@ final class ApiController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate document create request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateMediaTypeCreate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['name'] = !$request->hasData('name'))
|
||||
) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create document
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiMediaTypeCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateMediaTypeCreate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidCreateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$type = $this->createDocTypeFromRequest($request);
|
||||
$this->createModel($request->header->account, $type, MediaTypeMapper::class, 'doc_type', $request->getOrigin());
|
||||
$this->createStandardCreateResponse($request, $response, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create task from request.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return MediaType
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createDocTypeFromRequest(RequestAbstract $request) : MediaType
|
||||
{
|
||||
$type = new MediaType();
|
||||
$type->name = $request->getDataString('name') ?? '';
|
||||
|
||||
if ($request->hasData('title')) {
|
||||
$type->setL11n(
|
||||
$request->getDataString('title') ?? '',
|
||||
ISO639x1Enum::tryFromValue($request->getDataString('lang')) ?? $request->header->l11n->language
|
||||
);
|
||||
}
|
||||
|
||||
return $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate l11n create request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateMediaTypeL11nCreate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['title'] = !$request->hasData('title'))
|
||||
|| ($val['type'] = !$request->hasData('type'))
|
||||
) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create media type localization
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiMediaTypeL11nCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateMediaTypeL11nCreate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidCreateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$l11nMediaType = $this->createMediaTypeL11nFromRequest($request);
|
||||
$this->createModel($request->header->account, $l11nMediaType, MediaTypeL11nMapper::class, 'media_type_l11n', $request->getOrigin());
|
||||
$this->createStandardCreateResponse($request, $response, $l11nMediaType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create media type localization from request.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return BaseStringL11n
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createMediaTypeL11nFromRequest(RequestAbstract $request) : BaseStringL11n
|
||||
{
|
||||
$l11nMediaType = new BaseStringL11n();
|
||||
$l11nMediaType->ref = $request->getDataInt('type') ?? 0;
|
||||
$l11nMediaType->content = $request->getDataString('title') ?? '';
|
||||
$l11nMediaType->language = ISO639x1Enum::tryFromValue($request->getDataString('language')) ?? $request->header->l11n->language;
|
||||
|
||||
return $l11nMediaType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize image file
|
||||
*
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ use Modules\Media\Models\CollectionMapper;
|
|||
use Modules\Media\Models\Media;
|
||||
use Modules\Media\Models\MediaClass;
|
||||
use Modules\Media\Models\MediaMapper;
|
||||
use Modules\Media\Models\MediaTypeL11nMapper;
|
||||
use Modules\Media\Models\MediaTypeMapper;
|
||||
use Modules\Media\Models\NullMedia;
|
||||
use Modules\Media\Models\PermissionCategory;
|
||||
use Modules\Media\Theme\Backend\Components\Media\ElementView;
|
||||
|
|
@ -390,47 +388,11 @@ final class BackendController extends Controller
|
|||
$settings = SettingMapper::getAll()->where('module', $id)->executeGetArray();
|
||||
$view->data['settings'] = $settings;
|
||||
|
||||
$types = MediaTypeMapper::getAll()->with('title')->where('title/language', $response->header->l11n->language)->executeGetArray();
|
||||
$view->data['types'] = $types;
|
||||
|
||||
$view->setTemplate('/Modules/' . static::NAME . '/Admin/Settings/Theme/Backend/settings');
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Routing end-point for application behavior.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return RenderableInterface
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function viewMediaTypeSettings(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
|
||||
{
|
||||
$view = new View($this->app->l11nManager, $request, $response);
|
||||
$view->setTemplate('/Modules/' . static::NAME . '/Admin/Settings/Theme/Backend/settings-type');
|
||||
|
||||
/** @var \phpOMS\Localization\BaseStringL11n $type */
|
||||
$type = MediaTypeMapper::get()
|
||||
->with('title')
|
||||
->where('title/language', $response->header->l11n->language)
|
||||
->where('id', (int) $request->getData('id'))
|
||||
->execute();
|
||||
|
||||
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1007501001, $request, $response);
|
||||
$view->data['type'] = $type;
|
||||
|
||||
$l11n = MediaTypeL11nMapper::getAll()->where('type', $type->id)->executeGetArray();
|
||||
$view->data['l11n'] = $l11n;
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Routing end-point for application behavior.
|
||||
*
|
||||
|
|
|
|||
165
Models/Media.php
165
Models/Media.php
|
|
@ -16,7 +16,6 @@ namespace Modules\Media\Models;
|
|||
|
||||
use Modules\Admin\Models\Account;
|
||||
use Modules\Admin\Models\NullAccount;
|
||||
use Modules\Tag\Models\Tag;
|
||||
use phpOMS\Security\EncryptionHelper;
|
||||
|
||||
/**
|
||||
|
|
@ -53,14 +52,6 @@ class Media implements \JsonSerializable
|
|||
*/
|
||||
public ?MediaContent $content = null;
|
||||
|
||||
/**
|
||||
* Type.
|
||||
*
|
||||
* @var MediaType[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public array $types = [];
|
||||
|
||||
/**
|
||||
* Extension.
|
||||
*
|
||||
|
|
@ -189,14 +180,6 @@ class Media implements \JsonSerializable
|
|||
*/
|
||||
public ?int $unit = null;
|
||||
|
||||
/**
|
||||
* Tags.
|
||||
*
|
||||
* @var Tag[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public array $tags = [];
|
||||
|
||||
/**
|
||||
* Language.
|
||||
*
|
||||
|
|
@ -396,104 +379,18 @@ class Media implements \JsonSerializable
|
|||
}
|
||||
|
||||
/**
|
||||
* Adding new type.
|
||||
* Has media tag by id
|
||||
*
|
||||
* @param MediaType $type MediaType
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function addMediaType(MediaType $type) : int
|
||||
{
|
||||
$this->types[] = $type;
|
||||
|
||||
\end($this->types);
|
||||
$key = (int) \key($this->types);
|
||||
\reset($this->types);
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove MediaType from list.
|
||||
*
|
||||
* @param int $id MediaType
|
||||
* @param int $id Media tag id
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function removeMediaType($id) : bool
|
||||
public function hasMediaTagId(int $id) : bool
|
||||
{
|
||||
if (isset($this->types[$id])) {
|
||||
unset($this->types[$id]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get media types.
|
||||
*
|
||||
* @return MediaType[]
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getMediaTypes() : array
|
||||
{
|
||||
return $this->types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get media type.
|
||||
*
|
||||
* @param int $id Element id
|
||||
*
|
||||
* @return MediaType
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getMediaType(int $id) : MediaType
|
||||
{
|
||||
return $this->types[$id] ?? new NullMediaType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get media type by name
|
||||
*
|
||||
* @param string $name Type name
|
||||
*
|
||||
* @return MediaType
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getMediaTypeName(string $name) : MediaType
|
||||
{
|
||||
foreach ($this->types as $type) {
|
||||
if ($type->name === $name) {
|
||||
return $type;
|
||||
}
|
||||
}
|
||||
|
||||
return new NullMediaType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Has media type by id
|
||||
*
|
||||
* @param int $id Media type id
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function hasMediaTypeId(int $id) : bool
|
||||
{
|
||||
foreach ($this->types as $type) {
|
||||
if ($type->id === $id) {
|
||||
foreach ($this->tags as $tag) {
|
||||
if ($tag->id === $id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -502,18 +399,18 @@ class Media implements \JsonSerializable
|
|||
}
|
||||
|
||||
/**
|
||||
* Has media type by name
|
||||
* Has media tag by name
|
||||
*
|
||||
* @param string $name Media type name
|
||||
* @param string $name Media tag name
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function hasMediaTypeName(string $name) : bool
|
||||
public function hasMediaTagName(string $name) : bool
|
||||
{
|
||||
foreach ($this->types as $type) {
|
||||
if ($type->name === $name) {
|
||||
foreach ($this->tags as $tag) {
|
||||
if ($tag->name === $name) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -521,46 +418,6 @@ class Media implements \JsonSerializable
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adding new tag.
|
||||
*
|
||||
* @param Tag $tag Tag
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function addTag(Tag $tag) : int
|
||||
{
|
||||
$this->tags[] = $tag;
|
||||
|
||||
\end($this->tags);
|
||||
$key = (int) \key($this->tags);
|
||||
\reset($this->tags);
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove Tag from list.
|
||||
*
|
||||
* @param int $id Tag
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function removeTag($id) : bool
|
||||
{
|
||||
if (isset($this->tags[$id])) {
|
||||
unset($this->tags[$id]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -589,4 +446,6 @@ class Media implements \JsonSerializable
|
|||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
|
||||
use \Modules\Tag\Models\TagListTrait;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,18 +35,18 @@ trait MediaListTrait
|
|||
public array $files = [];
|
||||
|
||||
/**
|
||||
* Get media file by type
|
||||
* Get media file by tag
|
||||
*
|
||||
* @param int $type Media type
|
||||
* @param int $tag Media tag
|
||||
*
|
||||
* @return Media
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getFileByType(int $type) : Media
|
||||
public function getFileByTag(int $tag) : Media
|
||||
{
|
||||
foreach ($this->files as $file) {
|
||||
if ($file->hasMediaTypeId($type)) {
|
||||
if ($file->hasMediaTagId($tag)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
|
@ -55,18 +55,18 @@ trait MediaListTrait
|
|||
}
|
||||
|
||||
/**
|
||||
* Get all media files by type name
|
||||
* Get all media files by tag name
|
||||
*
|
||||
* @param string $type Media type
|
||||
* @param string $tag Media tag
|
||||
*
|
||||
* @return Media
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getFileByTypeName(string $type) : Media
|
||||
public function getFileByTagName(string $tag) : Media
|
||||
{
|
||||
foreach ($this->files as $file) {
|
||||
if ($file->hasMediaTypeName($type)) {
|
||||
if ($file->hasMediaTagName($tag)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
|
@ -75,19 +75,19 @@ trait MediaListTrait
|
|||
}
|
||||
|
||||
/**
|
||||
* Get all media files by type name
|
||||
* Get all media files by tag name
|
||||
*
|
||||
* @param string $type Media type
|
||||
* @param string $tag Media tag
|
||||
*
|
||||
* @return Media[]
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getFilesByTypeName(string $type) : array
|
||||
public function getFilesByTagName(string $tag) : array
|
||||
{
|
||||
$files = [];
|
||||
foreach ($this->files as $file) {
|
||||
if ($file->hasMediaTypeName($type)) {
|
||||
if ($file->hasMediaTagName($tag)) {
|
||||
$files[] = $file;
|
||||
}
|
||||
}
|
||||
|
|
@ -96,18 +96,18 @@ trait MediaListTrait
|
|||
}
|
||||
|
||||
/**
|
||||
* Check if file with a certain type name exists
|
||||
* Check if file with a certain tag name exists
|
||||
*
|
||||
* @param string $type Type name
|
||||
* @param string $tag Tag name
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function hasFileTypeName(string $type) : bool
|
||||
public function hasFileTagName(string $tag) : bool
|
||||
{
|
||||
foreach ($this->files as $file) {
|
||||
if ($file->hasMediaTypeName($type)) {
|
||||
if ($file->hasMediaTagName($tag)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,12 +106,6 @@ class MediaMapper extends DataMapperFactory
|
|||
'external' => 'media_tag_dst',
|
||||
'self' => 'media_tag_src',
|
||||
],
|
||||
'types' => [
|
||||
'mapper' => MediaTypeMapper::class,
|
||||
'table' => 'media_type_rel',
|
||||
'external' => 'media_type_rel_dst',
|
||||
'self' => 'media_type_rel_src',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -182,8 +176,6 @@ class MediaMapper extends DataMapperFactory
|
|||
/**
|
||||
* Get parent collection
|
||||
*
|
||||
* WARNING: THIS IS NOT RETURNING THE COLLECTION OF A MEDIA OBJECT BUT ITS PARENT!!!
|
||||
*
|
||||
* @param string $path Virtual path
|
||||
*
|
||||
* @return ReadMapper
|
||||
|
|
@ -196,9 +188,6 @@ class MediaMapper extends DataMapperFactory
|
|||
$name = \basename($path);
|
||||
$virtualPath = '/' . \trim(\dirname($path), '/');
|
||||
|
||||
//$virtualPath = '/' . \trim(\substr($path, 0, \strripos($path, '/') + 1), '/');
|
||||
//$name = \substr($path, \strripos($path, '/') + 1);
|
||||
|
||||
return CollectionMapper::get()
|
||||
->with('sources')
|
||||
->with('source')
|
||||
|
|
|
|||
|
|
@ -1,129 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.2
|
||||
*
|
||||
* @package Modules\Media\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Media\Models;
|
||||
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
* Media type class.
|
||||
*
|
||||
* @package Modules\Media\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class MediaType implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* Article ID.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $id = 0;
|
||||
|
||||
/**
|
||||
* Name.
|
||||
*
|
||||
* Name used for additional identification, doesn't have to be unique.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public string $name = '';
|
||||
|
||||
/**
|
||||
* Is this media type visible in lists or only internal?
|
||||
*
|
||||
* @var bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public bool $isVisible = true;
|
||||
|
||||
/**
|
||||
* Title.
|
||||
*
|
||||
* @var string|BaseStringL11n
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public string | BaseStringL11n $title = '';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $name Name
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(string $name = '')
|
||||
{
|
||||
$this->setL11n($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getL11n() : string
|
||||
{
|
||||
return $this->title instanceof BaseStringL11n ? $this->title->content : $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title
|
||||
*
|
||||
* @param string|BaseStringL11n $title Media article title
|
||||
* @param string $lang Language
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setL11n(string | BaseStringL11n $title, string $lang = ISO639x1Enum::_EN) : void
|
||||
{
|
||||
if ($title instanceof BaseStringL11n) {
|
||||
$this->title = $title;
|
||||
} elseif ($this->title instanceof BaseStringL11n) {
|
||||
$this->title->content = $title;
|
||||
} else {
|
||||
$this->title = new BaseStringL11n();
|
||||
$this->title->ref = $this->id;
|
||||
$this->title->content = $title;
|
||||
$this->title->language = $lang;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'title' => $this->title,
|
||||
'name' => $this->name,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.2
|
||||
*
|
||||
* @package Modules\Media\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Media\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
|
||||
/**
|
||||
* Media type l11n mapper class.
|
||||
*
|
||||
* @package Modules\Media\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @template T of BaseStringL11n
|
||||
* @extends DataMapperFactory<T>
|
||||
*/
|
||||
final class MediaTypeL11nMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const COLUMNS = [
|
||||
'media_type_l11n_id' => ['name' => 'media_type_l11n_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'media_type_l11n_title' => ['name' => 'media_type_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true],
|
||||
'media_type_l11n_type' => ['name' => 'media_type_l11n_type', 'type' => 'int', 'internal' => 'ref'],
|
||||
'media_type_l11n_language' => ['name' => 'media_type_l11n_language', 'type' => 'string', 'internal' => 'language'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'media_type_l11n';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD = 'media_type_l11n_id';
|
||||
|
||||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
* @var class-string<T>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const MODEL = BaseStringL11n::class;
|
||||
}
|
||||
|
|
@ -1,83 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.2
|
||||
*
|
||||
* @package Modules\Media\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Media\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Media type mapper class.
|
||||
*
|
||||
* @package Modules\Media\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @template T of MediaType
|
||||
* @extends DataMapperFactory<T>
|
||||
*/
|
||||
final class MediaTypeMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const COLUMNS = [
|
||||
'media_type_id' => ['name' => 'media_type_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'media_type_name' => ['name' => 'media_type_name', 'type' => 'string', 'internal' => 'name'],
|
||||
'media_type_isvisible' => ['name' => 'media_type_isvisible', 'type' => 'bool', 'internal' => 'isVisible'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Has many relation.
|
||||
*
|
||||
* @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const HAS_MANY = [
|
||||
'title' => [
|
||||
'mapper' => MediaTypeL11nMapper::class,
|
||||
'table' => 'media_type_l11n',
|
||||
'self' => 'media_type_l11n_type',
|
||||
'column' => 'content',
|
||||
'external' => null,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
* @var class-string<T>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const MODEL = MediaType::class;
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'media_type';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD = 'media_type_id';
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.2
|
||||
*
|
||||
* @package Modules\Media\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Media\Models;
|
||||
|
||||
/**
|
||||
* Null media type class.
|
||||
*
|
||||
* @package Modules\Media\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullMediaType extends MediaType
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return ['id' => $this->id];
|
||||
}
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ $next = empty($this->media)
|
|||
? '{%}'
|
||||
: '{%}?{?}&mpivot=' . \end($this->media)->id . '&mptype=n';
|
||||
?>
|
||||
<div class="portlet">
|
||||
<section class="portlet">
|
||||
<div class="portlet-head"><?= $this->getHtml('Media', 'Media'); ?><i class="g-icon download btn end-xs">download</i></div>
|
||||
<div class="slider">
|
||||
<table class="default sticky">
|
||||
|
|
@ -66,4 +66,4 @@ $next = empty($this->media)
|
|||
<a tabindex="0" class="button" href="<?= UriFactory::build($next); ?>"><?= $this->getHtml('Next', '0', '0'); ?></a>
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
</section>
|
||||
|
|
@ -17,7 +17,7 @@ use phpOMS\Uri\UriFactory;
|
|||
?>
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<div class="portlet">
|
||||
<section class="portlet">
|
||||
<div class="portlet-head"><?= $this->getHtml('Upload', 'Media', 'Backend'); ?></div>
|
||||
<form id="<?= $this->form; ?>-upload">
|
||||
<div class="portlet-body">
|
||||
|
|
@ -61,7 +61,7 @@ use phpOMS\Uri\UriFactory;
|
|||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="portlet">
|
||||
<div class="portlet-head"><?= $this->getHtml('Files', 'Media', 'Backend'); ?><i class="g-icon download btn end-xs">download</i></div>
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ use phpOMS\Uri\UriFactory;
|
|||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<form method="PUT" id="media-uploader" action="<?= UriFactory::build('{/api}media/collection?csrf={$CSRF}'); ?>">
|
||||
<div class="portlet">
|
||||
<section class="portlet">
|
||||
<form method="PUT" id="media-uploader" action="<?= UriFactory::build('{/api}media/collection?csrf={$CSRF}'); ?>">
|
||||
<div class="portlet-head"><?= $this->getHtml('CreateCollection'); ?></div>
|
||||
<div class="portlet-body">
|
||||
<div class="form-group">
|
||||
|
|
@ -61,6 +61,6 @@ use phpOMS\Uri\UriFactory;
|
|||
<input type="submit" id="iMediaCreate" name="mediaCreateButton" value="<?= $this->getHtml('Create', '0', '0'); ?>">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -20,17 +20,17 @@ use phpOMS\Uri\UriFactory;
|
|||
?>
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-8">
|
||||
<div class="portlet">
|
||||
<section class="portlet">
|
||||
<div class="portlet-body">
|
||||
<input autocomplete="off" form="fEditor" name="name" type="text" class="wf-100">
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="portlet">
|
||||
<section class="portlet">
|
||||
<div class="portlet-body">
|
||||
<?= $this->getData('editor')->render('editor'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="box">
|
||||
<?= $this->getData('editor')->getData('text')->render('editor', 'content', 'fEditor'); ?>
|
||||
|
|
@ -42,7 +42,7 @@ use phpOMS\Uri\UriFactory;
|
|||
<a tabindex="0" class="button" href="<?= UriFactory::build('{/base}/media/list?path={?path}'); ?>"><?= $this->getHtml('Back'); ?></a>
|
||||
</div>
|
||||
|
||||
<div class="portlet">
|
||||
<section class="portlet">
|
||||
<form id="fEditor" method="PUT" action="<?= UriFactory::build('{/api}media/file?{?}&csrf={$CSRF}'); ?>">
|
||||
<div class="portlet-head"><?= $this->getHtml('Settings'); ?></div>
|
||||
<div class="portlet-body">
|
||||
|
|
@ -64,9 +64,9 @@ use phpOMS\Uri\UriFactory;
|
|||
<input type="submit" value="<?= $this->getHtml('Save', '0', '0'); ?>" name="save-media-file">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="portlet">
|
||||
<section class="portlet">
|
||||
<div class="portlet-body">
|
||||
<form>
|
||||
<table class="layout">
|
||||
|
|
@ -79,7 +79,7 @@ use phpOMS\Uri\UriFactory;
|
|||
</table>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ $next = empty($media) ? '{/base}/media/list' : '{/base}/media/list?{?}&offse
|
|||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="portlet">
|
||||
<section class="portlet">
|
||||
<div class="portlet-head">
|
||||
<?= $this->getHtml('Media'); ?><i class="g-icon end-xs download btn">download</i>
|
||||
</div>
|
||||
|
|
@ -249,6 +249,6 @@ $next = empty($media) ? '{/base}/media/list' : '{/base}/media/list?{?}&offse
|
|||
<?= $this->getHtml('Download'); ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ use phpOMS\Uri\UriFactory;
|
|||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<form method="PUT" id="media-uploader" action="<?= UriFactory::build('{/api}media?csrf={$CSRF}'); ?>">
|
||||
<div class="portlet">
|
||||
<section class="portlet">
|
||||
<form method="PUT" id="media-uploader" action="<?= UriFactory::build('{/api}media?csrf={$CSRF}'); ?>">
|
||||
<div class="portlet-head"><?= $this->getHtml('Upload'); ?></div>
|
||||
<div class="portlet-body">
|
||||
<div class="form-group">
|
||||
|
|
@ -60,7 +60,7 @@ use phpOMS\Uri\UriFactory;
|
|||
<div class="portlet-foot">
|
||||
<input type="submit" id="iMediaCreate" name="mediaCreateButton" value="<?= $this->getHtml('Create', '0', '0'); ?>">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -24,8 +24,8 @@
|
|||
},
|
||||
"providing": {
|
||||
"Navigation": "*",
|
||||
"Media": "*",
|
||||
"Search": "*"
|
||||
"Search": "*",
|
||||
"Tag": "*"
|
||||
},
|
||||
"load": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,69 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.2
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Media\tests\Models;
|
||||
|
||||
use Modules\Media\Models\MediaType;
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
#[\PHPUnit\Framework\Attributes\CoversClass(\Modules\Media\Models\MediaType::class)]
|
||||
final class MediaTypeTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private MediaType $type;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->type = new MediaType();
|
||||
}
|
||||
|
||||
#[\PHPUnit\Framework\Attributes\Group('module')]
|
||||
public function testDefault() : void
|
||||
{
|
||||
self::assertEquals(0, $this->type->id);
|
||||
self::assertEquals('', $this->type->name);
|
||||
}
|
||||
|
||||
#[\PHPUnit\Framework\Attributes\Group('module')]
|
||||
public function testL11nInputOutput() : void
|
||||
{
|
||||
$this->type->setL11n('Test1');
|
||||
self::assertEquals('Test1', $this->type->getL11n());
|
||||
|
||||
$this->type->setL11n(new BaseStringL11n('Test2'));
|
||||
self::assertEquals('Test2', $this->type->getL11n());
|
||||
}
|
||||
|
||||
#[\PHPUnit\Framework\Attributes\Group('module')]
|
||||
public function testSerialize() : void
|
||||
{
|
||||
$this->type->name = 'Name';
|
||||
|
||||
$serialized = $this->type->jsonSerialize();
|
||||
unset($serialized['title']);
|
||||
|
||||
self::assertEquals(
|
||||
[
|
||||
'id' => 0,
|
||||
'name' => 'Name',
|
||||
],
|
||||
$serialized
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.2
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Media\tests\Models;
|
||||
|
||||
use Modules\Media\Models\NullMediaType;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
#[\PHPUnit\Framework\Attributes\CoversClass(\Modules\Media\Models\NullMediaType::class)]
|
||||
final class NullMediaTypeTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
#[\PHPUnit\Framework\Attributes\Group('module')]
|
||||
public function testNull() : void
|
||||
{
|
||||
self::assertInstanceOf('\Modules\Media\Models\MediaType', new NullMediaType());
|
||||
}
|
||||
|
||||
#[\PHPUnit\Framework\Attributes\Group('module')]
|
||||
public function testId() : void
|
||||
{
|
||||
$null = new NullMediaType(2);
|
||||
self::assertEquals(2, $null->id);
|
||||
}
|
||||
|
||||
#[\PHPUnit\Framework\Attributes\Group('module')]
|
||||
public function testJsonSerialize() : void
|
||||
{
|
||||
$null = new NullMediaType(2);
|
||||
self::assertEquals(['id' => 2], $null->jsonSerialize());
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user