fixed bug with empty file information array

This commit is contained in:
o.pinke 2023-02-10 11:45:26 +01:00
parent d3e73bfe0a
commit efa03003be
4 changed files with 31 additions and 16 deletions

View file

@ -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%;");

View file

@ -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%;");

View file

@ -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();
}
}
?>
}

View file

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta charset="utf-8">
<title>template.tplcfg_edit_form.html</title>
<link rel="stylesheet" type="text/css" href="styles/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="styles/contenido.css">