phpstan level 9: no more mixed declaration

master
Jean-Christian Paul Denis 2021-11-09 00:40:39 +01:00
parent 5e8d9dcc14
commit c3102b3636
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
13 changed files with 248 additions and 170 deletions

View File

@ -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)) {

View File

@ -52,15 +52,26 @@ abstract class ImproveAction
/** @var array<string> Action module settings */
private $settings = [];
/** @var array<mixed> 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
*/

View File

@ -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();

View File

@ -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;

View File

@ -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
));
}
}

View File

@ -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;

View File

@ -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') => '',

View File

@ -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;

View File

@ -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
'<p><label class="classic" for="phpexe_path">' .
__('Root directory of PHP executable:') . '<br />' .
form::field('phpexe_path', 160, 255, $this->getSetting('phpexe_path')) . '</label>' .
form::field('phpexe_path', 160, 255, $this->phpexe_path) . '</label>' .
'</p>' .
'<p class="form-note">' .
__('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;
}
}

View File

@ -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;
<p>' . __('Bloc content:') . '</p>
<p class="area">' .
form::textarea('bloc_content', 50, 10, html::escapeHTML($this->getSetting('bloc_content'))) . '
form::textarea('bloc_content', 50, 10, html::escapeHTML($this->bloc_content)) . '
</p><p class="form-note">' .
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'));

View File

@ -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
'<p class="info">' . __('You must enable improve details to view analyse results !') . '</p>' .
'<p><label class="classic" for="phpexe_path">' .
__('Root directory of PHP executable:') . '<br />' .
form::field('phpexe_path', 160, 255, $this->getSetting('phpexe_path')) . '</label>' .
form::field('phpexe_path', 160, 255, $this->phpexe_path) . '</label>' .
'</p>' .
'<p class="form-note">' .
__('If this module does not work you can try to put here directory to php executable (without executable file name).') .
' C:\path_to\php</p>' .
'<p><label class="classic" for="run_level">' . __('Level:') . ' </label>' .
form::number('run_level', ['min' => 0, 'max' => 9, 'default' => (int) $this->getSetting('run_level')]) . '</p>' .
form::number('run_level', ['min' => 0, 'max' => 9, 'default' => $this->run_level]) . '</p>' .
'<p><label class="classic" for="ignored_vars">' .
__('List of ignored variables:') . '<br />' .
form::field('ignored_vars', 160, 255, $this->getSetting('ignored_vars')) . '</label>' .
form::field('ignored_vars', 160, 255, $this->ignored_vars) . '</label>' .
'</p>' .
'<p class="form-note">' . 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)) {

View File

@ -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
<h4>' . __('Files') . '</h4>
<p><label for="pack_filename">' . __('Name of exported package:') . ' ' .
form::field('pack_filename', 65, 255, $this->getSetting('pack_filename'), 'maximal') .
form::field('pack_filename', 65, 255, $this->pack_filename, 'maximal') .
'</label></p>
<p class="form-note">' . sprintf(__('Preconization: %s'), '%type%-%id%') . '</p>
@ -105,7 +123,7 @@ class ImproveActionZip extends ImproveAction
<h4>' . __('Content') . '</h4>
<p><label for="pack_excludefiles">' . __('Extra files to exclude from package:') . ' ' .
form::field('pack_excludefiles', 65, 255, $this->getSetting('pack_excludefiles'), 'maximal') .
form::field('pack_excludefiles', 65, 255, $this->pack_excludefiles, 'maximal') .
'</label></p>
<p class="form-note">' . sprintf(__('Preconization: %s'), '*.zip,*.tar,*.tar.gz') . '<br />' .
sprintf(__('By default all these files are always removed from packages : %s'), implode(', ', self::$exclude)) . '</p>
@ -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;

View File

@ -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 '
<h3>' . sprintf(__('Configure module "%s"'), $action->get('name')) . '</h3>
<h3>' . sprintf(__('Configure module "%s"'), $action->name()) . '</h3>
<p><a class="back" href="' . $back_url . '">' . __('Back') . '</a></p>
<p class="info">' . html::escapeHTML($action->get('desc')) . '</p>
<p class="info">' . html::escapeHTML($action->description()) . '</p>
<form action="' . $core->adminurl->get('admin.plugin.improve') . '" method="post" id="form-actions">' .
(empty($res) ? '<p class="message">' . __('Nothing to configure') . '</p>' : $res) . '
<p class="clear"><input type="submit" name="save" value="' . __('Save') . '" />' .
form::hidden('type', $type) .
form::hidden('config', $action->get('id')) .
form::hidden('config', $action->id()) .
form::hidden('redir', $redir) .
$core->formNonce() . '</p>' .
'</form>';
@ -173,31 +173,30 @@ if (!empty($_REQUEST['config'])) {
(DC_DEBUG ? '<th scope="col">' . __('Priority') . '</td>' : '') .
'</tr></thead><tbody>';
foreach ($improve->modules() as $action) {
if (!in_array($type, $action->get('types'))) {
if (!in_array($type, $action->types())) {
continue;
}
echo
'<tr class="line' . ($action->isConfigured() ? '' : ' offline') . '">' .
'<td class="minimal">' . 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()
) . '</td>' .
'<td class="minimal nowrap">' .
'<label for="action_' . $action->get('id') . '" class="classic">' . html::escapeHTML($action->get('name')) . '</label>' .
'<label for="action_' . $action->id() . '" class="classic">' . html::escapeHTML($action->name()) . '</label>' .
'</td>' .
'<td class="maximal">' . $action->get('desc') . '</td>' .
'<td class="maximal">' . $action->description() . '</td>' .
'<td class="minimal nowrap modules">' . (
false === $action->get('config') ? '' :
'<a class="module-config" href="' .
(true === $action->get('config') ? $core->adminurl->get('admin.plugin.improve', ['type' => $type, 'config' => $action->get('id')]) : $action->get('config')) .
'" title="' . sprintf(__("Configure action '%s'"), $action->get('name')) . '">' . __('Configure') . '</a>'
false === $action->configurator() ? '' :
'<a class="module-config" href="' . $core->adminurl->get('admin.plugin.improve', ['type' => $type, 'config' => $action->id()]) .
'" title="' . sprintf(__("Configure action '%s'"), $action->name()) . '">' . __('Configure') . '</a>'
) . '</td>' .
(DC_DEBUG ? '<td class="minimal"><span class="debug">' . $action->get('priority') . '</span></td>' : '') .
(DC_DEBUG ? '<td class="minimal"><span class="debug">' . $action->priority() . '</span></td>' : '') .
'</tr>';
}
@ -227,7 +226,7 @@ if (!empty($_REQUEST['config'])) {
echo '<div class="' . $type . '"><ul>';
foreach ($tools as $tool => $msgs) {
$a = $improve->module($tool);
echo '<li>' . ($a !== null ? $a->get('name') : 'unknow') . '<ul>';
echo '<li>' . ($a !== null ? $a->name() : 'unknow') . '<ul>';
foreach ($msgs as $msg) {
echo '<li>' . $msg . '</li>';
}