diff --git a/inc/Config.php b/inc/Config.php index 5eda42d..3a61b18 100644 --- a/inc/Config.php +++ b/inc/Config.php @@ -52,29 +52,29 @@ class Config # -- Set settings -- try { - $packman_pack_nocomment = !empty($_POST['packman_pack_nocomment']); - $packman_pack_fixnewline = !empty($_POST['packman_pack_fixnewline']); - $packman_pack_overwrite = !empty($_POST['packman_pack_overwrite']); - $packman_pack_filename = (string) $_POST['packman_pack_filename']; - $packman_secondpack_filename = (string) $_POST['packman_secondpack_filename']; - $packman_pack_repository = (string) path::real($_POST['packman_pack_repository'], false); - $packman_pack_excludefiles = (string) $_POST['packman_pack_excludefiles']; + $pack_nocomment = !empty($_POST['pack_nocomment']); + $pack_fixnewline = !empty($_POST['pack_fixnewline']); + $pack_overwrite = !empty($_POST['pack_overwrite']); + $pack_filename = (string) $_POST['pack_filename']; + $secondpack_filename = (string) $_POST['secondpack_filename']; + $pack_repository = (string) path::real($_POST['pack_repository'], false); + $pack_excludefiles = (string) $_POST['pack_excludefiles']; $check = Utils::is_configured( - $packman_pack_repository, - $packman_pack_filename, - $packman_secondpack_filename + $pack_repository, + $pack_filename, + $secondpack_filename ); if ($check) { $s = dcCore::app()->blog->settings->__get(Core::id()); - $s->put('packman_pack_nocomment', $packman_pack_nocomment); - $s->put('packman_pack_fixnewline', $packman_pack_fixnewline); - $s->put('packman_pack_overwrite', $packman_pack_overwrite); - $s->put('packman_pack_filename', $packman_pack_filename); - $s->put('packman_secondpack_filename', $packman_secondpack_filename); - $s->put('packman_pack_repository', $packman_pack_repository); - $s->put('packman_pack_excludefiles', $packman_pack_excludefiles); + $s->put('pack_nocomment', $pack_nocomment); + $s->put('pack_fixnewline', $pack_fixnewline); + $s->put('pack_overwrite', $pack_overwrite); + $s->put('pack_filename', $pack_filename); + $s->put('secondpack_filename', $secondpack_filename); + $s->put('pack_repository', $pack_repository); + $s->put('pack_excludefiles', $pack_excludefiles); dcPage::addSuccessNotice( __('Configuration has been successfully updated.') @@ -103,8 +103,8 @@ class Config

' . __('Root') . '

-

' . '

' . sprintf( __('Preconization: %s'), @@ -116,18 +116,18 @@ class Config

' . __('Files') . '

-

' . sprintf(__('Preconization: %s'), '%type%-%id%') . '

-

' . sprintf(__('Preconization: %s'), '%type%-%id%-%version%') . '

-

@@ -135,17 +135,17 @@ class Config

' . __('Content') . '

-

' . sprintf(__('Preconization: %s'), '*.zip,*.tar,*.tar.gz') . '

-

-

'; diff --git a/inc/Install.php b/inc/Install.php index e1f9c7a..ac844d4 100644 --- a/inc/Install.php +++ b/inc/Install.php @@ -16,59 +16,60 @@ namespace Dotclear\Plugin\pacKman; /* dotclear ns */ use dcCore; +use dcNamespace; /* php ns */ use Exception; class Install { - # -- Module specs -- + // Module specs private static $mod_conf = [ [ - 'packman_menu_plugins', + 'menu_plugins', 'Add link to pacKman in plugins page', false, 'boolean', ], [ - 'packman_pack_nocomment', + 'pack_nocomment', 'Remove comments from files', false, 'boolean', ], [ - 'packman_pack_overwrite', + 'pack_overwrite', 'Overwrite existing package', false, 'boolean', ], [ - 'packman_pack_filename', + 'pack_filename', 'Name of package', '%type%-%id%', 'string', ], [ - 'packman_secondpack_filename', + 'secondpack_filename', 'Name of second package', '%type%-%id%-%version%', 'string', ], [ - 'packman_pack_repository', + 'pack_repository', 'Path to package repository', '', 'string', ], [ - 'packman_pack_excludefiles', + 'pack_excludefiles', 'Extra files to exclude from package', '*.zip,*.tar,*.tar.gz,.directory,.hg', 'string', ], ]; - # -- Nothing to change below -- + // Nothing to change below private static $init = false; public static function init(): bool @@ -85,7 +86,10 @@ class Install } try { - # Set module settings + // Upgrade + self::growUp(); + + // Set module settings dcCore::app()->blog->settings->addNamespace(Core::id()); foreach (self::$mod_conf as $v) { dcCore::app()->blog->settings->__get(Core::id())->put( @@ -105,4 +109,29 @@ class Install return false; } } + + public static function growUp() + { + $current = dcCore::app()->getVersion(Core::id()); + + // Update settings id, ns + if ($current && version_compare($current, '2022.12.19.1', '<=')) { + $record = dcCore::app()->con->select( + 'SELECT * FROM ' . dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME . ' ' . + "WHERE setting_ns = 'pacKman' " + ); + + while ($record->fetch()) { + if (preg_match('/^packman_(.*?)$/', $record->setting_id, $match)) { + $cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME); + $cur->setting_id = $match[1]; + $cur->setting_ns = Core::id(); + $cur->update( + "WHERE setting_id = '" . $record->setting_id . "' and setting_ns = 'pacKman' " . + 'AND blog_id ' . (null === $record->blog_id ? 'IS NULL ' : ("= '" . dcCore::app()->con->escape($record->blog_id) . "' ")) + ); + } + } + } + } } diff --git a/inc/Manage.php b/inc/Manage.php index 0c3423a..4d6be54 100644 --- a/inc/Manage.php +++ b/inc/Manage.php @@ -73,8 +73,8 @@ class Manage # Rights $is_writable = Utils::is_writable( - $s->get('packman_pack_repository'), - $s->get('packman_pack_filename') + $s->get('pack_repository'), + $s->get('pack_filename') ); $is_editable = !empty($type) && !empty($_POST['modules']) @@ -91,8 +91,8 @@ class Manage $modules = Core::getPackages(self::$themes_path); } else { $modules = array_merge( - Core::getPackages(dirname($s->get('packman_pack_repository') . '/' . $s->get('packman_pack_filename'))), - Core::getPackages(dirname($s->get('packman_pack_repository') . '/' . $s->get('packman_secondpack_filename'))) + Core::getPackages(dirname($s->get('pack_repository') . '/' . $s->get('pack_filename'))), + Core::getPackages(dirname($s->get('pack_repository') . '/' . $s->get('secondpack_filename'))) ); } @@ -133,15 +133,15 @@ class Manage $module['id'] = $id; $module['type'] = $type == 'themes' ? 'theme' : 'plugin'; - $root = (string) $s->get('packman_pack_repository'); + $root = (string) $s->get('pack_repository'); $files = [ - (string) $s->get('packman_pack_filename'), - (string) $s->get('packman_secondpack_filename'), + (string) $s->get('pack_filename'), + (string) $s->get('secondpack_filename'), ]; - $nocomment = (bool) $s->get('packman_pack_nocomment'); - $fixnewline = (bool) $s->get('packman_pack_fixnewline'); - $overwrite = (bool) $s->get('packman_pack_overwrite'); - $exclude = explode(',', (string) $s->get('packman_pack_excludefiles')); + $nocomment = (bool) $s->get('pack_nocomment'); + $fixnewline = (bool) $s->get('pack_fixnewline'); + $overwrite = (bool) $s->get('pack_overwrite'); + $exclude = explode(',', (string) $s->get('pack_excludefiles')); # --BEHAVIOR-- packmanBeforeCreatePackage dcCore::app()->callBehavior('packmanBeforeCreatePackage', $module); @@ -211,7 +211,7 @@ class Manage # Copy } elseif (strpos($action, 'copy_to_') !== false) { - $dest = (string) $s->get('packman_pack_repository'); + $dest = (string) $s->get('pack_repository'); if ($action == 'copy_to_plugins') { $dest = self::$plugins_path; } elseif ($action == 'copy_to_themes') { @@ -237,7 +237,7 @@ class Manage # Move } elseif (strpos($action, 'move_to_') !== false) { - $dest = (string) $s->get('packman_pack_repository'); + $dest = (string) $s->get('pack_repository'); if ($action == 'move_to_plugins') { $dest = self::$plugins_path; } elseif ($action == 'move_to_themes') { @@ -277,9 +277,9 @@ class Manage $s = dcCore::app()->blog->settings->get(Core::id()); $is_configured = Utils::is_configured( - $s->get('packman_pack_repository'), - $s->get('packman_pack_filename'), - $s->get('packman_secondpack_filename') + $s->get('pack_repository'), + $s->get('pack_filename'), + $s->get('secondpack_filename') ); # Display @@ -307,8 +307,8 @@ class Manage '
'; } else { $repo_path_modules = array_merge( - Core::getPackages(dirname($s->get('packman_pack_repository') . '/' . $s->get('packman_pack_filename'))), - Core::getPackages(dirname($s->get('packman_pack_repository') . '/' . $s->get('packman_secondpack_filename'))) + Core::getPackages(dirname($s->get('pack_repository') . '/' . $s->get('pack_filename'))), + Core::getPackages(dirname($s->get('pack_repository') . '/' . $s->get('secondpack_filename'))) ); $plugins_path_modules = Core::getPackages(self::$plugins_path); $themes_path_modules = Core::getPackages(self::$themes_path);