master
Jean-Christian Paul Denis 2022-12-03 00:55:39 +01:00
parent a1a9a06060
commit a487173608
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
4 changed files with 20 additions and 6 deletions

View File

@ -1,3 +1,3 @@
0.1 - 2022.12.04
0.1.1 - 2022.12.03
- Required Dotclear 2.19
- First release

View File

@ -18,7 +18,7 @@ $this->registerModule(
'Check store version',
'Check plugins and themes available version before update',
'Jean-Christian Denis and Contributors',
'0.1',
'0.1.1',
[
'requires' => [['core', '2.19']],
'permissions' => null,

View File

@ -2,10 +2,10 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="checkStoreVersion">
<name>Check store version</name>
<version>0.1</version>
<version>0.1.1</version>
<author>Jean-Christian Denis and Contributors</author>
<desc>Check plugins and themes available version before update</desc>
<file>https://github.com/JcDenis/checkStoreVersion/releases/download/v0.1/plugin-checkStoreVersion.zip</file>
<file>https://github.com/JcDenis/checkStoreVersion/releases/download/v0.1.1/plugin-checkStoreVersion.zip</file>
<da:dcmin>2.19</da:dcmin>
<da:details>https://plugins.dotaddict.org/dc2/details/checkStoreVersion</da:details>
<da:support>https://github.com/JcDenis/checkStoreVersion</da:support>

View File

@ -24,11 +24,15 @@ class csvStore extends dcStore
}
try {
$parser = DC_STORE_NOT_UPDATE ? false : csvStoreReader::quickParse($this->xml_url, null, true);
$parser = DC_STORE_NOT_UPDATE ? false : csvStoreReader::quickParse($this->xml_url, DC_TPL_CACHE, $force);
} catch (Exception $e) {
return false;
}
$raw_datas = !$parser ? [] : $parser->getModules();
uasort($raw_datas, fn ($a, $b) => strtolower($a['id']) <=> strtolower($b['id']));
$updates = [];
$current = array_merge($this->modules->getModules(), $this->modules->getDisabledModules());
foreach ($current as $p_id => $p_infos) {
@ -36,11 +40,21 @@ class csvStore extends dcStore
if (!is_array($p_infos)) {
continue;
}
# main repository
if (isset($raw_datas[$p_id])) {
if (dcUtils::versionsCompare($raw_datas[$p_id]['version'], $p_infos['version'], '>=')) {
$updates[$p_id] = $raw_datas[$p_id];
$updates[$p_id]['root'] = $p_infos['root'];
$updates[$p_id]['root_writable'] = $p_infos['root_writable'];
$updates[$p_id]['current_version'] = $p_infos['version'];
}
unset($raw_datas[$p_id]);
}
# per module third-party repository
if (!empty($p_infos['repository']) && DC_ALLOW_REPOSITORIES) {
try {
$dcs_url = substr($p_infos['repository'], -12, 12) == '/dcstore.xml' ? $p_infos['repository'] : http::concatURL($p_infos['repository'], 'dcstore.xml');
$dcs_parser = csvStoreReader::quickParse($dcs_url, null, true);
$dcs_parser = csvStoreReader::quickParse($dcs_url, DC_TPL_CACHE, $force);
if ($dcs_parser !== false) {
$dcs_raw_datas = $dcs_parser->getModules();
if (isset($dcs_raw_datas[$p_id]) && dcUtils::versionsCompare($dcs_raw_datas[$p_id]['version'], $p_infos['version'], '>=')) {