From 33f05db67db1fef5c9a03efbbfaa632780843750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B9=20=D0=9B=D0=B5?= =?UTF-8?q?=D0=B4=D0=B5=D0=BD=D0=B5=D0=B2?= Date: Tue, 29 Jan 2019 01:34:10 +0300 Subject: [PATCH] some interface improvements --- src/Module.php | 4 +++- src/Options/Form.php | 23 +++++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/Module.php b/src/Module.php index 7b77806..161502d 100644 --- a/src/Module.php +++ b/src/Module.php @@ -8,6 +8,7 @@ class Module { private $MODULE_ID; private $MODULE_VERSION; private $MODULE_VERSION_DATE; + private $ADMIN_FORM_ID; public $options; public $logger; @@ -25,6 +26,7 @@ public function __construct(array $options = []) { $this->MODULE_ID = $options['MODULE_ID']; $this->MODULE_VERSION = $options['MODULE_VERSION']; $this->MODULE_VERSION_DATE = $options['MODULE_VERSION_DATE']; + $this->ADMIN_FORM_ID = $options['ADMIN_FORM_ID']; $this->options = new Options\Manager($this->MODULE_ID); $this->logger = new Logger($this->MODULE_ID); @@ -71,7 +73,7 @@ public function setVersionDate($MODULE_VERSION_DATE) { } public function showOptionsForm() { - $form = new Options\Form($this->options); + $form = new Options\Form($this->options, $this->ADMIN_FORM_ID); $form->handleRequest(); $form->write(); } diff --git a/src/Options/Form.php b/src/Options/Form.php index 9571f89..4dadde8 100644 --- a/src/Options/Form.php +++ b/src/Options/Form.php @@ -19,15 +19,17 @@ class Form { private $tabControl = null; private $context = null; + private $formId = null; - public function __construct($options) { + public function __construct($options, $formId) { global $USER, $APPLICATION; if (!$USER->isAdmin()) { - $APPLICATION->authForm('Nope'); + $APPLICATION->authForm('Access denied.'); } $this->options = $options; $this->context = Application::getInstance()->getContext(); + $this->formId = $formId ?: 'module_settings_form'; defined('ADMIN_MODULE_NAME') or define('ADMIN_MODULE_NAME', $this->options->getModuleId()); } @@ -99,20 +101,28 @@ public function write() { $this->tabControl->begin(); ?> -
+ tabControl->tabs as $tab) { $this->tabControl->beginNextTab(); $filteredOpts = array_filter($fields, function ($opt) use ($tab) { return $opt['tab'] === $tab['DIV']; }); foreach ($filteredOpts as $opt_name=>$opt) { ?> - + - + if (strlen($opt['label'])) { + ?> + + + + +