mirror of
https://github.com/Karaka-Management/oms-QA.git
synced 2026-02-15 23:38:41 +00:00
implement todos
This commit is contained in:
parent
7dbf3fb489
commit
3bed5d68f7
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": "QA",
|
||||||
|
"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\QA\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\QA\Admin\Install;
|
||||||
|
|
||||||
|
use phpOMS\Application\ApplicationAbstract;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Media class.
|
||||||
|
*
|
||||||
|
* @package Modules\QA\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']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -72,6 +72,32 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"qa_question_media": {
|
||||||
|
"name": "qa_question_media",
|
||||||
|
"fields": {
|
||||||
|
"qa_question_media_id": {
|
||||||
|
"name": "qa_question_media_id",
|
||||||
|
"type": "INT",
|
||||||
|
"null": false,
|
||||||
|
"primary": true,
|
||||||
|
"autoincrement": true
|
||||||
|
},
|
||||||
|
"qa_question_media_src": {
|
||||||
|
"name": "qa_question_media_src",
|
||||||
|
"type": "INT",
|
||||||
|
"null": false,
|
||||||
|
"foreignTable": "qa_question",
|
||||||
|
"foreignKey": "qa_question_id"
|
||||||
|
},
|
||||||
|
"qa_question_media_dst": {
|
||||||
|
"name": "qa_question_media_dst",
|
||||||
|
"type": "INT",
|
||||||
|
"null": false,
|
||||||
|
"foreignTable": "media",
|
||||||
|
"foreignKey": "media_id"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"qa_question_vote": {
|
"qa_question_vote": {
|
||||||
"name": "qa_question_vote",
|
"name": "qa_question_vote",
|
||||||
"fields": {
|
"fields": {
|
||||||
|
|
@ -187,6 +213,32 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"qa_answer_media": {
|
||||||
|
"name": "qa_answer_media",
|
||||||
|
"fields": {
|
||||||
|
"qa_answer_media_id": {
|
||||||
|
"name": "qa_answer_media_id",
|
||||||
|
"type": "INT",
|
||||||
|
"null": false,
|
||||||
|
"primary": true,
|
||||||
|
"autoincrement": true
|
||||||
|
},
|
||||||
|
"qa_answer_media_src": {
|
||||||
|
"name": "qa_answer_media_src",
|
||||||
|
"type": "INT",
|
||||||
|
"null": false,
|
||||||
|
"foreignTable": "qa_answer",
|
||||||
|
"foreignKey": "qa_answer_id"
|
||||||
|
},
|
||||||
|
"qa_answer_media_dst": {
|
||||||
|
"name": "qa_answer_media_dst",
|
||||||
|
"type": "INT",
|
||||||
|
"null": false,
|
||||||
|
"foreignTable": "media",
|
||||||
|
"foreignKey": "media_id"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"qa_answer_vote": {
|
"qa_answer_vote": {
|
||||||
"name": "qa_answer_vote",
|
"name": "qa_answer_vote",
|
||||||
"fields": {
|
"fields": {
|
||||||
|
|
|
||||||
|
|
@ -170,6 +170,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/QA',
|
||||||
|
'/Modules/QA',
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($uploaded as $media) {
|
||||||
|
$question->addMedia($media);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $question;
|
return $question;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -247,6 +261,20 @@ final class ApiController extends Controller
|
||||||
$answer->setStatus((int) $request->getData('status'));
|
$answer->setStatus((int) $request->getData('status'));
|
||||||
$answer->createdBy = new Profile(new NullAccount($request->header->account));
|
$answer->createdBy = new Profile(new NullAccount($request->header->account));
|
||||||
|
|
||||||
|
if (!empty($uploadedFiles = $request->getFiles() ?? [])) {
|
||||||
|
$uploaded = $this->app->moduleManager->get('Media')->uploadFiles(
|
||||||
|
[''],
|
||||||
|
$uploadedFiles,
|
||||||
|
$request->header->account,
|
||||||
|
__DIR__ . '/../../../Modules/Media/Files/Modules/QA',
|
||||||
|
'/Modules/QA',
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($uploaded as $media) {
|
||||||
|
$answer->addMedia($media);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $answer;
|
return $answer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
BIN
Docs/Dev/img/er.png
Normal file
BIN
Docs/Dev/img/er.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 229 KiB |
|
|
@ -99,6 +99,14 @@ class QAAnswer implements \JsonSerializable
|
||||||
*/
|
*/
|
||||||
private array $votes = [];
|
private array $votes = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Media files
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected array $media = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
|
|
@ -252,6 +260,32 @@ class QAAnswer implements \JsonSerializable
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ namespace Modules\QA\Models;
|
||||||
|
|
||||||
use Modules\Profile\Models\ProfileMapper;
|
use Modules\Profile\Models\ProfileMapper;
|
||||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||||
|
use Modules\Media\Models\MediaMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mapper class.
|
* Mapper class.
|
||||||
|
|
@ -75,6 +76,12 @@ final class QAAnswerMapper extends DataMapperAbstract
|
||||||
'self' => 'qa_answer_vote_answer',
|
'self' => 'qa_answer_vote_answer',
|
||||||
'external' => null,
|
'external' => null,
|
||||||
],
|
],
|
||||||
|
'media' => [
|
||||||
|
'mapper' => MediaMapper::class,
|
||||||
|
'table' => 'qa_answer_media',
|
||||||
|
'external' => 'qa_answer_media_dst',
|
||||||
|
'self' => 'qa_answer_media_src',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,14 @@ class QAQuestion implements \JsonSerializable
|
||||||
*/
|
*/
|
||||||
public QAApp $app;
|
public QAApp $app;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Media files
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected array $media = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
|
|
@ -393,6 +401,32 @@ class QAQuestion implements \JsonSerializable
|
||||||
$this->answers[] = $answer;
|
$this->answers[] = $answer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ namespace Modules\QA\Models;
|
||||||
use Modules\Profile\Models\ProfileMapper;
|
use Modules\Profile\Models\ProfileMapper;
|
||||||
use Modules\Tag\Models\TagMapper;
|
use Modules\Tag\Models\TagMapper;
|
||||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||||
|
use Modules\Media\Models\MediaMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mapper class.
|
* Mapper class.
|
||||||
|
|
@ -71,6 +72,12 @@ final class QAQuestionMapper extends DataMapperAbstract
|
||||||
'self' => 'qa_tag_dst',
|
'self' => 'qa_tag_dst',
|
||||||
'external' => 'qa_tag_src',
|
'external' => 'qa_tag_src',
|
||||||
],
|
],
|
||||||
|
'media' => [
|
||||||
|
'mapper' => MediaMapper::class,
|
||||||
|
'table' => 'qa_question_media',
|
||||||
|
'external' => 'qa_question_media_dst',
|
||||||
|
'self' => 'qa_question_media_src',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,10 @@ echo $this->getData('nav')->render();
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?php $files = $question->getMedia(); foreach ($files as $file) : ?>
|
||||||
|
<span class="file"><?= $this->printHtml($file->name); ?></span>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
||||||
<a class="account-info" href="<?= UriFactory::build('{/prefix}profile/single?{?}&id=' . $question->createdBy->getId()); ?>">
|
<a class="account-info" href="<?= UriFactory::build('{/prefix}profile/single?{?}&id=' . $question->createdBy->getId()); ?>">
|
||||||
<span class="name">
|
<span class="name">
|
||||||
<div class="content"><?= $this->printHtml($question->createdBy->account->name2); ?>, <?= $this->printHtml($question->createdBy->account->name1); ?></div>
|
<div class="content"><?= $this->printHtml($question->createdBy->account->name2); ?>, <?= $this->printHtml($question->createdBy->account->name1); ?></div>
|
||||||
|
|
@ -90,13 +94,17 @@ echo $this->getData('nav')->render();
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<section class="portlet">
|
<section class="portlet wf-100">
|
||||||
<div class="portlet-body">
|
<div class="portlet-body">
|
||||||
<article>
|
<article>
|
||||||
<?= $answer->answer; ?>
|
<?= $answer->answer; ?>
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
<div class="portlet-foot qa-portlet-foot">
|
<div class="portlet-foot qa-portlet-foot">
|
||||||
|
<?php $files = $answer->getMedia(); foreach ($files as $file) : ?>
|
||||||
|
<span class="file"><?= $this->printHtml($file->name); ?></span>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
||||||
<a class="account-info" href="<?= UriFactory::build('{/prefix}profile/single?{?}&id=' . $answer->createdBy->getId()); ?>">
|
<a class="account-info" href="<?= UriFactory::build('{/prefix}profile/single?{?}&id=' . $answer->createdBy->getId()); ?>">
|
||||||
<span class="name">
|
<span class="name">
|
||||||
<div class="content"><?= $this->printHtml($answer->createdBy->account->name2); ?> <?= $this->printHtml($answer->createdBy->account->name1); ?></div>
|
<div class="content"><?= $this->printHtml($answer->createdBy->account->name2); ?> <?= $this->printHtml($answer->createdBy->account->name1); ?></div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user