diff --git a/_admin.php b/_admin.php index 7da3631..fc7ee91 100644 --- a/_admin.php +++ b/_admin.php @@ -1,16 +1,15 @@ 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'; } } \ No newline at end of file diff --git a/_config.php b/_config.php index e08ba74..039d24a 100644 --- a/_config.php +++ b/_config.php @@ -1,45 +1,44 @@ 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 '

' . -'

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

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

@@ -96,7 +97,7 @@ form::field('packman_secondpack_filename', 65, 255, $packman_secondpack_filename '

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

-

diff --git a/_define.php b/_define.php index 5bb03c5..dd13af0 100644 --- a/_define.php +++ b/_define.php @@ -1,16 +1,15 @@ 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' ] ); \ No newline at end of file diff --git a/_install.php b/_install.php index d0beb79..37ab0af 100644 --- a/_install.php +++ b/_install.php @@ -1,24 +1,23 @@ 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; diff --git a/_prepend.php b/_prepend.php index 7d175bf..0518eff 100644 --- a/_prepend.php +++ b/_prepend.php @@ -1,22 +1,21 @@ addUserAction( - /* type */ 'settings', - /* action */ 'delete_all', - /* ns */ $mod_id, - /* desc */ __('delete all settings') + /* type */ + 'settings', + /* action */ + 'delete_all', + /* ns */ + $mod_id, + /* desc */ + __('delete all settings') ); $this->addUserAction( - /* type */ 'plugins', - /* action */ 'delete', - /* ns */ $mod_id, - /* desc */ __('delete plugin files') + /* type */ + 'plugins', + /* action */ + 'delete', + /* ns */ + $mod_id, + /* desc */ + __('delete plugin files') ); $this->addUserAction( - /* type */ 'versions', - /* action */ 'delete', - /* ns */ $mod_id, - /* desc */ __('delete the version number') + /* type */ + 'versions', + /* action */ + 'delete', + /* ns */ + $mod_id, + /* desc */ + __('delete the version number') ); $this->addDirectAction( - /* type */ 'settings', - /* action */ 'delete_all', - /* ns */ $mod_id, - /* desc */ sprintf(__('delete all %s settings'), $mod_id) + /* type */ + 'settings', + /* action */ + 'delete_all', + /* ns */ + $mod_id, + /* desc */ + sprintf(__('delete all %s settings'), $mod_id) ); $this->addDirectAction( - /* type */ 'plugins', - /* action */ 'delete', - /* ns */ $mod_id, - /* desc */ sprintf(__('delete %s plugin files'), $mod_id) + /* type */ + 'plugins', + /* action */ + 'delete', + /* ns */ + $mod_id, + /* desc */ + sprintf(__('delete %s plugin files'), $mod_id) ); $this->addDirectAction( - /* type */ 'versions', - /* action */ 'delete', - /* ns */ $mod_id, - /* desc */ sprintf(__('delete %s version number'), $mod_id) + /* type */ + 'versions', + /* action */ + 'delete', + /* ns */ + $mod_id, + /* desc */ + sprintf(__('delete %s version number'), $mod_id) ); \ No newline at end of file diff --git a/inc/class.dc.packman.php b/inc/class.dc.packman.php index 836ddc6..f711317 100644 --- a/inc/class.dc.packman.php +++ b/inc/class.dc.packman.php @@ -1,16 +1,15 @@ $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'; } diff --git a/inc/lib.packman.filezip.php b/inc/lib.packman.filezip.php index 12fcf98..8c9c83f 100644 --- a/inc/lib.packman.filezip.php +++ b/inc/lib.packman.filezip.php @@ -1,20 +1,19 @@ 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; } diff --git a/inc/lib.packman.php b/inc/lib.packman.php index b8d0d5f..9f6960d 100644 --- a/inc/lib.packman.php +++ b/inc/lib.packman.php @@ -1,16 +1,15 @@ ' . '

' . $title . '

' . @@ -76,7 +75,7 @@ class libPackman '' . __('Root') . '' . ''; - foreach (self::sort($modules) as $id => $module) { + foreach (self::sort($modules) as $id => $module) { echo '' . '