Skip to content

Commit

Permalink
always save content from the text editor
Browse files Browse the repository at this point in the history
(cherry picked from commit d28ab43)
  • Loading branch information
ChristianMayer committed Jan 25, 2020
1 parent 7a332f2 commit 3630da0
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions source/editor/bin/save_config.php
Expand Up @@ -118,29 +118,31 @@
/** die alten Mappings und stylings übernehmen */
$objDOM = new DOMDocument('1.0', 'UTF-8');
$objDOM->formatOutput = true;
$content = "";

if ($configType === "string") {
$objDOM->loadXML($arrData[0]);
$content = $arrData[0];
} else {
foreach ($arrData as $arrRootNodeData) {
$objDOM->appendChild(createDOMFromData($objDOM, $arrRootNodeData));
}
$objDOM->preserveWhiteSpace = false;
$objDOM->formatOutput = true;

foreach ($arrData as $arrRootNodeData) {
$objDOM->appendChild(createDOMFromData($objDOM, $arrRootNodeData));
}
$content = $objDOM->saveXML();
}

$objDOM->preserveWhiteSpace = false;
$objDOM->formatOutput = true;

if ($isOhGenerated === false) {
// save the XML to its configuration file
$handle = fopen($strConfigFQFilename, "w");
fputs($handle, $objDOM->saveXML());
fputs($handle, $content);
fclose($handle);
} else {
// send generated data to openhab
$data = array(
'config' => $strConfig,
'data' => $objDOM->saveXML(),
'data' => $content,
'type' => 'xml'
);

Expand All @@ -155,7 +157,7 @@
$result = file_get_contents($saveUrl, false, $context);

if ($result === false) {
exitWithResponse(false, 'error: ' . $resp);
exitWithResponse(false, 'error');
} else {
exitWithResponse(true, 'all good, file ' . $strConfigFQFilename . ' saved');
}
Expand Down

0 comments on commit 3630da0

Please sign in to comment.