use dotclear method to check version

This commit is contained in:
Jean-Christian Denis 2022-12-10 15:20:39 +01:00
parent fbc7a75e12
commit a41edabd8a
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951

View file

@ -15,25 +15,14 @@ if (!defined('DC_CONTEXT_ADMIN')) {
} }
try { try {
# Grab info # Version
$mod_id = basename(__DIR__); if (!dcCore::app()->newVersion(
$dc_min = dcCore::app()->plugins->moduleInfo($mod_id, 'requires')[0][1]; basename(__DIR__),
$old_version = dcCore::app()->getVersion($mod_id); dcCore::app()->plugins->moduleInfo(basename(__DIR__), 'version')
)) {
if (version_compare($old_version, dcCore::app()->plugins->moduleInfo($mod_id, 'version'), '>=')) {
return null; return null;
} }
# Check Dotclear version
if (!method_exists('dcUtils', 'versionsCompare')
|| dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) {
throw new Exception(sprintf(
'%s requires Dotclear %s',
$mod_id,
$dc_min
));
}
# Database # Database
$s = new dbStruct(dcCore::app()->con, dcCore::app()->prefix); $s = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
$s->{initEnhancePostContent::EPC_TABLE_NAME} $s->{initEnhancePostContent::EPC_TABLE_NAME}
@ -56,8 +45,8 @@ try {
$s = null; $s = null;
# Settings # Settings
dcCore::app()->blog->settings->addNamespace($mod_id); dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
$s = dcCore::app()->blog->settings->enhancePostContent; $s = dcCore::app()->blog->settings->__get(basename(__DIR__));
$s->put('enhancePostContent_active', false, 'boolean', 'Enable enhancePostContent', false, true); $s->put('enhancePostContent_active', false, 'boolean', 'Enable enhancePostContent', false, true);
$s->put('enhancePostContent_list_sortby', 'epc_key', 'string', 'Admin records list field order', false, true); $s->put('enhancePostContent_list_sortby', 'epc_key', 'string', 'Admin records list field order', false, true);
@ -87,6 +76,7 @@ try {
} }
# Update old versions # Update old versions
$old_version = dcCore::app()->getVersion($mod_id);
if ($old_version && version_compare('2021.10.05', $old_version, '>=')) { if ($old_version && version_compare('2021.10.05', $old_version, '>=')) {
include_once dirname(__FILE__) . '/inc/lib.epc.update.php'; include_once dirname(__FILE__) . '/inc/lib.epc.update.php';
} }