From e7abe59147d6bbcbfa930a625ec25362170ceb60 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Tue, 28 Sep 2021 00:41:10 +0200 Subject: [PATCH] use xmlTag() to manage file content --- inc/class.tweakstores.php | 58 +++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/inc/class.tweakstores.php b/inc/class.tweakstores.php index b173b0f..cceafc7 100644 --- a/inc/class.tweakstores.php +++ b/inc/class.tweakstores.php @@ -1,15 +1,15 @@ ']; # id if (empty($module['id'])) { self::$failed[] = 'unknow module'; } - $xml[] = sprintf('', html::escapeHTML($module['id'])); + $rsp->id = $module['id']; # name if (empty($module['name'])) { self::$failed[] = 'no module name set in _define.php'; } - $xml[] = sprintf('%s', html::escapeHTML($module['oname'])); + $rsp->name($module['oname']); # version if (empty($module['version'])) { self::$failed[] = 'no module version set in _define.php'; } - $xml[] = sprintf('%s', html::escapeHTML($module['version'])); + $rsp->version($module['version']); # author if (empty($module['author'])) { self::$failed[] = 'no module author set in _define.php'; } - $xml[] = sprintf('%s', html::escapeHTML($module['author'])); + $rsp->author($module['author']); # desc if (empty($module['desc'])) { self::$failed[] = 'no module description set in _define.php'; } - $xml[] = sprintf('%s', html::escapeHTML($module['desc'])); + $rsp->desc($module['desc']); # repository if (empty($module['repository'])) { @@ -140,10 +140,10 @@ class tweakStores if (empty($file_pattern)) { self::$failed[] = 'no zip file pattern set in Tweak Store configuration'; } - $xml[] = sprintf('%s', html::escapeHTML($file_pattern)); + $rsp->file($file_pattern); # da dc_min or requires core - if (!empty($>module['requires']) && is_array($module['requires'])) { + if (!empty($module['requires']) && is_array($module['requires'])) { foreach ($module['requires'] as $req) { if (!is_array($req)) { $req = [$req]; @@ -157,28 +157,32 @@ class tweakStores if (empty($module['dc_min'])) { self::$notice[] = 'no minimum dotclear version'; } else { - $xml[] = sprintf('%s', html::escapeHTML($module['dc_min'])); + $rsp->insertNode(new xmlTag('da:dcmin', $module['dc_min'])); } # details if (empty($module['details'])) { self::$notice[] = 'no details URL'; + } else { + $rsp->insertNode(new xmlTag('da:details', $module['details'])); } - $xml[] = sprintf('%s', html::escapeHTML($module['details'])); # section - $xml[] = sprintf('%s', html::escapeHTML($module['section'])); + if (!empty($module['section'])) { + $rsp->insertNode(new xmlTag('da:section', $module['section'])); + } # support if (empty($module['support'])) { self::$notice[] = 'no support URL'; + } else { + $rsp->insertNode(new xmlTag('da:support', $module['support'])); } - $xml[] = sprintf('%s', html::escapeHTML($module['support'])); - $xml[] = ''; - $xml[] = ''; + $res = new xmlTag('modules', $rsp); + $res->insertAttr('xmlns:da', 'http://dotaddict.org/da/'); - return implode("\n", $xml); + return $res->toXML(); } public static function writeXML($id, $module, $file_pattern)