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 - Required Dotclear 2.19
- First release - First release

View File

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

View File

@ -2,10 +2,10 @@
<modules xmlns:da="http://dotaddict.org/da/"> <modules xmlns:da="http://dotaddict.org/da/">
<module id="checkStoreVersion"> <module id="checkStoreVersion">
<name>Check store version</name> <name>Check store version</name>
<version>0.1</version> <version>0.1.1</version>
<author>Jean-Christian Denis and Contributors</author> <author>Jean-Christian Denis and Contributors</author>
<desc>Check plugins and themes available version before update</desc> <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:dcmin>2.19</da:dcmin>
<da:details>https://plugins.dotaddict.org/dc2/details/checkStoreVersion</da:details> <da:details>https://plugins.dotaddict.org/dc2/details/checkStoreVersion</da:details>
<da:support>https://github.com/JcDenis/checkStoreVersion</da:support> <da:support>https://github.com/JcDenis/checkStoreVersion</da:support>

View File

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