release 0.3 - namespace

This commit is contained in:
Jean-Christian Paul Denis 2023-03-11 20:03:02 +01:00
parent 66fd478a06
commit 45499b0b75
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
13 changed files with 284 additions and 205 deletions

View File

@ -1,4 +1,6 @@
x.x
0.3 - 2023.03.11
- required Dotclear 2.25, up to 2.25.3
- use php namespace
- fix translation
0.2 - 2022.12.03
@ -6,5 +8,5 @@ x.x
- Add Dotclear maximum version compatibility (thanks @Gvx- )
0.1.1 - 2022.12.03
- Required Dotclear 2.19
- Required Dotclear 2.19, up to 2.23.1
- First release

View File

@ -3,7 +3,7 @@
[![Release](https://img.shields.io/github/v/release/JcDenis/checkStoreVersion)](https://github.com/JcDenis/checkStoreVersion/releases)
[![Date](https://img.shields.io/github/release-date/JcDenis/checkStoreVersion)](https://github.com/JcDenis/checkStoreVersion/releases)
[![Issues](https://img.shields.io/github/issues/JcDenis/checkStoreVersion)](https://github.com/JcDenis/checkStoreVersion/issues)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.19-blue.svg)](https://fr.dotclear.org/download)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.25-blue.svg)](https://fr.dotclear.org/download)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/checkStoreVersion)
[![License](https://img.shields.io/github/license/JcDenis/checkStoreVersion)](https://github.com/JcDenis/checkStoreVersion/blob/master/LICENSE)
@ -20,7 +20,7 @@ This plugin check official or third-party repositories of installed plugins or t
_CheckStoreVersion_ requires:
* superadmin permissions
* Dotclear 2.19
* Dotclear 2.25
## USAGE

View File

@ -18,13 +18,13 @@ $this->registerModule(
'Check store version',
'Check plugins and themes available version before update',
'Jean-Christian Denis and Contributors',
'0.2',
'0.3',
[
'requires' => [['core', '2.19']],
'requires' => [['core', '2.25']],
'permissions' => null,
'type' => 'plugin',
'support' => 'https://github.com/JcDenis/checkStoreVersion',
'details' => 'https://plugins.dotaddict.org/dc2/details/checkStoreVersion',
'repository' => 'https://raw.githubusercontent.com/JcDenis/checkStoreVersion/master/dcstore.xml'
'repository' => 'https://raw.githubusercontent.com/JcDenis/checkStoreVersion/master/dcstore.xml',
]
);

View File

@ -1,19 +0,0 @@
<?php
/**
* @brief checkStoreVersion, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis and Contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
$__autoload['csvStore'] = dirname(__FILE__) . '/inc/class.csv.store.php';
$__autoload['csvStoreReader'] = dirname(__FILE__) . '/inc/class.csv.store.reader.php';
$__autoload['csvStoreParser'] = dirname(__FILE__) . '/inc/class.csv.store.parser.php';

View File

@ -2,11 +2,11 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="checkStoreVersion">
<name>Check store version</name>
<version>0.2</version>
<version>0.3</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.2/plugin-checkStoreVersion.zip</file>
<da:dcmin>2.19</da:dcmin>
<file>https://github.com/JcDenis/checkStoreVersion/releases/download/v0.3/plugin-checkStoreVersion.zip</file>
<da:dcmin>2.25</da:dcmin>
<da:details>https://plugins.dotaddict.org/dc2/details/checkStoreVersion</da:details>
<da:support>https://github.com/JcDenis/checkStoreVersion</da:support>
</module>

23
locales/fr/main.lang.php Normal file
View File

@ -0,0 +1,23 @@
<?php
/**
* @package Dotclear
*
* @copyright Olivier Meunier & Association Dotclear
* @copyright GPL-2.0-only
*/
#
# DOT NOT MODIFY THIS FILE !
#
l10n::$locales['Store version'] = 'Version de dépôt';
l10n::$locales['Check stores versions'] = 'Vérifier les version sur les dépôts';
l10n::$locales['This version does not support Dotclear > %s'] = 'Cette version ne supporte pas Dotclear > %s';
l10n::$locales['There is no module to check'] = 'Il n\'y a pas de module à vérifier';
l10n::$locales['Check lastest stores versions'] = 'Vérifier les dernières versions sur les dépôts';
l10n::$locales['Modules list'] = 'Liste des modules';
l10n::$locales['Latest version'] = 'Dernière version';
l10n::$locales['Written for Dotclear'] = 'Ecrit pour Dotclear';
l10n::$locales['No version available'] = 'Aucune version disponible';
l10n::$locales['No update available'] = 'Aucune mise à jour disponible';
l10n::$locales['Newer version available'] = 'Une nouvelle version disponible';
l10n::$locales['No version available on stores'] = 'Aucune version disponible sur les dépôts';

View File

@ -3,7 +3,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Project-Id-Version: checkStoreVersion 0.2\n"
"POT-Creation-Date: \n"
"PO-Revision-Date: 2022-12-03T19:31:22+00:00\n"
"PO-Revision-Date: 2023-03-11T18:50:59+00:00\n"
"Last-Translator: Jean-Christian Denis\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"

44
src/Backend.php Normal file
View File

@ -0,0 +1,44 @@
<?php
/**
* @brief checkStoreVersion, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis and Contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1);
namespace Dotclear\Plugin\checkStoreVersion;
use dcCore;
use dcNsProcess;
class Backend extends dcNsProcess
{
public static function init(): bool
{
if (defined('DC_CONTEXT_ADMIN')) {
self::$init = dcCore::app()->auth->isSuperAdmin();
}
return self::$init;
}
public static function process(): bool
{
if (!self::$init) {
return false;
}
dcCore::app()->addBehaviors([
'pluginsToolsTabsV2' => [BackendBehaviors::class, 'pluginTabs'],
'themesToolsTabsV2' => [BackendBehaviors::class, 'themesTabs'],
]);
return true;
}
}

View File

@ -10,46 +10,44 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
declare(strict_types=1);
# only superadmin
if (!$core->auth->isSuperAdmin()) {
return null;
}
namespace Dotclear\Plugin\checkStoreVersion;
# admin behaviors
$core->addBehavior('pluginsToolsTabs', ['csvBehaviors', 'pluginsToolsTabs']);
$core->addBehavior('themesToolsTabs', ['csvBehaviors', 'themesToolsTabs']);
use dcAdminHelper;
use dcCore;
use dcModules;
use dcPage;
use dcUtils;
use html;
class csvBehaviors
class BackendBehaviors
{
public const DC_MAX = '2.23.1';
# admin plugins page tab
public static function pluginsToolsTabs(dcCore $core): void
public static function pluginsToolsTabs(): void
{
self::modulesToolsTabs($core, $core->plugins, explode(',', DC_DISTRIB_PLUGINS), $core->adminurl->get('admin.plugins'));
self::modulesToolsTabs(dcCore::app()->plugins, explode(',', DC_DISTRIB_PLUGINS), dcCore::app()->adminurl->get('admin.plugins'));
}
# admin themes page tab
public static function themesToolsTabs(dcCore $core): void
public static function themesToolsTabs(): void
{
self::modulesToolsTabs($core, $core->themes, explode(',', DC_DISTRIB_THEMES), $core->adminurl->get('admin.blog.theme'));
self::modulesToolsTabs(dcCore::app()->themes, explode(',', DC_DISTRIB_THEMES), dcCore::app()->adminurl->get('admin.blog.theme'));
}
# generic page tab
private static function modulesToolsTabs(dcCore $core, dcModules $modules, array $excludes, string $page_url): void
private static function modulesToolsTabs(dcModules $modules, array $excludes, string $page_url): void
{
$repos = empty($_POST['csvcheck']) ? null :
(new CsvStore($modules, (string) dcCore::app()->blog->settings->get('system')->get('store_plugin_url'), true))->get(true);
echo
'<div class="multi-part" id="csv" title="' . __('Store version') . '">' .
'<h3>' . __('Check stores versions') . '</h3>';
if (!method_exists('dcUtils', 'versionsCompare')
|| dcUtils::versionsCompare(DC_VERSION, self::DC_MAX, '>', false)) {
if (dcUtils::versionsCompare(DC_VERSION, My::DC_MAX, '>', false)) {
echo
'<div class="error"><p>' . sprintf(__('This version does not support Dotclear > %s'), self::DC_MAX) . '</p></div>';
'<div class="error"><p>' . sprintf(__('This version does not support Dotclear > %s'), My::DC_MAX) . '</p></div>';
return;
}
@ -72,12 +70,11 @@ class csvBehaviors
echo
'<form method="post" action="' . $page_url . '#csv" id="csvform">' .
'<p><input type="submit" name="csvcheck" value="' . __('Check lastest stores versions') . '" />' .
$core->formNonce() . '</p>' .
dcCore::app()->formNonce() . '</p>' .
'</form>';
if (!empty($_POST['csvcheck'])) {
$store = new csvStore($modules, dcCore::app()->blog->settings->system->store_plugin_url, true);
self::modulesList($list, $store->get(true));
if ($repos !== null) {
self::modulesList($list, $repos);
}
echo
@ -101,7 +98,6 @@ class csvBehaviors
}
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)) {

View File

@ -10,21 +10,26 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
declare(strict_types=1);
class csvStore extends dcStore
namespace Dotclear\Plugin\checkStoreVersion;
use dcStore;
use dcUtils;
use Exception;
use http;
class CsvStore extends dcStore
{
# overwrite dcStore::check to remove cache and use csvStoreReader and check disabled modules
public function check($force = true)
# overwrite dcStore::check to remove cache and use csvStoreReader and check disabled modules
public function check(bool $force = true): bool
{
if (!$this->xml_url) {
return false;
}
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, DC_TPL_CACHE, $force);
} catch (Exception $e) {
return false;
}
@ -54,7 +59,7 @@ class csvStore extends dcStore
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, 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'], '>=')) {

View File

@ -10,13 +10,15 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
declare(strict_types=1);
class csvStoreParser extends dcStoreParser
namespace Dotclear\Plugin\checkStoreVersion;
use dcStoreParser;
class CsvStoreParser extends dcStoreParser
{
# overwrite dcStoreParser to bypasse current dotclear version
# overwrite dcStoreParser to bypasse current dotclear version
protected function _parse()
{
if (empty($this->xml->module)) {

View File

@ -10,9 +10,15 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class csvStoreReader extends dcStoreReader
declare(strict_types=1);
namespace Dotclear\Plugin\checkStoreVersion;
use dcStoreReader;
class CsvStoreReader extends dcStoreReader
{
# overwrite dcStoreReader to remove cache and use mvStoreParser
# overwrite dcStoreReader to remove cache and use mvStoreParser
public function parse($url)
{
$this->validators = [];
@ -21,10 +27,10 @@ class csvStoreReader extends dcStoreReader
return false;
}
return new csvStoreParser($this->getContent());
return new CsvStoreParser($this->getContent());
}
# overwrite dcStoreReader to remove cache and use mvStoreParser
# overwrite dcStoreReader to remove cache and use mvStoreParser
public static function quickParse($url, $cache_dir = null, $force = true)
{
$parser = new self();

20
src/My.php Normal file
View File

@ -0,0 +1,20 @@
<?php
/**
* @brief checkStoreVersion, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis and Contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1);
namespace Dotclear\Plugin\checkStoreVersion;
class My
{
public const DC_MAX = '2.25.3';
}