set_base(utils::GetAbsoluteUrlAppRoot().'pages/'); $sAceDir = 'node_modules/ace-builds/src-min/'; $this->LinkScriptFromAppRoot($sAceDir.'ace.js'); $this->LinkScriptFromAppRoot($sAceDir.'mode-php.js'); $this->LinkScriptFromAppRoot($sAceDir.'theme-eclipse.js'); $this->LinkScriptFromAppRoot($sAceDir.'ext-searchbox.js'); $this->AddUiBlock(TitleUIBlockFactory::MakeForPage(Dict::S('config-edit-title'))); } public function AddAlertFromException(\Exception $e) { $oAlert = match ($e->getCode()) { self::CONFIG_WARNING => AlertUIBlockFactory::MakeForWarning('', $e->getMessage()), self::CONFIG_INFO => AlertUIBlockFactory::MakeForInformation('', $e->getMessage()), default => AlertUIBlockFactory::MakeForDanger('', $e->getMessage()), }; $this->AddUiBlock($oAlert); } public function AddConfigScripts() { $this->add_script(<<add_ready_script(<<add_script(<<isSubclassOf('AsyncTask') && !$oRefClass->isAbstract()) { $aMessages = AsyncTask::CheckRetryConfig($oTempConfig, $oRefClass->getName()); if (count($aMessages) !== 0) { foreach ($aMessages as $sMessage) { $oAlert = AlertUIBlockFactory::MakeForWarning('', $sMessage); $this->AddUiBlock($oAlert); } } } } } public function AddEditor(string $sPrevConfig, string $sNewConfig) { $sConfigChecksum = md5($sPrevConfig); // (remove EscapeHtml) N°5914 - Wrong encoding in modules configuration editor $this->AddUiBlock(new Html('

'.Dict::S('config-edit-intro').'

')); $oForm = new Form(); $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden('operation', 'save', 'operation')); $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden('transaction_id', utils::GetNewTransactionId())); $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden('checksum', $sConfigChecksum)); //--- Cancel button $oCancelButton = ButtonUIBlockFactory::MakeForCancel(Dict::S('config-cancel'), 'cancel_button', null, true, 'cancel_button'); $oCancelButton->SetOnClickJsCode("return ResetConfig();"); $oForm->AddSubBlock($oCancelButton); //--- Submit button $oSubmitButton = ButtonUIBlockFactory::MakeForPrimaryAction(Dict::S('config-apply'), null, Dict::S('config-apply'), true, 'submit_button'); $oForm->AddSubBlock($oSubmitButton); //--- Config editor $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden('prev_config', $sPrevConfig, 'prev_config')); $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden('new_config', $sNewConfig)); $oForm->AddHtml("
"); $this->AddUiBlock($oForm); $this->AddConfigScripts(); } }