mirror of
https://github.com/Karaka-Management/oms-Editor.git
synced 2026-01-11 17:18:42 +00:00
many fixes and expands and module expansions
This commit is contained in:
parent
9bb5f561c2
commit
5ab9ad8fd1
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": "Editor",
|
||||
"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\Editor\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\Editor\Admin\Install;
|
||||
|
||||
use phpOMS\DataStorage\Database\DatabasePool;
|
||||
|
||||
/**
|
||||
* Media class.
|
||||
*
|
||||
* @package Modules\Editor\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 DatabasePool $dbPool Database pool for database interaction
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function install(string $path, DatabasePool $dbPool) : void
|
||||
{
|
||||
\Modules\Media\Admin\Installer::installExternal($dbPool, ['path' => __DIR__ . '/Media.install.json']);
|
||||
}
|
||||
}
|
||||
|
|
@ -73,5 +73,31 @@
|
|||
"foreignKey": "tag_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"editor_doc_media": {
|
||||
"name": "editor_doc_media",
|
||||
"fields": {
|
||||
"editor_doc_media_id": {
|
||||
"name": "editor_doc_media_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"editor_doc_media_src": {
|
||||
"name": "editor_doc_media_src",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "editor_doc",
|
||||
"foreignKey": "editor_doc_id"
|
||||
},
|
||||
"editor_doc_media_dst": {
|
||||
"name": "editor_doc_media_dst",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "media",
|
||||
"foreignKey": "media_id"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -25,6 +25,7 @@ use phpOMS\Message\RequestAbstract;
|
|||
use phpOMS\Message\ResponseAbstract;
|
||||
use phpOMS\Model\Message\FormValidation;
|
||||
use phpOMS\Utils\Parser\Markdown\Markdown;
|
||||
use Modules\Media\Models\PathSettings;
|
||||
|
||||
/**
|
||||
* Calendar controller class.
|
||||
|
|
@ -204,4 +205,50 @@ final class ApiController extends Controller
|
|||
$this->deleteModel($request->header->account, $doc, EditorDocMapper::class, 'doc', $request->getOrigin());
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Document', 'Document successfully deleted', $doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create files
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiFileCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
||||
{
|
||||
$uploadedFiles = $request->getFiles() ?? [];
|
||||
|
||||
if (empty($uploadedFiles)) {
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::ERROR, 'Editor', 'Invalid file', $uploadedFiles);
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$uploaded = $this->app->moduleManager->get('Media')->uploadFiles(
|
||||
$request->getData('name') ?? '',
|
||||
$uploadedFiles,
|
||||
$request->header->account,
|
||||
__DIR__ . '/../../../Modules/Media/Files/Modules/Editor/' . ($request->getData('doc') ?? '0'),
|
||||
'/Modules/Editor/' . ($request->getData('doc') ?? '0'),
|
||||
$request->getData('type') ?? '',
|
||||
'',
|
||||
'',
|
||||
PathSettings::FILE_PATH
|
||||
);
|
||||
|
||||
$this->createModelRelation(
|
||||
$request->header->account,
|
||||
(int) $request->getData('doc'),
|
||||
\reset($uploaded)->getId(),
|
||||
EditorDocMapper::class, 'media', '', $request->getOrigin()
|
||||
);
|
||||
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'File', 'File successfully updated', $uploaded);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,6 +109,7 @@ final class BackendController extends Controller
|
|||
$view->addData('collections', $collection);
|
||||
$view->addData('path', $path);
|
||||
$view->addData('docs', $docs);
|
||||
$view->addData('account', $this->app->accountManager->get($request->header->account));
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ declare(strict_types=1);
|
|||
namespace Modules\Editor\Models;
|
||||
|
||||
use Modules\Admin\Models\Account;
|
||||
use Modules\Media\Models\Media;
|
||||
use Modules\Admin\Models\NullAccount;
|
||||
use Modules\Tag\Models\Tag;
|
||||
use phpOMS\Contract\ArrayableInterface;
|
||||
|
|
@ -101,6 +102,14 @@ class EditorDoc implements \JsonSerializable, ArrayableInterface
|
|||
*/
|
||||
private array $tags = [];
|
||||
|
||||
/**
|
||||
* Media files
|
||||
*
|
||||
* @var Media[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected array $media = [];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
|
@ -176,6 +185,32 @@ class EditorDoc 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}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use Modules\Admin\Models\AccountMapper;
|
|||
use Modules\Tag\Models\TagMapper;
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\RelationType;
|
||||
use Modules\Media\Models\MediaMapper;
|
||||
|
||||
/**
|
||||
* Editor doc mapper class.
|
||||
|
|
@ -72,6 +73,12 @@ final class EditorDocMapper extends DataMapperAbstract
|
|||
'self' => 'editor_doc_tag_dst',
|
||||
'external' => 'editor_doc_tag_src',
|
||||
],
|
||||
'media' => [
|
||||
'mapper' => MediaMapper::class,
|
||||
'table' => 'editor_doc_media',
|
||||
'external' => 'editor_doc_media_dst',
|
||||
'self' => 'editor_doc_media_src',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
name="<?= $this->renderName(); ?>"
|
||||
form="<?= $this->renderForm(); ?>"
|
||||
data-tpl-text="<?= $this->renderTplText(); ?>"
|
||||
data-tpl-value="<?= $this->renderTplValue(); ?>"><?= \str_replace("\n", ' ', $this->renderPlain()); ?></textarea>
|
||||
data-tpl-value="<?= $this->renderTplValue(); ?>"><?= \str_replace("\n", ' ', $this->renderPlain()); ?></textarea>
|
||||
<input type="hidden" id="<?= $this->renderId(); ?>-parsed">
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ $docs = $this->getData('docs');
|
|||
/** @var \Modules\Media\Models\Collection[] */
|
||||
$collections = $this->getData('collections');
|
||||
$mediaPath = \urldecode($this->getData('path') ?? '/');
|
||||
$account = $this->getData('account');
|
||||
|
||||
$accountDir = $account->getId() . ' ' . $account->login;
|
||||
|
||||
$previous = empty($docs) ? '{/prefix}editor/list' : '{/prefix}editor/list?{?}&id=' . \reset($docs)->getId() . '&ptype=p';
|
||||
$next = empty($docs) ? '{/prefix}editor/list' : '{/prefix}editor/list?{?}&id=' . \end($docs)->getId() . '&ptype=n';
|
||||
|
|
@ -34,17 +37,23 @@ echo $this->getData('nav')->render(); ?>
|
|||
<div class="col-xs-12">
|
||||
<div class="box">
|
||||
<ul class="crumbs-2">
|
||||
<li data-href="<?= UriFactory::build('{/prefix}editor/list?path=/Accounts/' . $accountDir); ?>"><a href="<?= UriFactory::build('{/prefix}editor/list?path=/Accounts/' . $accountDir); ?>"><i class="fa fa-home"></i></a>
|
||||
<li data-href="<?= UriFactory::build('{/prefix}editor/list?path=/'); ?>"><a href="<?= UriFactory::build('{/prefix}editor/list?path=/'); ?>">/</a></li>
|
||||
<?php
|
||||
$subPath = '';
|
||||
$paths = \explode('/', \ltrim($mediaPath, '/'));
|
||||
$length = \count($paths);
|
||||
$parentPath = '';
|
||||
|
||||
for ($i = 0; $i < $length; ++$i) :
|
||||
if ($paths[$i] === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($i === $length - 1) {
|
||||
$parentPath = $subPath === '' ? '/' : $subPath;
|
||||
}
|
||||
|
||||
$subPath .= '/' . $paths[$i];
|
||||
|
||||
$url = UriFactory::build('{/prefix}editor/list?path=' . $subPath);
|
||||
|
|
@ -63,6 +72,10 @@ echo $this->getData('nav')->render(); ?>
|
|||
<table id="editorList" class="default">
|
||||
<thead>
|
||||
<tr>
|
||||
<td><label class="checkbox" for="editorList-0">
|
||||
<input type="checkbox" id="editorList-0" name="editorselect">
|
||||
<span class="checkmark"></span>
|
||||
</label>
|
||||
<td>
|
||||
<td class="wf-100"><?= $this->getHtml('Title'); ?>
|
||||
<label for="editorList-sort-1">
|
||||
|
|
@ -101,10 +114,23 @@ echo $this->getData('nav')->render(); ?>
|
|||
<i class="filter fa fa-filter"></i>
|
||||
</label>
|
||||
<tbody>
|
||||
<?php if (!empty($parentPath)) : $url = UriFactory::build('{/prefix}editor/list?path=' . $parentPath); ?>
|
||||
<tr tabindex="0" data-href="<?= $url; ?>">
|
||||
<td>
|
||||
<td data-label="<?= $this->getHtml('Type'); ?>"><a href="<?= $url; ?>"><i class="fa fa-folder-open-o"></i></a>
|
||||
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>">..
|
||||
</a>
|
||||
<td>
|
||||
<td>
|
||||
<?php endif; ?>
|
||||
<?php $count = 0; foreach ($collections as $key => $value) : ++$count;
|
||||
$url = UriFactory::build('{/prefix}editor/list?path=' . \rtrim($value->getVirtualPath(), '/') . '/' . $value->name);
|
||||
?>
|
||||
<tr data-href="<?= $url; ?>">
|
||||
<td><label class="checkbox" for="editorList-<?= $key; ?>">
|
||||
<input type="checkbox" id="editorList-<?= $key; ?>" name="editorselect">
|
||||
<span class="checkmark"></span>
|
||||
</label>
|
||||
<td><a href="<?= $url; ?>"><i class="fa fa-folder-open-o"></i></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->name); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->createdBy->name1); ?></a>
|
||||
|
|
@ -113,6 +139,10 @@ echo $this->getData('nav')->render(); ?>
|
|||
<?php foreach ($docs as $key => $value) : ++$count;
|
||||
$url = UriFactory::build('{/prefix}editor/single?{?}&id=' . $value->getId()); ?>
|
||||
<tr tabindex="0" data-href="<?= $url; ?>">
|
||||
<td><label class="checkbox" for="editorList-<?= $key; ?>">
|
||||
<input type="checkbox" id="editorList-<?= $key; ?>" name="editorselect">
|
||||
<span class="checkmark"></span>
|
||||
</label>
|
||||
<td><i class="fa fa-file-o"></i>
|
||||
<td data-label="<?= $this->getHtml('Title'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->title); ?></a>
|
||||
<td data-label="<?= $this->getHtml('Creator'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->createdBy->name1); ?></a>
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ use phpOMS\Uri\UriFactory;
|
|||
|
||||
/** @var \Modules\Editor\Models\EditorDoc $doc */
|
||||
$doc = $this->getData('doc');
|
||||
$files = $doc->getMedia();
|
||||
|
||||
/** @var bool $editable */
|
||||
$editable = $this->getData('editable');
|
||||
|
|
@ -50,6 +51,15 @@ echo $this->getData('nav')->render(); ?>
|
|||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($files)) : ?>
|
||||
<div class="portlet-foot">
|
||||
<ul>
|
||||
<?php foreach ($files as $file) : ?>
|
||||
<li><?= $this->printHtml($file->name); ?>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user