From bf5eb7afe51107fe935b671a30d421c382a0c854 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 10 Dec 2022 22:17:54 +0100 Subject: [PATCH] fix urls --- Admin/Install/Navigation.install.json | 24 ++++++------- Controller/ApiController.php | 36 +++++++++++++++++-- .../GroupTagSelector/group-selector.tpl.php | 4 +-- Theme/Backend/accounts-list.tpl.php | 2 +- Theme/Backend/accounts-single.tpl.php | 4 +-- Theme/Backend/groups-list.tpl.php | 2 +- Theme/Backend/groups-single.tpl.php | 4 +-- Theme/Backend/modules-list.tpl.php | 2 +- Theme/Backend/modules-log.tpl.php | 2 +- Theme/Backend/page-list.tpl.php | 6 ++-- info.json | 2 +- 11 files changed, 59 insertions(+), 29 deletions(-) diff --git a/Admin/Install/Navigation.install.json b/Admin/Install/Navigation.install.json index a4d0e1e..c0afb28 100755 --- a/Admin/Install/Navigation.install.json +++ b/Admin/Install/Navigation.install.json @@ -19,7 +19,7 @@ "type": 2, "subtype": 1, "name": "Groups", - "uri": "{/prefix}admin/group/list", + "uri": "{/lang}/{/app}/admin/group/list", "target": "self", "icon": null, "order": 2, @@ -33,7 +33,7 @@ "type": 3, "subtype": 1, "name": "List", - "uri": "{/prefix}admin/group/list", + "uri": "{/lang}/{/app}/admin/group/list", "target": "self", "icon": null, "order": 1, @@ -48,7 +48,7 @@ "type": 3, "subtype": 1, "name": "Create", - "uri": "{/prefix}admin/group/create?{?}", + "uri": "{/lang}/{/app}/admin/group/create?{?}", "target": "self", "icon": null, "order": 5, @@ -65,7 +65,7 @@ "type": 2, "subtype": 1, "name": "Accounts", - "uri": "{/prefix}admin/account/list", + "uri": "{/lang}/{/app}/admin/account/list", "target": "self", "icon": null, "order": 4, @@ -79,7 +79,7 @@ "type": 3, "subtype": 1, "name": "List", - "uri": "{/prefix}admin/account/list", + "uri": "{/lang}/{/app}/admin/account/list", "target": "self", "icon": null, "order": 1, @@ -94,7 +94,7 @@ "type": 3, "subtype": 1, "name": "Create", - "uri": "{/prefix}admin/account/create?{?}", + "uri": "{/lang}/{/app}/admin/account/create?{?}", "target": "self", "icon": null, "order": 5, @@ -111,7 +111,7 @@ "type": 2, "subtype": 1, "name": "Modules", - "uri": "{/prefix}admin/module/list", + "uri": "{/lang}/{/app}/admin/module/list", "target": "self", "icon": null, "order": 5, @@ -125,7 +125,7 @@ "type": 3, "subtype": 1, "name": "Info", - "uri": "{/prefix}admin/module/info?{?}", + "uri": "{/lang}/{/app}/admin/module/info?{?}", "target": "self", "icon": null, "order": 1, @@ -140,7 +140,7 @@ "type": 3, "subtype": 1, "name": "Settings", - "uri": "{/prefix}admin/module/settings?{?}", + "uri": "{/lang}/{/app}/admin/module/settings?{?}", "target": "self", "icon": null, "order": 5, @@ -155,7 +155,7 @@ "type": 3, "subtype": 1, "name": "Routes", - "uri": "{/prefix}admin/module/route/list?{?}", + "uri": "{/lang}/{/app}/admin/module/route/list?{?}", "target": "self", "icon": null, "order": 15, @@ -170,7 +170,7 @@ "type": 3, "subtype": 1, "name": "Hooks", - "uri": "{/prefix}admin/module/hook/list?{?}", + "uri": "{/lang}/{/app}/admin/module/hook/list?{?}", "target": "self", "icon": null, "order": 15, @@ -185,7 +185,7 @@ "type": 3, "subtype": 1, "name": "Log", - "uri": "{/prefix}admin/module/log?{?}", + "uri": "{/lang}/{/app}/admin/module/log?{?}", "target": "self", "icon": null, "order": 20, diff --git a/Controller/ApiController.php b/Controller/ApiController.php index d05aa0e..cf0b6f4 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -69,7 +69,9 @@ use phpOMS\System\SystemType; use phpOMS\System\SystemUtils; use phpOMS\Uri\HttpUri; use phpOMS\Uri\UriFactory; +use phpOMS\Utils\ArrayUtils; use phpOMS\Utils\Parser\Markdown\Markdown; +use phpOMS\Utils\Parser\Php\ArrayParser; use phpOMS\Utils\RnG\StringUtils as StringRng; use phpOMS\Utils\StringUtils; use phpOMS\Validation\Network\Email as EmailValidator; @@ -227,7 +229,7 @@ final class ApiController extends Controller $token = (string) \random_bytes(64); $handler = $this->setUpServerMailHandler(); - $resetLink = UriFactory::build('{/backend}reset?user=' . $account->getId() . '&token=' . $token); + $resetLink = UriFactory::build('{/lang}/{/app}/{/backend}reset?user=' . $account->getId() . '&token=' . $token); $mail = new Email(); $mail->setFrom($emailSettings[SettingsEnum::MAIL_SERVER_ADDR], 'Karaka'); @@ -336,7 +338,7 @@ final class ApiController extends Controller ); $handler = $this->setUpServerMailHandler(); - $loginLink = UriFactory::build('{/backend}'); + $loginLink = UriFactory::build('{/lang}/{/app}/{/backend}'); $mail = new Email(); $mail->setFrom($emailSettings[SettingsEnum::MAIL_SERVER_ADDR], 'Karaka'); @@ -417,6 +419,34 @@ final class ApiController extends Controller ); } + /** + * Set app config + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return void + * + * @api + * + * @since 1.0.0 + */ + public function apiAppConfigSet(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void + { + $dataSettings = $request->getDataJson('settings'); + + $config = include __DIR__ . '/../../../config.php'; + + foreach ($dataSettings as $data) { + $config = ArrayUtils::setArray($data['path'], $config, $data['value'], '/', true); + } + + \file_put_contents(__DIR__ . '/../../../config.php', "fillJsonResponse($request, $response, NotificationLevel::OK, 'Config', 'Config successfully modified', $dataSettings); + } + /** * Api method for modifying settings * @@ -1048,7 +1078,7 @@ final class ApiController extends Controller NotificationLevel::OK, 'Account', 'Account successfully created. Link: Account', $account ); diff --git a/Theme/Backend/Components/GroupTagSelector/group-selector.tpl.php b/Theme/Backend/Components/GroupTagSelector/group-selector.tpl.php index e1c62ae..9ca6da8 100755 --- a/Theme/Backend/Components/GroupTagSelector/group-selector.tpl.php +++ b/Theme/Backend/Components/GroupTagSelector/group-selector.tpl.php @@ -6,9 +6,9 @@ { "key": 1, "listener": "click", "action": [ {"key": 1, "type": "dom.popup", "selector": "#group-selector-tpl", "aniIn": "fadeIn", "id": "getId(); ?>"}, - {"key": 2, "type": "message.request", "uri": "", "method": "GET", "request_type": "json"}, + {"key": 2, "type": "message.request", "uri": "", "method": "GET", "request_type": "json"}, {"key": 3, "type": "dom.table.append", "id": "acc-table", "aniIn": "fadeIn", "data": [], "bindings": {"id": "id", "name": "name/0"}, "position": -1}, - {"key": 4, "type": "message.request", "uri": "", "method": "GET", "request_type": "json"}, + {"key": 4, "type": "message.request", "uri": "", "method": "GET", "request_type": "json"}, {"key": 5, "type": "dom.table.append", "id": "grp-table", "aniIn": "fadeIn", "data": [], "bindings": {"id": "id", "name": "name/0"}, "position": -1} ] } diff --git a/Theme/Backend/accounts-list.tpl.php b/Theme/Backend/accounts-list.tpl.php index 4d64605..bc056a8 100755 --- a/Theme/Backend/accounts-list.tpl.php +++ b/Theme/Backend/accounts-list.tpl.php @@ -86,7 +86,7 @@ echo $this->getData('nav')->render(); ?> $value) : ++$c; - $url = UriFactory::build('admin/account/settings?{?}&id=' . $value->getId()); + $url = UriFactory::build('{/lang}/{/app}/admin/account/settings?{?}&id=' . $value->getId()); $color = 'darkred'; if ($value->getStatus() === AccountStatus::ACTIVE) { $color = 'green'; } diff --git a/Theme/Backend/accounts-single.tpl.php b/Theme/Backend/accounts-single.tpl.php index 0022981..b180745 100755 --- a/Theme/Backend/accounts-single.tpl.php +++ b/Theme/Backend/accounts-single.tpl.php @@ -190,7 +190,7 @@ echo $this->getData('nav')->render(); ?> $c = 0; $groups = $account->getGroups(); foreach ($groups as $key => $value) : ++$c; - $url = UriFactory::build('admin/group/settings?{?}&id=' . $value->getId()); + $url = UriFactory::build('{/lang}/{/app}/admin/group/settings?{?}&id=' . $value->getId()); ?> @@ -827,7 +827,7 @@ echo $this->getData('nav')->render(); ?> $audit) : ++$count; - $url = UriFactory::build('admin/audit/single?{?}&id=' . $audit->getId()); + $url = UriFactory::build('{/lang}/{/app}/admin/audit/single?{?}&id=' . $audit->getId()); ?> getId(); ?> diff --git a/Theme/Backend/groups-list.tpl.php b/Theme/Backend/groups-list.tpl.php index 940bb09..b384d73 100755 --- a/Theme/Backend/groups-list.tpl.php +++ b/Theme/Backend/groups-list.tpl.php @@ -85,7 +85,7 @@ echo $this->getData('nav')->render(); ?> $value) : ++$c; - $url = UriFactory::build('admin/group/settings?{?}&id=' . $value->getId()); + $url = UriFactory::build('{/lang}/{/app}/admin/group/settings?{?}&id=' . $value->getId()); $color = 'darkred'; if ($value->getStatus() === GroupStatus::ACTIVE) { $color = 'green'; } diff --git a/Theme/Backend/groups-single.tpl.php b/Theme/Backend/groups-single.tpl.php index b9e68a8..2fb4427 100755 --- a/Theme/Backend/groups-single.tpl.php +++ b/Theme/Backend/groups-single.tpl.php @@ -118,7 +118,7 @@ echo $this->getData('nav')->render(); ?> getHtml('ID', '0', '0'); ?> getHtml('Name'); ?> - $value) : ++$c; $url = UriFactory::build('admin/account/settings?{?}&id=' . $value->getId()); ?> + $value) : ++$c; $url = UriFactory::build('{/lang}/{/app}/admin/account/settings?{?}&id=' . $value->getId()); ?> name1; ?> name2; ?> @@ -320,7 +320,7 @@ echo $this->getData('nav')->render(); ?> getHtml('Date', 'Auditor'); ?> $audit) : ++$count; - $url = UriFactory::build('admin/audit/single?{?}&id=' . $audit->getId()); ?> + $url = UriFactory::build('{/lang}/{/app}/admin/audit/single?{?}&id=' . $audit->getId()); ?> getId(); ?> printHtml($audit->getModule()); ?> diff --git a/Theme/Backend/modules-list.tpl.php b/Theme/Backend/modules-list.tpl.php index 9fe3a54..fa678ea 100755 --- a/Theme/Backend/modules-list.tpl.php +++ b/Theme/Backend/modules-list.tpl.php @@ -75,7 +75,7 @@ $tableView->setObjects($modules); $module) : ++$count; - $url = UriFactory::build('admin/module/info?{?}&id=' . $module->getInternalName()); + $url = UriFactory::build('{/lang}/{/app}/admin/module/info?{?}&id=' . $module->getInternalName()); if (isset($active[$module->getInternalName()])) { $status = ModuleStatus::ACTIVE; diff --git a/Theme/Backend/modules-log.tpl.php b/Theme/Backend/modules-log.tpl.php index c3bf1a0..244d41b 100755 --- a/Theme/Backend/modules-log.tpl.php +++ b/Theme/Backend/modules-log.tpl.php @@ -54,7 +54,7 @@ echo $this->getData('nav')->render(); getHtml('Date', 'Auditor'); ?> $audit) : ++$count; - $url = UriFactory::build('admin/audit/single?{?}&id=' . $audit->getId()); ?> + $url = UriFactory::build('{/lang}/{/app}/admin/audit/single?{?}&id=' . $audit->getId()); ?> getId(); ?> printHtml($audit->getModule()); ?> diff --git a/Theme/Backend/page-list.tpl.php b/Theme/Backend/page-list.tpl.php index 307a66d..3da6c07 100755 --- a/Theme/Backend/page-list.tpl.php +++ b/Theme/Backend/page-list.tpl.php @@ -21,8 +21,8 @@ use phpOMS\Uri\UriFactory; */ $pages = $this->getData('pages') ?? []; -$previous = empty($pages) ? 'admin/page/list' : 'admin/page/list?{?}&id=' . \reset($pages)->getId() . '&ptype=p'; -$next = empty($pages) ? 'admin/page/list' : 'admin/page/list?{?}&id=' . \end($pages)->getId() . '&ptype=n'; +$previous = empty($pages) ? 'admin/page/list' : '{/lang}/{/app}/admin/page/list?{?}&id=' . \reset($pages)->getId() . '&ptype=p'; +$next = empty($pages) ? 'admin/page/list' : '{/lang}/{/app}/admin/page/list?{?}&id=' . \end($pages)->getId() . '&ptype=n'; echo $this->getData('nav')->render(); ?> @@ -90,7 +90,7 @@ echo $this->getData('nav')->render(); ?> $value) : ++$c; - $url = UriFactory::build('admin/account/settings?{?}&id=' . $value->getId()); + $url = UriFactory::build('{/lang}/{/app}/admin/account/settings?{?}&id=' . $value->getId()); $color = 'darkred'; if ($value->getStatus() === AccountStatus::ACTIVE) { $color = 'green'; } elseif ($value->getStatus() === AccountStatus::INACTIVE) { $color = 'darkblue'; } diff --git a/info.json b/info.json index 60b4a47..97b8c82 100755 --- a/info.json +++ b/info.json @@ -12,7 +12,7 @@ }, "creator": { "name": "Karaka", - "website": "www.spl1nes.com" + "website": "jingga.app" }, "description": "The administration module.", "directory": "Admin",