implement todos

This commit is contained in:
Dennis Eichhorn 2021-07-15 21:51:30 +02:00
parent 072b19a076
commit c09d00214a
9 changed files with 139 additions and 1 deletions

View File

@ -0,0 +1,9 @@
[
{
"type": "collection",
"create_directory": true,
"name": "Knowledgebase",
"virtualPath": "/Modules",
"user": 1
}
]

43
Admin/Install/Media.php Normal file
View File

@ -0,0 +1,43 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\Knowledgebase\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\Knowledgebase\Admin\Install;
use phpOMS\Application\ApplicationAbstract;
/**
* Media class.
*
* @package Modules\Knowledgebase\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']);
}
}

View File

@ -135,6 +135,32 @@
}
}
},
"wiki_article": {
"name": "wiki_article",
"fields": {
"wiki_article_id": {
"name": "wiki_article_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"wiki_article_src": {
"name": "wiki_article_src",
"type": "INT",
"null": false,
"foreignTable": "wiki_article",
"foreignKey": "wiki_article_id"
},
"wiki_article_dst": {
"name": "wiki_article_dst",
"type": "INT",
"null": false,
"foreignTable": "media",
"foreignKey": "media_id"
}
}
},
"wiki_tag": {
"name": "wiki_tag",
"fields": {

View File

@ -110,6 +110,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/Knowledgebase',
'/Modules/Knowledgebase',
);
foreach ($uploaded as $media) {
$doc->addMedia($media);
}
}
return $doc;
}

BIN
Docs/Dev/img/er.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 KiB

View File

@ -100,6 +100,14 @@ class WikiDoc implements \JsonSerializable
*/
private array $tags = [];
/**
* Media files
*
* @var array
* @since 1.0.0
*/
protected array $media = [];
/**
* Get id.
*
@ -190,6 +198,32 @@ class WikiDoc implements \JsonSerializable
$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}
*/

View File

@ -18,6 +18,7 @@ use Modules\Tag\Models\TagMapper;
use phpOMS\DataStorage\Database\DataMapperAbstract;
use phpOMS\DataStorage\Database\Query\Builder;
use phpOMS\DataStorage\Database\RelationType;
use Modules\Media\Models\MediaMapper;
/**
* Mapper class.
@ -59,6 +60,12 @@ final class WikiDocMapper extends DataMapperAbstract
'self' => 'wiki_tag_dst',
'external' => 'wiki_tag_src',
],
'media' => [
'mapper' => MediaMapper::class,
'table' => 'wiki_article_media',
'external' => 'wiki_article_media_dst',
'self' => 'wiki_article_media_src',
],
];
/**

View File

@ -48,6 +48,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 = $doc->getMedia(); foreach ($files as $file) : ?>
<span class="file"><?= $this->printHtml($file->name); ?></span>
<?php endforeach; ?>
</div>
<?php if ($editable) : ?>
<div class="col-xs-6 rightText">

View File

@ -23,7 +23,8 @@
"Tag": "1.0.0"
},
"providing": {
"Navigation": "*"
"Navigation": "*",
"Media": "*"
},
"load": [
{