From 42f12a73e64a8a9f6aa60ad8087a972293ee6b8e Mon Sep 17 00:00:00 2001 From: JcDenis Date: Tue, 17 Aug 2021 23:12:33 +0200 Subject: [PATCH] move to Franck style --- CHANGELOG.md | 10 +- README.md | 8 +- _admin.php | 66 ++++--- _config.php | 130 +++++++------- _define.php | 32 ++-- _install.php | 151 ++++++++-------- _prepend.php | 9 +- _uninstall.php | 53 +++--- index.php | 463 ++++++++++++++++++++++++------------------------- 9 files changed, 450 insertions(+), 472 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f265de9..c391667 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,14 @@ +pacKman 2021.08.17 + * move to Franck style + pacKman 2013.11.15 -=========================================================== * Fix all forms: Use modules root intead of Id pacKman 2013.10.28 -=========================================================== * Change behaviors arguments * Typo and minor fixes pacKman 2013.10.26 -=========================================================== * Switch to DC 2.6 * Fix use of dcThemes, thx franckpaul * New icon, thx kozlika @@ -16,23 +16,19 @@ pacKman 2013.10.26 * Clean up code and (again) lighter admin interface pacKman 2013.05.11 -=========================================================== * Added option to remove comments from files * Fixed page title and messages and contents pacKman 0.5.1 - 2010-10-12 -=========================================================== * Fixed install on nightly build * Fixed missing namespace on admin pacKman 0.5 - 2010-06-05 -=========================================================== * Switched to DC 2.2 * Changed admin interface (easy, light, fast) * Added direct download button on repository (closes #449) pacKman 0.4 - 2009-10-10 -=========================================================== * Fixed second package management * Fixed subfolder in filename * Added install and uninstall features diff --git a/README.md b/README.md index 14a6a9c..b443512 100644 --- a/README.md +++ b/README.md @@ -26,4 +26,10 @@ Go to ''plugins manager'', expand pacKman information then go to ''configure plugin'', fill in form. Once it's done you can manage your packages from menu -''Packages repository'' on sidebar or you can add dashboard icon. \ No newline at end of file +''Packages repository'' on sidebar or you can add dashboard icon. + +## MORE + + * License : GNU GPL v2 + * Source & contribution : [GitHub Page](https://github.com/JcDenis/pacKman) + * Packages & details: [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/pacKman) \ No newline at end of file diff --git a/_admin.php b/_admin.php index 7215b74..f697ebe 100644 --- a/_admin.php +++ b/_admin.php @@ -13,49 +13,45 @@ # -- END LICENSE BLOCK ------------------------------------ if (!defined('DC_CONTEXT_ADMIN')) { - - return null; + return null; } $core->blog->settings->addNamespace('pacKman'); -$core->addBehavior( - 'adminDashboardFavorites', - array('packmanBehaviors', 'adminDashboardFavorites') -); +$core->addBehavior('adminDashboardFavorites', ['packmanBehaviors', 'adminDashboardFavorites']); $_menu['Plugins']->addItem( - __('Packages repository'), - 'plugin.php?p=pacKman#packman-repository-repository', - 'index.php?pf=pacKman/icon.png', - preg_match( - '/plugin.php\?p=pacKman(&.*)?$/', - $_SERVER['REQUEST_URI'] - ), - $core->auth->isSuperAdmin() + __('Packages repository'), + 'plugin.php?p=pacKman#packman-repository-repository', + 'index.php?pf=pacKman/icon.png', + preg_match( + '/plugin.php\?p=pacKman(&.*)?$/', + $_SERVER['REQUEST_URI'] + ), + $core->auth->isSuperAdmin() ); class packmanBehaviors { - public static function adminDashboardFavorites($core, $favs) - { - $favs->register('pacKman', array( - 'title' => __('Packages repository'), - 'url' => 'plugin.php?p=pacKman#packman-repository-repository', - 'small-icon' => 'index.php?pf=pacKman/icon.png', - 'large-icon' => 'index.php?pf=pacKman/icon-big.png', - 'permissions' => $core->auth->isSuperAdmin(), - 'active_cb' => array( - 'packmanBehaviors', - 'adminDashboardFavoritesActive' - ) - )); - } + public static function adminDashboardFavorites($core, $favs) + { + $favs->register('pacKman', [ + 'title' => __('Packages repository'), + 'url' => 'plugin.php?p=pacKman#packman-repository-repository', + 'small-icon' => 'index.php?pf=pacKman/icon.png', + 'large-icon' => 'index.php?pf=pacKman/icon-big.png', + 'permissions' => $core->auth->isSuperAdmin(), + 'active_cb' => array( + 'packmanBehaviors', + 'adminDashboardFavoritesActive' + ) + ]); + } - public static function adminDashboardFavoritesActive($request, $params) - { - return $request == 'plugin.php' - && isset($params['p']) - && $params['p'] == 'pacKman'; - } -} + public static function adminDashboardFavoritesActive($request, $params) + { + return $request == 'plugin.php' + && isset($params['p']) + && $params['p'] == 'pacKman'; + } +} \ No newline at end of file diff --git a/_config.php b/_config.php index a3b62a2..3adde98 100644 --- a/_config.php +++ b/_config.php @@ -13,108 +13,106 @@ # -- END LICENSE BLOCK ------------------------------------ if (!defined('DC_CONTEXT_MODULE')) { - - return null; + return null; } $redir = empty($_REQUEST['redir']) ? - $list->getURL().'#plugins' : $_REQUEST['redir']; + $list->getURL() . '#plugins' : $_REQUEST['redir']; # -- Get settings -- $core->blog->settings->addNamespace('pacKman'); $s = $core->blog->settings->pacKman; -$packman_pack_nocomment = $s->packman_pack_nocomment; -$packman_pack_overwrite = $s->packman_pack_overwrite; -$packman_pack_filename = $s->packman_pack_filename; -$packman_secondpack_filename = $s->packman_secondpack_filename; -$packman_pack_repository = $s->packman_pack_repository; -$packman_pack_excludefiles = $s->packman_pack_excludefiles; +$packman_pack_nocomment = $s->packman_pack_nocomment; +$packman_pack_overwrite = $s->packman_pack_overwrite; +$packman_pack_filename = $s->packman_pack_filename; +$packman_secondpack_filename = $s->packman_secondpack_filename; +$packman_pack_repository = $s->packman_pack_repository; +$packman_pack_excludefiles = $s->packman_pack_excludefiles; # -- Set settings -- if (!empty($_POST['save'])) { - try { - $packman_pack_nocomment = !empty($_POST['packman_pack_nocomment']); - $packman_pack_overwrite = !empty($_POST['packman_pack_overwrite']); - $packman_pack_filename = $_POST['packman_pack_filename']; - $packman_secondpack_filename = $_POST['packman_secondpack_filename']; - $packman_pack_repository = path::real($_POST['packman_pack_repository'], false); - $packman_pack_excludefiles = $_POST['packman_pack_excludefiles']; + try { + $packman_pack_nocomment = !empty($_POST['packman_pack_nocomment']); + $packman_pack_overwrite = !empty($_POST['packman_pack_overwrite']); + $packman_pack_filename = $_POST['packman_pack_filename']; + $packman_secondpack_filename = $_POST['packman_secondpack_filename']; + $packman_pack_repository = path::real($_POST['packman_pack_repository'], false); + $packman_pack_excludefiles = $_POST['packman_pack_excludefiles']; - $check = libPackman::is_configured( - $core, - $packman_pack_repository, - $packman_pack_filename, - $packman_secondpack_filename - ); + $check = libPackman::is_configured( + $core, + $packman_pack_repository, + $packman_pack_filename, + $packman_secondpack_filename + ); - if ($check) { + if ($check) { - $s->put('packman_pack_nocomment', $packman_pack_nocomment); - $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('packman_pack_nocomment', $packman_pack_nocomment); + $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); - dcPage::addSuccessNotice( - __('Configuration has been successfully updated.') - ); - http::redirect( - $list->getURL('module=pacKman&conf=1&redir='. - $list->getRedir()) - ); - } - } - catch (Exception $e) { - $core->error->add($e->getMessage()); - } + dcPage::addSuccessNotice( + __('Configuration has been successfully updated.') + ); + http::redirect( + $list->getURL('module=pacKman&conf=1&redir=' . + $list->getRedir()) + ); + } + } + catch (Exception $e) { + $core->error->add($e->getMessage()); + } } # -- Display form -- echo ' -
-

'.__('Root').'

+

' . __('Root') . '

-

'. -'

'.sprintf(__('Preconization: %s'), $core->blog->public_path ? - $core->blog->public_path : __("Blog's public directory") -).'

+

' . +'

' . sprintf(__('Preconization: %s'), $core->blog->public_path ? + $core->blog->public_path : __("Blog's public directory") +) . '

-

'.__('Files').'

+

' . __('Files') . '

-

-

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

+

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

-

-

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

+

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

+form::checkbox('packman_pack_overwrite', 1, $packman_pack_overwrite) . ' ' . +__('Overwrite existing package') . '

-

'.__('Content').'

+

' . __('Content') . '

-

-

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

+

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

-

+

-
'; +'; \ No newline at end of file diff --git a/_define.php b/_define.php index a612682..9217ceb 100644 --- a/_define.php +++ b/_define.php @@ -13,25 +13,19 @@ # -- END LICENSE BLOCK ------------------------------------ if (!defined('DC_RC_PATH')) { - - return null; + return null; } $this->registerModule( - /* Name */ - "pacKman", - /* Description*/ - "Manage your Dotclear packages", - /* Author */ - "Jean-Christian Denis", - /* Version */ - '2013.11.15', - /* Properies */ - array( - 'permissions' => null, - 'type' => 'plugin', - 'dc_min' => '2.6', - 'support' => 'http://jcd.lv/q=pacKman', - 'details' => 'http://plugins.dotaddict.org/dc2/details/pacKman' - ) -); + 'pacKman', // Name + 'Manage your Dotclear packages', // Description + 'Jean-Christian Denis', // Author + '2021.08.17', // Version + [ + 'permissions' => null, + 'type' => 'plugin', + 'dc_min' => '2.19', + 'support' => 'https://github.com/JcDenis/pacKman', + 'details' => 'https://plugins.dotaddict.org/dc2/details/pacKman' + ] +); \ No newline at end of file diff --git a/_install.php b/_install.php index 5fcb987..62b8ec0 100644 --- a/_install.php +++ b/_install.php @@ -13,8 +13,7 @@ # -- END LICENSE BLOCK ------------------------------------ if (!defined('DC_CONTEXT_ADMIN')) { - - return null; + return null; } # -- Module specs -- @@ -22,92 +21,90 @@ if (!defined('DC_CONTEXT_ADMIN')) { $dc_min = '2.6'; $mod_id = 'pacKman'; $mod_conf = array( - array( - 'packman_menu_plugins', - 'Add link to pacKman in plugins page', - false, - 'boolean' - ), - array( - 'packman_pack_nocomment', - 'Remove comments from files', - false, - 'boolean' - ), - array( - 'packman_pack_overwrite', - 'Overwrite existing package', - false, - 'boolean' - ), - array( - 'packman_pack_filename', - 'Name of package', - '%type%-%id%', - 'string' - ), - array( - 'packman_secondpack_filename', - 'Name of second package', - '%type%-%id%-%version%', - 'string' - ), - array( - 'packman_pack_repository', - 'Path to package repository', - '', - 'string' - ), - array( - 'packman_pack_excludefiles', - 'Extra files to exclude from package', - '*.zip,*.tar,*.tar.gz,.directory,.hg', - 'string' - ) + array( + 'packman_menu_plugins', + 'Add link to pacKman in plugins page', + false, + 'boolean' + ), + array( + 'packman_pack_nocomment', + 'Remove comments from files', + false, + 'boolean' + ), + array( + 'packman_pack_overwrite', + 'Overwrite existing package', + false, + 'boolean' + ), + array( + 'packman_pack_filename', + 'Name of package', + '%type%-%id%', + 'string' + ), + array( + 'packman_secondpack_filename', + 'Name of second package', + '%type%-%id%-%version%', + 'string' + ), + array( + 'packman_pack_repository', + 'Path to package repository', + '', + 'string' + ), + array( + 'packman_pack_excludefiles', + 'Extra files to exclude from package', + '*.zip,*.tar,*.tar.gz,.directory,.hg', + 'string' + ) ); # -- Nothing to change below -- try { - # Check module version - if (version_compare( - $core->getVersion($mod_id), - $core->plugins->moduleInfo($mod_id, 'version'), - '>=' - )) { + # Check module version + if (version_compare( + $core->getVersion($mod_id), + $core->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 - )); - } + # 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 + )); + } - # Set module settings - $core->blog->settings->addNamespace($mod_id); - foreach($mod_conf as $v) { - $core->blog->settings->{$mod_id}->put( - $v[0], $v[2], $v[3], $v[1], false, true - ); - } + # Set module settings + $core->blog->settings->addNamespace($mod_id); + foreach($mod_conf as $v) { + $core->blog->settings->{$mod_id}->put( + $v[0], $v[2], $v[3], $v[1], false, true + ); + } - # Set module version - $core->setVersion( - $mod_id, - $core->plugins->moduleInfo($mod_id, 'version') - ); + # Set module version + $core->setVersion( + $mod_id, + $core->plugins->moduleInfo($mod_id, 'version') + ); - return true; + return true; } catch (Exception $e) { - $core->error->add($e->getMessage()); + $core->error->add($e->getMessage()); - return false; -} - -?> \ No newline at end of file + return false; +} \ No newline at end of file diff --git a/_prepend.php b/_prepend.php index 12d8a89..42d5761 100644 --- a/_prepend.php +++ b/_prepend.php @@ -13,12 +13,11 @@ # -- END LICENSE BLOCK ------------------------------------ if (!defined('DC_RC_PATH')) { - - return null; + return null; } $d = dirname(__FILE__).'/inc/'; -$__autoload['dcPackman'] = $d.'class.dc.packman.php'; -$__autoload['libPackman'] = $d.'lib.packman.php'; -$__autoload['packmanFileZip'] = $d.'lib.packman.filezip.php'; +$__autoload['dcPackman'] = $d.'class.dc.packman.php'; +$__autoload['libPackman'] = $d.'lib.packman.php'; +$__autoload['packmanFileZip'] = $d.'lib.packman.filezip.php'; \ No newline at end of file diff --git a/_uninstall.php b/_uninstall.php index 96734ac..a53789d 100644 --- a/_uninstall.php +++ b/_uninstall.php @@ -13,51 +13,50 @@ # -- END LICENSE BLOCK ------------------------------------ if (!defined('DC_CONTEXT_ADMIN')) { - - return null; + return null; } $mod_id = 'pacKman'; $this->addUserAction( - /* type */ 'settings', - /* action */ 'delete_all', - /* ns */ $mod_id, - /* desc */ __('delete all settings') + /* type */ 'settings', + /* action */ 'delete_all', + /* ns */ $mod_id, + /* desc */ __('delete all settings') ); $this->addUserAction( - /* type */ 'plugins', - /* action */ 'delete', - /* ns */ $mod_id, - /* desc */ __('delete plugin files') + /* type */ 'plugins', + /* action */ 'delete', + /* ns */ $mod_id, + /* desc */ __('delete plugin files') ); $this->addUserAction( - /* type */ 'versions', - /* action */ 'delete', - /* ns */ $mod_id, - /* desc */ __('delete the version number') + /* type */ 'versions', + /* action */ 'delete', + /* ns */ $mod_id, + /* desc */ __('delete the version number') ); $this->addDirectAction( - /* type */ 'settings', - /* action */ 'delete_all', - /* ns */ $mod_id, - /* desc */ sprintf(__('delete all %s settings'), $mod_id) + /* type */ 'settings', + /* action */ 'delete_all', + /* ns */ $mod_id, + /* desc */ sprintf(__('delete all %s settings'), $mod_id) ); $this->addDirectAction( - /* type */ 'plugins', - /* action */ 'delete', - /* ns */ $mod_id, - /* desc */ sprintf(__('delete %s plugin files'), $mod_id) + /* type */ 'plugins', + /* action */ 'delete', + /* ns */ $mod_id, + /* desc */ sprintf(__('delete %s plugin files'), $mod_id) ); $this->addDirectAction( - /* type */ 'versions', - /* action */ 'delete', - /* ns */ $mod_id, - /* desc */ sprintf(__('delete %s version number'), $mod_id) -); + /* type */ 'versions', + /* action */ 'delete', + /* ns */ $mod_id, + /* desc */ sprintf(__('delete %s version number'), $mod_id) +); \ No newline at end of file diff --git a/index.php b/index.php index a816367..a7fa45f 100644 --- a/index.php +++ b/index.php @@ -13,7 +13,7 @@ # -- END LICENSE BLOCK ------------------------------------ if (!defined('DC_CONTEXT_ADMIN')) { - return null; + return null; } dcPage::checkSuper(); @@ -22,7 +22,7 @@ dcPage::checkSuper(); $p_url = 'plugin.php?p=pacKman'; $action = isset($_POST['action']) ? $_POST['action'] : ''; $type = isset($_POST['type']) && in_array($_POST['type'], - array('plugins','themes','repository')) ? $_POST['type'] : ''; + array('plugins', 'themes', 'repository')) ? $_POST['type'] : ''; # Settings $core->blog->settings->addNamespace('pacKman'); @@ -30,8 +30,8 @@ $s = $core->blog->settings->pacKman; # Modules if (!isset($core->themes)) { - $core->themes = new dcThemes($core); - $core->themes->loadModules($core->blog->themes_path,null); + $core->themes = new dcThemes($core); + $core->themes->loadModules($core->blog->themes_path, null); } $themes = $core->themes; $plugins = $core->plugins; @@ -45,301 +45,301 @@ $repo_path = $s->packman_pack_repository; # Rights $is_writable = libPackman::is_writable( - $s->packman_pack_repository, - $s->packman_pack_filename + $s->packman_pack_repository, + $s->packman_pack_filename ); $is_editable = - !empty($type) - && !empty($_POST['modules']) - && is_array($_POST['modules']); + !empty($type) + && !empty($_POST['modules']) + && is_array($_POST['modules']); $is_configured = libPackman::is_configured( - $core, - $s->packman_pack_repository, - $s->packman_pack_filename, - $s->packman_secondpack_filename + $core, + $s->packman_pack_repository, + $s->packman_pack_filename, + $s->packman_secondpack_filename ); # Actions try { - # Download - if (isset($_REQUEST['package']) && empty($type)) { + # Download + if (isset($_REQUEST['package']) && empty($type)) { - $modules = array(); - if ($type == 'plugins') { - $modules = dcPackman::getPackages($core, $plugins_path); - } - elseif ($type == 'themes') { - $modules = dcPackman::getPackages($core, $themes_path); - } - else { - $modules = array_merge( - dcPackman::getPackages($core, dirname($repo_path.'/'.$s->packman_pack_filename)), - dcPackman::getPackages($core, dirname($repo_path.'/'.$s->packman_secondpack_filename)) - ); - } + $modules = array(); + if ($type == 'plugins') { + $modules = dcPackman::getPackages($core, $plugins_path); + } + elseif ($type == 'themes') { + $modules = dcPackman::getPackages($core, $themes_path); + } + else { + $modules = array_merge( + dcPackman::getPackages($core, dirname($repo_path . '/' . $s->packman_pack_filename)), + dcPackman::getPackages($core, dirname($repo_path . '/' . $s->packman_secondpack_filename)) + ); + } - foreach($modules as $f) { + foreach($modules as $f) { - if (preg_match('/'.preg_quote($_REQUEST['package']).'$/', $f['root']) - && is_file($f['root']) && is_readable($f['root']) - ) { + if (preg_match('/' . preg_quote($_REQUEST['package']) . '$/', $f['root']) + && is_file($f['root']) && is_readable($f['root']) + ) { - # --BEHAVIOR-- packmanBeforeDownloadPackage - $core->callBehavior('packmanBeforeDownloadPackage', $f, $type); + # --BEHAVIOR-- packmanBeforeDownloadPackage + $core->callBehavior('packmanBeforeDownloadPackage', $f, $type); - header('Content-Type: application/zip'); - header('Content-Length: '.filesize($f['root'])); - header('Content-Disposition: attachment; filename="'.basename($f['root']).'"'); - readfile($f['root']); + header('Content-Type: application/zip'); + header('Content-Length: ' . filesize($f['root'])); + header('Content-Disposition: attachment; filename="' . basename($f['root']) . '"'); + readfile($f['root']); - # --BEHAVIOR-- packmanAfterDownloadPackage - $core->callBehavior('packmanAfterDownloadPackage', $f, $type); + # --BEHAVIOR-- packmanAfterDownloadPackage + $core->callBehavior('packmanAfterDownloadPackage', $f, $type); - exit; - } - } + exit; + } + } - # Not found - header('Content-Type: text/plain'); - http::head(404,'Not Found'); - exit; - } - elseif (!empty($action) && !$is_editable) { - throw new Exception('No selected modules'); - } + # Not found + header('Content-Type: text/plain'); + http::head(404, 'Not Found'); + exit; + } + elseif (!empty($action) && !$is_editable) { + throw new Exception('No selected modules'); + } - # Pack - elseif ($action == 'packup') { + # Pack + elseif ($action == 'packup') { - foreach ($_POST['modules'] as $root => $id) { + foreach ($_POST['modules'] as $root => $id) { - if (!${$type}->moduleExists($id)) { - throw new Exception('No such module'); - } + if (!${$type}->moduleExists($id)) { + throw new Exception('No such module'); + } - $module = ${$type}->getModules($id); - $module['id'] = $id; - $module['type'] = $type == 'themes' ? 'theme' : 'plugin'; + $module = ${$type}->getModules($id); + $module['id'] = $id; + $module['type'] = $type == 'themes' ? 'theme' : 'plugin'; - $root = $s->packman_pack_repository; - $files = array( - $s->packman_pack_filename, - $s->packman_secondpack_filename - ); - $nocomment = $s->packman_pack_nocomment; - $overwrite = $s->packman_pack_overwrite; - $exclude = explode(',', $s->packman_pack_excludefiles); + $root = $s->packman_pack_repository; + $files = array( + $s->packman_pack_filename, + $s->packman_secondpack_filename + ); + $nocomment = $s->packman_pack_nocomment; + $overwrite = $s->packman_pack_overwrite; + $exclude = explode(',', $s->packman_pack_excludefiles); - # --BEHAVIOR-- packmanBeforeCreatePackage - $core->callBehavior('packmanBeforeCreatePackage', $core, $module); + # --BEHAVIOR-- packmanBeforeCreatePackage + $core->callBehavior('packmanBeforeCreatePackage', $core, $module); - dcPackman::pack($module, $root, $files, $overwrite, $exclude, $nocomment); + dcPackman::pack($module, $root, $files, $overwrite, $exclude, $nocomment); - # --BEHAVIOR-- packmanAfterCreatePackage - $core->callBehavior('packmanAfterCreatePackage', $core, $module); + # --BEHAVIOR-- packmanAfterCreatePackage + $core->callBehavior('packmanAfterCreatePackage', $core, $module); - } + } - dcPage::addSuccessNotice( - __('Package successfully created.') - ); - http::redirect(empty($_POST['redir']) ? - $p_url.'#packman-'.$type : $_POST['redir'] - ); - } + dcPage::addSuccessNotice( + __('Package successfully created.') + ); + http::redirect(empty($_POST['redir']) ? + $p_url . '#packman-' . $type : $_POST['redir'] + ); + } - # Delete - elseif ($action == 'delete') { + # Delete + elseif ($action == 'delete') { - foreach ($_POST['modules'] as $root => $id) { - if (!file_exists($root) || !files::isDeletable($root)) { - throw new Exception('Undeletable file: '.$root); - } + foreach ($_POST['modules'] as $root => $id) { + if (!file_exists($root) || !files::isDeletable($root)) { + throw new Exception('Undeletable file: ' . $root); + } - unlink($root); - } + unlink($root); + } - dcPage::addSuccessNotice( - __('Package successfully deleted.') - ); - http::redirect( - $p_url.'#packman-repository-'.$type - ); - } + dcPage::addSuccessNotice( + __('Package successfully deleted.') + ); + http::redirect( + $p_url . '#packman-repository-' . $type + ); + } - # Install - elseif ($action == 'install') { + # Install + elseif ($action == 'install') { - foreach ($_POST['modules'] as $root => $id) { + foreach ($_POST['modules'] as $root => $id) { - # --BEHAVIOR-- packmanBeforeInstallPackage - $core->callBehavior('packmanBeforeInstallPackage', $type, $id, $root); + # --BEHAVIOR-- packmanBeforeInstallPackage + $core->callBehavior('packmanBeforeInstallPackage', $type, $id, $root); - if ($type == 'plugins') { - $plugins->installPackage($root, $plugins); - } - if ($type == 'themes') { - $themes->installPackage($root, $themes); - } + if ($type == 'plugins') { + $plugins->installPackage($root, $plugins); + } + if ($type == 'themes') { + $themes->installPackage($root, $themes); + } - # --BEHAVIOR-- packmanAfterInstallPackage - $core->callBehavior('packmanAfterInstallPackage', $type, $id, $root); + # --BEHAVIOR-- packmanAfterInstallPackage + $core->callBehavior('packmanAfterInstallPackage', $type, $id, $root); - } + } - dcPage::addSuccessNotice( - __('Package successfully installed.') - ); - http::redirect( - $p_url.'#packman-repository-'.$type - ); - } + dcPage::addSuccessNotice( + __('Package successfully installed.') + ); + http::redirect( + $p_url . '#packman-repository-' . $type + ); + } - # Copy - elseif (strpos($action, 'copy_to_') !== false) { + # Copy + elseif (strpos($action, 'copy_to_') !== false) { - if ($action == 'copy_to_plugins') { - $dest = $plugins_path; - } - elseif ($action == 'copy_to_themes') { - $dest = $themes_path; - } - elseif ($action == 'copy_to_repository') { - $dest = $repo_path; - } + if ($action == 'copy_to_plugins') { + $dest = $plugins_path; + } + elseif ($action == 'copy_to_themes') { + $dest = $themes_path; + } + elseif ($action == 'copy_to_repository') { + $dest = $repo_path; + } - foreach ($_POST['modules'] as $root => $id) { - file_put_contents( - $dest.'/'.basename($root), - file_get_contents($root) - ); - } + foreach ($_POST['modules'] as $root => $id) { + file_put_contents( + $dest . '/' . basename($root), + file_get_contents($root) + ); + } - dcPage::addSuccessNotice( - __('Package successfully copied.') - ); - http::redirect( - $p_url.'#packman-repository-'.$type - ); - } + dcPage::addSuccessNotice( + __('Package successfully copied.') + ); + http::redirect( + $p_url . '#packman-repository-' . $type + ); + } - # Move - elseif (strpos($action, 'move_to_') !== false) { + # Move + elseif (strpos($action, 'move_to_') !== false) { - if ($action == 'move_to_plugins') { - $dest = $plugins_path; - } - elseif ($action == 'move_to_themes') { - $dest = $themes_path; - } - elseif ($action == 'move_to_repository') { - $dest = $repo_path; - } + if ($action == 'move_to_plugins') { + $dest = $plugins_path; + } + elseif ($action == 'move_to_themes') { + $dest = $themes_path; + } + elseif ($action == 'move_to_repository') { + $dest = $repo_path; + } - foreach ($_POST['modules'] as $root => $id) { - file_put_contents( - $dest.'/'.basename($root), - file_get_contents($root) - ); - unlink($root); - } + foreach ($_POST['modules'] as $root => $id) { + file_put_contents( + $dest . '/' . basename($root), + file_get_contents($root) + ); + unlink($root); + } - dcPage::addSuccessNotice( - __('Package successfully moved.') - ); - http::redirect( - $p_url.'#packman-repository-'.$type - ); - } + dcPage::addSuccessNotice( + __('Package successfully moved.') + ); + http::redirect( + $p_url . '#packman-repository-' . $type + ); + } } catch(Exception $e) { - $core->error->add($e->getMessage()); + $core->error->add($e->getMessage()); } # Display echo -''.__('pacKman').''. -dcPage::jsPageTabs(). +'' . __('pacKman') . '' . +dcPage::jsPageTabs() . dcPage::jsLoad('index.php?pf=pacKman/js/packman.js'); # --BEHAVIOR-- packmanAdminHeader $core->callBehavior('packmanAdminHeader', $core); echo -''. +'' . dcPage::breadcrumb( - array( - __('Plugins') => '', - __('pacKman') => '' - ) + array( + __('Plugins') => '', + __('pacKman') => '' + ) ). dcPage::notices(); if ($core->error->flag()) { - echo - '

'.__('pacKman is not well configured.').' '. - ''.__('Configuration').''. - '

'; + echo + '

' . __('pacKman is not well configured.') . ' ' . + '' . __('Configuration') . '' . + '

'; } else { - $repo_path_modules = array_merge( - dcPackman::getPackages( - $core, - dirname($repo_path.'/'.$s->packman_pack_filename) - ), - dcPackman::getPackages( - $core, - dirname($repo_path.'/'.$s->packman_secondpack_filename) - ) - ); - $plugins_path_modules = dcPackman::getPackages( - $core, - $plugins_path - ); - $themes_path_modules = dcPackman::getPackages( - $core, - $themes_path - ); + $repo_path_modules = array_merge( + dcPackman::getPackages( + $core, + dirname($repo_path . '/' . $s->packman_pack_filename) + ), + dcPackman::getPackages( + $core, + dirname($repo_path . '/' . $s->packman_secondpack_filename) + ) + ); + $plugins_path_modules = dcPackman::getPackages( + $core, + $plugins_path + ); + $themes_path_modules = dcPackman::getPackages( + $core, + $themes_path + ); - libPackman::modules( - $core, - $plugins->getModules(), - 'plugins', - __('Installed plugins') - ); + libPackman::modules( + $core, + $plugins->getModules(), + 'plugins', + __('Installed plugins') + ); - libPackman::modules( - $core, - $themes->getModules(), - 'themes', - __('Installed themes') - ); + libPackman::modules( + $core, + $themes->getModules(), + 'themes', + __('Installed themes') + ); - libPackman::repository( - $core, - $plugins_path_modules, - 'plugins', - __('Plugins root') - ); + libPackman::repository( + $core, + $plugins_path_modules, + 'plugins', + __('Plugins root') + ); - libPackman::repository( - $core, - $themes_path_modules, - 'themes', - __('Themes root') - ); + libPackman::repository( + $core, + $themes_path_modules, + 'themes', + __('Themes root') + ); - libPackman::repository( - $core, - $repo_path_modules, - 'repository', - __('Packages repository') - ); + libPackman::repository( + $core, + $repo_path_modules, + 'repository', + __('Packages repository') + ); } # --BEHAVIOR-- packmanAdminTabs @@ -348,11 +348,4 @@ $core->callBehavior('packmanAdminTabs', $core); dcPage::helpBlock('pacKman'); echo -'

-'.__('Configuration').' - -pacKman - '.$core->plugins->moduleInfo('pacKman', 'version').'  -'.__('pacKman').' -

-'; +''; \ No newline at end of file