mirror of
https://github.com/Karaka-Management/oms-Media.git
synced 2026-02-15 16:58:42 +00:00
september update 1
This commit is contained in:
parent
5e3a49e0e9
commit
843dfd6ea2
|
|
@ -1,4 +1,53 @@
|
||||||
{
|
{
|
||||||
|
"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_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": {
|
"media": {
|
||||||
"name": "media",
|
"name": "media",
|
||||||
"fields": {
|
"fields": {
|
||||||
|
|
@ -16,8 +65,10 @@
|
||||||
},
|
},
|
||||||
"media_type": {
|
"media_type": {
|
||||||
"name": "media_type",
|
"name": "media_type",
|
||||||
"type": "VARCHAR(255)",
|
"type": "INT",
|
||||||
"null": false
|
"null": true,
|
||||||
|
"foreignTable": "media_type",
|
||||||
|
"foreignKey": "media_type_id"
|
||||||
},
|
},
|
||||||
"media_description": {
|
"media_description": {
|
||||||
"name": "media_description",
|
"name": "media_description",
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,10 @@ namespace Modules\Media\Admin;
|
||||||
use Modules\Admin\Models\AccountMapper;
|
use Modules\Admin\Models\AccountMapper;
|
||||||
use Modules\Admin\Models\NullAccount;
|
use Modules\Admin\Models\NullAccount;
|
||||||
use Modules\Media\Controller\ApiController;
|
use Modules\Media\Controller\ApiController;
|
||||||
|
use Modules\Media\Models\MediaType;
|
||||||
|
use Modules\Media\Models\MediaTypeMapper;
|
||||||
|
use Modules\Media\Models\MediaTypeL11n;
|
||||||
|
use Modules\Media\Models\MediaTypeL11nMapper;
|
||||||
use Modules\Media\Models\Collection;
|
use Modules\Media\Models\Collection;
|
||||||
use Modules\Media\Models\CollectionMapper;
|
use Modules\Media\Models\CollectionMapper;
|
||||||
use Modules\Media\Models\Media;
|
use Modules\Media\Models\Media;
|
||||||
|
|
@ -111,6 +115,7 @@ final class Installer extends InstallerAbstract
|
||||||
$result = [
|
$result = [
|
||||||
'collection' => [],
|
'collection' => [],
|
||||||
'upload' => [],
|
'upload' => [],
|
||||||
|
'type' => [],
|
||||||
];
|
];
|
||||||
|
|
||||||
\mkdir(__DIR__ . '/tmp');
|
\mkdir(__DIR__ . '/tmp');
|
||||||
|
|
@ -122,6 +127,9 @@ final class Installer extends InstallerAbstract
|
||||||
case 'upload':
|
case 'upload':
|
||||||
$result['upload'][] = self::uploadMedia($app->dbPool, $media);
|
$result['upload'][] = self::uploadMedia($app->dbPool, $media);
|
||||||
break;
|
break;
|
||||||
|
case 'type':
|
||||||
|
$result['type'][] = self::createType($app->dbPool, $media);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -166,6 +174,33 @@ final class Installer extends InstallerAbstract
|
||||||
return $collection;
|
return $collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create type.
|
||||||
|
*
|
||||||
|
* @param DatabasePool $dbPool Database instance
|
||||||
|
* @param array $data Media info
|
||||||
|
*
|
||||||
|
* @return MediaType
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
private static function createType(DatabasePool $dbPool, array $data) : MediaType
|
||||||
|
{
|
||||||
|
$type = new MediaType();
|
||||||
|
$type->name = $data['name'] ?? '';
|
||||||
|
|
||||||
|
$id = MediaTypeMapper::create($type);
|
||||||
|
|
||||||
|
foreach ($data['l11n'] as $l11n) {
|
||||||
|
$l11n = new MediaTypeL11n($l11n['title'], $l11n['lang']);
|
||||||
|
$l11n->type = $id;
|
||||||
|
|
||||||
|
MediaTypeL11nMapper::create($l11n);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $type;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Upload media.
|
* Upload media.
|
||||||
*
|
*
|
||||||
|
|
@ -224,12 +259,12 @@ final class Installer extends InstallerAbstract
|
||||||
$media = new Media();
|
$media = new Media();
|
||||||
|
|
||||||
$media->setPath(ApiController::normalizeDbPath($data['path']) . '/' . $uFile['filename']);
|
$media->setPath(ApiController::normalizeDbPath($data['path']) . '/' . $uFile['filename']);
|
||||||
$media->name = $uFile['filename'];
|
$media->name = !empty($uFile['name']) ? $uFile['name'] : $uFile['filename'];
|
||||||
$media->size = $uFile['size'];
|
$media->size = $uFile['size'];
|
||||||
$media->createdBy = new NullAccount((int) $data['user'] ?? 1);
|
$media->createdBy = new NullAccount((int) $data['user'] ?? 1);
|
||||||
$media->extension = $uFile['extension'];
|
$media->extension = $uFile['extension'];
|
||||||
$media->setVirtualPath((string) ($data['virtualPath'] ?? '/') . '/' . $data['name']);
|
$media->setVirtualPath((string) ($data['virtualPath'] ?? '/'));
|
||||||
$media->type = $data['media_type'] ?? ''; // = identifier for modules
|
$media->type = $data['media_type'] ?? null; // = identifier for modules
|
||||||
|
|
||||||
MediaMapper::create($media);
|
MediaMapper::create($media);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,16 @@
|
||||||
<?php declare(strict_types=1);
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 8.0
|
||||||
|
*
|
||||||
|
* @package Modules
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link https://orange-management.org
|
||||||
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
use Modules\Media\Controller\ApiController;
|
use Modules\Media\Controller\ApiController;
|
||||||
use Modules\Media\Models\PermissionState;
|
use Modules\Media\Models\PermissionState;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,16 @@
|
||||||
<?php declare(strict_types=1);
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 8.0
|
||||||
|
*
|
||||||
|
* @package Modules
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link https://orange-management.org
|
||||||
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
use Modules\Media\Controller\BackendController;
|
use Modules\Media\Controller\BackendController;
|
||||||
use Modules\Media\Models\PermissionState;
|
use Modules\Media\Models\PermissionState;
|
||||||
|
|
|
||||||
|
|
@ -594,8 +594,22 @@ final class ApiController extends Controller
|
||||||
*/
|
*/
|
||||||
public function apiMediaExport(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
public function apiMediaExport(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
||||||
{
|
{
|
||||||
/** @var Media $media */
|
if (((int) $request->getData('id')) !== 0) {
|
||||||
$media = MediaMapper::get((int) $request->getData('id'));
|
/** @var Media $media */
|
||||||
|
$media = MediaMapper::get((int) $request->getData('id'));
|
||||||
|
} else {
|
||||||
|
$path = \urldecode($request->getData('path'));
|
||||||
|
$media = new NullMedia();
|
||||||
|
if (\is_file(__DIR__ . '/../../../' . \ltrim($path, '\\/'))) {
|
||||||
|
$name = \explode('.', \basename($path));
|
||||||
|
|
||||||
|
$media->name = $name[0];
|
||||||
|
$media->extension = $name[1] ?? '';
|
||||||
|
$media->setVirtualPath(\dirname($path));
|
||||||
|
$media->setPath('/' . \ltrim($path, '\\/'));
|
||||||
|
$media->isAbsolute = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$view = $this->createView($media, $request, $response);
|
$view = $this->createView($media, $request, $response);
|
||||||
$this->setMediaResponseHeader($view, $media, $request, $response);
|
$this->setMediaResponseHeader($view, $media, $request, $response);
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ final class BackendController extends Controller
|
||||||
$pathinfo = \pathinfo($file);
|
$pathinfo = \pathinfo($file);
|
||||||
|
|
||||||
$localMedia = new Media();
|
$localMedia = new Media();
|
||||||
$localMedia->name = $pathinfo['filename'];
|
$localMedia->name = $pathinfo['basename'];
|
||||||
$localMedia->extension = \is_dir($file) ? 'collection' : $pathinfo['extension'] ?? '';
|
$localMedia->extension = \is_dir($file) ? 'collection' : $pathinfo['extension'] ?? '';
|
||||||
$localMedia->setVirtualPath($path);
|
$localMedia->setVirtualPath($path);
|
||||||
$localMedia->createdBy = new Account();
|
$localMedia->createdBy = new Account();
|
||||||
|
|
|
||||||
|
|
@ -48,10 +48,10 @@ class Media implements \JsonSerializable
|
||||||
/**
|
/**
|
||||||
* Type.
|
* Type.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var null|int|MediaType
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public string $type = '';
|
public null|int|MediaType $type = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extension.
|
* Extension.
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ class MediaMapper extends DataMapperAbstract
|
||||||
protected static array $columns = [
|
protected static array $columns = [
|
||||||
'media_id' => ['name' => 'media_id', 'type' => 'int', 'internal' => 'id'],
|
'media_id' => ['name' => 'media_id', 'type' => 'int', 'internal' => 'id'],
|
||||||
'media_name' => ['name' => 'media_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
|
'media_name' => ['name' => 'media_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
|
||||||
'media_type' => ['name' => 'media_type', 'type' => 'string', 'internal' => 'type'],
|
'media_type' => ['name' => 'media_type', 'type' => 'int', 'internal' => 'type'],
|
||||||
'media_description' => ['name' => 'media_description', 'type' => 'string', 'internal' => 'description', 'autocomplete' => true],
|
'media_description' => ['name' => 'media_description', 'type' => 'string', 'internal' => 'description', 'autocomplete' => true],
|
||||||
'media_description_raw' => ['name' => 'media_description_raw', 'type' => 'string', 'internal' => 'descriptionRaw'],
|
'media_description_raw' => ['name' => 'media_description_raw', 'type' => 'string', 'internal' => 'descriptionRaw'],
|
||||||
'media_versioned' => ['name' => 'media_versioned', 'type' => 'bool', 'internal' => 'isVersioned'],
|
'media_versioned' => ['name' => 'media_versioned', 'type' => 'bool', 'internal' => 'isVersioned'],
|
||||||
|
|
@ -68,6 +68,19 @@ class MediaMapper extends DataMapperAbstract
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Belongs to.
|
||||||
|
*
|
||||||
|
* @var array<string, array{mapper:string, external:string}>
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected static array $ownsOne = [
|
||||||
|
'type' => [
|
||||||
|
'mapper' => MediaTypeMapper::class,
|
||||||
|
'external' => 'media_type',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Has many relation.
|
* Has many relation.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
118
Models/MediaType.php
Normal file
118
Models/MediaType.php
Normal file
|
|
@ -0,0 +1,118 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 8.0
|
||||||
|
*
|
||||||
|
* @package Modules\Media\Models
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link https://orange-management.org
|
||||||
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Modules\Media\Models;
|
||||||
|
|
||||||
|
use phpOMS\Contract\ArrayableInterface;
|
||||||
|
use phpOMS\Localization\ISO639x1Enum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Media type class.
|
||||||
|
*
|
||||||
|
* @package Modules\Media\Models
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @link https://orange-management.org
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
class MediaType implements \JsonSerializable, ArrayableInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Article ID.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected int $id = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected string $name = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Title.
|
||||||
|
*
|
||||||
|
* @var string|MediaTypeL11n
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected $title = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get id
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function getId() : int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function getL11n() : string
|
||||||
|
{
|
||||||
|
return $this->title instanceof MediaTypeL11n ? $this->title->title : $this->title;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set title
|
||||||
|
*
|
||||||
|
* @param string|MediaTypeL11n $title Media article title
|
||||||
|
* @param string $lang Language
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function setL11n(string | MediaTypeL11n $title, string $lang = ISO639x1Enum::_EN) : void
|
||||||
|
{
|
||||||
|
if ($title instanceof MediaTypeL11n) {
|
||||||
|
$this->title = $title;
|
||||||
|
} elseif (isset($this->title) && $this->title instanceof MediaTypeL11n) {
|
||||||
|
$this->title->title = $title;
|
||||||
|
} else {
|
||||||
|
$this->title = new MediaTypeL11n();
|
||||||
|
$this->title->title = $title;
|
||||||
|
$this->title->setLanguage($lang);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function toArray() : array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'title' => $this->title,
|
||||||
|
'name' => $this->name,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function jsonSerialize()
|
||||||
|
{
|
||||||
|
return $this->toArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
133
Models/MediaTypeL11n.php
Normal file
133
Models/MediaTypeL11n.php
Normal file
|
|
@ -0,0 +1,133 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 8.0
|
||||||
|
*
|
||||||
|
* @package Modules\Media\Models
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link https://orange-management.org
|
||||||
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Modules\Media\Models;
|
||||||
|
|
||||||
|
use phpOMS\Contract\ArrayableInterface;
|
||||||
|
use phpOMS\Localization\ISO639x1Enum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Media type l11n class.
|
||||||
|
*
|
||||||
|
* @package Modules\Media\Models
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @link https://orange-management.org
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
class MediaTypeL11n implements \JsonSerializable, ArrayableInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* ID.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected int $id = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type ID.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public int $type = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Language.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected string $language = ISO639x1Enum::_EN;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Title.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public string $title = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param string $title Title
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function __construct(string $title = '', string $language = ISO639x1Enum::_EN)
|
||||||
|
{
|
||||||
|
$this->title = $title;
|
||||||
|
$this->language = $language;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get id
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function getId() : int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get language
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function getLanguage() : string
|
||||||
|
{
|
||||||
|
return $this->language;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set language
|
||||||
|
*
|
||||||
|
* @param string $language Language
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function setLanguage(string $language) : void
|
||||||
|
{
|
||||||
|
$this->language = $language;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function toArray() : array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'title' => $this->title,
|
||||||
|
'type' => $this->type,
|
||||||
|
'language' => $this->language,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function jsonSerialize()
|
||||||
|
{
|
||||||
|
return $this->toArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
57
Models/MediaTypeL11nMapper.php
Normal file
57
Models/MediaTypeL11nMapper.php
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 8.0
|
||||||
|
*
|
||||||
|
* @package Modules\Media\Models
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link https://orange-management.org
|
||||||
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Modules\Media\Models;
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Media type l11n mapper class.
|
||||||
|
*
|
||||||
|
* @package Modules\Media\Models
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @link https://orange-management.org
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
final class MediaTypeL11nMapper extends DataMapperAbstract
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Columns.
|
||||||
|
*
|
||||||
|
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected static array $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' => 'title', 'autocomplete' => true],
|
||||||
|
'media_type_l11n_type' => ['name' => 'media_type_l11n_type', 'type' => 'int', 'internal' => 'type'],
|
||||||
|
'media_type_l11n_language' => ['name' => 'media_type_l11n_language', 'type' => 'string', 'internal' => 'language'],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Primary table.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected static string $table = 'media_type_l11n';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Primary field name.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected static string $primaryField = 'media_type_l11n_id';
|
||||||
|
}
|
||||||
80
Models/MediaTypeMapper.php
Normal file
80
Models/MediaTypeMapper.php
Normal file
|
|
@ -0,0 +1,80 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 8.0
|
||||||
|
*
|
||||||
|
* @package Modules\Media\Models
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link https://orange-management.org
|
||||||
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Modules\Media\Models;
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Media type mapper class.
|
||||||
|
*
|
||||||
|
* @package Modules\Media\Models
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @link https://orange-management.org
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
final class MediaTypeMapper extends DataMapperAbstract
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Columns.
|
||||||
|
*
|
||||||
|
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected static array $columns = [
|
||||||
|
'media_type_id' => ['name' => 'media_type_id', 'type' => 'int', 'internal' => 'id'],
|
||||||
|
'media_type_name' => ['name' => 'media_type_name', 'type' => 'string', 'internal' => 'name'],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Has many relation.
|
||||||
|
*
|
||||||
|
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected static array $hasMany = [
|
||||||
|
'title' => [
|
||||||
|
'mapper' => MediaTypeL11nMapper::class,
|
||||||
|
'table' => 'media_type_l11n',
|
||||||
|
'self' => 'media_type_l11n_type',
|
||||||
|
'column' => 'title',
|
||||||
|
'conditional' => true,
|
||||||
|
'external' => null,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model to use by the mapper.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected static string $model = MediaType::class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Primary table.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected static string $table = 'media_type';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Primary field name.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected static string $primaryField = 'media_type_id';
|
||||||
|
}
|
||||||
38
Models/NullMediaType.php
Normal file
38
Models/NullMediaType.php
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 8.0
|
||||||
|
*
|
||||||
|
* @package Modules\Media\Models
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link https://orange-management.org
|
||||||
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Modules\Media\Models;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Media type class.
|
||||||
|
*
|
||||||
|
* @package Modules\Media\Models
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @link https://orange-management.org
|
||||||
|
* @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;
|
||||||
|
}
|
||||||
|
}
|
||||||
39
Models/NullMediaTypeL11n.php
Normal file
39
Models/NullMediaTypeL11n.php
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 8.0
|
||||||
|
*
|
||||||
|
* @package Modules\Media\Models
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link https://orange-management.org
|
||||||
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Modules\Media\Models;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Media type l11n class.
|
||||||
|
*
|
||||||
|
* @package Modules\Media\Models
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @link https://orange-management.org
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
final class NullMediaTypeL11n extends MediaTypeL11n
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param int $id Model id
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function __construct(int $id = 0)
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -17,6 +17,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
$media = $this->getData('media');
|
$media = $this->getData('media');
|
||||||
|
|
||||||
|
$t = ($media->isAbsolute ? '' : __DIR__ . '/../../../../') . $media->getPath();
|
||||||
|
|
||||||
$fp = \fopen(($media->isAbsolute ? '' : __DIR__ . '/../../../../') . $media->getPath(), 'r');
|
$fp = \fopen(($media->isAbsolute ? '' : __DIR__ . '/../../../../') . $media->getPath(), 'r');
|
||||||
\fpassthru($fp);
|
\fpassthru($fp);
|
||||||
\fclose($fp);
|
\fclose($fp);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,10 @@ use phpOMS\Uri\UriFactory;
|
||||||
<section id="mediaFile" class="portlet">
|
<section id="mediaFile" class="portlet">
|
||||||
<div class="portlet-body">
|
<div class="portlet-body">
|
||||||
<div class="h-overflow centerText">
|
<div class="h-overflow centerText">
|
||||||
<img style="max-width: 100%" src="<?= UriFactory::build('{/api}media/export?id=' . $this->media->getId()); ?>" alt="<?= $this->printHtml($this->media->name); ?>">
|
<img style="max-width: 100%" src="<?= $this->media->getId() !== 0
|
||||||
|
? UriFactory::build('{/api}media/export?id=' . $this->media->getId())
|
||||||
|
: UriFactory::build('{/api}media/export?path=' . \urlencode($this->media->getPath()));
|
||||||
|
?>" alt="<?= $this->printHtml($this->media->name); ?>">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
Loading…
Reference in New Issue
Block a user