fix dcstore xml rendering (thanks @franck-paul) closes #4
This commit is contained in:
parent
27c8f2d0af
commit
e127b460e9
2 changed files with 29 additions and 12 deletions
|
@ -1,3 +1,4 @@
|
|||
<?xml version="1.0"?>
|
||||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="improve">
|
||||
<name>improve</name>
|
||||
|
|
|
@ -60,6 +60,8 @@ class ImproveActionDcstore extends ImproveAction
|
|||
return false;
|
||||
}
|
||||
|
||||
$content = $this->prettyXML($content);
|
||||
|
||||
try {
|
||||
files::putContent($this->module['sroot'] . '/dcstore.xml', $content);
|
||||
$this->setSuccess(__('Write dcstore.xml file.'));
|
||||
|
@ -166,7 +168,21 @@ class ImproveActionDcstore extends ImproveAction
|
|||
$res = new xmlTag('modules', $rsp);
|
||||
$res->insertAttr('xmlns:da', 'http://dotaddict.org/da/');
|
||||
|
||||
return str_replace('><', ">\n<", $res->toXML());
|
||||
return self::prettyXML($res->toXML());
|
||||
}
|
||||
|
||||
private static function prettyXML(string $str): string
|
||||
{
|
||||
if (class_exists('DOMDocument')) {
|
||||
$dom = new DOMDocument('1.0');
|
||||
$dom->preserveWhiteSpace = false;
|
||||
$dom->formatOutput = true;
|
||||
$dom->loadXML($str);
|
||||
|
||||
return $dom->saveXML();
|
||||
}
|
||||
|
||||
return str_replace('><', ">\n<", $str);
|
||||
}
|
||||
|
||||
private function parseFilePattern()
|
||||
|
|
Loading…
Reference in a new issue