fix PSR coding style

This commit is contained in:
Jean-Christian Denis 2021-11-01 11:39:02 +01:00
parent e2d8a94e28
commit af474f0189
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
10 changed files with 190 additions and 171 deletions

View file

@ -1,16 +1,15 @@
<?php
/**
* @brief pacKman, a plugin for Dotclear 2
*
*
* @package Dotclear
* @subpackage Plugin
*
*
* @author Jean-Christian Denis
*
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
@ -35,13 +34,13 @@ class packmanBehaviors
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',
'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' => [
'packmanBehaviors',
'active_cb' => [
'packmanBehaviors',
'adminDashboardFavoritesActive'
]
]);
@ -49,8 +48,8 @@ class packmanBehaviors
public static function adminDashboardFavoritesActive($request, $params)
{
return $request == 'plugin.php'
&& isset($params['p'])
return $request == 'plugin.php'
&& isset($params['p'])
&& $params['p'] == 'pacKman';
}
}

View file

@ -1,45 +1,44 @@
<?php
/**
* @brief pacKman, a plugin for Dotclear 2
*
*
* @package Dotclear
* @subpackage Plugin
*
*
* @author Jean-Christian Denis
*
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_MODULE')) {
return null;
}
$redir = empty($_REQUEST['redir']) ?
$redir = empty($_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_fixnewline = $s->packman_pack_fixnewline;
$packman_pack_overwrite = $s->packman_pack_overwrite;
$packman_pack_filename = $s->packman_pack_filename;
$packman_pack_nocomment = $s->packman_pack_nocomment;
$packman_pack_fixnewline = $s->packman_pack_fixnewline;
$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_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_fixnewline = !empty($_POST['packman_pack_fixnewline']);
$packman_pack_overwrite = !empty($_POST['packman_pack_overwrite']);
$packman_pack_filename = $_POST['packman_pack_filename'];
$packman_pack_nocomment = !empty($_POST['packman_pack_nocomment']);
$packman_pack_fixnewline = !empty($_POST['packman_pack_fixnewline']);
$packman_pack_overwrite = !empty($_POST['packman_pack_overwrite']);
$packman_pack_filename = $_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'];
$packman_pack_repository = path::real($_POST['packman_pack_repository'], false);
$packman_pack_excludefiles = $_POST['packman_pack_excludefiles'];
$check = libPackman::is_configured(
$core,
@ -78,7 +77,9 @@ echo '
<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 ?
'<p class="form-note">' . sprintf(
__('Preconization: %s'),
$core->blog->public_path ?
$core->blog->public_path : __("Blog's public directory")
) . '</p>
</div>
@ -96,7 +97,7 @@ form::field('packman_secondpack_filename', 65, 255, $packman_secondpack_filename
'</label></p>
<p class="form-note">' . sprintf(__('Preconization: %s'), '%type%-%id%-%version%') . '</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) . ' ' .
__('Overwrite existing package') . '</label></p>

View file

@ -1,16 +1,15 @@
<?php
/**
* @brief pacKman, a plugin for Dotclear 2
*
*
* @package Dotclear
* @subpackage Plugin
*
*
* @author Jean-Christian Denis
*
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
@ -21,11 +20,11 @@ $this->registerModule(
'Jean-Christian Denis',
'2021.10.28',
[
'requires' => [['core', '2.19']],
'permissions' => null,
'type' => 'plugin',
'support' => 'https://github.com/JcDenis/pacKman',
'details' => 'https://plugins.dotaddict.org/dc2/details/pacKman',
'repository' => 'https://raw.githubusercontent.com/JcDenis/pacKman/master/dcstore.xml'
'requires' => [['core', '2.19']],
'permissions' => null,
'type' => 'plugin',
'support' => 'https://github.com/JcDenis/pacKman',
'details' => 'https://plugins.dotaddict.org/dc2/details/pacKman',
'repository' => 'https://raw.githubusercontent.com/JcDenis/pacKman/master/dcstore.xml'
]
);

View file

@ -1,24 +1,23 @@
<?php
/**
* @brief pacKman, a plugin for Dotclear 2
*
*
* @package Dotclear
* @subpackage Plugin
*
*
* @author Jean-Christian Denis
*
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
# -- Module specs --
$dc_min = '2.18';
$mod_id = 'pacKman';
$dc_min = '2.18';
$mod_id = 'pacKman';
$mod_conf = [
[
'packman_menu_plugins',
@ -72,23 +71,31 @@ try {
if (version_compare(
$core->getVersion($mod_id),
$core->plugins->moduleInfo($mod_id, 'version'),
'>=')) {
'>='
)) {
return null;
}
# Check Dotclear version
if (!method_exists('dcUtils', 'versionsCompare')
if (!method_exists('dcUtils', 'versionsCompare')
|| dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) {
throw new Exception(sprintf(
'%s requires Dotclear %s', $mod_id, $dc_min
'%s requires Dotclear %s',
$mod_id,
$dc_min
));
}
# Set module settings
$core->blog->settings->addNamespace($mod_id);
foreach($mod_conf as $v) {
foreach ($mod_conf as $v) {
$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
);
}
@ -99,8 +106,7 @@ try {
);
return true;
}
catch (Exception $e) {
} catch (Exception $e) {
$core->error->add($e->getMessage());
return false;

View file

@ -1,22 +1,21 @@
<?php
/**
* @brief pacKman, a plugin for Dotclear 2
*
*
* @package Dotclear
* @subpackage Plugin
*
*
* @author Jean-Christian Denis
*
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
$d = dirname(__FILE__) . '/inc/';
$__autoload['dcPackman'] = $d . 'class.dc.packman.php';
$__autoload['libPackman'] = $d . 'lib.packman.php';
$__autoload['dcPackman'] = $d . 'class.dc.packman.php';
$__autoload['libPackman'] = $d . 'lib.packman.php';
$__autoload['packmanFileZip'] = $d . 'lib.packman.filezip.php';

View file

@ -1,16 +1,15 @@
<?php
/**
* @brief pacKman, a plugin for Dotclear 2
*
*
* @package Dotclear
* @subpackage Plugin
*
*
* @author Jean-Christian Denis
*
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
@ -18,43 +17,67 @@ if (!defined('DC_CONTEXT_ADMIN')) {
$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)
);

View file

@ -1,16 +1,15 @@
<?php
/**
* @brief pacKman, a plugin for Dotclear 2
*
*
* @package Dotclear
* @subpackage Plugin
*
*
* @author Jean-Christian Denis
*
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
@ -31,7 +30,7 @@ class dcPackman
public static function quote_exclude($exclude)
{
foreach($exclude AS $k => $v) {
foreach ($exclude as $k => $v) {
$exclude[$k] = '#(^|/)(' . str_replace(
['.', '*'],
['\.', '.*?'],
@ -51,9 +50,9 @@ class dcPackman
return $res;
}
$files = files::scanDir($root);
$files = files::scanDir($root);
$zip_files = [];
foreach($files as $file) {
foreach ($files as $file) {
if (!preg_match('#(^|/)(.*?)\.zip(/|$)#', $file)) {
continue;
}
@ -65,16 +64,16 @@ class dcPackman
}
$i = 0;
foreach($zip_files as $zip_file) {
foreach ($zip_files as $zip_file) {
$zip = new fileUnzip($root . '/' . $zip_file);
$zip_root_dir = $zip->getRootDir();
if ($zip_root_dir != false) {
$define = $zip_root_dir . '/_define.php';
$define = $zip_root_dir . '/_define.php';
$has_define = $zip->hasFile($define);
} else {
$define = '_define.php';
$define = '_define.php';
$has_define = $zip->hasFile($define);
}
@ -93,7 +92,7 @@ class dcPackman
$themes->requireDefine($cache, $zip_root_dir);
$res[$i] = $themes->getModules($zip_root_dir);
}
$res[$i]['id'] = $zip_root_dir;
$res[$i]['id'] = $zip_root_dir;
$res[$i]['root'] = $root . '/' . $zip_file;
unlink($cache . '_define.php');
@ -113,7 +112,7 @@ class dcPackman
$exclude = self::getExclude($exclude);
foreach($files as $file) {
foreach ($files as $file) {
if (!($file = self::getFile($file, $info))
|| !($dest = self::getOverwrite($overwrite, $root, $file))
) {
@ -131,7 +130,7 @@ class dcPackman
}
$zip = new packmanFileZip($fp);
foreach($exclude AS $e) {
foreach ($exclude as $e) {
$zip->addExclusion($e);
}
$zip->addDirectory(
@ -160,8 +159,8 @@ class dcPackman
private static function getInfo($info)
{
if (!isset($info['root'])
|| !isset($info['id'])
if (!isset($info['root'])
|| !isset($info['id'])
|| !is_dir($info['root'])
) {
throw new Exception('Failed to get module info');
@ -201,9 +200,10 @@ class dcPackman
$file
);
$parts = explode('/', $file);
foreach($parts as $i => $part) {
foreach ($parts as $i => $part) {
$parts[$i] = files::tidyFileName($part);
}
return implode('/', $parts) . '.zip';
}

View file

@ -1,20 +1,19 @@
<?php
/**
* @brief pacKman, a plugin for Dotclear 2
*
*
* @package Dotclear
* @subpackage Plugin
*
*
* @author Jean-Christian Denis
*
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class packmanFileZip extends fileZip
{
public static $remove_comment = false;
public static $fix_newline = false;
public static $fix_newline = false;
protected function writeFile($name, $file, $size, $mtime)
{
@ -29,17 +28,17 @@ class packmanFileZip extends fileZip
//cleanup file contents
// at this time only php files
if (self::$remove_comment && substr($file,-4) == '.php') {
if (self::$remove_comment && substr($file, -4) == '.php') {
$content = self::removePHPComment($content);
}
if (self::$fix_newline && substr($file,-4) == '.php') {
if (self::$fix_newline && substr($file, -4) == '.php') {
$content = self::fixNewline($content);
}
$unc_len = strlen($content);
$crc = crc32($content);
$zdata = gzdeflate($content);
$c_len = strlen($zdata);
$crc = crc32($content);
$zdata = gzdeflate($content);
$c_len = strlen($zdata);
unset($content);
@ -47,8 +46,7 @@ class packmanFileZip extends fileZip
$mtime = $this->makeTime($mtime);
# Data descriptor
$data_desc =
"\x50\x4b\x03\x04" .
$data_desc = "\x50\x4b\x03\x04" .
"\x14\x00" . # ver needed to extract
"\x00\x00" . # gen purpose bit flag
"\x08\x00" . # compression method
@ -58,7 +56,7 @@ class packmanFileZip extends fileZip
pack('V', $c_len) . # compressed filesize
pack('V', $unc_len) . # uncompressed filesize
pack('v', strlen($name)) . # length of filename
pack('v' ,0) . # extra field length
pack('v', 0) . # extra field length
$name . # end of "local file header" segment
$zdata . # "file data" segment
pack('V', $crc) . # crc32
@ -71,8 +69,7 @@ class packmanFileZip extends fileZip
$new_offset = $this->old_offset + strlen($data_desc);
# Add to central directory record
$cdrec =
"\x50\x4b\x01\x02" .
$cdrec = "\x50\x4b\x01\x02" .
"\x00\x00" . # version made by
"\x14\x00" . # version needed to extract
"\x00\x00" . # gen purpose bit flag
@ -88,7 +85,7 @@ class packmanFileZip extends fileZip
pack('v', 0) . # disk number start
pack('v', 0) . # internal file attributes
pack('V', 32) . # external file attributes - 'archive' bit set
pack('V', $this->old_offset). # relative offset of local header
pack('V', $this->old_offset) . # relative offset of local header
$name;
$this->old_offset = $new_offset;
@ -119,6 +116,7 @@ class packmanFileZip extends fileZip
$newStr .= $token;
}
}
return $newStr;
}

View file

@ -1,16 +1,15 @@
<?php
/**
* @brief pacKman, a plugin for Dotclear 2
*
*
* @package Dotclear
* @subpackage Plugin
*
*
* @author Jean-Christian Denis
*
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
@ -64,7 +63,7 @@ class libPackman
$type = $type == 'themes' ? 'themes' : 'plugins';
echo
echo
'<div class="multi-part" ' .
'id="packman-' . $type . '" title="' . $title . '">' .
'<h3>' . $title . '</h3>' .
@ -76,7 +75,7 @@ class libPackman
'<th class="nowrap">' . __('Root') . '</th>' .
'</tr>';
foreach (self::sort($modules) as $id => $module) {
foreach (self::sort($modules) as $id => $module) {
echo
'<tr class="line">' .
'<td class="nowrap"><label class="classic">' .
@ -99,7 +98,8 @@ class libPackman
'</table>' .
'<p class="checkboxes-helpers"></p>' .
'<p>' .
(!empty($_REQUEST['redir']) ?
(
!empty($_REQUEST['redir']) ?
form::hidden(
['redir'],
html::escapeHTML($_REQUEST['redir'])
@ -109,7 +109,7 @@ class libPackman
form::hidden(['type'], $type) .
form::hidden(['action'], 'packup') .
'<input type="submit" name="packup" value="' .
__('Pack up selected modules') .'" />' .
__('Pack up selected modules') . '" />' .
$core->formNonce() . '</p>' .
'</form>' .
@ -125,7 +125,7 @@ class libPackman
return null;
}
echo
echo
'<div class="multi-part" ' .
'id="packman-repository-' . $type . '" title="' . $title . '">' .
'<h3>' . $title . '</h3>';
@ -148,7 +148,7 @@ class libPackman
$combo_action[sprintf(__('move to %s directory'), __('repository'))] = 'move_to_repository';
}
echo
echo
'<form action="plugin.php" method="post">' .
'<table class="clear"><tr>' .
'<th class="nowrap">' . __('Id') . '</th>' .
@ -158,7 +158,7 @@ class libPackman
'</tr>';
$dup = [];
foreach(self::sort($modules) AS $module) {
foreach (self::sort($modules) as $module) {
if (isset($dup[$module['root']])) {
continue;
}
@ -179,8 +179,8 @@ class libPackman
__(html::escapeHTML($module['name'])) .
'</td>' .
'<td class="nowrap">' .
'<a class="packman-download" href="plugin.php?p=pacKman&amp;package=' .
basename($module['root']) . '&amp;repo=' . $type . '" title="'. __('Download') . '">' .
'<a class="packman-download" href="plugin.php?p=pacKman&amp;package=' .
basename($module['root']) . '&amp;repo=' . $type . '" title="' . __('Download') . '">' .
html::escapeHTML(basename($module['root'])) . '</a>' .
'</td>' .
'</tr>';
@ -206,7 +206,7 @@ class libPackman
protected static function sort($modules)
{
$key = $ver = [];
foreach($modules as $i => $module) {
foreach ($modules as $i => $module) {
$key[$i] = $module['id'] ?? $i;
$ver[$i] = $module['version'];
}

View file

@ -1,16 +1,15 @@
<?php
/**
* @brief pacKman, a plugin for Dotclear 2
*
*
* @package Dotclear
* @subpackage Plugin
*
*
* @author Jean-Christian Denis
*
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
@ -18,8 +17,8 @@ if (!defined('DC_CONTEXT_ADMIN')) {
dcPage::checkSuper();
# Queries
$action = isset($_POST['action']) ? $_POST['action'] : '';
$type = isset($_POST['type']) && in_array($_POST['type'], ['plugins', 'themes', 'repository']) ? $_POST['type'] : '';
$action = $_POST['action'] ?? '';
$type = isset($_POST['type']) && in_array($_POST['type'], ['plugins', 'themes', 'repository']) ? $_POST['type'] : '';
# Settings
$core->blog->settings->addNamespace('pacKman');
@ -30,24 +29,23 @@ if (!isset($core->themes)) {
$core->themes = new dcThemes($core);
$core->themes->loadModules($core->blog->themes_path, null);
}
$themes = $core->themes;
$themes = $core->themes;
$plugins = $core->plugins;
# Paths
$ppexp = explode(PATH_SEPARATOR, DC_PLUGINS_ROOT);
$pppop = array_pop($ppexp);
$ppexp = explode(PATH_SEPARATOR, DC_PLUGINS_ROOT);
$pppop = array_pop($ppexp);
$plugins_path = path::real($pppop);
$themes_path = $core->blog->themes_path;
$repo_path = $s->packman_pack_repository;
$themes_path = $core->blog->themes_path;
$repo_path = $s->packman_pack_repository;
# Rights
$is_writable = libPackman::is_writable(
$s->packman_pack_repository,
$s->packman_pack_filename
);
$is_editable =
!empty($type)
&& !empty($_POST['modules'])
$is_editable = !empty($type)
&& !empty($_POST['modules'])
&& is_array($_POST['modules']);
$is_configured = libPackman::is_configured(
@ -73,7 +71,7 @@ try {
);
}
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'])
) {
@ -97,7 +95,6 @@ try {
header('Content-Type: text/plain');
http::head(404, 'Not Found');
exit;
} elseif (!empty($action) && !$is_editable) {
throw new Exception('No selected modules');
@ -108,19 +105,19 @@ try {
throw new Exception('No such module');
}
$module = ${$type}->getModules($id);
$module['id'] = $id;
$module = ${$type}->getModules($id);
$module['id'] = $id;
$module['type'] = $type == 'themes' ? 'theme' : 'plugin';
$root = $s->packman_pack_repository;
$root = $s->packman_pack_repository;
$files = [
$s->packman_pack_filename,
$s->packman_secondpack_filename
];
$nocomment = $s->packman_pack_nocomment;
$nocomment = $s->packman_pack_nocomment;
$fixnewline = $s->packman_pack_fixnewline;
$overwrite = $s->packman_pack_overwrite;
$exclude = explode(',', $s->packman_pack_excludefiles);
$overwrite = $s->packman_pack_overwrite;
$exclude = explode(',', $s->packman_pack_excludefiles);
# --BEHAVIOR-- packmanBeforeCreatePackage
$core->callBehavior('packmanBeforeCreatePackage', $core, $module);
@ -129,7 +126,6 @@ try {
# --BEHAVIOR-- packmanAfterCreatePackage
$core->callBehavior('packmanAfterCreatePackage', $core, $module);
}
dcPage::addSuccessNotice(
@ -142,10 +138,10 @@ try {
$core->adminurl->redirect('admin.plugin.pacKman', [], '#packman-' . $type);
}
# Delete
# Delete
} elseif ($action == 'delete') {
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);
}
@ -162,7 +158,7 @@ try {
$core->adminurl->redirect('admin.plugin.pacKman', [], '#packman-repository-' . $type);
}
# Install
# Install
} elseif ($action == 'install') {
foreach ($_POST['modules'] as $root => $id) {
@ -178,7 +174,6 @@ try {
# --BEHAVIOR-- packmanAfterInstallPackage
$core->callBehavior('packmanAfterInstallPackage', $type, $id, $root);
}
dcPage::addSuccessNotice(
@ -191,7 +186,7 @@ try {
$core->adminurl->redirect('admin.plugin.pacKman', [], '#packman-repository-' . $type);
}
# Copy
# Copy
} elseif (strpos($action, 'copy_to_') !== false) {
if ($action == 'copy_to_plugins') {
$dest = $plugins_path;
@ -218,7 +213,7 @@ try {
$core->adminurl->redirect('admin.plugin.pacKman', [], '#packman-repository-' . $type);
}
# Move
# Move
} elseif (strpos($action, 'move_to_') !== false) {
if ($action == 'move_to_plugins') {
$dest = $plugins_path;
@ -246,12 +241,12 @@ try {
$core->adminurl->redirect('admin.plugin.pacKman', [], '#packman-repository-' . $type);
}
}
} catch(Exception $e) {
} catch (Exception $e) {
$core->error->add($e->getMessage());
}
# Display
echo
echo
'<html><head><title>' . __('pacKman') . '</title>' .
dcPage::jsPageTabs() .
dcPage::jsLoad(dcPage::getPF('pacKman/js/packman.js'));
@ -259,13 +254,13 @@ dcPage::jsLoad(dcPage::getPF('pacKman/js/packman.js'));
# --BEHAVIOR-- packmanAdminHeader
$core->callBehavior('packmanAdminHeader', $core);
echo
echo
'</head><body>' .
dcPage::breadcrumb([
__('Plugins') => '',
__('pacKman') => ''
]).
__('Plugins') => '',
__('pacKman') => ''
]) .
dcPage::notices();
if ($core->error->flag()) {
@ -274,7 +269,6 @@ if ($core->error->flag()) {
'<a href="plugins.php?module=pacKman&amp;conf=1&amp;redir=' .
urlencode('plugin.php?p=pacKman') . '">' . __('Configuration') . '</a>' .
'</p>';
} else {
$repo_path_modules = array_merge(
dcPackman::getPackages(
@ -336,5 +330,5 @@ $core->callBehavior('packmanAdminTabs', $core);
dcPage::helpBlock('pacKman');
echo
echo
'</body></html>';