move to Franck style
This commit is contained in:
parent
373a26d730
commit
42f12a73e6
9 changed files with 450 additions and 472 deletions
10
CHANGELOG.md
10
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
|
||||
|
|
|
@ -27,3 +27,9 @@ 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.
|
||||
|
||||
## 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)
|
64
_admin.php
64
_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';
|
||||
}
|
||||
}
|
128
_config.php
128
_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 '
|
||||
|
||||
<div class="fieldset">
|
||||
<h4>'.__('Root').'</h4>
|
||||
<h4>' . __('Root') . '</h4>
|
||||
|
||||
<p><label for="packman_pack_repository">'.__('Path to repository:').' '.
|
||||
form::field('packman_pack_repository', 65, 255, $packman_pack_repository, 'maximal').
|
||||
'</label></p>'.
|
||||
'<p class="form-note">'.sprintf(__('Preconization: %s'), $core->blog->public_path ?
|
||||
$core->blog->public_path : __("Blog's public directory")
|
||||
).'</p>
|
||||
<p><label for="packman_pack_repository">' . __('Path to repository:') . ' ' .
|
||||
form::field('packman_pack_repository', 65, 255, $packman_pack_repository, 'maximal') .
|
||||
'</label></p>' .
|
||||
'<p class="form-note">' . sprintf(__('Preconization: %s'), $core->blog->public_path ?
|
||||
$core->blog->public_path : __("Blog's public directory")
|
||||
) . '</p>
|
||||
</div>
|
||||
|
||||
<div class="fieldset">
|
||||
<h4>'.__('Files').'</h4>
|
||||
<h4>' . __('Files') . '</h4>
|
||||
|
||||
<p><label for="packman_pack_filename">'.__('Name of exported package:').' '.
|
||||
form::field('packman_pack_filename', 65, 255, $packman_pack_filename, 'maximal').
|
||||
<p><label for="packman_pack_filename">' . __('Name of exported package:') . ' ' .
|
||||
form::field('packman_pack_filename', 65, 255, $packman_pack_filename, 'maximal') .
|
||||
'</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:').' '.
|
||||
form::field('packman_secondpack_filename', 65, 255, $packman_secondpack_filename, 'maximal').
|
||||
<p><label for="packman_secondpack_filename">' . __('Name of second exported package:') . ' ' .
|
||||
form::field('packman_secondpack_filename', 65, 255, $packman_secondpack_filename, 'maximal') .
|
||||
'</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">'.
|
||||
form::checkbox('packman_pack_overwrite', 1, $packman_pack_overwrite).' '.
|
||||
__('Overwrite existing package').'</label></p>
|
||||
form::checkbox('packman_pack_overwrite', 1, $packman_pack_overwrite) . ' ' .
|
||||
__('Overwrite existing package') . '</label></p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="fieldset">
|
||||
<h4>'.__('Content').'</h4>
|
||||
<h4>' . __('Content') . '</h4>
|
||||
|
||||
<p><label for="packman_pack_excludefiles">'.__('Extra files to exclude from package:').' '.
|
||||
form::field('packman_pack_excludefiles', 65, 255, $packman_pack_excludefiles, 'maximal').
|
||||
<p><label for="packman_pack_excludefiles">' . __('Extra files to exclude from package:') . ' ' .
|
||||
form::field('packman_pack_excludefiles', 65, 255, $packman_pack_excludefiles, 'maximal') .
|
||||
'</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">'.
|
||||
form::checkbox('packman_pack_nocomment', 1, $packman_pack_nocomment).' '.
|
||||
__('Remove comments from files').'</label></p>
|
||||
<p><label class="classic" for="packman_pack_nocomment">' .
|
||||
form::checkbox('packman_pack_nocomment', 1, $packman_pack_nocomment) . ' ' .
|
||||
__('Remove comments from files') . '</label></p>
|
||||
|
||||
</div>';
|
30
_define.php
30
_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'
|
||||
]
|
||||
);
|
149
_install.php
149
_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;
|
||||
return false;
|
||||
}
|
||||
|
||||
?>
|
|
@ -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';
|
|
@ -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)
|
||||
);
|
463
index.php
463
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
|
||||
'<html><head><title>'.__('pacKman').'</title>'.
|
||||
dcPage::jsPageTabs().
|
||||
'<html><head><title>' . __('pacKman') . '</title>' .
|
||||
dcPage::jsPageTabs() .
|
||||
dcPage::jsLoad('index.php?pf=pacKman/js/packman.js');
|
||||
|
||||
# --BEHAVIOR-- packmanAdminHeader
|
||||
$core->callBehavior('packmanAdminHeader', $core);
|
||||
|
||||
echo
|
||||
'</head><body>'.
|
||||
'</head><body>' .
|
||||
|
||||
dcPage::breadcrumb(
|
||||
array(
|
||||
__('Plugins') => '',
|
||||
__('pacKman') => ''
|
||||
)
|
||||
array(
|
||||
__('Plugins') => '',
|
||||
__('pacKman') => ''
|
||||
)
|
||||
).
|
||||
dcPage::notices();
|
||||
|
||||
if ($core->error->flag()) {
|
||||
echo
|
||||
'<p class="warning">'.__('pacKman is not well configured.').' '.
|
||||
'<a href="plugins.php?module=pacKman&conf=1&redir='.
|
||||
urlencode('plugin.php?p=pacKman').'">'.__('Configuration').'</a>'.
|
||||
'</p>';
|
||||
echo
|
||||
'<p class="warning">' . __('pacKman is not well configured.') . ' ' .
|
||||
'<a href="plugins.php?module=pacKman&conf=1&redir=' .
|
||||
urlencode('plugin.php?p=pacKman') . '">' . __('Configuration') . '</a>' .
|
||||
'</p>';
|
||||
}
|
||||
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
|
||||
'<hr class="clear"/><p class="right modules">
|
||||
<a class="module-config" '.
|
||||
'href="plugins.php?module=pacKman&conf=1&redir='.
|
||||
urlencode('plugin.php?p=pacKman').'">'.__('Configuration').'</a> -
|
||||
pacKman - '.$core->plugins->moduleInfo('pacKman', 'version').'
|
||||
<img alt="'.__('pacKman').'" src="index.php?pf=pacKman/icon.png" />
|
||||
</p>
|
||||
</body></html>';
|
||||
'</body></html>';
|
Loading…
Reference in a new issue