commit ff25d0f72cc93a96ff4ba32a3e656367c6024dc0 Author: Dennis Eichhorn Date: Sat Jun 1 20:49:59 2019 +0200 Create first search draft diff --git a/Admin/Installer.php b/Admin/Installer.php new file mode 100644 index 0000000..19e9b99 --- /dev/null +++ b/Admin/Installer.php @@ -0,0 +1,87 @@ + [ + [ + 'dest' => '\Modules\Search\Controller\ApiController:routeSearch', + 'verb' => RouteVerb::ANY, + 'permission' => [ + 'module' => ApiController::MODULE_NAME, + 'type' => PermissionType::READ, + 'state' => PermissionState::SEARCH, + ], + ], + ], +]; diff --git a/Admin/Routes/Web/Backend.php b/Admin/Routes/Web/Backend.php new file mode 100644 index 0000000..f0b60b4 --- /dev/null +++ b/Admin/Routes/Web/Backend.php @@ -0,0 +1,3 @@ += 800 + e.nextElementSibling.checked = width < 800; + } + + e.scrollTop = this.navigation[e.id].getScrollPosition().y; + e.scrollLeft = this.navigation[e.id].getScrollPosition().x; + + // Bind minimize/maximize + jsOMS.addEventListenerToAll(extend, 'click', function () { + let box = document.getElementById(this.getAttribute('for')); + + if (!box.checked) { + self.navigation[e.id].setOpen(box.id); + } else { + self.navigation[e.id].setClose(box.id); + } + + localStorage.setItem(Search.MODULE_NAME, JSON.stringify(self.navigation)); + }); + + // Bind show/hide + e.addEventListener('change', function () { + self.navigation[e.id].setVisible(this.checked); + localStorage.setItem(Search.MODULE_NAME, JSON.stringify(self.navigation)); + }); + + // Bind scroll + e.addEventListener('scroll', function () { + self.navigation[e.id].setScrollPosition(this.scrollLeft, this.scrollTop); + localStorage.setItem(Search.MODULE_NAME, JSON.stringify(self.navigation)); + }); + }; +}; + +/** + * Module id + * + * @var {string} + * @since 1.0.0 + */ +Search.MODULE_NAME = '1000500001'; + +window.omsApp.moduleManager.get('Search').bind('nav-side'); diff --git a/Controller/ApiController.php b/Controller/ApiController.php new file mode 100644 index 0000000..90daf1b --- /dev/null +++ b/Controller/ApiController.php @@ -0,0 +1,81 @@ +router = new Router(); + $this->router->importFromFile(__DIR__ . '/../SearchCommands.php'); + } + + /** + * Api method to handle basic search request + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return void + * + * @api + * + * @since 1.0.0 + */ + public function routeSearch(RequestAbstract $request, ResponseAbstract $response, $data = null) : void + { + $searchResults = $this->app->dispatcher->dispatch( + $this->router->route( + $request->getData('search') ?? '', + $request->getData('CSRF'), + $request->getRouteVerb(), + $this->app->appName, + $this->app->orgId, + $this->app->accountManager->get($request->getHeader()->getAccount()) + ), + $request, + $response + ); + + $response->getHeader()->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); + $response->set($request->getUri()->__toString(), [ + 'status' => NotificationLevel::HIDDEN, + 'response' => $searchResults, + ]); + } +} diff --git a/Controller/Controller.php b/Controller/Controller.php new file mode 100644 index 0000000..93e2811 --- /dev/null +++ b/Controller/Controller.php @@ -0,0 +1,80 @@ + [ + 0 => [ + 'dest' => '\Modules\Help\Controller\SearchController:searchHelp', + 'permission' => [ + 'module' => 'Help', + 'type' => 2, + 'state' => 2, + ], + ], + 1 => [ + 'dest' => '\Modules\Help\Controller\SearchController:searchHelp', + 'permission' => [ + 'module' => 'Help', + 'type' => 2, + 'state' => 2, + ], + ], + 2 => [ + 'dest' => '\Modules\Help\Controller\SearchController:searchHelp', + 'verb' => 16, + 'permission' => [ + 'module' => 'Help', + 'type' => 2, + 'state' => 2, + ], + ], + ], + '^:help :user .*$' => [ + 0 => [ + 'dest' => '\Modules\Help\Controller\SearchController:searchHelp', + 'permission' => [ + 'module' => 'Help', + 'type' => 2, + 'state' => 2, + ], + ], + 1 => [ + 'dest' => '\Modules\Help\Controller\SearchController:searchHelp', + 'permission' => [ + 'module' => 'Help', + 'type' => 2, + 'state' => 2, + ], + ], + 2 => [ + 'dest' => '\Modules\Help\Controller\SearchController:searchHelp', + 'verb' => 16, + 'permission' => [ + 'module' => 'Help', + 'type' => 2, + 'state' => 2, + ], + ], + ], + '^:help :dev .*$' => [ + 0 => [ + 'dest' => '\Modules\Help\Controller\SearchController:searchHelp', + 'permission' => [ + 'module' => 'Help', + 'type' => 2, + 'state' => 3, + ], + ], + 1 => [ + 'dest' => '\Modules\Help\Controller\SearchController:searchHelp', + 'permission' => [ + 'module' => 'Help', + 'type' => 2, + 'state' => 3, + ], + ], + 2 => [ + 'dest' => '\Modules\Help\Controller\SearchController:searchHelp', + 'verb' => 16, + 'permission' => [ + 'module' => 'Help', + 'type' => 2, + 'state' => 3, + ], + ], + ], + '^:help :module .*$' => [ + 0 => [ + 'dest' => '\Modules\Help\Controller\SearchController:searchHelp', + 'permission' => [ + 'module' => 'Help', + 'type' => 2, + 'state' => 2, + ], + ], + 1 => [ + 'dest' => '\Modules\Help\Controller\SearchController:searchHelp', + 'permission' => [ + 'module' => 'Help', + 'type' => 2, + 'state' => 2, + ], + ], + 2 => [ + 'dest' => '\Modules\Help\Controller\SearchController:searchHelp', + 'verb' => 16, + 'permission' => [ + 'module' => 'Help', + 'type' => 2, + 'state' => 2, + ], + ], + ], +]; diff --git a/img/module_teaser_small.png b/img/module_teaser_small.png new file mode 100644 index 0000000..9147e4f Binary files /dev/null and b/img/module_teaser_small.png differ diff --git a/info.json b/info.json new file mode 100644 index 0000000..cde7b54 --- /dev/null +++ b/info.json @@ -0,0 +1,38 @@ +{ + "name": { + "id": 1007600000, + "internal": "Search", + "external": "Search" + }, + "category": "General", + "version": "1.0.0", + "requirements": { + "phpOMS": "1.0.0", + "phpOMS-db": "1.0.0" + }, + "creator": { + "name": "Orange Management", + "website": "www.spl1nes.com" + }, + "description": "The search module.", + "directory": "Search", + "dependencies": { + "Admin": "1.0.0" + }, + "providing": { + }, + "load": [ + { + "pid": [ + "/" + ], + "type": 4, + "for": "Content", + "file": "Search", + "from": "Admin" + } + ], + "lang": false, + "js": true, + "css": false +}