From 8989ea0e804045b0fb186512a85eb109203ee8ae Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 9 Oct 2016 20:07:30 +0200 Subject: [PATCH 01/14] Fix install --- Admin/Install/Navigation.php | 2 +- Admin/Installer.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Admin/Install/Navigation.php b/Admin/Install/Navigation.php index b8883ee..002d3fa 100644 --- a/Admin/Install/Navigation.php +++ b/Admin/Install/Navigation.php @@ -29,7 +29,7 @@ use phpOMS\DataStorage\Database\Pool; */ class Navigation { - public static function install(Pool $dbPool) + public static function install(string $path, Pool $dbPool) { $navData = json_decode(file_get_contents(__DIR__ . '/Navigation.install.json'), true); diff --git a/Admin/Installer.php b/Admin/Installer.php index dd0d03e..b5f9edf 100644 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -37,9 +37,9 @@ class Installer extends InstallerAbstract /** * {@inheritdoc} */ - public static function install(Pool $dbPool, InfoManager $info) + public static function install(string $path, Pool $dbPool, InfoManager $info) { - parent::install($dbPool, $info); + parent::install($path, $dbPool, $info); switch ($dbPool->get('core')->getType()) { case DatabaseType::MYSQL: From 3a6a4339a886e1f70cdfb0a9f36933d93457abeb Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 23 Oct 2016 21:49:16 +0200 Subject: [PATCH 02/14] Fixing editor bugs --- Theme/Backend/editor.tpl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Theme/Backend/editor.tpl.php b/Theme/Backend/editor.tpl.php index b11ee3d..e1850b1 100644 --- a/Theme/Backend/editor.tpl.php +++ b/Theme/Backend/editor.tpl.php @@ -1,6 +1,6 @@
- +
@@ -32,7 +32,7 @@
- +
From 51d8f8572432263265e66b2afddf8962ae679fd3 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 29 Oct 2016 20:44:52 +0200 Subject: [PATCH 03/14] Adjust database pool name --- Admin/Activate.php | 4 ++-- Admin/Deactivate.php | 4 ++-- Admin/Install/Navigation.php | 4 ++-- Admin/Installer.php | 4 ++-- Admin/Uninstall.php | 4 ++-- Admin/Update.php | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Admin/Activate.php b/Admin/Activate.php index ae2b55b..67ca2ea 100644 --- a/Admin/Activate.php +++ b/Admin/Activate.php @@ -16,7 +16,7 @@ namespace Modules\Editor\Admin; -use phpOMS\DataStorage\Database\Pool; +use phpOMS\DataStorage\Database\DatabasePool; use phpOMS\Module\ActivateAbstract; use phpOMS\Module\InfoManager; @@ -37,7 +37,7 @@ class Activate extends ActivateAbstract /** * {@inheritdoc} */ - public static function activate(Pool $dbPool, InfoManager $info) + public static function activate(DatabasePool $dbPool, InfoManager $info) { parent::activate($dbPool, $info); } diff --git a/Admin/Deactivate.php b/Admin/Deactivate.php index edfd5f5..9b7e816 100644 --- a/Admin/Deactivate.php +++ b/Admin/Deactivate.php @@ -16,7 +16,7 @@ namespace Modules\Editor\Admin; -use phpOMS\DataStorage\Database\Pool; +use phpOMS\DataStorage\Database\DatabasePool; use phpOMS\Module\DeactivateAbstract; use phpOMS\Module\InfoManager; @@ -37,7 +37,7 @@ class Deactivate extends DeactivateAbstract /** * {@inheritdoc} */ - public static function deactivate(Pool $dbPool, InfoManager $info) + public static function deactivate(DatabasePool $dbPool, InfoManager $info) { parent::deactivate($dbPool, $info); } diff --git a/Admin/Install/Navigation.php b/Admin/Install/Navigation.php index 002d3fa..2d35c76 100644 --- a/Admin/Install/Navigation.php +++ b/Admin/Install/Navigation.php @@ -14,7 +14,7 @@ * @link http://orange-management.com */ namespace Modules\Editor\Admin\Install; -use phpOMS\DataStorage\Database\Pool; +use phpOMS\DataStorage\Database\DatabasePool; /** * Navigation class. @@ -29,7 +29,7 @@ use phpOMS\DataStorage\Database\Pool; */ class Navigation { - public static function install(string $path, Pool $dbPool) + public static function install(string $path, DatabasePool $dbPool) { $navData = json_decode(file_get_contents(__DIR__ . '/Navigation.install.json'), true); diff --git a/Admin/Installer.php b/Admin/Installer.php index b5f9edf..094f268 100644 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -16,7 +16,7 @@ namespace Modules\Editor\Admin; use phpOMS\DataStorage\Database\DatabaseType; -use phpOMS\DataStorage\Database\Pool; +use phpOMS\DataStorage\Database\DatabasePool; use phpOMS\Module\InfoManager; use phpOMS\Module\InstallerAbstract; @@ -37,7 +37,7 @@ class Installer extends InstallerAbstract /** * {@inheritdoc} */ - public static function install(string $path, Pool $dbPool, InfoManager $info) + public static function install(string $path, DatabasePool $dbPool, InfoManager $info) { parent::install($path, $dbPool, $info); diff --git a/Admin/Uninstall.php b/Admin/Uninstall.php index 640b9a8..fb0bf01 100644 --- a/Admin/Uninstall.php +++ b/Admin/Uninstall.php @@ -16,7 +16,7 @@ namespace Modules\Editor\Admin; -use phpOMS\DataStorage\Database\Pool; +use phpOMS\DataStorage\Database\DatabasePool; use phpOMS\Module\UninstallAbstract; /** @@ -36,7 +36,7 @@ class Uninstall extends UninstallAbstract /** * {@inheritdoc} */ - public static function uninstall(Pool $dbPool, InfoManager $info) + public static function uninstall(DatabasePool $dbPool, InfoManager $info) { parent::uninstall($dbPool, $info); } diff --git a/Admin/Update.php b/Admin/Update.php index 08e2229..2745066 100644 --- a/Admin/Update.php +++ b/Admin/Update.php @@ -16,7 +16,7 @@ namespace Modules\Editor\Admin; -use phpOMS\DataStorage\Database\Pool; +use phpOMS\DataStorage\Database\DatabasePool; use phpOMS\Module\UpdateAbstract; use phpOMS\System\File\Directory; @@ -37,7 +37,7 @@ class Update extends UpdateAbstract /** * {@inheritdoc} */ - public static function update(Pool $dbPool, array $info) + public static function update(DatabasePool $dbPool, array $info) { Directory::deletePath(__DIR__ . '/Update'); mkdir('Update'); From c7ff36a00620297986ad0903bdc8ccfad5f91a85 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 6 Nov 2016 14:41:32 +0100 Subject: [PATCH 04/14] Creating first function for editor --- Models/Editor.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Models/Editor.js diff --git a/Models/Editor.js b/Models/Editor.js new file mode 100644 index 0000000..9ffd623 --- /dev/null +++ b/Models/Editor.js @@ -0,0 +1,28 @@ +(function (jsOMS) + { + "use strict"; + + jsOMS.Modules.Editor.Editor = function (editor) + { + + }; + + jsOMS.Modules.Editor.prototype.getSelectedText = function() + { + var text = ''; + var activeEl = document.activeElement; + var activeElTagName = activeEl ? activeEl.tagName.toLowerCase() : null; + if ( + (activeElTagName === 'textarea' || activeElTagName === 'input') && + /^(?:text|search|password|tel|url)$/i.test(activeEl.type) && + (typeof activeEl.selectionStart === 'number') + ) { + text = activeEl.value.slice(activeEl.selectionStart, activeEl.selectionEnd); + } else if (window.getSelection) { + text = window.getSelection().toString(); + } + return text; + }; + + }(window.jsOMS = window.jsOMS || {}) +); \ No newline at end of file From 835fa99d549767013544ba11d2813724080a925a Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 9 Nov 2016 21:14:37 +0100 Subject: [PATCH 05/14] Preparing editor CRUD --- Admin/Routes/Web/Api.php | 12 +++++++++ Controller.js | 0 Controller.php | 38 ++++++++++++++++++++++++++++- Theme/backend/editor-create.tpl.php | 2 +- 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 Admin/Routes/Web/Api.php create mode 100644 Controller.js diff --git a/Admin/Routes/Web/Api.php b/Admin/Routes/Web/Api.php new file mode 100644 index 0000000..308d911 --- /dev/null +++ b/Admin/Routes/Web/Api.php @@ -0,0 +1,12 @@ + [ + [ + 'dest' => '\Modules\Editor\Controller:apiEditorCreate', + 'verb' => RouteVerb::SET, + ], + ], +]; diff --git a/Controller.js b/Controller.js new file mode 100644 index 0000000..e69de29 diff --git a/Controller.php b/Controller.php index c9f9185..dc8c824 100644 --- a/Controller.php +++ b/Controller.php @@ -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 + */ + 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()); + } + } diff --git a/Theme/backend/editor-create.tpl.php b/Theme/backend/editor-create.tpl.php index a663d66..baa93e1 100644 --- a/Theme/backend/editor-create.tpl.php +++ b/Theme/backend/editor-create.tpl.php @@ -113,7 +113,7 @@ echo $this->getData('nav')->render(); ?>