diff --git a/Admin/Installer.php b/Admin/Installer.php index cb9229f..b4f04c8 100755 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -14,7 +14,12 @@ declare(strict_types=1); namespace Modules\Support\Admin; +use Modules\Support\Models\SupportApp; +use Modules\Support\Models\SupportAppMapper; use phpOMS\Module\InstallerAbstract; +use phpOMS\DataStorage\Database\DatabasePool; +use phpOMS\Module\ModuleInfo; +use phpOMS\Config\SettingsInterface; /** * Installer class. @@ -26,4 +31,16 @@ use phpOMS\Module\InstallerAbstract; */ final class Installer extends InstallerAbstract { + /** + * {@inheritdoc} + */ + public static function install(DatabasePool $dbPool, ModuleInfo $info, SettingsInterface $cfgHandler) : void + { + parent::install($dbPool, $info, $cfgHandler); + + $app = new SupportApp(); + $app->name = 'Backend'; + + $id = SupportAppMapper::create($app); + } } diff --git a/Admin/Routes/Web/Api.php b/Admin/Routes/Web/Api.php index aa3e3bd..9981d27 100755 --- a/Admin/Routes/Web/Api.php +++ b/Admin/Routes/Web/Api.php @@ -1,4 +1,16 @@ - [ + [ + 'dest' => '\Modules\Support\Controller\BackendController:viewModuleSettings', + 'verb' => RouteVerb::GET, + 'permission' => [ + 'module' => BackendController::MODULE_NAME, + 'type' => PermissionType::READ, + 'state' => \Modules\Admin\Models\PermissionState::MODULE, + ], + ], + ], '^.*/support/list.*$' => [ [ 'dest' => '\Modules\Support\Controller\BackendController:viewSupportList', diff --git a/Admin/Settings/Theme/Backend/settings.tpl.php b/Admin/Settings/Theme/Backend/settings.tpl.php new file mode 100644 index 0000000..ebebbb3 --- /dev/null +++ b/Admin/Settings/Theme/Backend/settings.tpl.php @@ -0,0 +1,216 @@ +getData('settings') ?? []; +$applications = $this->getData('applications') ?? []; + +echo $this->getData('nav')->render(); ?> + +
+
+ +
+
+ request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>> +
+
+
+
+
+
getHtml('Settings'); ?>
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+
+ + +
+
+
+
+ +
+
+
getHtml('Applications'); ?>
+
+ + + + + $application) : ++$count; + ?> + +
+ getHtml('ID', '0', '0'); ?> + + + + getHtml('Name'); ?> + + + +
+ getId(); ?> + printHtml($application->name); ?> + + +
getHtml('Empty', '0', '0'); ?> + +
+
+
+
+
+
+ + request->uri->fragment === 'c-tab-2' ? ' checked' : ''; ?>> +
+
+
+
+
getHtml('Settings'); ?>
+
+ + + + + $setting) : ++$count; + ?> + +
+ getHtml('ID', '0', '0'); ?> + + + + getHtml('Name'); ?> + + + + getHtml('Value'); ?> + getHtml('Group'); ?> + + + + getHtml('Account'); ?> + + + +
+ getId(); ?> + printHtml($setting->name); ?> + printHtml($setting->content); ?> + printHtml($setting->group); ?> + printHtml($setting->account); ?> + + +
getHtml('Empty', '0', '0'); ?> + +
+
+
+
+
+
+
+
diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 7f76971..889f506 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -14,6 +14,9 @@ declare(strict_types=1); namespace Modules\Support\Controller; +use Model\NullSetting; +use Model\SettingMapper; +use Modules\Support\Models\SupportApp; use Modules\Support\Models\TicketMapper; use Modules\Support\Views\TicketView; use phpOMS\Contract\RenderableInterface; @@ -21,6 +24,7 @@ use phpOMS\Message\RequestAbstract; use phpOMS\Message\ResponseAbstract; use phpOMS\Views\View; use phpOMS\Asset\AssetType; +use Modules\Support\Models\SupportAppMapper; /** * Support controller class. @@ -32,6 +36,22 @@ use phpOMS\Asset\AssetType; */ final class BackendController extends Controller { + /** + * 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 viewSettings(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface + { + } + /** * Routing end-point for application behaviour. * @@ -193,4 +213,39 @@ final class BackendController extends Controller return $view; } + + /** + * Method which generates the module profile view. + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return RenderableInterface Response can be rendered + * + * @since 1.0.0 + */ + public function viewModuleSettings(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface + { + $view = new View($this->app->l11nManager, $request, $response); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000105001, $request, $response)); + + $id = $request->getData('id') ?? ''; + + $settings = SettingMapper::getFor($id, 'module'); + if (!($settings instanceof NullSetting)) { + $view->setData('settings', !\is_array($settings) ? [$settings] : $settings); + } + + $applications = SupportAppMapper::getAll(); + $view->setData('applications', $applications); + + if (\is_file(__DIR__ . '/../Admin/Settings/Theme/Backend/settings.tpl.php')) { + $view->setTemplate('/Modules/' . static::MODULE_NAME . '/Admin/Settings/Theme/Backend/settings'); + } else { + $view->setTemplate('/Modules/Admin/Theme/Backend/modules-settings'); + } + + return $view; + } }