mirror of
https://github.com/Karaka-Management/oms-Editor.git
synced 2026-01-25 07:48:42 +00:00
structure editor similar to news
This commit is contained in:
parent
bf019dc76d
commit
2313782bec
|
|
@ -48,4 +48,15 @@ return [
|
|||
],
|
||||
],
|
||||
],
|
||||
'^.*/editor/edit.*$' => [
|
||||
[
|
||||
'dest' => '\Modules\Editor\Controller\BackendController:viewEditorEdit',
|
||||
'verb' => RouteVerb::GET,
|
||||
'permission' => [
|
||||
'module' => BackendController::MODULE_NAME,
|
||||
'type' => PermissionType::MODIFY,
|
||||
'state' => PermissionState::DOC,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -159,6 +159,52 @@ final class BackendController extends Controller
|
|||
$tagSelector = new \Modules\Tag\Theme\Backend\Components\TagSelector\BaseView($this->app->l11nManager, $request, $response);
|
||||
$view->addData('tagSelector', $tagSelector);
|
||||
|
||||
$view->addData('editable', $this->app->accountManager->get($accountId)->hasPermission(
|
||||
PermissionType::MODIFY, $this->app->orgId, $this->app->appName, self::MODULE_NAME, PermissionState::DOC, $doc->getId())
|
||||
);
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Routing end-point for application behaviour.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return RenderableInterface
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function viewEditorEdit(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
|
||||
{
|
||||
$view = new View($this->app->l11nManager, $request, $response);
|
||||
|
||||
/** @var \Modules\Editor\Models\EditorDoc $doc */
|
||||
$doc = EditorDocMapper::get((int) $request->getData('id'));
|
||||
$accountId = $request->getHeader()->getAccount();
|
||||
|
||||
if ($doc->getCreatedBy()->getId() !== $accountId
|
||||
&& !$this->app->accountManager->get($accountId)->hasPermission(
|
||||
PermissionType::READ, $this->app->orgId, $this->app->appName, self::MODULE_NAME, PermissionState::DOC, $doc->getId())
|
||||
) {
|
||||
$view->setTemplate('/Web/Backend/Error/403_inline');
|
||||
$response->getHeader()->setStatusCode(RequestStatusCode::R_403);
|
||||
return $view;
|
||||
}
|
||||
|
||||
$view->setTemplate('/Modules/Editor/Theme/Backend/editor-create');
|
||||
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005301001, $request, $response));
|
||||
$view->addData('doc', $doc);
|
||||
|
||||
$editor = new \Modules\Editor\Theme\Backend\Components\Editor\BaseView($this->app->l11nManager, $request, $response);
|
||||
$view->addData('editor', $editor);
|
||||
|
||||
$tagSelector = new \Modules\Tag\Theme\Backend\Components\TagSelector\BaseView($this->app->l11nManager, $request, $response);
|
||||
$view->addData('tagSelector', $tagSelector);
|
||||
|
||||
return $view;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,11 @@
|
|||
declare(strict_types=1);
|
||||
|
||||
use phpOMS\Uri\UriFactory;
|
||||
use Modules\Editor\Models\NullEditorDoc;
|
||||
|
||||
/** @var \Modules\Editor\Models\EditorDoc $doc */
|
||||
$doc = $this->getData('doc') ?? new NullEditorDoc();
|
||||
$isNewDoc = $doc instanceof NullEditorDoc;
|
||||
|
||||
/** @var \phpOMS\Views\View $this */
|
||||
echo $this->getData('nav')->render(); ?>
|
||||
|
|
@ -21,9 +26,9 @@ echo $this->getData('nav')->render(); ?>
|
|||
<div class="col-xs-12 col-md-8">
|
||||
<div class="portlet">
|
||||
<div class="portlet-body">
|
||||
<form id="fEditor" method="PUT" action="<?= UriFactory::build('{/api}editor?{?}&csrf={$CSRF}'); ?>">
|
||||
<form id="fEditor" method="<?= $isNewDoc ? 'PUT' : 'POST'; ?>" action="<?= UriFactory::build('{/api}editor?{?}&csrf={$CSRF}'); ?>">
|
||||
<div class="ipt-wrap">
|
||||
<div class="ipt-first"><input name="title" type="text" class="wf-100"></div>
|
||||
<div class="ipt-first"><input name="title" type="text" class="wf-100" value="<?= $doc->getTitle(); ?>"></div>
|
||||
<div class="ipt-second"><input type="submit" value="<?= $this->getHtml('Save') ?>"></div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
@ -37,7 +42,13 @@ echo $this->getData('nav')->render(); ?>
|
|||
</div>
|
||||
|
||||
<div class="box">
|
||||
<?= $this->getData('editor')->getData('text')->render('editor', 'plain', 'fEditor'); ?>
|
||||
<?= $this->getData('editor')->getData('text')->render(
|
||||
'editor',
|
||||
'plain',
|
||||
'fEditor',
|
||||
$doc->getPlain(),
|
||||
$doc->getContent()
|
||||
); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
|
|
@ -12,64 +13,42 @@
|
|||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @var \phpOMS\Views\View $this
|
||||
*/
|
||||
use phpOMS\Uri\UriFactory;
|
||||
|
||||
/** @var \Modules\Editor\Models\EditorDoc $doc */
|
||||
$doc = $this->getData('doc');
|
||||
|
||||
/** @var bool $editable */
|
||||
$editable = $this->getData('editable');
|
||||
|
||||
/** @var \Modules\Tag\Models\Tag[] $tag */
|
||||
$tags = $doc->getTags();
|
||||
|
||||
/** @var \phpOMS\Views\View $this */
|
||||
echo $this->getData('nav')->render(); ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<section class="box wf-100">
|
||||
<div class="inner">
|
||||
<form id="fEditor" method="POST" action="<?= \phpOMS\Uri\UriFactory::build('{/api}editor?{?}&csrf={$CSRF}'); ?>">
|
||||
<div class="ipt-wrap">
|
||||
<div class="ipt-first"><input name="title" type="text" class="wf-100" value="<?= $doc->getTitle(); ?>"></div>
|
||||
<div class="ipt-second"><input type="submit" value="<?= $this->getHtml('Save') ?>"></div>
|
||||
<section class="portlet">
|
||||
<article>
|
||||
<h1><?= $this->printHtml($doc->getTitle()); ?></h1>
|
||||
<?= $doc->getContent(); ?>
|
||||
</article>
|
||||
<?php if ($editable || !empty($tags)) : ?>
|
||||
<div class="portlet-foot">
|
||||
<div class="row">
|
||||
<div class="col-xs-6 overflowfix">
|
||||
<?php foreach ($tags as $tag) : ?>
|
||||
<span class="tag" style="background: <?= $this->printHtml($tag->getColor()); ?>"><?= $this->printHtml($tag->getTitle()); ?></span>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<section class="box wf-100">
|
||||
<div class="inner">
|
||||
<?= $this->getData('editor')->render('editor'); ?>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="box col-xs-12">
|
||||
<?= $this->getData('editor')->getData('text')->render(
|
||||
'editor',
|
||||
'plain',
|
||||
'fEditor',
|
||||
$doc->getPlain(),
|
||||
$doc->getContent()
|
||||
); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<section class="box wf-100">
|
||||
<div class="inner">
|
||||
<form>
|
||||
<table class="layout">
|
||||
<tr><td colspan="2"><label><?= $this->getHtml('Permission'); ?></label>
|
||||
<tr><td><select>
|
||||
<option>
|
||||
</select>
|
||||
<tr><td colspan="2"><label><?= $this->getHtml('GroupUser'); ?></label>
|
||||
<tr><td><input id="iPermission" name="group" type="text" placeholder=""><td><button><?= $this->getHtml('Add'); ?></button>
|
||||
</table>
|
||||
</form>
|
||||
<?php if ($editable) : ?>
|
||||
<div class="col-xs-6 rightText">
|
||||
<a tabindex="0" class="button" href="<?= UriFactory::build('{/prefix}editor/edit?id=' . $doc->getId()); ?>">Edit</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user