From f78305118dcebdef3254d9ae2d4261fe68a176b3 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Tue, 28 Sep 2021 21:39:07 +0200 Subject: [PATCH] use of xmlTag to generate dcstore.xml contents --- inc/lib.improve.action.dcstore.php | 33 ++++++++++++++++-------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/inc/lib.improve.action.dcstore.php b/inc/lib.improve.action.dcstore.php index c5d7b91..07e6760 100644 --- a/inc/lib.improve.action.dcstore.php +++ b/inc/lib.improve.action.dcstore.php @@ -75,37 +75,38 @@ class ImproveActionDcstore extends ImproveAction public function generateXML() { $xml = ['']; + $rsp = new xmlTag('module'); # id if (empty($this->module['id'])) { $this->setError(__('unkow module id')); } - $xml[] = sprintf('', html::escapeHTML($this->module['id'])); + $rsp->id = $this->module['id']; # name if (empty($this->module['oname'])) { $this->setError(__('unknow module name')); } - $xml[] = sprintf('%s', html::escapeHTML($this->module['oname'])); + $rsp->name($this->module['oname']); # version if (empty($this->module['version'])) { $this->setError(__('unknow module version')); } - $xml[] = sprintf('%s', html::escapeHTML($this->module['version'])); + $rsp->version($this->module['version']); # author if (empty($this->module['author'])) { $this->setError(__('unknow module author')); } - $xml[] = sprintf('%s', html::escapeHTML($this->module['author'])); + $rsp->author($this->module['author']); # desc if (empty($this->module['desc'])) { $this->setError(__('unknow module description')); } - $xml[] = sprintf('%s', html::escapeHTML($this->module['desc'])); + $rsp->desc($this->module['desc']); # repository if (empty($this->module['repository'])) { @@ -117,7 +118,7 @@ class ImproveActionDcstore extends ImproveAction if (empty($file_pattern)) { $this->setError(__('no zip file pattern set in configuration')); } - $xml[] = sprintf('%s', html::escapeHTML($file_pattern)); + $rsp->file($file_pattern); # da dc_min or requires core if (!empty($this->module['requires']) && is_array($this->module['requires'])) { @@ -134,36 +135,38 @@ class ImproveActionDcstore extends ImproveAction if (empty($this->module['dc_min'])) { $this->setWarning(__('no minimum dotclear version')); } else { - $xml[] = sprintf('%s', html::escapeHTML($this->module['dc_min'])); + $rsp->insertNode(new xmlTag('da:dcmin', $this->module['dc_min'])); } # da details if (empty($this->module['details'])) { $this->setWarning(__('no details URL')); } else { - $xml[] = sprintf('%s', html::escapeHTML($this->module['details'])); + $rsp->insertNode(new xmlTag('da:details', $this->module['details'])); } # da sshot - //$xml[] = sprintf('%s', html::escapeHTML($this->module['sshot'])); + //$rsp->insertNode(new xmlTag('da:sshot', $this->module['sshot'])); # da section - //$xml[] = sprintf('%s', html::escapeHTML($this->module['section'])); + if (!empty($this->module['section'])) { + $rsp->insertNode(new xmlTag('da:section', $this->module['section'])); + } # da support if (empty($this->module['support'])) { $this->setWarning(__('no support URL')); } else { - $xml[] = sprintf('%s', html::escapeHTML($this->module['support'])); + $rsp->insertNode(new xmlTag('da:support', $this->module['support'])); } # da tags - //$xml[] = sprintf('%s', html::escapeHTML($this->module['tags'])); + //$rsp->insertNode(new xmlTag('da:tags', $this->module['tags'])); - $xml[] = ''; - $xml[] = ''; + $res = new xmlTag('modules', $rsp); + $res->insertAttr('xmlns:da', 'http://dotaddict.org/da/'); - return implode("\n", $xml); + return str_replace('><', ">\n<", $res->toXML()); } private function parseFilePattern()