mirror of
https://github.com/Karaka-Management/oms-Editor.git
synced 2026-02-08 06:38:39 +00:00
Preparing editor CRUD
This commit is contained in:
parent
c7ff36a006
commit
835fa99d54
12
Admin/Routes/Web/Api.php
Normal file
12
Admin/Routes/Web/Api.php
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
use phpOMS\Router\RouteVerb;
|
||||
|
||||
return [
|
||||
'^.*/api/editor.*$' => [
|
||||
[
|
||||
'dest' => '\Modules\Editor\Controller:apiEditorCreate',
|
||||
'verb' => RouteVerb::SET,
|
||||
],
|
||||
],
|
||||
];
|
||||
0
Controller.js
Normal file
0
Controller.js
Normal file
|
|
@ -94,7 +94,7 @@ class Controller extends ModuleAbstract implements WebInterface
|
|||
public function setUpEditorEditor(RequestAbstract $request, ResponseAbstract $response, $data = null)
|
||||
{
|
||||
$head = $response->get('Content')->getData('head');
|
||||
$head->addAsset(AssetType::JS, $request->getUri()->getBase() . 'Modules/Editor/ModuleEditor.js');
|
||||
$head->addAsset(AssetType::JS, $request->getUri()->getBase() . 'Modules/Editor/Controller.js');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -135,4 +135,40 @@ class Controller extends ModuleAbstract implements WebInterface
|
|||
return $view;
|
||||
}
|
||||
|
||||
private function validateEditorCreate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (
|
||||
($val['title'] = empty($request->getData('title')))
|
||||
|| ($val['plain'] = empty($request->getData('plain')))
|
||||
) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function apiEditorCreate(RequestAbstract $request, ResponseAbstract $response, $data = null)
|
||||
{
|
||||
if (!empty($val = $this->validateEditorCreate($request))) {
|
||||
$response->set('editor_create', new FormValidation($val));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$editorArticle = new Editor();
|
||||
|
||||
EditorMapper::create($editorArticle);
|
||||
|
||||
$response->set('editor', $editorArticle->jsonSerialize());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
<option>
|
||||
</select>
|
||||
<tr><td colspan="2"><label><?= $this->getText('GroupUser') ?></label>
|
||||
<tr><td><input id="iPermission" name="group" type="text" placeholder=""><td><button><?= $this->getText('Add', 0, 0) ?></button>
|
||||
<tr><td><input id="iPermission" name="group" type="text" placeholder=""><td><button><?= $this->getText('Add') ?></button>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user