fix PSR coding style

This commit is contained in:
Jean-Christian Paul 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

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis * @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis * @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
if (!defined('DC_CONTEXT_MODULE')) { if (!defined('DC_CONTEXT_MODULE')) {
return null; return null;
} }
@ -78,7 +77,9 @@ echo '
<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>

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis * @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis * @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
@ -72,7 +71,8 @@ try {
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;
} }
@ -80,7 +80,9 @@ try {
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
)); ));
} }
@ -88,7 +90,12 @@ try {
$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
); );
} }
@ -99,8 +106,7 @@ try {
); );
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

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis * @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis * @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
@ -18,43 +17,67 @@ if (!defined('DC_CONTEXT_ADMIN')) {
$mod_id = 'pacKman'; $mod_id = 'pacKman';
$this->addUserAction( $this->addUserAction(
/* type */ 'settings', /* type */
/* action */ 'delete_all', 'settings',
/* ns */ $mod_id, /* action */
/* desc */ __('delete all settings') 'delete_all',
/* ns */
$mod_id,
/* desc */
__('delete all settings')
); );
$this->addUserAction( $this->addUserAction(
/* type */ 'plugins', /* type */
/* action */ 'delete', 'plugins',
/* ns */ $mod_id, /* action */
/* desc */ __('delete plugin files') 'delete',
/* ns */
$mod_id,
/* desc */
__('delete plugin files')
); );
$this->addUserAction( $this->addUserAction(
/* type */ 'versions', /* type */
/* action */ 'delete', 'versions',
/* ns */ $mod_id, /* action */
/* desc */ __('delete the version number') 'delete',
/* ns */
$mod_id,
/* desc */
__('delete the version number')
); );
$this->addDirectAction( $this->addDirectAction(
/* type */ 'settings', /* type */
/* action */ 'delete_all', 'settings',
/* ns */ $mod_id, /* action */
/* desc */ sprintf(__('delete all %s settings'), $mod_id) 'delete_all',
/* ns */
$mod_id,
/* desc */
sprintf(__('delete all %s settings'), $mod_id)
); );
$this->addDirectAction( $this->addDirectAction(
/* type */ 'plugins', /* type */
/* action */ 'delete', 'plugins',
/* ns */ $mod_id, /* action */
/* desc */ sprintf(__('delete %s plugin files'), $mod_id) 'delete',
/* ns */
$mod_id,
/* desc */
sprintf(__('delete %s plugin files'), $mod_id)
); );
$this->addDirectAction( $this->addDirectAction(
/* type */ 'versions', /* type */
/* action */ 'delete', 'versions',
/* ns */ $mod_id, /* action */
/* desc */ sprintf(__('delete %s version number'), $mod_id) 'delete',
/* ns */
$mod_id,
/* desc */
sprintf(__('delete %s version number'), $mod_id)
); );

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis * @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
@ -31,7 +30,7 @@ class dcPackman
public static function quote_exclude($exclude) public static function quote_exclude($exclude)
{ {
foreach($exclude AS $k => $v) { foreach ($exclude as $k => $v) {
$exclude[$k] = '#(^|/)(' . str_replace( $exclude[$k] = '#(^|/)(' . str_replace(
['.', '*'], ['.', '*'],
['\.', '.*?'], ['\.', '.*?'],
@ -131,7 +130,7 @@ class dcPackman
} }
$zip = new packmanFileZip($fp); $zip = new packmanFileZip($fp);
foreach($exclude AS $e) { foreach ($exclude as $e) {
$zip->addExclusion($e); $zip->addExclusion($e);
} }
$zip->addDirectory( $zip->addDirectory(
@ -204,6 +203,7 @@ class dcPackman
foreach ($parts as $i => $part) { foreach ($parts as $i => $part) {
$parts[$i] = files::tidyFileName($part); $parts[$i] = files::tidyFileName($part);
} }
return implode('/', $parts) . '.zip'; return implode('/', $parts) . '.zip';
} }

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis * @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
class packmanFileZip extends fileZip class packmanFileZip extends fileZip
{ {
public static $remove_comment = false; public static $remove_comment = false;
@ -47,8 +46,7 @@ class packmanFileZip extends fileZip
$mtime = $this->makeTime($mtime); $mtime = $this->makeTime($mtime);
# Data descriptor # Data descriptor
$data_desc = $data_desc = "\x50\x4b\x03\x04" .
"\x50\x4b\x03\x04" .
"\x14\x00" . # ver needed to extract "\x14\x00" . # ver needed to extract
"\x00\x00" . # gen purpose bit flag "\x00\x00" . # gen purpose bit flag
"\x08\x00" . # compression method "\x08\x00" . # compression method
@ -71,8 +69,7 @@ class packmanFileZip extends fileZip
$new_offset = $this->old_offset + strlen($data_desc); $new_offset = $this->old_offset + strlen($data_desc);
# Add to central directory record # Add to central directory record
$cdrec = $cdrec = "\x50\x4b\x01\x02" .
"\x50\x4b\x01\x02" .
"\x00\x00" . # version made by "\x00\x00" . # version made by
"\x14\x00" . # version needed to extract "\x14\x00" . # version needed to extract
"\x00\x00" . # gen purpose bit flag "\x00\x00" . # gen purpose bit flag
@ -119,6 +116,7 @@ class packmanFileZip extends fileZip
$newStr .= $token; $newStr .= $token;
} }
} }
return $newStr; return $newStr;
} }

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis * @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
@ -99,7 +98,8 @@ class libPackman
'</table>' . '</table>' .
'<p class="checkboxes-helpers"></p>' . '<p class="checkboxes-helpers"></p>' .
'<p>' . '<p>' .
(!empty($_REQUEST['redir']) ? (
!empty($_REQUEST['redir']) ?
form::hidden( form::hidden(
['redir'], ['redir'],
html::escapeHTML($_REQUEST['redir']) html::escapeHTML($_REQUEST['redir'])
@ -158,7 +158,7 @@ class libPackman
'</tr>'; '</tr>';
$dup = []; $dup = [];
foreach(self::sort($modules) AS $module) { foreach (self::sort($modules) as $module) {
if (isset($dup[$module['root']])) { if (isset($dup[$module['root']])) {
continue; continue;
} }

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis * @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
@ -18,7 +17,7 @@ if (!defined('DC_CONTEXT_ADMIN')) {
dcPage::checkSuper(); dcPage::checkSuper();
# Queries # Queries
$action = isset($_POST['action']) ? $_POST['action'] : ''; $action = $_POST['action'] ?? '';
$type = isset($_POST['type']) && in_array($_POST['type'], ['plugins', 'themes', 'repository']) ? $_POST['type'] : ''; $type = isset($_POST['type']) && in_array($_POST['type'], ['plugins', 'themes', 'repository']) ? $_POST['type'] : '';
# Settings # Settings
@ -45,8 +44,7 @@ $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']);
@ -97,7 +95,6 @@ try {
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');
@ -129,7 +126,6 @@ try {
# --BEHAVIOR-- packmanAfterCreatePackage # --BEHAVIOR-- packmanAfterCreatePackage
$core->callBehavior('packmanAfterCreatePackage', $core, $module); $core->callBehavior('packmanAfterCreatePackage', $core, $module);
} }
dcPage::addSuccessNotice( dcPage::addSuccessNotice(
@ -178,7 +174,6 @@ try {
# --BEHAVIOR-- packmanAfterInstallPackage # --BEHAVIOR-- packmanAfterInstallPackage
$core->callBehavior('packmanAfterInstallPackage', $type, $id, $root); $core->callBehavior('packmanAfterInstallPackage', $type, $id, $root);
} }
dcPage::addSuccessNotice( dcPage::addSuccessNotice(
@ -274,7 +269,6 @@ if ($core->error->flag()) {
'<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(