From 88300edc5b128713598dbfefe165630822574d24 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Sat, 3 Dec 2022 00:39:07 +0100 Subject: [PATCH] first cleanup --- _admin.php | 54 +++++++++++++++++++++++++--------- _define.php | 2 +- inc/class.csv.store.parser.php | 24 +++++++-------- inc/class.csv.store.php | 44 ++++++++++----------------- inc/class.csv.store.reader.php | 28 ++++++++---------- locales/fr/main.po | 45 ++++++++++++++++++++++++++++ 6 files changed, 125 insertions(+), 72 deletions(-) create mode 100644 locales/fr/main.po diff --git a/_admin.php b/_admin.php index 463c2bd..72a4460 100644 --- a/_admin.php +++ b/_admin.php @@ -49,7 +49,7 @@ class csvBehaviors echo '
' . - '

' . __('Check store version') . '

'; + '

' . __('Check stores versions') . '

'; if (!count($list)) { echo @@ -61,7 +61,7 @@ class csvBehaviors echo '
' . - '

' . + '

' . $core->formNonce() . '

' . '
'; @@ -84,13 +84,27 @@ class csvBehaviors '
' . '' . '' . - '' . + '' . '' . '' . ''; + if (DC_ALLOW_REPOSITORIES) { + echo + ''; + } + foreach ($modules as $id => $module) { + if (!isset($repos[$id])) { + $img = [__('No version available'), 'check-off.png']; + } elseif (isset($repos[$id]) && dcUtils::versionsCompare(DC_VERSION, $repos[$id]['dc_min'], '>=', false)) { + $img = [__('No update available'), 'check-wrn.png']; + } else { + $img = [__('Newer version available'), 'check-on.png']; + } + $img = sprintf('%1$s', $img[0], $img[1]); + $default_icon = false; if (file_exists($module['root'] . '/icon.svg')) { @@ -110,23 +124,35 @@ class csvBehaviors } echo - '' . - '' . - '' . + '' . + '' . + '' . - '' . - ''; + '' . + '' . + ''; + + if (DC_ALLOW_REPOSITORIES) { + echo + ''; + } } else { echo - '' . - ''; + '' . + ''; } echo diff --git a/_define.php b/_define.php index 51e4584..29172dc 100644 --- a/_define.php +++ b/_define.php @@ -18,7 +18,7 @@ $this->registerModule( 'Check store version', 'Check plugins and themes available version before update', 'Jean-Christian Denis and Contributors', - '0.1-dev', + '0.1', [ 'requires' => [['core', '2.19']], 'permissions' => null, diff --git a/inc/class.csv.store.parser.php b/inc/class.csv.store.parser.php index 85c3557..1832722 100644 --- a/inc/class.csv.store.parser.php +++ b/inc/class.csv.store.parser.php @@ -1,15 +1,15 @@ -xml_url, DC_TPL_CACHE, $force); + $parser = DC_STORE_NOT_UPDATE ? false : csvStoreReader::quickParse($this->xml_url, null, true); } 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) { @@ -40,21 +36,11 @@ 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, DC_TPL_CACHE, $force); + $dcs_parser = csvStoreReader::quickParse($dcs_url, null, true); 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'], '>=')) { @@ -73,7 +59,7 @@ class csvStore extends dcStore } $this->data = [ - 'new' => $raw_datas, + 'new' => [], 'update' => $updates, ]; diff --git a/inc/class.csv.store.reader.php b/inc/class.csv.store.reader.php index c12234d..a577b7d 100644 --- a/inc/class.csv.store.reader.php +++ b/inc/class.csv.store.reader.php @@ -1,19 +1,15 @@ - 1);\n" + +msgid "Store version" +msgstr "Version de dépôt" + +msgid "Check stores versions" +msgstr "Vérifier les version sur les dépôts" + +msgid "There is no module to check" +msgstr "Il n'y a pas de module à vérifier" + +msgid "Check lastest stores versions" +msgstr "Vérifier les dernières versions sur les dépôts" + +msgid "Modules list" +msgstr "Liste des modules" + +msgid "Latest version" +msgstr "Dernière version" + +msgid "Written for Dotclear" +msgstr "Ecrit pour Dotclear" + +msgid "No version available" +msgstr "Aucune version disponible" + +msgid "No update available" +msgstr "Aucune mise à jour disponible" + +msgid "Newer version available" +msgstr "Une nouvelle version disponible" + +msgid "No version available on stores" +msgstr "Aucune version disponible sur les dépôts" +
' . __('Name') . '' . __('Name') . '' . __('Current version') . '' . __('Latest version') . '' . __('Written for Dotclear') . '' . __('Repository') . '
' . - dcAdminHelper::adminIcon($icon, false, html::escapeHTML($id), html::escapeHTML($id)) . - '' . - html::escapeHTML($module['name']) . ($id != $module['name'] ? sprintf(__(' (%s)'), $id) : '') . + '
' . + $img . '' . + dcAdminHelper::adminIcon($icon, false, html::escapeHTML($id), html::escapeHTML($id)) . '' . + html::escapeHTML($module['name']) . ($id != $module['name'] ? sprintf(__(' (%s)'), $id) : '') . ''; if (isset($repos[$id])) { echo - '' . html::escapeHTML($repos[$id]['current_version']) . '' . html::escapeHTML($repos[$id]['version']) . '' . html::escapeHTML($repos[$id]['dc_min']) . '' . + html::escapeHTML($repos[$id]['current_version']) . '' . + html::escapeHTML($repos[$id]['version']) . '' . + html::escapeHTML($repos[$id]['dc_min']) . '' . + (empty($module['repository']) ? __('Official repository') : __('Third-party repository')) . '' . html::escapeHTML($module['version']) . '' . html::escapeHTML(__('No version available on store')) . '' . + html::escapeHTML($module['version']) . '' . + html::escapeHTML(__('No version available on stores')) . '