diff --git a/_config.php b/_config.php index 702c4c4..0a15a3e 100644 --- a/_config.php +++ b/_config.php @@ -21,7 +21,7 @@ $improve = new Improve($core); $combo_actions = []; foreach ($improve->modules() as $action) { - $combo_actions[$action->get('name')] = $action->get('id'); + $combo_actions[$action->name()] = $action->id(); } $disabled = $improve->disabled(); if (!empty($disabled)) { diff --git a/inc/class.improve.action.php b/inc/class.improve.action.php index bbb4d52..5940c87 100644 --- a/inc/class.improve.action.php +++ b/inc/class.improve.action.php @@ -52,15 +52,26 @@ abstract class ImproveAction /** @var array Action module settings */ private $settings = []; - /** @var array Action module properties */ - private $properties = [ - 'id' => '', - 'name' => '', - 'desc' => '', - 'priority' => 500, - 'config' => false, //mixed bool for internal, string for ext url - 'types' => ['plugin'] - ]; + /** @var array List of allowed properties */ + protected static $allowed_properties = ['id', 'name', 'description', 'priority', 'configurator', 'types']; + + /** @var string Module id */ + private $id = ''; + + /** @var string Module name */ + private $name = ''; + + /** @var string Module description */ + private $description = ''; + + /** @var integer Module id */ + private $priority = 500; + + /** @var boolean Module has config page */ + private $configurator = false; + + /** @var array Module supported types */ + private $types = ['plugin']; /** * ImproveAction constructor inits properpties and settings of a child class. @@ -79,7 +90,7 @@ abstract class ImproveAction // can overload priority by settings if (1 < ($p = (int) $core->blog->settings->improve->get('priority_' . $this->class_name))) { - $this->properties['priority'] = $p; + $this->priority = $p; } } @@ -117,50 +128,61 @@ abstract class ImproveAction */ final public function get(string $key) { - if (isset($this->properties[$key])) { - return $this->properties[$key]; - } elseif (isset($this->settings[$key])) { + if (isset($this->settings[$key])) { return $this->settings[$key]; } return null; } - /** - * Get a definition property of action class - * - * @return mixed A property of action definition. - */ - final public function getProperty(string $property) + /** Get action module id */ + final public function id(): string { - return $this->properties[$property] ?? null; + return $this->id; + } + + /** Get action module name */ + final public function name(): string + { + return $this->name; + } + + /** Get action module description */ + final public function description(): string + { + return $this->description; + } + + /** Get action module priority */ + final public function priority(): int + { + return $this->priority; + } + + /** Get action module configuration url if any */ + final public function configurator(): bool + { + return $this->configurator; + } + + /** Get action module supported types */ + final public function types(): array + { + return $this->types; } /** - * Set a definition property of action class + * Set properties of action class * - * Property can be: - * - id : action id - * - name : action short name - * - desc : action short description, - * - priority : order of execution of this action - * - config : as configuration gui, false = none, true = internal, string = ext url - * - types : array of supported type of module, can : be plugins and/or themes - * - * @param mixed $property one or more definition - * @param mixed $value value for a single property + * @param array $properties Properties * * @return boolean Success */ - final protected function setProperties($property, $value = null): bool + final protected function setProperties(array $properties): bool { - $properties = is_array($property) ? $property : [$property => $value]; - foreach ($properties as $k => $v) { - if (isset($this->properties[$k])) { - if ($k == 'types' && !is_array($v)) { - $v = [$v]; - } - $this->properties[$k] = $v; + foreach ($properties as $key => $value) { + if (in_array($key, self::$allowed_properties)) { + $this->{$key} = $value; } } @@ -385,7 +407,7 @@ abstract class ImproveAction /** * Get action logs. * - * @param mixed $type type of message, can be error, warning, succes + * @param string|null $type type of message, can be error, warning, succes * * @return array Arry of given type of log or all if type is null */ diff --git a/inc/class.improve.php b/inc/class.improve.php index ceab866..d42c4da 100644 --- a/inc/class.improve.php +++ b/inc/class.improve.php @@ -51,11 +51,11 @@ class Improve $this->core->callBehavior('improveAddAction', $list, $this->core); foreach ($list as $action) { - if (is_a($action, 'ImproveAction') && !isset($this->actions[$action->get('id')])) { - if (in_array($action->get('id'), $disabled)) { - $this->disabled[$action->get('id')] = $action->get('name'); + if (is_a($action, 'ImproveAction') && !isset($this->actions[$action->id()])) { + if (in_array($action->id(), $disabled)) { + $this->disabled[$action->id()] = $action->name(); } else { - $this->actions[$action->get('id')] = $action; + $this->actions[$action->id()] = $action; } } } @@ -96,7 +96,9 @@ class Improve } $this->core->log->delLogs($rs->log_id); - return unserialize($rs->log_msg); + $res = unserialize($rs->log_msg); + + return is_array($res) ? $res : []; } public function parselogs(int $id): array @@ -182,7 +184,7 @@ class Improve } foreach ($workers as $action) { // trace all path and action in logs - $this->logs['improve'][__('Begin')][] = $action->get('id'); + $this->logs['improve'][__('Begin')][] = $action->id(); // info: set current module $action->setModule($module); $action->setPath(__('Begin'), '', true); @@ -199,7 +201,7 @@ class Improve } foreach ($workers as $action) { // trace all path and action in logs - $this->logs['improve'][$file[0]][] = $action->get('id'); + $this->logs['improve'][$file[0]][] = $action->id(); // info: set current path $action->setPath($file[0], $file[1], $file[2]); } @@ -223,7 +225,7 @@ class Improve throw new Exception(sprintf( __('File content has been removed: %s by %s'), $file[0], - $action->get('name') + $action->name() )); } } @@ -238,7 +240,7 @@ class Improve } foreach ($workers as $action) { // trace all path and action in logs - $this->logs['improve'][__('End')][] = $action->get('id'); + $this->logs['improve'][__('End')][] = $action->id(); // info: set current module $action->setPath(__('End'), '', true); // action: close module @@ -246,7 +248,7 @@ class Improve } // info: get acions reports foreach ($workers as $action) { - $this->logs[$action->get('id')] = $action->getLogs(); + $this->logs[$action->id()] = $action->getLogs(); foreach ($this->has_log as $type => $v) { if ($action->hasLog($type)) { $this->has_log[$type] = true; @@ -329,11 +331,11 @@ class Improve */ private function sortModules(ImproveAction $a, ImproveAction $b): int { - if ($a->get('priority') == $b->get('priority')) { - return strcasecmp($a->get('name'), $b->get('name')); + if ($a->priority() == $b->priority()) { + return strcasecmp($a->name(), $b->name()); } - return $a->get('priority') < $b->get('priority') ? -1 : 1; + return $a->priority() < $b->priority() ? -1 : 1; } } @@ -411,7 +413,7 @@ class ImproveDefinition * * @return boolean Success */ - private function registerModule(string $name, string $desc, string $author, string $version, $properties = []): bool // @phpstan-ignore-line + private function registerModule(string $name, string $desc, string $author, string $version, $properties = []): bool { if (!is_array($properties)) { $args = func_get_args(); diff --git a/inc/lib.improve.action.dcdeprecated.php b/inc/lib.improve.action.dcdeprecated.php index 866c73b..cbaa528 100644 --- a/inc/lib.improve.action.dcdeprecated.php +++ b/inc/lib.improve.action.dcdeprecated.php @@ -62,11 +62,11 @@ class ImproveActionDcdeprecated extends ImproveAction protected function init(): bool { $this->setProperties([ - 'id' => 'dcdeprecated', - 'name' => __('Dotclear deprecated'), - 'desc' => __('Search for use of deprecated Dotclear functions'), - 'priority' => 520, - 'types' => ['plugin', 'theme'] + 'id' => 'dcdeprecated', + 'name' => __('Dotclear deprecated'), + 'description' => __('Search for use of deprecated Dotclear functions'), + 'priority' => 520, + 'types' => ['plugin', 'theme'] ]); return true; diff --git a/inc/lib.improve.action.dcstore.php b/inc/lib.improve.action.dcstore.php index f6a479a..b77173d 100644 --- a/inc/lib.improve.action.dcstore.php +++ b/inc/lib.improve.action.dcstore.php @@ -15,12 +15,12 @@ class ImproveActionDcstore extends ImproveAction protected function init(): bool { $this->setProperties([ - 'id' => 'dcstore', - 'name' => __('Store file'), - 'desc' => __('Re-create dcstore.xml file according to _define.php variables'), - 'priority' => 420, - 'config' => true, - 'types' => ['plugin', 'theme'] + 'id' => 'dcstore', + 'name' => __('Store file'), + 'description' => __('Re-create dcstore.xml file according to _define.php variables'), + 'priority' => 420, + 'configurator' => true, + 'types' => ['plugin', 'theme'] ]); return true; @@ -187,6 +187,11 @@ class ImproveActionDcstore extends ImproveAction private function parseFilePattern(): string { + $str = $this->getSetting('pattern'); + if (!is_string($str)) { + return ''; + } + return text::tidyURL(str_replace( [ '%type%', @@ -200,7 +205,7 @@ class ImproveActionDcstore extends ImproveAction $this->module['version'], $this->module['author'] ], - $this->getSetting('pattern') + $str )); } } diff --git a/inc/lib.improve.action.gitshields.php b/inc/lib.improve.action.gitshields.php index c0bf28e..eba9080 100644 --- a/inc/lib.improve.action.gitshields.php +++ b/inc/lib.improve.action.gitshields.php @@ -37,12 +37,12 @@ class ImproveActionGitshields extends ImproveAction protected function init(): bool { $this->setProperties([ - 'id' => 'gitshields', - 'name' => __('Shields badges'), - 'desc' => __('Add and maintain shields.io badges to the REDAME.md file'), - 'priority' => 380, - 'config' => true, - 'types' => ['plugin', 'theme'] + 'id' => 'gitshields', + 'name' => __('Shields badges'), + 'description' => __('Add and maintain shields.io badges to the REDAME.md file'), + 'priority' => 380, + 'configurator' => true, + 'types' => ['plugin', 'theme'] ]); return true; diff --git a/inc/lib.improve.action.licensefile.php b/inc/lib.improve.action.licensefile.php index f45f550..bc6f180 100644 --- a/inc/lib.improve.action.licensefile.php +++ b/inc/lib.improve.action.licensefile.php @@ -28,12 +28,12 @@ class ImproveActionLicensefile extends ImproveAction protected function init(): bool { $this->setProperties([ - 'id' => 'license', - 'name' => __('License file'), - 'desc' => __('Add or remove full license file to module root'), - 'priority' => 330, - 'config' => true, - 'types' => ['plugin', 'theme'] + 'id' => 'license', + 'name' => __('License file'), + 'description' => __('Add or remove full license file to module root'), + 'priority' => 330, + 'configurator' => true, + 'types' => ['plugin', 'theme'] ]); $this->action_version = [ __('no version selected') => '', diff --git a/inc/lib.improve.action.php b/inc/lib.improve.action.php index 808720f..da54745 100644 --- a/inc/lib.improve.action.php +++ b/inc/lib.improve.action.php @@ -15,11 +15,11 @@ class ImproveActionTab extends ImproveAction protected function init(): bool { $this->setProperties([ - 'id' => 'tab', - 'name' => __('Tabulations'), - 'desc' => __('Replace tabulation by four space in php files'), - 'priority' => 820, - 'types' => ['plugin', 'theme'] + 'id' => 'tab', + 'name' => __('Tabulations'), + 'description' => __('Replace tabulation by four space in php files'), + 'priority' => 820, + 'types' => ['plugin', 'theme'] ]); return true; @@ -50,12 +50,12 @@ class ImproveActionNewline extends ImproveAction protected function init(): bool { $this->setProperties([ - 'id' => 'newline', - 'name' => __('Newlines'), - 'desc' => __('Replace bad and repetitive and empty newline by single newline in files'), - 'priority' => 840, - 'config' => true, - 'types' => ['plugin', 'theme'] + 'id' => 'newline', + 'name' => __('Newlines'), + 'description' => __('Replace bad and repetitive and empty newline by single newline in files'), + 'priority' => 840, + 'configurator' => true, + 'types' => ['plugin', 'theme'] ]); /* $ext = @unserialize($this->core->blog->settings->improve->newline_extensions); @@ -129,12 +129,12 @@ class ImproveActionEndoffile extends ImproveAction protected function init(): bool { $this->setProperties([ - 'id' => 'endoffile', - 'name' => __('End of files'), - 'desc' => __('Remove php tag and empty lines from end of files'), - 'priority' => 860, - 'config' => true, - 'types' => ['plugin', 'theme'] + 'id' => 'endoffile', + 'name' => __('End of files'), + 'description' => __('Remove php tag and empty lines from end of files'), + 'priority' => 860, + 'configurator' => true, + 'types' => ['plugin', 'theme'] ]); return true; diff --git a/inc/lib.improve.action.phpcsfixer.php b/inc/lib.improve.action.phpcsfixer.php index efd32fd..a88ef09 100644 --- a/inc/lib.improve.action.phpcsfixer.php +++ b/inc/lib.improve.action.phpcsfixer.php @@ -29,17 +29,22 @@ class ImproveActionPhpcsfixer extends ImproveAction /** @var string User pref for colored synthax theme */ protected static $user_ui_colorsyntax_theme = 'default'; + /** @var string Settings PHP executable path */ + private $phpexe_path = ''; + protected function init(): bool { $this->setProperties([ - 'id' => 'phpcsfixer', - 'name' => __('PHP CS Fixer'), - 'desc' => __('Fix PSR coding style using Php CS Fixer'), - 'priority' => 920, - 'config' => true, - 'types' => ['plugin', 'theme'] + 'id' => 'phpcsfixer', + 'name' => __('PHP CS Fixer'), + 'description' => __('Fix PSR coding style using Php CS Fixer'), + 'priority' => 920, + 'configurator' => true, + 'types' => ['plugin', 'theme'] ]); + $this->getPhpPath(); + $this->core->auth->user_prefs->addWorkspace('interface'); self::$user_ui_colorsyntax = $this->core->auth->user_prefs->interface->colorsyntax; self::$user_ui_colorsyntax_theme = $this->core->auth->user_prefs->interface->colorsyntax_theme; @@ -74,7 +79,7 @@ class ImproveActionPhpcsfixer extends ImproveAction return '

' . + form::field('phpexe_path', 160, 255, $this->phpexe_path) . '' . '

' . '

' . __('If this module does not work you can try to put here directory to php executable (without executable file name).') . @@ -95,14 +100,9 @@ class ImproveActionPhpcsfixer extends ImproveAction public function closeModule(): ?bool { - $phpexe_path = $this->getPhpPath(); - if (!empty($phpexe_path)) { - $phpexe_path .= '/'; - } - $command = sprintf( '%sphp %s/libs/php-cs-fixer.phar fix %s --config=%s/libs/dc.phpcsfixer.rules.php --using-cache=no', - $phpexe_path, + $this->phpexe_path, dirname(__FILE__), $this->module['sroot'], dirname(__FILE__) @@ -131,16 +131,20 @@ class ImproveActionPhpcsfixer extends ImproveAction /** * Get php executable path - * - * @return string The path */ - private function getPhpPath(): string + private function getPhpPath(): void { $phpexe_path = $this->getSetting('phpexe_path'); + if (!is_string($phpexe_path)) { + $phpexe_path = ''; + } if (empty($phpexe_path) && !empty(PHP_BINDIR)) { $phpexe_path = PHP_BINDIR; } - - return (string) path::real($phpexe_path); + $phpexe_path = (string) path::real($phpexe_path); + if (!empty($phpexe_path)) { + $phpexe_path .= '/'; + } + $this->phpexe_path = $phpexe_path; } } diff --git a/inc/lib.improve.action.phpheader.php b/inc/lib.improve.action.phpheader.php index 98f3c2e..e4f1614 100644 --- a/inc/lib.improve.action.phpheader.php +++ b/inc/lib.improve.action.phpheader.php @@ -47,15 +47,18 @@ EOF; /** @var boolean Stop parsing files */ private $stop_scan = false; + /** @var string Settings bloc content */ + private $bloc_content = ''; + protected function init(): bool { $this->setProperties([ - 'id' => 'phpheader', - 'name' => __('PHP header'), - 'desc' => __('Add or remove phpdoc header bloc from php file'), - 'priority' => 340, - 'config' => true, - 'types' => ['plugin', 'theme'] + 'id' => 'phpheader', + 'name' => __('PHP header'), + 'description' => __('Add or remove phpdoc header bloc from php file'), + 'priority' => 340, + 'configurator' => true, + 'types' => ['plugin', 'theme'] ]); $this->action_bloc = [ @@ -66,6 +69,9 @@ EOF; __('Remove existing bloc header') => 'remove' ]; + $bloc_content = $this->getSetting('bloc_content'); + $this->bloc_content = is_string($bloc_content) ? $bloc_content : ''; + return true; } @@ -103,7 +109,7 @@ EOF;

' . __('Bloc content:') . '

' . - form::textarea('bloc_content', 50, 10, html::escapeHTML($this->getSetting('bloc_content'))) . ' + form::textarea('bloc_content', 50, 10, html::escapeHTML($this->bloc_content)) . '

' . sprintf( __('You can use wildcards %s'), @@ -114,7 +120,7 @@ EOF; public function openModule(): ?bool { - $bloc = trim($this->getSetting('bloc_content')); + $bloc = trim($this->bloc_content); if (empty($bloc)) { $this->setWarning(__('bloc is empty')); diff --git a/inc/lib.improve.action.phpstan.php b/inc/lib.improve.action.phpstan.php index b0dab98..5d26cb8 100644 --- a/inc/lib.improve.action.phpstan.php +++ b/inc/lib.improve.action.phpstan.php @@ -18,17 +18,34 @@ class ImproveActionPhpstan extends ImproveAction /** @var string User pref for colored synthax theme */ protected static $user_ui_colorsyntax_theme = 'default'; + /** @var integer Settings phpstan run level */ + private $run_level = 5; + + /** @var string Settings phpstan ignored vars */ + private $ignored_vars = ''; + + /** @var string Settings PHP executable path */ + private $phpexe_path = ''; + protected function init(): bool { $this->setProperties([ - 'id' => 'phpstan', - 'name' => __('PHPStan'), - 'desc' => __('Analyse php code using PHPStan'), - 'priority' => 910, - 'config' => true, - 'types' => ['plugin'] + 'id' => 'phpstan', + 'name' => __('PHPStan'), + 'description' => __('Analyse php code using PHPStan'), + 'priority' => 910, + 'configurator' => true, + 'types' => ['plugin'] ]); + $this->getPhpPath(); + + $run_level = $this->getSetting('run_level'); + $this->run_level = is_int($run_level) ? $run_level : 5; + + $ignored_vars = $this->getSetting('ignored_vars'); + $this->ignored_vars = is_string($ignored_vars) ? $ignored_vars : ''; + $this->core->auth->user_prefs->addWorkspace('interface'); self::$user_ui_colorsyntax = $this->core->auth->user_prefs->interface->colorsyntax; self::$user_ui_colorsyntax_theme = $this->core->auth->user_prefs->interface->colorsyntax_theme; @@ -67,16 +84,16 @@ class ImproveActionPhpstan extends ImproveAction '

' . __('You must enable improve details to view analyse results !') . '

' . '

' . + form::field('phpexe_path', 160, 255, $this->phpexe_path) . '' . '

' . '

' . __('If this module does not work you can try to put here directory to php executable (without executable file name).') . ' C:\path_to\php

' . '

' . - form::number('run_level', ['min' => 0, 'max' => 9, 'default' => (int) $this->getSetting('run_level')]) . '

' . + form::number('run_level', ['min' => 0, 'max' => 9, 'default' => $this->run_level]) . '

' . '

' . + form::field('ignored_vars', 160, 255, $this->ignored_vars) . '' . '

' . '

' . sprintf( __('If you have errors like "%s", you can add this var here. Use ; as separator and do not put $ ahead.'), @@ -136,17 +153,13 @@ class ImproveActionPhpstan extends ImproveAction private function execFixer(string $path = null): bool { - $phpexe_path = $this->getPhpPath(); - if (!empty($phpexe_path)) { - $phpexe_path .= '/'; - } if (!empty($path)) { $path .= ' '; } $command = sprintf( '%sphp %s/libs/phpstan.phar analyse ' . $path . '--configuration=%s', - $phpexe_path, + $this->phpexe_path, dirname(__FILE__), DC_VAR . '/phpstan.neon' ); @@ -171,14 +184,23 @@ class ImproveActionPhpstan extends ImproveAction } } - private function getPhpPath(): string + /** + * Get php executable path + */ + private function getPhpPath(): void { $phpexe_path = $this->getSetting('phpexe_path'); + if (!is_string($phpexe_path)) { + $phpexe_path = ''; + } if (empty($phpexe_path) && !empty(PHP_BINDIR)) { $phpexe_path = PHP_BINDIR; } - - return (string) path::real($phpexe_path); + $phpexe_path = (string) path::real($phpexe_path); + if (!empty($phpexe_path)) { + $phpexe_path .= '/'; + } + $this->phpexe_path = $phpexe_path; } private function writeConf(): bool @@ -191,7 +213,7 @@ class ImproveActionPhpstan extends ImproveAction '%BOOTSTRAP_ROOT%' ], [ - (int) $this->getSetting('run_level'), + $this->run_level, $this->module['sroot'], DC_ROOT, dirname(__FILE__) . '/libs/' @@ -199,7 +221,7 @@ class ImproveActionPhpstan extends ImproveAction (string) file_get_contents(dirname(__FILE__) . '/libs/dc.phpstan.rules.conf') ); - $ignored = explode(';', $this->getSetting('ignored_vars')); + $ignored = explode(';', $this->ignored_vars); foreach ($ignored as $var) { $var = trim($var); if (empty($var)) { diff --git a/inc/lib.improve.action.zip.php b/inc/lib.improve.action.zip.php index 6f52952..7a16fdd 100644 --- a/inc/lib.improve.action.zip.php +++ b/inc/lib.improve.action.zip.php @@ -35,17 +35,35 @@ class ImproveActionZip extends ImproveAction '%time%' ]; + /** @var string Settings Excluded files */ + private $pack_excludefiles = ''; + + /** @var string Settings Main packacge filename */ + private $pack_filename = ''; + + /** @var string Settings Second package filename */ + private $secondpack_filename = ''; + protected function init(): bool { $this->setProperties([ - 'id' => 'zip', - 'name' => __('Zip module'), - 'desc' => __('Compress module into a ready to install package'), - 'priority' => 980, - 'config' => true, - 'types' => ['plugin', 'theme'] + 'id' => 'zip', + 'name' => __('Zip module'), + 'description' => __('Compress module into a ready to install package'), + 'priority' => 980, + 'configurator' => true, + 'types' => ['plugin', 'theme'] ]); + $pack_excludefiles = $this->getSetting('pack_excludefiles'); + $this->pack_excludefiles = is_string($pack_excludefiles) ? $pack_excludefiles : ''; + + $pack_filename = $this->getSetting('pack_filename'); + $this->pack_filename = is_string($pack_filename) ? $pack_filename : ''; + + $secondpack_filename = $this->getSetting('secondpack_filename'); + $this->secondpack_filename = is_string($secondpack_filename) ? $secondpack_filename : ''; + return true; } @@ -86,7 +104,7 @@ class ImproveActionZip extends ImproveAction

' . __('Files') . '

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

@@ -105,7 +123,7 @@ class ImproveActionZip extends ImproveAction

' . __('Content') . '

' . sprintf(__('Preconization: %s'), '*.zip,*.tar,*.tar.gz') . '
' . sprintf(__('By default all these files are always removed from packages : %s'), implode(', ', self::$exclude)) . '

@@ -121,7 +139,7 @@ class ImproveActionZip extends ImproveAction { $exclude = array_merge( self::$exclude, - explode(',', $this->getSetting('pack_excludefiles')) + explode(',', $this->pack_excludefiles) ); $this->setSuccess(sprintf(__('Prepare excluded files "%s"'), implode(', ', $exclude))); if (!empty($this->getSetting('pack_nocomment'))) { @@ -129,10 +147,10 @@ class ImproveActionZip extends ImproveAction $this->setSuccess(__('Prepare comment removal')); } if (!empty($this->getSetting('pack_filename'))) { - $this->zipModule($this->getSetting('pack_filename'), $exclude); + $this->zipModule($this->pack_filename, $exclude); } if (!empty($this->getSetting('secondpack_filename'))) { - $this->zipModule($this->getSetting('secondpack_filename'), $exclude); + $this->zipModule($this->secondpack_filename, $exclude); } return null; diff --git a/index.php b/index.php index 2641fc6..8831c13 100644 --- a/index.php +++ b/index.php @@ -31,8 +31,8 @@ if (!empty($_POST['save_preferences'])) { $preferences[$type] = []; if (!empty($_POST['actions'])) { foreach ($improve->modules() as $action) { - if (in_array($type, $action->get('types')) && in_array($action->get('id'), $_POST['actions'])) { - $preferences[$type][] = $action->get('id'); + if (in_array($type, $action->types()) && in_array($action->id(), $_POST['actions'])) { + $preferences[$type][] = $action->id(); } } } @@ -141,18 +141,18 @@ if (!empty($_REQUEST['config'])) { $back_url = $_REQUEST['redir'] ?? $core->adminurl->get('admin.plugin.improve', ['type' => $type]); if (null !== $action) { - $redir = $_REQUEST['redir'] ?? $core->adminurl->get('admin.plugin.improve', ['type' => $type, 'config' => $action->get('id')]); + $redir = $_REQUEST['redir'] ?? $core->adminurl->get('admin.plugin.improve', ['type' => $type, 'config' => $action->id()]); $res = $action->configure($redir); echo ' -

' . sprintf(__('Configure module "%s"'), $action->get('name')) . '

+

' . sprintf(__('Configure module "%s"'), $action->name()) . '

' . __('Back') . '

-

' . html::escapeHTML($action->get('desc')) . '

+

' . html::escapeHTML($action->description()) . '

' . (empty($res) ? '

' . __('Nothing to configure') . '

' : $res) . '

' . form::hidden('type', $type) . - form::hidden('config', $action->get('id')) . + form::hidden('config', $action->id()) . form::hidden('redir', $redir) . $core->formNonce() . '

' . '
'; @@ -173,31 +173,30 @@ if (!empty($_REQUEST['config'])) { (DC_DEBUG ? '' . __('Priority') . '' : '') . ''; foreach ($improve->modules() as $action) { - if (!in_array($type, $action->get('types'))) { + if (!in_array($type, $action->types())) { continue; } echo '' . '' . form::checkbox( ['actions[]', - 'action_' . $action->get('id')], - $action->get('id'), - in_array($action->get('id'), $preferences[$type]) && $action->isConfigured(), + 'action_' . $action->id()], + $action->id(), + in_array($action->id(), $preferences[$type]) && $action->isConfigured(), '', '', !$action->isConfigured() ) . '' . '' . - '' . + '' . '' . - '' . $action->get('desc') . '' . + '' . $action->description() . '' . '' . ( - false === $action->get('config') ? '' : - 'get('name')) . '">' . __('Configure') . '' + false === $action->configurator() ? '' : + 'name()) . '">' . __('Configure') . '' ) . '' . - (DC_DEBUG ? '' . $action->get('priority') . '' : '') . + (DC_DEBUG ? '' . $action->priority() . '' : '') . ''; } @@ -227,7 +226,7 @@ if (!empty($_REQUEST['config'])) { echo '
    '; foreach ($tools as $tool => $msgs) { $a = $improve->module($tool); - echo '
  • ' . ($a !== null ? $a->get('name') : 'unknow') . '
      '; + echo '
    • ' . ($a !== null ? $a->name() : 'unknow') . '
        '; foreach ($msgs as $msg) { echo '
      • ' . $msg . '
      • '; }