move to Franck style

This commit is contained in:
Jean-Christian Paul Denis 2021-08-17 23:12:33 +02:00
parent 373a26d730
commit 42f12a73e6
9 changed files with 450 additions and 472 deletions

View File

@ -1,14 +1,14 @@
pacKman 2021.08.17
* move to Franck style
pacKman 2013.11.15 pacKman 2013.11.15
===========================================================
* Fix all forms: Use modules root intead of Id * Fix all forms: Use modules root intead of Id
pacKman 2013.10.28 pacKman 2013.10.28
===========================================================
* Change behaviors arguments * Change behaviors arguments
* Typo and minor fixes * Typo and minor fixes
pacKman 2013.10.26 pacKman 2013.10.26
===========================================================
* Switch to DC 2.6 * Switch to DC 2.6
* Fix use of dcThemes, thx franckpaul * Fix use of dcThemes, thx franckpaul
* New icon, thx kozlika * New icon, thx kozlika
@ -16,23 +16,19 @@ pacKman 2013.10.26
* Clean up code and (again) lighter admin interface * Clean up code and (again) lighter admin interface
pacKman 2013.05.11 pacKman 2013.05.11
===========================================================
* Added option to remove comments from files * Added option to remove comments from files
* Fixed page title and messages and contents * Fixed page title and messages and contents
pacKman 0.5.1 - 2010-10-12 pacKman 0.5.1 - 2010-10-12
===========================================================
* Fixed install on nightly build * Fixed install on nightly build
* Fixed missing namespace on admin * Fixed missing namespace on admin
pacKman 0.5 - 2010-06-05 pacKman 0.5 - 2010-06-05
===========================================================
* Switched to DC 2.2 * Switched to DC 2.2
* Changed admin interface (easy, light, fast) * Changed admin interface (easy, light, fast)
* Added direct download button on repository (closes #449) * Added direct download button on repository (closes #449)
pacKman 0.4 - 2009-10-10 pacKman 0.4 - 2009-10-10
===========================================================
* Fixed second package management * Fixed second package management
* Fixed subfolder in filename * Fixed subfolder in filename
* Added install and uninstall features * Added install and uninstall features

View File

@ -27,3 +27,9 @@ go to ''configure plugin'', fill in form.
Once it's done you can manage your packages from menu Once it's done you can manage your packages from menu
''Packages repository'' on sidebar or you can add dashboard icon. ''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)

View File

@ -13,49 +13,45 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null;
return null;
} }
$core->blog->settings->addNamespace('pacKman'); $core->blog->settings->addNamespace('pacKman');
$core->addBehavior( $core->addBehavior('adminDashboardFavorites', ['packmanBehaviors', 'adminDashboardFavorites']);
'adminDashboardFavorites',
array('packmanBehaviors', 'adminDashboardFavorites')
);
$_menu['Plugins']->addItem( $_menu['Plugins']->addItem(
__('Packages repository'), __('Packages repository'),
'plugin.php?p=pacKman#packman-repository-repository', 'plugin.php?p=pacKman#packman-repository-repository',
'index.php?pf=pacKman/icon.png', 'index.php?pf=pacKman/icon.png',
preg_match( preg_match(
'/plugin.php\?p=pacKman(&.*)?$/', '/plugin.php\?p=pacKman(&.*)?$/',
$_SERVER['REQUEST_URI'] $_SERVER['REQUEST_URI']
), ),
$core->auth->isSuperAdmin() $core->auth->isSuperAdmin()
); );
class packmanBehaviors class packmanBehaviors
{ {
public static function adminDashboardFavorites($core, $favs) public static function adminDashboardFavorites($core, $favs)
{ {
$favs->register('pacKman', array( $favs->register('pacKman', [
'title' => __('Packages repository'), 'title' => __('Packages repository'),
'url' => 'plugin.php?p=pacKman#packman-repository-repository', 'url' => 'plugin.php?p=pacKman#packman-repository-repository',
'small-icon' => 'index.php?pf=pacKman/icon.png', 'small-icon' => 'index.php?pf=pacKman/icon.png',
'large-icon' => 'index.php?pf=pacKman/icon-big.png', 'large-icon' => 'index.php?pf=pacKman/icon-big.png',
'permissions' => $core->auth->isSuperAdmin(), 'permissions' => $core->auth->isSuperAdmin(),
'active_cb' => array( 'active_cb' => array(
'packmanBehaviors', 'packmanBehaviors',
'adminDashboardFavoritesActive' 'adminDashboardFavoritesActive'
) )
)); ]);
} }
public static function adminDashboardFavoritesActive($request, $params) public static function adminDashboardFavoritesActive($request, $params)
{ {
return $request == 'plugin.php' return $request == 'plugin.php'
&& isset($params['p']) && isset($params['p'])
&& $params['p'] == 'pacKman'; && $params['p'] == 'pacKman';
} }
} }

View File

@ -13,108 +13,106 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_MODULE')) { if (!defined('DC_CONTEXT_MODULE')) {
return null;
return null;
} }
$redir = empty($_REQUEST['redir']) ? $redir = empty($_REQUEST['redir']) ?
$list->getURL().'#plugins' : $_REQUEST['redir']; $list->getURL() . '#plugins' : $_REQUEST['redir'];
# -- Get settings -- # -- Get settings --
$core->blog->settings->addNamespace('pacKman'); $core->blog->settings->addNamespace('pacKman');
$s = $core->blog->settings->pacKman; $s = $core->blog->settings->pacKman;
$packman_pack_nocomment = $s->packman_pack_nocomment; $packman_pack_nocomment = $s->packman_pack_nocomment;
$packman_pack_overwrite = $s->packman_pack_overwrite; $packman_pack_overwrite = $s->packman_pack_overwrite;
$packman_pack_filename = $s->packman_pack_filename; $packman_pack_filename = $s->packman_pack_filename;
$packman_secondpack_filename = $s->packman_secondpack_filename; $packman_secondpack_filename = $s->packman_secondpack_filename;
$packman_pack_repository = $s->packman_pack_repository; $packman_pack_repository = $s->packman_pack_repository;
$packman_pack_excludefiles = $s->packman_pack_excludefiles; $packman_pack_excludefiles = $s->packman_pack_excludefiles;
# -- Set settings -- # -- Set settings --
if (!empty($_POST['save'])) { if (!empty($_POST['save'])) {
try { try {
$packman_pack_nocomment = !empty($_POST['packman_pack_nocomment']); $packman_pack_nocomment = !empty($_POST['packman_pack_nocomment']);
$packman_pack_overwrite = !empty($_POST['packman_pack_overwrite']); $packman_pack_overwrite = !empty($_POST['packman_pack_overwrite']);
$packman_pack_filename = $_POST['packman_pack_filename']; $packman_pack_filename = $_POST['packman_pack_filename'];
$packman_secondpack_filename = $_POST['packman_secondpack_filename']; $packman_secondpack_filename = $_POST['packman_secondpack_filename'];
$packman_pack_repository = path::real($_POST['packman_pack_repository'], false); $packman_pack_repository = path::real($_POST['packman_pack_repository'], false);
$packman_pack_excludefiles = $_POST['packman_pack_excludefiles']; $packman_pack_excludefiles = $_POST['packman_pack_excludefiles'];
$check = libPackman::is_configured( $check = libPackman::is_configured(
$core, $core,
$packman_pack_repository, $packman_pack_repository,
$packman_pack_filename, $packman_pack_filename,
$packman_secondpack_filename $packman_secondpack_filename
); );
if ($check) { if ($check) {
$s->put('packman_pack_nocomment', $packman_pack_nocomment); $s->put('packman_pack_nocomment', $packman_pack_nocomment);
$s->put('packman_pack_overwrite', $packman_pack_overwrite); $s->put('packman_pack_overwrite', $packman_pack_overwrite);
$s->put('packman_pack_filename', $packman_pack_filename); $s->put('packman_pack_filename', $packman_pack_filename);
$s->put('packman_secondpack_filename', $packman_secondpack_filename); $s->put('packman_secondpack_filename', $packman_secondpack_filename);
$s->put('packman_pack_repository', $packman_pack_repository); $s->put('packman_pack_repository', $packman_pack_repository);
$s->put('packman_pack_excludefiles', $packman_pack_excludefiles); $s->put('packman_pack_excludefiles', $packman_pack_excludefiles);
dcPage::addSuccessNotice( dcPage::addSuccessNotice(
__('Configuration has been successfully updated.') __('Configuration has been successfully updated.')
); );
http::redirect( http::redirect(
$list->getURL('module=pacKman&conf=1&redir='. $list->getURL('module=pacKman&conf=1&redir=' .
$list->getRedir()) $list->getRedir())
); );
} }
} }
catch (Exception $e) { catch (Exception $e) {
$core->error->add($e->getMessage()); $core->error->add($e->getMessage());
} }
} }
# -- Display form -- # -- Display form --
echo ' echo '
<div class="fieldset"> <div class="fieldset">
<h4>'.__('Root').'</h4> <h4>' . __('Root') . '</h4>
<p><label for="packman_pack_repository">'.__('Path to repository:').' '. <p><label for="packman_pack_repository">' . __('Path to repository:') . ' ' .
form::field('packman_pack_repository', 65, 255, $packman_pack_repository, 'maximal'). form::field('packman_pack_repository', 65, 255, $packman_pack_repository, 'maximal') .
'</label></p>'. '</label></p>' .
'<p class="form-note">'.sprintf(__('Preconization: %s'), $core->blog->public_path ? '<p class="form-note">' . sprintf(__('Preconization: %s'), $core->blog->public_path ?
$core->blog->public_path : __("Blog's public directory") $core->blog->public_path : __("Blog's public directory")
).'</p> ) . '</p>
</div> </div>
<div class="fieldset"> <div class="fieldset">
<h4>'.__('Files').'</h4> <h4>' . __('Files') . '</h4>
<p><label for="packman_pack_filename">'.__('Name of exported package:').' '. <p><label for="packman_pack_filename">' . __('Name of exported package:') . ' ' .
form::field('packman_pack_filename', 65, 255, $packman_pack_filename, 'maximal'). form::field('packman_pack_filename', 65, 255, $packman_pack_filename, 'maximal') .
'</label></p> '</label></p>
<p class="form-note">'.sprintf(__('Preconization: %s'), '%type%-%id%-%version%').'</p> <p class="form-note">' . sprintf(__('Preconization: %s'), '%type%-%id%-%version%') . '</p>
<p><label for="packman_secondpack_filename">'.__('Name of second exported package:').' '. <p><label for="packman_secondpack_filename">' . __('Name of second exported package:') . ' ' .
form::field('packman_secondpack_filename', 65, 255, $packman_secondpack_filename, 'maximal'). form::field('packman_secondpack_filename', 65, 255, $packman_secondpack_filename, 'maximal') .
'</label></p> '</label></p>
<p class="form-note">'.sprintf(__('Preconization: %s'), '%type%-%id%').'</p> <p class="form-note">' . sprintf(__('Preconization: %s'), '%type%-%id%') . '</p>
<p><label class="classic" for="packman_pack_overwrite">'. <p><label class="classic" for="packman_pack_overwrite">'.
form::checkbox('packman_pack_overwrite', 1, $packman_pack_overwrite).' '. form::checkbox('packman_pack_overwrite', 1, $packman_pack_overwrite) . ' ' .
__('Overwrite existing package').'</label></p> __('Overwrite existing package') . '</label></p>
</div> </div>
<div class="fieldset"> <div class="fieldset">
<h4>'.__('Content').'</h4> <h4>' . __('Content') . '</h4>
<p><label for="packman_pack_excludefiles">'.__('Extra files to exclude from package:').' '. <p><label for="packman_pack_excludefiles">' . __('Extra files to exclude from package:') . ' ' .
form::field('packman_pack_excludefiles', 65, 255, $packman_pack_excludefiles, 'maximal'). form::field('packman_pack_excludefiles', 65, 255, $packman_pack_excludefiles, 'maximal') .
'</label></p> '</label></p>
<p class="form-note">'.sprintf(__('Preconization: %s'), '*.zip,*.tar,*.tar.gz').'</p> <p class="form-note">' . sprintf(__('Preconization: %s'), '*.zip,*.tar,*.tar.gz') . '</p>
<p><label class="classic" for="packman_pack_nocomment">'. <p><label class="classic" for="packman_pack_nocomment">' .
form::checkbox('packman_pack_nocomment', 1, $packman_pack_nocomment).' '. form::checkbox('packman_pack_nocomment', 1, $packman_pack_nocomment) . ' ' .
__('Remove comments from files').'</label></p> __('Remove comments from files') . '</label></p>
</div>'; </div>';

View File

@ -13,25 +13,19 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null;
return null;
} }
$this->registerModule( $this->registerModule(
/* Name */ 'pacKman', // Name
"pacKman", 'Manage your Dotclear packages', // Description
/* Description*/ 'Jean-Christian Denis', // Author
"Manage your Dotclear packages", '2021.08.17', // Version
/* Author */ [
"Jean-Christian Denis", 'permissions' => null,
/* Version */ 'type' => 'plugin',
'2013.11.15', 'dc_min' => '2.19',
/* Properies */ 'support' => 'https://github.com/JcDenis/pacKman',
array( 'details' => 'https://plugins.dotaddict.org/dc2/details/pacKman'
'permissions' => null, ]
'type' => 'plugin',
'dc_min' => '2.6',
'support' => 'http://jcd.lv/q=pacKman',
'details' => 'http://plugins.dotaddict.org/dc2/details/pacKman'
)
); );

View File

@ -13,8 +13,7 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null;
return null;
} }
# -- Module specs -- # -- Module specs --
@ -22,92 +21,90 @@ if (!defined('DC_CONTEXT_ADMIN')) {
$dc_min = '2.6'; $dc_min = '2.6';
$mod_id = 'pacKman'; $mod_id = 'pacKman';
$mod_conf = array( $mod_conf = array(
array( array(
'packman_menu_plugins', 'packman_menu_plugins',
'Add link to pacKman in plugins page', 'Add link to pacKman in plugins page',
false, false,
'boolean' 'boolean'
), ),
array( array(
'packman_pack_nocomment', 'packman_pack_nocomment',
'Remove comments from files', 'Remove comments from files',
false, false,
'boolean' 'boolean'
), ),
array( array(
'packman_pack_overwrite', 'packman_pack_overwrite',
'Overwrite existing package', 'Overwrite existing package',
false, false,
'boolean' 'boolean'
), ),
array( array(
'packman_pack_filename', 'packman_pack_filename',
'Name of package', 'Name of package',
'%type%-%id%', '%type%-%id%',
'string' 'string'
), ),
array( array(
'packman_secondpack_filename', 'packman_secondpack_filename',
'Name of second package', 'Name of second package',
'%type%-%id%-%version%', '%type%-%id%-%version%',
'string' 'string'
), ),
array( array(
'packman_pack_repository', 'packman_pack_repository',
'Path to package repository', 'Path to package repository',
'', '',
'string' 'string'
), ),
array( array(
'packman_pack_excludefiles', 'packman_pack_excludefiles',
'Extra files to exclude from package', 'Extra files to exclude from package',
'*.zip,*.tar,*.tar.gz,.directory,.hg', '*.zip,*.tar,*.tar.gz,.directory,.hg',
'string' 'string'
) )
); );
# -- Nothing to change below -- # -- Nothing to change below --
try { try {
# Check module version # Check module version
if (version_compare( if (version_compare(
$core->getVersion($mod_id), $core->getVersion($mod_id),
$core->plugins->moduleInfo($mod_id, 'version'), $core->plugins->moduleInfo($mod_id, 'version'),
'>=' '>='
)) { )) {
return null; return null;
} }
# Check Dotclear version # Check Dotclear version
if (!method_exists('dcUtils', 'versionsCompare') if (!method_exists('dcUtils', 'versionsCompare')
|| dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) { || dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) {
throw new Exception(sprintf( throw new Exception(sprintf(
'%s requires Dotclear %s', $mod_id, $dc_min '%s requires Dotclear %s', $mod_id, $dc_min
)); ));
} }
# Set module settings # Set module settings
$core->blog->settings->addNamespace($mod_id); $core->blog->settings->addNamespace($mod_id);
foreach($mod_conf as $v) { foreach($mod_conf as $v) {
$core->blog->settings->{$mod_id}->put( $core->blog->settings->{$mod_id}->put(
$v[0], $v[2], $v[3], $v[1], false, true $v[0], $v[2], $v[3], $v[1], false, true
); );
} }
# Set module version # Set module version
$core->setVersion( $core->setVersion(
$mod_id, $mod_id,
$core->plugins->moduleInfo($mod_id, 'version') $core->plugins->moduleInfo($mod_id, 'version')
); );
return true; return true;
} }
catch (Exception $e) { catch (Exception $e) {
$core->error->add($e->getMessage()); $core->error->add($e->getMessage());
return false; return false;
} }
?>

View File

@ -13,12 +13,11 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null;
return null;
} }
$d = dirname(__FILE__).'/inc/'; $d = dirname(__FILE__).'/inc/';
$__autoload['dcPackman'] = $d.'class.dc.packman.php'; $__autoload['dcPackman'] = $d.'class.dc.packman.php';
$__autoload['libPackman'] = $d.'lib.packman.php'; $__autoload['libPackman'] = $d.'lib.packman.php';
$__autoload['packmanFileZip'] = $d.'lib.packman.filezip.php'; $__autoload['packmanFileZip'] = $d.'lib.packman.filezip.php';

View File

@ -13,51 +13,50 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null;
return null;
} }
$mod_id = 'pacKman'; $mod_id = 'pacKman';
$this->addUserAction( $this->addUserAction(
/* type */ 'settings', /* type */ 'settings',
/* action */ 'delete_all', /* action */ 'delete_all',
/* ns */ $mod_id, /* ns */ $mod_id,
/* desc */ __('delete all settings') /* desc */ __('delete all settings')
); );
$this->addUserAction( $this->addUserAction(
/* type */ 'plugins', /* type */ 'plugins',
/* action */ 'delete', /* action */ 'delete',
/* ns */ $mod_id, /* ns */ $mod_id,
/* desc */ __('delete plugin files') /* desc */ __('delete plugin files')
); );
$this->addUserAction( $this->addUserAction(
/* type */ 'versions', /* type */ 'versions',
/* action */ 'delete', /* action */ 'delete',
/* ns */ $mod_id, /* ns */ $mod_id,
/* desc */ __('delete the version number') /* desc */ __('delete the version number')
); );
$this->addDirectAction( $this->addDirectAction(
/* type */ 'settings', /* type */ 'settings',
/* action */ 'delete_all', /* action */ 'delete_all',
/* ns */ $mod_id, /* ns */ $mod_id,
/* desc */ sprintf(__('delete all %s settings'), $mod_id) /* desc */ sprintf(__('delete all %s settings'), $mod_id)
); );
$this->addDirectAction( $this->addDirectAction(
/* type */ 'plugins', /* type */ 'plugins',
/* action */ 'delete', /* action */ 'delete',
/* ns */ $mod_id, /* ns */ $mod_id,
/* desc */ sprintf(__('delete %s plugin files'), $mod_id) /* desc */ sprintf(__('delete %s plugin files'), $mod_id)
); );
$this->addDirectAction( $this->addDirectAction(
/* type */ 'versions', /* type */ 'versions',
/* action */ 'delete', /* action */ 'delete',
/* ns */ $mod_id, /* ns */ $mod_id,
/* desc */ sprintf(__('delete %s version number'), $mod_id) /* desc */ sprintf(__('delete %s version number'), $mod_id)
); );

463
index.php
View File

@ -13,7 +13,7 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
dcPage::checkSuper(); dcPage::checkSuper();
@ -22,7 +22,7 @@ dcPage::checkSuper();
$p_url = 'plugin.php?p=pacKman'; $p_url = 'plugin.php?p=pacKman';
$action = isset($_POST['action']) ? $_POST['action'] : ''; $action = isset($_POST['action']) ? $_POST['action'] : '';
$type = isset($_POST['type']) && in_array($_POST['type'], $type = isset($_POST['type']) && in_array($_POST['type'],
array('plugins','themes','repository')) ? $_POST['type'] : ''; array('plugins', 'themes', 'repository')) ? $_POST['type'] : '';
# Settings # Settings
$core->blog->settings->addNamespace('pacKman'); $core->blog->settings->addNamespace('pacKman');
@ -30,8 +30,8 @@ $s = $core->blog->settings->pacKman;
# Modules # Modules
if (!isset($core->themes)) { if (!isset($core->themes)) {
$core->themes = new dcThemes($core); $core->themes = new dcThemes($core);
$core->themes->loadModules($core->blog->themes_path,null); $core->themes->loadModules($core->blog->themes_path, null);
} }
$themes = $core->themes; $themes = $core->themes;
$plugins = $core->plugins; $plugins = $core->plugins;
@ -45,301 +45,301 @@ $repo_path = $s->packman_pack_repository;
# Rights # Rights
$is_writable = libPackman::is_writable( $is_writable = libPackman::is_writable(
$s->packman_pack_repository, $s->packman_pack_repository,
$s->packman_pack_filename $s->packman_pack_filename
); );
$is_editable = $is_editable =
!empty($type) !empty($type)
&& !empty($_POST['modules']) && !empty($_POST['modules'])
&& is_array($_POST['modules']); && is_array($_POST['modules']);
$is_configured = libPackman::is_configured( $is_configured = libPackman::is_configured(
$core, $core,
$s->packman_pack_repository, $s->packman_pack_repository,
$s->packman_pack_filename, $s->packman_pack_filename,
$s->packman_secondpack_filename $s->packman_secondpack_filename
); );
# Actions # Actions
try try
{ {
# Download # Download
if (isset($_REQUEST['package']) && empty($type)) { if (isset($_REQUEST['package']) && empty($type)) {
$modules = array(); $modules = array();
if ($type == 'plugins') { if ($type == 'plugins') {
$modules = dcPackman::getPackages($core, $plugins_path); $modules = dcPackman::getPackages($core, $plugins_path);
} }
elseif ($type == 'themes') { elseif ($type == 'themes') {
$modules = dcPackman::getPackages($core, $themes_path); $modules = dcPackman::getPackages($core, $themes_path);
} }
else { else {
$modules = array_merge( $modules = array_merge(
dcPackman::getPackages($core, dirname($repo_path.'/'.$s->packman_pack_filename)), dcPackman::getPackages($core, dirname($repo_path . '/' . $s->packman_pack_filename)),
dcPackman::getPackages($core, dirname($repo_path.'/'.$s->packman_secondpack_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']) if (preg_match('/' . preg_quote($_REQUEST['package']) . '$/', $f['root'])
&& is_file($f['root']) && is_readable($f['root']) && is_file($f['root']) && is_readable($f['root'])
) { ) {
# --BEHAVIOR-- packmanBeforeDownloadPackage # --BEHAVIOR-- packmanBeforeDownloadPackage
$core->callBehavior('packmanBeforeDownloadPackage', $f, $type); $core->callBehavior('packmanBeforeDownloadPackage', $f, $type);
header('Content-Type: application/zip'); header('Content-Type: application/zip');
header('Content-Length: '.filesize($f['root'])); header('Content-Length: ' . filesize($f['root']));
header('Content-Disposition: attachment; filename="'.basename($f['root']).'"'); header('Content-Disposition: attachment; filename="' . basename($f['root']) . '"');
readfile($f['root']); readfile($f['root']);
# --BEHAVIOR-- packmanAfterDownloadPackage # --BEHAVIOR-- packmanAfterDownloadPackage
$core->callBehavior('packmanAfterDownloadPackage', $f, $type); $core->callBehavior('packmanAfterDownloadPackage', $f, $type);
exit; exit;
} }
} }
# Not found # Not found
header('Content-Type: text/plain'); header('Content-Type: text/plain');
http::head(404,'Not Found'); http::head(404, 'Not Found');
exit; exit;
} }
elseif (!empty($action) && !$is_editable) { elseif (!empty($action) && !$is_editable) {
throw new Exception('No selected modules'); throw new Exception('No selected modules');
} }
# Pack # Pack
elseif ($action == 'packup') { elseif ($action == 'packup') {
foreach ($_POST['modules'] as $root => $id) { foreach ($_POST['modules'] as $root => $id) {
if (!${$type}->moduleExists($id)) { if (!${$type}->moduleExists($id)) {
throw new Exception('No such module'); throw new Exception('No such module');
} }
$module = ${$type}->getModules($id); $module = ${$type}->getModules($id);
$module['id'] = $id; $module['id'] = $id;
$module['type'] = $type == 'themes' ? 'theme' : 'plugin'; $module['type'] = $type == 'themes' ? 'theme' : 'plugin';
$root = $s->packman_pack_repository; $root = $s->packman_pack_repository;
$files = array( $files = array(
$s->packman_pack_filename, $s->packman_pack_filename,
$s->packman_secondpack_filename $s->packman_secondpack_filename
); );
$nocomment = $s->packman_pack_nocomment; $nocomment = $s->packman_pack_nocomment;
$overwrite = $s->packman_pack_overwrite; $overwrite = $s->packman_pack_overwrite;
$exclude = explode(',', $s->packman_pack_excludefiles); $exclude = explode(',', $s->packman_pack_excludefiles);
# --BEHAVIOR-- packmanBeforeCreatePackage # --BEHAVIOR-- packmanBeforeCreatePackage
$core->callBehavior('packmanBeforeCreatePackage', $core, $module); $core->callBehavior('packmanBeforeCreatePackage', $core, $module);
dcPackman::pack($module, $root, $files, $overwrite, $exclude, $nocomment); dcPackman::pack($module, $root, $files, $overwrite, $exclude, $nocomment);
# --BEHAVIOR-- packmanAfterCreatePackage # --BEHAVIOR-- packmanAfterCreatePackage
$core->callBehavior('packmanAfterCreatePackage', $core, $module); $core->callBehavior('packmanAfterCreatePackage', $core, $module);
} }
dcPage::addSuccessNotice( dcPage::addSuccessNotice(
__('Package successfully created.') __('Package successfully created.')
); );
http::redirect(empty($_POST['redir']) ? http::redirect(empty($_POST['redir']) ?
$p_url.'#packman-'.$type : $_POST['redir'] $p_url . '#packman-' . $type : $_POST['redir']
); );
} }
# Delete # Delete
elseif ($action == 'delete') { elseif ($action == 'delete') {
foreach ($_POST['modules'] as $root => $id) { foreach ($_POST['modules'] as $root => $id) {
if (!file_exists($root) || !files::isDeletable($root)) { if (!file_exists($root) || !files::isDeletable($root)) {
throw new Exception('Undeletable file: '.$root); throw new Exception('Undeletable file: ' . $root);
} }
unlink($root); unlink($root);
} }
dcPage::addSuccessNotice( dcPage::addSuccessNotice(
__('Package successfully deleted.') __('Package successfully deleted.')
); );
http::redirect( http::redirect(
$p_url.'#packman-repository-'.$type $p_url . '#packman-repository-' . $type
); );
} }
# Install # Install
elseif ($action == 'install') { elseif ($action == 'install') {
foreach ($_POST['modules'] as $root => $id) { foreach ($_POST['modules'] as $root => $id) {
# --BEHAVIOR-- packmanBeforeInstallPackage # --BEHAVIOR-- packmanBeforeInstallPackage
$core->callBehavior('packmanBeforeInstallPackage', $type, $id, $root); $core->callBehavior('packmanBeforeInstallPackage', $type, $id, $root);
if ($type == 'plugins') { if ($type == 'plugins') {
$plugins->installPackage($root, $plugins); $plugins->installPackage($root, $plugins);
} }
if ($type == 'themes') { if ($type == 'themes') {
$themes->installPackage($root, $themes); $themes->installPackage($root, $themes);
} }
# --BEHAVIOR-- packmanAfterInstallPackage # --BEHAVIOR-- packmanAfterInstallPackage
$core->callBehavior('packmanAfterInstallPackage', $type, $id, $root); $core->callBehavior('packmanAfterInstallPackage', $type, $id, $root);
} }
dcPage::addSuccessNotice( dcPage::addSuccessNotice(
__('Package successfully installed.') __('Package successfully installed.')
); );
http::redirect( http::redirect(
$p_url.'#packman-repository-'.$type $p_url . '#packman-repository-' . $type
); );
} }
# Copy # Copy
elseif (strpos($action, 'copy_to_') !== false) { elseif (strpos($action, 'copy_to_') !== false) {
if ($action == 'copy_to_plugins') { if ($action == 'copy_to_plugins') {
$dest = $plugins_path; $dest = $plugins_path;
} }
elseif ($action == 'copy_to_themes') { elseif ($action == 'copy_to_themes') {
$dest = $themes_path; $dest = $themes_path;
} }
elseif ($action == 'copy_to_repository') { elseif ($action == 'copy_to_repository') {
$dest = $repo_path; $dest = $repo_path;
} }
foreach ($_POST['modules'] as $root => $id) { foreach ($_POST['modules'] as $root => $id) {
file_put_contents( file_put_contents(
$dest.'/'.basename($root), $dest . '/' . basename($root),
file_get_contents($root) file_get_contents($root)
); );
} }
dcPage::addSuccessNotice( dcPage::addSuccessNotice(
__('Package successfully copied.') __('Package successfully copied.')
); );
http::redirect( http::redirect(
$p_url.'#packman-repository-'.$type $p_url . '#packman-repository-' . $type
); );
} }
# Move # Move
elseif (strpos($action, 'move_to_') !== false) { elseif (strpos($action, 'move_to_') !== false) {
if ($action == 'move_to_plugins') { if ($action == 'move_to_plugins') {
$dest = $plugins_path; $dest = $plugins_path;
} }
elseif ($action == 'move_to_themes') { elseif ($action == 'move_to_themes') {
$dest = $themes_path; $dest = $themes_path;
} }
elseif ($action == 'move_to_repository') { elseif ($action == 'move_to_repository') {
$dest = $repo_path; $dest = $repo_path;
} }
foreach ($_POST['modules'] as $root => $id) { foreach ($_POST['modules'] as $root => $id) {
file_put_contents( file_put_contents(
$dest.'/'.basename($root), $dest . '/' . basename($root),
file_get_contents($root) file_get_contents($root)
); );
unlink($root); unlink($root);
} }
dcPage::addSuccessNotice( dcPage::addSuccessNotice(
__('Package successfully moved.') __('Package successfully moved.')
); );
http::redirect( http::redirect(
$p_url.'#packman-repository-'.$type $p_url . '#packman-repository-' . $type
); );
} }
} }
catch(Exception $e) { catch(Exception $e) {
$core->error->add($e->getMessage()); $core->error->add($e->getMessage());
} }
# Display # Display
echo echo
'<html><head><title>'.__('pacKman').'</title>'. '<html><head><title>' . __('pacKman') . '</title>' .
dcPage::jsPageTabs(). dcPage::jsPageTabs() .
dcPage::jsLoad('index.php?pf=pacKman/js/packman.js'); dcPage::jsLoad('index.php?pf=pacKman/js/packman.js');
# --BEHAVIOR-- packmanAdminHeader # --BEHAVIOR-- packmanAdminHeader
$core->callBehavior('packmanAdminHeader', $core); $core->callBehavior('packmanAdminHeader', $core);
echo echo
'</head><body>'. '</head><body>' .
dcPage::breadcrumb( dcPage::breadcrumb(
array( array(
__('Plugins') => '', __('Plugins') => '',
__('pacKman') => '' __('pacKman') => ''
) )
). ).
dcPage::notices(); dcPage::notices();
if ($core->error->flag()) { if ($core->error->flag()) {
echo echo
'<p class="warning">'.__('pacKman is not well configured.').' '. '<p class="warning">' . __('pacKman is not well configured.') . ' ' .
'<a href="plugins.php?module=pacKman&amp;conf=1&amp;redir='. '<a href="plugins.php?module=pacKman&amp;conf=1&amp;redir=' .
urlencode('plugin.php?p=pacKman').'">'.__('Configuration').'</a>'. urlencode('plugin.php?p=pacKman') . '">' . __('Configuration') . '</a>' .
'</p>'; '</p>';
} }
else { else {
$repo_path_modules = array_merge( $repo_path_modules = array_merge(
dcPackman::getPackages( dcPackman::getPackages(
$core, $core,
dirname($repo_path.'/'.$s->packman_pack_filename) dirname($repo_path . '/' . $s->packman_pack_filename)
), ),
dcPackman::getPackages( dcPackman::getPackages(
$core, $core,
dirname($repo_path.'/'.$s->packman_secondpack_filename) dirname($repo_path . '/' . $s->packman_secondpack_filename)
) )
); );
$plugins_path_modules = dcPackman::getPackages( $plugins_path_modules = dcPackman::getPackages(
$core, $core,
$plugins_path $plugins_path
); );
$themes_path_modules = dcPackman::getPackages( $themes_path_modules = dcPackman::getPackages(
$core, $core,
$themes_path $themes_path
); );
libPackman::modules( libPackman::modules(
$core, $core,
$plugins->getModules(), $plugins->getModules(),
'plugins', 'plugins',
__('Installed plugins') __('Installed plugins')
); );
libPackman::modules( libPackman::modules(
$core, $core,
$themes->getModules(), $themes->getModules(),
'themes', 'themes',
__('Installed themes') __('Installed themes')
); );
libPackman::repository( libPackman::repository(
$core, $core,
$plugins_path_modules, $plugins_path_modules,
'plugins', 'plugins',
__('Plugins root') __('Plugins root')
); );
libPackman::repository( libPackman::repository(
$core, $core,
$themes_path_modules, $themes_path_modules,
'themes', 'themes',
__('Themes root') __('Themes root')
); );
libPackman::repository( libPackman::repository(
$core, $core,
$repo_path_modules, $repo_path_modules,
'repository', 'repository',
__('Packages repository') __('Packages repository')
); );
} }
# --BEHAVIOR-- packmanAdminTabs # --BEHAVIOR-- packmanAdminTabs
@ -348,11 +348,4 @@ $core->callBehavior('packmanAdminTabs', $core);
dcPage::helpBlock('pacKman'); dcPage::helpBlock('pacKman');
echo echo
'<hr class="clear"/><p class="right modules"> '</body></html>';
<a class="module-config" '.
'href="plugins.php?module=pacKman&amp;conf=1&amp;redir='.
urlencode('plugin.php?p=pacKman').'">'.__('Configuration').'</a> -
pacKman - '.$core->plugins->moduleInfo('pacKman', 'version').'&nbsp;
<img alt="'.__('pacKman').'" src="index.php?pf=pacKman/icon.png" />
</p>
</body></html>';