From efa03003be6f0ca0c03c69e06ba845f2bda6fac8 Mon Sep 17 00:00:00 2001 From: "o.pinke" Date: Fri, 10 Feb 2023 11:45:26 +0100 Subject: [PATCH] fixed bug with empty file information array --- .../includes/include.html_tpl_edit_form.php | 7 ++++- conlite/includes/include.js_edit_form.php | 7 ++++- conlite/includes/include.style_edit_form.php | 31 +++++++++++-------- .../standard/template.tplcfg_edit_form.html | 2 +- 4 files changed, 31 insertions(+), 16 deletions(-) diff --git a/conlite/includes/include.html_tpl_edit_form.php b/conlite/includes/include.html_tpl_edit_form.php index 15b78ff..d3a5346 100644 --- a/conlite/includes/include.html_tpl_edit_form.php +++ b/conlite/includes/include.html_tpl_edit_form.php @@ -174,6 +174,11 @@ if (!$perm->have_perm_area_action($area, $action)) { } $aFileInfo = getFileInformation($client, $sTempFilename, $sTypeContent, $db); + if(!empty($aFileInfo["description"])) { + $sDescription = clHtmlSpecialChars($aFileInfo["description"]); + } else { + $sDescription = ''; + } $form = new UI_Table_Form("file_editor"); $form->addHeader(i18n("Edit file")); @@ -186,7 +191,7 @@ if (!$perm->have_perm_area_action($area, $action)) { $tb_name = new cHTMLTextbox("file", $sFilename, 60); $ta_code = new cHTMLTextarea("code", clHtmlSpecialChars($sCode), 100, 35, "code"); - $descr = new cHTMLTextarea("description", clHtmlSpecialChars($aFileInfo["description"]), 100, 5); + $descr = new cHTMLTextarea("description", $sDescription, 100, 5); $ta_code->setStyle("font-family: monospace;width: 100%;"); $descr->setStyle("font-family: monospace;width: 100%;"); diff --git a/conlite/includes/include.js_edit_form.php b/conlite/includes/include.js_edit_form.php index 3c663b1..0f03770 100644 --- a/conlite/includes/include.js_edit_form.php +++ b/conlite/includes/include.js_edit_form.php @@ -134,6 +134,11 @@ if (!$perm->have_perm_area_action($area, $action)) { # generate edit form if (isset($_REQUEST['action'])) { $aFileInfo = getFileInformation($client, $sFilename, $sTypeContent, $db); + if(!empty($aFileInfo["description"])) { + $sDescription = clHtmlSpecialChars($aFileInfo["description"]); + } else { + $sDescription = ''; + } $sAction = ($bEdit) ? $sActionEdit : $_REQUEST['action']; @@ -154,7 +159,7 @@ if (!$perm->have_perm_area_action($area, $action)) { $tb_name = new cHTMLTextbox("file", $sFilename, 60); $ta_code = new cHTMLTextarea("code", clHtmlSpecialChars($sCode), 100, 35, "code"); - $descr = new cHTMLTextarea("description", clHtmlSpecialChars($aFileInfo["description"]), 100, 5); + $descr = new cHTMLTextarea("description", $sDescription, 100, 5); $ta_code->setStyle("font-family: monospace;width: 100%;"); $descr->setStyle("font-family: monospace;width: 100%;"); diff --git a/conlite/includes/include.style_edit_form.php b/conlite/includes/include.style_edit_form.php index 078bcc7..4c6b271 100644 --- a/conlite/includes/include.style_edit_form.php +++ b/conlite/includes/include.style_edit_form.php @@ -158,11 +158,9 @@ if (!$perm->have_perm_area_action($area, $action)) { if ($_REQUEST['action'] == $sActionEdit) { $sCode = getFileContent($sFilename, $path); } else { - $sCode = $_REQUEST['code']; # stripslashes is required here in case of creating a new file + $sCode = $_REQUEST['code']; } - $aFileInfo = getFileInformation($client, $sTempFilename, "css", $db); - $form = new UI_Table_Form("file_editor"); $form->addHeader(i18n("Edit file")); $form->setWidth("100%"); @@ -173,16 +171,24 @@ if (!$perm->have_perm_area_action($area, $action)) { $form->setVar("tmp_file", $sTempFilename); $tb_name = new cHTMLTextbox("file", $sFilename, 60); - $ta_code = new cHTMLTextarea("code", clHtmlSpecialChars($sCode), 100, 35, "code"); - $descr = new cHTMLTextarea("description", clHtmlSpecialChars($aFileInfo["description"]), 100, 5); - - $ta_code->setStyle("font-family: monospace;width: 100%;"); - $descr->setStyle("font-family: monospace;width: 100%;"); - $ta_code->updateAttributes(array("wrap" => getEffectiveSetting('style_editor', 'wrap', 'off'))); - $form->add(i18n("Name"), $tb_name); - $form->add(i18n("Description"), $descr->render()); + + $ta_code = new cHTMLTextarea("code", clHtmlSpecialChars($sCode), 100, 35, "code"); + $ta_code->updateAttributes(array("wrap" => getEffectiveSetting('style_editor', 'wrap', 'off'))); + $ta_code->setStyle("font-family: monospace;width: 100%;"); $form->add(i18n("Code"), $ta_code); + + $aFileInfo = getFileInformation($client, $sTempFilename, "css", $db); + if(!empty($aFileInfo["description"])) { + $sDescription = clHtmlSpecialChars($aFileInfo["description"]); + } else { + $sDescription = ''; + } + + $descr = new cHTMLTextarea("description", $sDescription, 100, 5); + + $descr->setStyle("font-family: monospace;width: 100%;"); + $form->add(i18n("Description"), $descr->render()); $page->setContent($form->render()); @@ -192,5 +198,4 @@ if (!$perm->have_perm_area_action($area, $action)) { $page->addScript('reload', $sReloadScript); $page->render(); } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/conlite/templates/standard/template.tplcfg_edit_form.html b/conlite/templates/standard/template.tplcfg_edit_form.html index 3c00b3b..fa411bf 100644 --- a/conlite/templates/standard/template.tplcfg_edit_form.html +++ b/conlite/templates/standard/template.tplcfg_edit_form.html @@ -1,7 +1,7 @@ - + template.tplcfg_edit_form.html