first cleanup

master
Jean-Christian Paul Denis 2022-12-03 00:39:07 +01:00
parent 06cc847af8
commit 88300edc5b
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
6 changed files with 125 additions and 72 deletions

View File

@ -49,7 +49,7 @@ class csvBehaviors
echo
'<div class="multi-part" id="csv" title="' . __('Store version') . '">' .
'<h3>' . __('Check store version') . '</h3>';
'<h3>' . __('Check stores versions') . '</h3>';
if (!count($list)) {
echo
@ -61,7 +61,7 @@ class csvBehaviors
echo
'<form method="post" action="' . $page_url . '" id="csvform">' .
'<p><input type="submit" name="csvcheck" value="' . __('Check lastest store versions') . '" />' .
'<p><input type="submit" name="csvcheck" value="' . __('Check lastest stores versions') . '" />' .
$core->formNonce() . '</p>' .
'</form>';
@ -84,13 +84,27 @@ class csvBehaviors
'<div class="table-outer">' .
'<table id="mvmodules" class="modules">' .
'<caption class="hidden">' . html::escapeHTML(__('Modules list')) . '</caption><tr>' .
'<th class="first nowrap" colspan="2">' . __('Name') . '</th>' .
'<th class="first nowrap" colspan="3">' . __('Name') . '</th>' .
'<th class="nowrap count" scope="col">' . __('Current version') . '</th>' .
'<th class="nowrap count" scope="col">' . __('Latest version') . '</th>' .
'<th class="nowrap count" scope="col">' . __('Written for Dotclear') . '</th>';
if (DC_ALLOW_REPOSITORIES) {
echo
'<th class="nowrap count" scope="col">' . __('Repository') . '</th>';
}
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('<img alt="%1$s" title="%1$s" src="images/%2$s" />', $img[0], $img[1]);
$default_icon = false;
if (file_exists($module['root'] . '/icon.svg')) {
@ -110,23 +124,35 @@ class csvBehaviors
}
echo
'<tr class="line" id="mvmodules_m_' . html::escapeHTML($id) . '">' .
'<td class="module-icon nowrap minimal">' .
dcAdminHelper::adminIcon($icon, false, html::escapeHTML($id), html::escapeHTML($id)) .
'</td>' .
'<th class="module-name nowrap minimal" scope="row">' .
html::escapeHTML($module['name']) . ($id != $module['name'] ? sprintf(__(' (%s)'), $id) : '') .
'<tr class="line' . (isset($repos[$id]) ? '' : ' offline') . '" id="mvmodules_m_' . html::escapeHTML($id) . '">' .
'<td class="module-icon nowrap">' .
$img . '</td>' .
'<td class="module-icon nowrap">' .
dcAdminHelper::adminIcon($icon, false, html::escapeHTML($id), html::escapeHTML($id)) . '</td>' .
'<th class="module-name nowrap" scope="row">' .
html::escapeHTML($module['name']) . ($id != $module['name'] ? sprintf(__(' (%s)'), $id) : '') .
'</td>';
if (isset($repos[$id])) {
echo
'<td class="module-current-version nowrap count minimal">' . html::escapeHTML($repos[$id]['current_version']) . '</td>' .
'<td class="module-version nowrap count">' . html::escapeHTML($repos[$id]['version']) . '</td>' .
'<td class="module-version nowrap count">' . html::escapeHTML($repos[$id]['dc_min']) . '</td>';
'<td class="module-version nowrap count">' .
html::escapeHTML($repos[$id]['current_version']) . '</td>' .
'<td class="module-version nowrap count maximal">' .
html::escapeHTML($repos[$id]['version']) . '</td>' .
'<td class="module-version nowrap count">' .
html::escapeHTML($repos[$id]['dc_min']) . '</td>';
if (DC_ALLOW_REPOSITORIES) {
echo
'<td class="module-repository nowrap count">' .
(empty($module['repository']) ? __('Official repository') : __('Third-party repository')) . '</td>';
}
} else {
echo
'<td class="module-current-version nowrap count minimal">' . html::escapeHTML($module['version']) . '</td>' .
'<td class="module-version nowrap count" colspan="2">' . html::escapeHTML(__('No version available on store')) . '</td>';
'<td class="module-current-version nowrap count">' .
html::escapeHTML($module['version']) . '</td>' .
'<td class="module-version nowrap count maximal" colspan="' . (DC_ALLOW_REPOSITORIES ? '3' : '2') . '">' .
html::escapeHTML(__('No version available on stores')) . '</td>';
}
echo

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-dev',
'0.1',
[
'requires' => [['core', '2.19']],
'permissions' => null,

View File

@ -24,15 +24,11 @@ class csvStore extends dcStore
}
try {
$parser = DC_STORE_NOT_UPDATE ? false : csvStoreReader::quickParse($this->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,
];

View File

@ -10,10 +10,6 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
class csvStoreReader extends dcStoreReader
{
# overwrite dcStoreReader to remove cache and use mvStoreParser

45
locales/fr/main.po 100644
View File

@ -0,0 +1,45 @@
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Project-Id-Version: checkStoreVersion 0.1-dev\n"
"POT-Creation-Date: \n"
"PO-Revision-Date: 2022-12-02T23:12:39+00:00\n"
"Last-Translator: Jean-Christian Denis\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 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"