userPreferences = new UserPreferences(); $formClass = PageFormList::get($formGroupName); if ($formClass === null) { return; } if (isset($_REQUEST['printview']) && $_REQUEST['printview'] == '1') { return; } if (! empty($elemId)) { $this->elemId = $elemId; } $this->groupName = $formGroupName; $cf = new ConfigFile($GLOBALS['config']->baseSettings); $this->userPreferences->pageInit($cf); $formDisplay = new $formClass($cf); // Process form $error = null; if (isset($_POST['submit_save']) && $_POST['submit_save'] == $formGroupName) { $this->processPageSettings($formDisplay, $cf, $error); } // Display forms $this->HTML = $this->getPageSettingsDisplay($formDisplay, $error); } /** * Process response to form * * @param FormDisplay $formDisplay Form * @param ConfigFile $cf Configuration file * @param Message|null $error Error message */ private function processPageSettings(&$formDisplay, &$cf, &$error): void { if (! $formDisplay->process(false) || $formDisplay->hasErrors()) { return; } // save settings $result = $this->userPreferences->save($cf->getConfigArray()); if ($result === true) { // reload page $response = ResponseRenderer::getInstance(); Core::sendHeaderLocation( $response->getFooter()->getSelfUrl() ); exit; } $error = $result; } /** * Store errors in _errorHTML * * @param FormDisplay $formDisplay Form * @param Message|null $error Error message */ private function storeError(&$formDisplay, &$error): void { $retval = ''; if ($error) { $retval .= $error->getDisplay(); } if ($formDisplay->hasErrors()) { // form has errors $retval .= ''; } $this->errorHTML = $retval; } /** * Display page-related settings * * @param FormDisplay $formDisplay Form * @param Message $error Error message * * @return string */ private function getPageSettingsDisplay(&$formDisplay, &$error) { $response = ResponseRenderer::getInstance(); $retval = ''; $this->storeError($formDisplay, $error); $retval .= '
'; $retval .= '
'; $retval .= $formDisplay->getDisplay( false, $response->getFooter()->getSelfUrl(), [ 'submit_save' => $this->groupName, ] ); $retval .= '
'; $retval .= '
'; return $retval; } /** * Get HTML output * * @return string */ public function getHTML() { return $this->HTML; } /** * Get error HTML output * * @return string */ public function getErrorHTML() { return $this->errorHTML; } }