fix PSR coding style
This commit is contained in:
parent
e2d8a94e28
commit
af474f0189
10 changed files with 190 additions and 171 deletions
|
@ -10,7 +10,6 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_MODULE')) {
|
||||
return null;
|
||||
}
|
||||
|
@ -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>
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
|
20
_install.php
20
_install.php
|
@ -10,7 +10,6 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
@ -72,7 +71,8 @@ try {
|
|||
if (version_compare(
|
||||
$core->getVersion($mod_id),
|
||||
$core->plugins->moduleInfo($mod_id, 'version'),
|
||||
'>=')) {
|
||||
'>='
|
||||
)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -80,15 +80,22 @@ try {
|
|||
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;
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
* @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)
|
||||
);
|
|
@ -10,7 +10,6 @@
|
|||
* @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(
|
||||
['.', '*'],
|
||||
['\.', '.*?'],
|
||||
|
@ -53,7 +52,7 @@ class dcPackman
|
|||
|
||||
$files = files::scanDir($root);
|
||||
$zip_files = [];
|
||||
foreach($files as $file) {
|
||||
foreach ($files as $file) {
|
||||
if (!preg_match('#(^|/)(.*?)\.zip(/|$)#', $file)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -65,7 +64,7 @@ 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();
|
||||
|
@ -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(
|
||||
|
@ -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';
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
* @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;
|
||||
|
@ -29,10 +28,10 @@ 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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
@ -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>' .
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ class libPackman
|
|||
'</td>' .
|
||||
'<td class="nowrap">' .
|
||||
'<a class="packman-download" href="plugin.php?p=pacKman&package=' .
|
||||
basename($module['root']) . '&repo=' . $type . '" title="'. __('Download') . '">' .
|
||||
basename($module['root']) . '&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'];
|
||||
}
|
||||
|
|
16
index.php
16
index.php
|
@ -10,7 +10,6 @@
|
|||
* @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,7 +17,7 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
|||
dcPage::checkSuper();
|
||||
|
||||
# Queries
|
||||
$action = isset($_POST['action']) ? $_POST['action'] : '';
|
||||
$action = $_POST['action'] ?? '';
|
||||
$type = isset($_POST['type']) && in_array($_POST['type'], ['plugins', 'themes', 'repository']) ? $_POST['type'] : '';
|
||||
|
||||
# Settings
|
||||
|
@ -45,8 +44,7 @@ $is_writable = libPackman::is_writable(
|
|||
$s->packman_pack_repository,
|
||||
$s->packman_pack_filename
|
||||
);
|
||||
$is_editable =
|
||||
!empty($type)
|
||||
$is_editable = !empty($type)
|
||||
&& !empty($_POST['modules'])
|
||||
&& is_array($_POST['modules']);
|
||||
|
||||
|
@ -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');
|
||||
|
||||
|
@ -129,7 +126,6 @@ try {
|
|||
|
||||
# --BEHAVIOR-- packmanAfterCreatePackage
|
||||
$core->callBehavior('packmanAfterCreatePackage', $core, $module);
|
||||
|
||||
}
|
||||
|
||||
dcPage::addSuccessNotice(
|
||||
|
@ -178,7 +174,6 @@ try {
|
|||
|
||||
# --BEHAVIOR-- packmanAfterInstallPackage
|
||||
$core->callBehavior('packmanAfterInstallPackage', $type, $id, $root);
|
||||
|
||||
}
|
||||
|
||||
dcPage::addSuccessNotice(
|
||||
|
@ -246,7 +241,7 @@ try {
|
|||
$core->adminurl->redirect('admin.plugin.pacKman', [], '#packman-repository-' . $type);
|
||||
}
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
}
|
||||
|
||||
|
@ -265,7 +260,7 @@ echo
|
|||
dcPage::breadcrumb([
|
||||
__('Plugins') => '',
|
||||
__('pacKman') => ''
|
||||
]).
|
||||
]) .
|
||||
dcPage::notices();
|
||||
|
||||
if ($core->error->flag()) {
|
||||
|
@ -274,7 +269,6 @@ if ($core->error->flag()) {
|
|||
'<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(
|
||||
|
|
Loading…
Reference in a new issue