Clean up xml in cnf files

Indentation was not satisfactory. Improves readability and presentation of cnf files created

Thanks to @dkgroot for proposing this improvement
This commit is contained in:
steve-lad 2021-07-06 12:24:34 +02:00
parent 8b06495938
commit acdf777bcc
3 changed files with 13 additions and 4 deletions

View file

@ -1,7 +1,7 @@
<module> <module>
<rawname>sccp_manager</rawname> <rawname>sccp_manager</rawname>
<name>SCCP Manager</name> <name>SCCP Manager</name>
<version>14.3.0.1</version> <version>14.3.0.0</version>
<type>setup</type> <type>setup</type>
<category>SCCP Connectivity</category> <category>SCCP Connectivity</category>
<publisher>Steve Lad, Alex GP</publisher> <publisher>Steve Lad, Alex GP</publisher>

View file

@ -112,7 +112,7 @@ class xmlinterface
$node->addAttribute('model', $var['vendor'] . ' ' . $var['model']); $node->addAttribute('model', $var['vendor'] . ' ' . $var['model']);
} }
} }
$xml_work->asXml($xml_name); // Save XMLDefault1.cnf.xml \FreePBX::Sccp_manager()->saveXml($xml_work, $xml_name); // Save XMLDefault1.cnf.xml
} }
} }
@ -347,7 +347,7 @@ class xmlinterface
} }
} }
$xml_work->asXml($xml_name); // Save \FreePBX::Sccp_manager()->saveXml($xml_work, $xml_name); // Save
return time(); return time();
} }
@ -667,7 +667,7 @@ class xmlinterface
} }
} }
$xml_work->asXml($xml_name); // Save \FreePBX::Sccp_manager()->saveXml($xml_work, $xml_name); // Save
} else { } else {
die('Error Hardware template :' . $xml_template . ' not found'); die('Error Hardware template :' . $xml_template . ' not found');
} }

View file

@ -213,6 +213,15 @@ trait helperfunctions {
return false; return false;
} }
// temporary helper function to save xml with proper indentation
public function saveXml($xml, $filename) {
$dom = new \DOMDocument("1.0");
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML($xml->asXML());
$dom->save($filename);
}
public function initVarfromXml() { public function initVarfromXml() {
if ((array) $this->xml_data) { if ((array) $this->xml_data) {
foreach ($this->xml_data->xpath('//page_group') as $item) { foreach ($this->xml_data->xpath('//page_group') as $item) {