mirror of
https://github.com/Karaka-Management/oms-News.git
synced 2026-01-11 16:18:41 +00:00
implement todos
This commit is contained in:
parent
2e308380f8
commit
0663b517d7
9
Admin/Install/Media.install.json
Normal file
9
Admin/Install/Media.install.json
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
[
|
||||
{
|
||||
"type": "collection",
|
||||
"create_directory": true,
|
||||
"name": "News",
|
||||
"virtualPath": "/Modules",
|
||||
"user": 1
|
||||
}
|
||||
]
|
||||
43
Admin/Install/Media.php
Normal file
43
Admin/Install/Media.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\News\Admin\Install
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\News\Admin\Install;
|
||||
|
||||
use phpOMS\Application\ApplicationAbstract;
|
||||
|
||||
/**
|
||||
* Media class.
|
||||
*
|
||||
* @package Modules\News\Admin\Install
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Media
|
||||
{
|
||||
/**
|
||||
* Install media providing
|
||||
*
|
||||
* @param string $path Module path
|
||||
* @param ApplicationAbstract $app Application
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function install(string $path, ApplicationAbstract $app) : void
|
||||
{
|
||||
\Modules\Media\Admin\Installer::installExternal($app, ['path' => __DIR__ . '/Media.install.json']);
|
||||
}
|
||||
}
|
||||
|
|
@ -96,6 +96,32 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"news_media": {
|
||||
"name": "news_media",
|
||||
"fields": {
|
||||
"news_media_id": {
|
||||
"name": "news_media_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"news_media_src": {
|
||||
"name": "news_media_src",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "news",
|
||||
"foreignKey": "news_id"
|
||||
},
|
||||
"news_media_dst": {
|
||||
"name": "news_media_dst",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "media",
|
||||
"foreignKey": "media_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"news_seen": {
|
||||
"name": "news_seen",
|
||||
"fields": {
|
||||
|
|
|
|||
|
|
@ -194,6 +194,20 @@ final class ApiController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
if (!empty($uploadedFiles = $request->getFiles() ?? [])) {
|
||||
$uploaded = $this->app->moduleManager->get('Media')->uploadFiles(
|
||||
[''],
|
||||
$uploadedFiles,
|
||||
$request->header->account,
|
||||
__DIR__ . '/../../../Modules/Media/Files/Modules/News',
|
||||
'/Modules/News',
|
||||
);
|
||||
|
||||
foreach ($uploaded as $media) {
|
||||
$newsArticle->addMedia($media);
|
||||
}
|
||||
}
|
||||
|
||||
return $newsArticle;
|
||||
}
|
||||
|
||||
|
|
|
|||
BIN
Docs/Dev/img/er.png
Normal file
BIN
Docs/Dev/img/er.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 150 KiB |
|
|
@ -21,6 +21,7 @@ use Modules\Tag\Models\Tag;
|
|||
use phpOMS\Contract\ArrayableInterface;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
use phpOMS\Stdlib\Base\Exception\InvalidEnumValue;
|
||||
use Modules\Media\Models\Media;
|
||||
|
||||
/**
|
||||
* News article class.
|
||||
|
|
@ -136,6 +137,14 @@ class NewsArticle implements \JsonSerializable, ArrayableInterface
|
|||
*/
|
||||
public ?CommentList $comments = null;
|
||||
|
||||
/**
|
||||
* Media files
|
||||
*
|
||||
* @var array
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected array $media = [];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
|
@ -326,6 +335,32 @@ class NewsArticle implements \JsonSerializable, ArrayableInterface
|
|||
$this->tags[] = $tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all media
|
||||
*
|
||||
* @return Media[]
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getMedia() : array
|
||||
{
|
||||
return $this->media;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add media
|
||||
*
|
||||
* @param Media $media Media to add
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function addMedia(Media $media) : void
|
||||
{
|
||||
$this->media[] = $media;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -94,6 +94,12 @@ final class NewsArticleMapper extends DataMapperAbstract
|
|||
'self' => 'news_tag_dst',
|
||||
'external' => 'news_tag_src',
|
||||
],
|
||||
'media' => [
|
||||
'mapper' => MediaMapper::class,
|
||||
'table' => 'news_media',
|
||||
'external' => 'news_media_dst',
|
||||
'self' => 'news_media_src',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -42,6 +42,10 @@ echo $this->getData('nav')->render(); ?>
|
|||
<?php foreach ($tags as $tag) : ?>
|
||||
<span class="tag" style="background: <?= $this->printHtml($tag->color); ?>"><?= $tag->icon !== null ? '<i class="' . $this->printHtml($tag->icon ?? '') . '"></i>' : ''; ?><?= $this->printHtml($tag->getL11n()); ?></span>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php $files = $news->getMedia(); foreach ($files as $file) : ?>
|
||||
<span class="file"><?= $this->printHtml($file->name); ?></span>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php if ($editable) : ?>
|
||||
<div class="col-xs-6 end-xs plain-grid">
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user