test php-cs-fixer module on itself

master
Jean-Christian Paul Denis 2021-11-01 22:17:44 +01:00
parent 2f84837479
commit 102c4e128a
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
11 changed files with 314 additions and 297 deletions

View File

@ -1,16 +1,15 @@
<?php
/**
* @brief improve, a plugin for Dotclear 2
*
*
* @package Dotclear
* @subpackage Plugin
*
*
* @author Jean-Christian Denis and contributors
*
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
@ -28,4 +27,4 @@ $this->registerModule(
'details' => 'https://github.com/JcDenis/improve',
'repository' => 'https://raw.githubusercontent.com/JcDenis/improve/master/dcstore.xml'
]
);
);

View File

@ -1,12 +1,12 @@
<?php
/**
* @brief improve, a plugin for Dotclear 2
*
*
* @package Dotclear
* @subpackage Plugin
*
*
* @author Jean-Christian Denis and contributors
*
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
@ -15,9 +15,9 @@
* @brief Plugin improve action class
*
* Action class must extends class ImproveAction.
* If your class signature is myActionClass extends ImproveAction,
* If your class signature is myActionClass extends ImproveAction,
* do $core->addBehavior('ImproveAddAction'), ['myClass', 'create']);
* yoru action class is automatically created,
* yoru action class is automatically created,
* then function init() of your class wil be called.
* One class must manage only one action.
*
@ -30,38 +30,38 @@
abstract class ImproveAction
{
protected $core;
protected $module = [];
protected $path_full = '';
protected $module = [];
protected $path_full = '';
protected $path_extension = '';
protected $path_is_dir = null;
protected $path_is_dir = null;
private $logs = ['success' => [], 'warning' => [], 'error' => []];
private $settings = [];
private $logs = ['success' => [], 'warning' => [], 'error' => []];
private $settings = [];
private $properties = [
'id' => '',
'name' => '',
'desc' => '',
'id' => '',
'name' => '',
'desc' => '',
'priority' => 500,
'config' => false, //mixed bool for internal, string for ext url
'types' => ['plugin']
'config' => false, //mixed bool for internal, string for ext url
'types' => ['plugin']
];
/**
* ImproveAction constructor inits properpties and settings of a child class.
*
*
* @param string $core dcCore instance
*/
final public function __construct(dcCore $core)
{
$this->core = $core;
$settings = @unserialize($core->blog->settings->improve->get('settings_' . get_called_class()));
$settings = @unserialize($core->blog->settings->improve->get('settings_' . get_called_class()));
$this->settings = is_array($settings) ? $settings : [];
$this->init();
// can overload priority by settings
if (1 < ($p = (int) $core->blog->settings->improve->get('priority_'. get_called_class()))) {
if (1 < ($p = (int) $core->blog->settings->improve->get('priority_' . get_called_class()))) {
$this->priority = $p;
}
}
@ -80,10 +80,10 @@ abstract class ImproveAction
/**
* Action initialisation function.
*
* It's called when an instance of ImproveAction child class is created.
*
* It's called when an instance of ImproveAction child class is created.
* Usefull to setup action class.
*
*
* @return bool True if initialisation is ok.
*/
abstract protected function init(): bool;
@ -100,7 +100,7 @@ abstract class ImproveAction
/**
* Get a definition property of action class
*
*
* @return mixed A property of action definition.
*/
final public function getProperty(string $property)
@ -110,7 +110,7 @@ abstract class ImproveAction
/**
* Set a definition property of action class
*
*
* Property can be:
* - id : action id
* - name : action short name
@ -118,16 +118,16 @@ abstract class ImproveAction
* - 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 dtring $value value for a single property
*
*
* @return mixed A property of action definition.
*/
final protected function setProperties($property, $value = null): bool
{
$properties = is_array($property) ? $property : [$property => $value];
foreach($properties as $k => $v) {
foreach ($properties as $k => $v) {
if (isset($this->properties[$k])) {
if ($k == 'types' && !is_array($v)) {
$v = [$v];
@ -135,6 +135,7 @@ abstract class ImproveAction
$this->properties[$k] = $v;
}
}
return true;
}
//@}
@ -143,9 +144,9 @@ abstract class ImproveAction
//@{
/**
* Get a settings of action class
*
*
* @param string $setting a settings id
*
*
* @return mixed A setting of action.
*/
final protected function getSetting(string $setting)
@ -155,36 +156,37 @@ abstract class ImproveAction
/**
* Set one or more setting of action class
*
*
* @param mixed $settings one or more settings
* @param string $value value for a single setting
*
*
* @return mixed A setting of action.
*/
final protected function setSettings($settings, $value = null)
{
$settings = is_array($settings) ? $settings : [$settings => $value];
foreach($settings as $k => $v) {
foreach ($settings as $k => $v) {
$this->settings[$k] = $v;
}
return true;
}
/**
* Redirection after settings update
*
*
* This save settings update before redirect.
*
*
* @param string $url redirect url after settings update
*/
final protected function redirect(string $url)
{
$this->core->blog->settings->improve->put(
'settings_' . get_called_class(),
serialize($this->settings),
'string',
null,
true,
'settings_' . get_called_class(),
serialize($this->settings),
'string',
null,
true,
true
);
$this->core->blog->triggerBlog();
@ -194,22 +196,22 @@ abstract class ImproveAction
/**
* Check if action class is well configured
*
*
* @return boolean True if class action is well configured
*/
abstract public function isConfigured(): bool;
/**
* Get configuraton gui
*
* If action class uses internal configuration,
*
* If action class uses internal configuration,
* it must share here html form content of its settings.
* It must not use enclose bloc "form" nor button "save".
* This function is also called to redirect form
* This function is also called to redirect form
* after validation with $this->redirect($url);
*
*
* @param string $url post form redirect url
*
*
* @return mixed A setting of action.
*/
public function configure(string $url): ?string
@ -220,9 +222,9 @@ abstract class ImproveAction
/**
* Set in class var current module definitions.
*
*
* @see Improve::sanitizeModule()
*
*
* @param array $module Full array of module definitons
*/
final public function setModule(array $module)
@ -232,16 +234,16 @@ abstract class ImproveAction
/**
* Set in class var current path definitons.
*
*
* @param string $path_full Full path
* @param string $path_extension Path extension (if it is a file)
* @param string $path_is_dir True if path is a directory
*/
final public function setPath(string $path_full, string $path_extension, bool $path_is_dir)
{
$this->path_full = $path_full;
$this->path_full = $path_full;
$this->path_extension = $path_extension;
$this->path_is_dir = $path_is_dir;
$this->path_is_dir = $path_is_dir;
}
/// @name Fix methods
@ -272,12 +274,12 @@ abstract class ImproveAction
/**
* Called when read content of a file to fix.
*
*
* Content is shared from action to another.
* If an action erase content, fix is stopped.
* If you want to erase a content you must erase
* If you want to erase a content you must erase
* the file on action openDirectory.
*
*
* @param string $content File content
*/
public function readFile(string &$content): ?bool
@ -306,12 +308,12 @@ abstract class ImproveAction
//@{
/**
* Set an action log.
*
*
* Log must be use every time an action something happen.
*
*
* @param string $type type of message, can be error, warning, succes
* @param string $message message to log
*
*
* @return boolean True if message is logged.
*/
final public function setLog(string $type, string $message): bool
@ -320,14 +322,15 @@ abstract class ImproveAction
return false;
}
$this->logs[$type][$this->path_full][] = $message;
return true;
}
/**
* Check if action class has log of given type.
*
*
* @param string $type type of message, can be error, warning, succes
*
*
* @return boolean True if messages exist.
*/
final public function hasLog(string $type): bool
@ -337,9 +340,9 @@ abstract class ImproveAction
/**
* Get action logs.
*
*
* @param mixed $type type of message, can be error, warning, succes
*
*
* @return array Arry of given type of log or all if type is null
*/
final public function getLogs($type = null): array
@ -347,12 +350,13 @@ abstract class ImproveAction
if (null === $type) {
return $this->logs;
}
if (empty($this->path_full)
if (empty($this->path_full)
|| !array_key_exists($type, $this->logs)
|| !array_key_exists($this->path_full, $this->logs[$type])
) {
return [];
}
return $this->logs[$type][$this->path_full];
}
@ -428,4 +432,4 @@ abstract class ImproveAction
return $this->getLogs('success');
}
//@}
}
}

View File

@ -1,12 +1,12 @@
<?php
/**
* @brief improve, a plugin for Dotclear 2
*
*
* @package Dotclear
* @subpackage Plugin
*
*
* @author Jean-Christian Denis and contributors
*
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
@ -21,7 +21,7 @@ class Improve
];
private $core;
private $actions = [];
private $logs = [];
private $logs = [];
private $has_log = ['success' => false, 'warning' => false, 'error' => false];
public function __construct(dcCore $core)
@ -33,8 +33,8 @@ class Improve
try {
$this->core->callBehavior('improveAddAction', $list, $this->core);
foreach($list as $action) {
if ($action instanceOf ImproveAction && !isset($this->actions[$action->id])) {
foreach ($list as $action) {
if ($action instanceof ImproveAction && !isset($this->actions[$action->id])) {
$this->actions[$action->id] = $action;
}
}
@ -59,21 +59,22 @@ class Improve
if (empty($this->logs)) {
return '';
}
$cur = $this->core->con->openCursor($this->core->prefix . 'log');
$cur->log_msg = serialize($this->logs);
$cur = $this->core->con->openCursor($this->core->prefix . 'log');
$cur->log_msg = serialize($this->logs);
$cur->log_table = 'improve';
$id = $this->core->log->addLog($cur);
$id = $this->core->log->addLog($cur);
return $id;
}
public function readLogs(int $id ): array
public function readLogs(int $id): array
{
$rs = $this->core->log->getLogs(['log_table' => 'improve', 'log_id' => $id, 'limit' => 1]);
if ($rs->isEmpty()) {
return [];
}
$this->core->log->delLogs($rs->log_id);
return unserialize($rs->log_msg);
}
@ -84,14 +85,14 @@ class Improve
return [];
}
$lines = [];
foreach($logs['improve'] as $path => $tools) {
foreach ($logs['improve'] as $path => $tools) {
$l_types = [];
foreach(['success', 'warning', 'error'] as $type) {
foreach (['success', 'warning', 'error'] as $type) {
$l_tools = [];
foreach($tools as $tool) {
foreach ($tools as $tool) {
$l_msg = [];
if (!empty($logs[$tool][$type][$path])) {
foreach($logs[$tool][$type][$path] as $msg) {
foreach ($logs[$tool][$type][$path] as $msg) {
$l_msg[] = $msg;
}
}
@ -107,6 +108,7 @@ class Improve
$lines[$path] = $l_types;
}
}
return $lines;
}
@ -115,6 +117,7 @@ class Improve
if (empty($id)) {
return $this->actions;
}
return $this->actions[$id] ?? null;
}
@ -123,21 +126,22 @@ class Improve
if (empty($id)) {
return $this->actions;
}
return $this->actions[$id] ?? null;
}
public function fixModule(string $type, string $id, array $properties, array $actions): float
{
$time_start = microtime(true);
$module = ImproveDefinition::clean($type, $id, $properties);
$module = ImproveDefinition::clean($type, $id, $properties);
$workers = [];
foreach($actions as $action) {
foreach ($actions as $action) {
if (isset($this->actions[$action]) && $this->actions[$action]->isConfigured()) {
$workers[] = $this->actions[$action];
}
}
foreach($workers as $action) {
foreach ($workers as $action) {
// trace all path and action in logs
$this->logs['improve'][__('Begin')][] = $action->id;
// info: set current module
@ -150,48 +154,50 @@ class Improve
throw new Exception(__('Module path is not writable'));
}
$tree = self::getModuleFiles($module['sroot']);
foreach($tree as $file) {
foreach ($tree as $file) {
if (!file_exists($file[0])) {
continue;
}
foreach($workers as $action) {
foreach ($workers as $action) {
// trace all path and action in logs
$this->logs['improve'][$file[0]][] = $action->id;
// info: set current path
$action->setPath($file[0], $file[1], $file[2]);
}
if (!$file[2]) {
foreach($workers as $action) {
foreach ($workers as $action) {
// action: open a directory. full path
$action->openDirectory();
}
} else {
foreach($workers as $action) {
foreach ($workers as $action) {
// action: before openning a file. full path, extension
$action->openFile();
}
if (in_array($file[1], self::$readfile_extensions)) {
if (false !== ($content = file_get_contents($file[0]))) {
$no_content = empty($content);
foreach($workers as $action) {
foreach ($workers as $action) {
// action: read a file content. full path, extension, content
$action->readFile($content);
if (empty($content) && !$no_content) {
throw new Exception(sprintf(
__('File content has been removed: %s by %s'), $file[0], $action->name
__('File content has been removed: %s by %s'),
$file[0],
$action->name
));
}
}
files::putContent($file[0], $content);
}
foreach($workers as $action) {
foreach ($workers as $action) {
// action: after closing a file. full path, extension
$action->closeFile();
}
}
}
}
foreach($workers as $action) {
foreach ($workers as $action) {
// trace all path and action in logs
$this->logs['improve'][__('End')][] = $action->id;
// info: set current module
@ -200,9 +206,9 @@ class Improve
$action->closeModule();
}
// info: get acions reports
foreach($workers as $action) {
foreach ($workers as $action) {
$this->logs[$action->id] = $action->getLogs();
foreach($this->has_log as $type => $v) {
foreach ($this->has_log as $type => $v) {
if ($action->hasLog($type)) {
$this->has_log[$type] = true;
}
@ -224,19 +230,21 @@ class Improve
$res[] = [$dir, '', false];
$files = files::scandir($path);
foreach($files AS $file) {
foreach ($files as $file) {
if (substr($file, 0, 1) == '.') {
continue;
}
if (is_dir($path . '/' . $file)) {
$res = self::getModuleFiles(
$path . '/' . $file, $dir . '/' . $file,
$path . '/' . $file,
$dir . '/' . $file,
$res
);
} else {
$res[] = [empty($dir) ? $file : $dir . '/' . $file, files::getExtension($file), true];
}
}
return $res;
}
@ -252,13 +260,14 @@ class Improve
$in = explode(',', $in);
}
if (!empty($in)) {
foreach($in as $v) {
foreach ($in as $v) {
$v = trim(files::getExtension('a.' . $v));
if (!empty($v)) {
$out[] = $v;
}
}
}
return $out;
}
@ -267,6 +276,7 @@ class Improve
if ($a->priority == $b->priority) {
return strcasecmp($a->name, $b->name);
}
return $a->priority < $b->priority ? -1 : 1;
}
}
@ -290,6 +300,7 @@ class ImproveDefinition
public static function clean(string $type, string $id, array $properties): array
{
$p = new self($type, $id, $properties);
return $p->get();
}
@ -314,7 +325,7 @@ class ImproveDefinition
$properties['permissions'] = $args[4];
}
if (isset($args[5])) {
$properties['priority'] = (integer) $args[5];
$properties['priority'] = (int) $args[5];
}
}
@ -328,7 +339,8 @@ class ImproveDefinition
'requires' => [],
'settings' => [],
'repository' => ''
], $properties
],
$properties
);
}
@ -337,7 +349,7 @@ class ImproveDefinition
{
$label = empty($properties['label']) ? $id : $properties['label'];
$name = __(empty($properties['name']) ? $label : $properties['name']);
$oname = empty($properties['name']) ? $label : $properties['name'];
$oname = empty($properties['name']) ? $label : $properties['name'];
return array_merge(
# Default values
@ -385,4 +397,4 @@ class ImproveDefinition
{
return preg_replace('/[^A-Za-z0-9\@\#+_-]/', '', strtolower($str));
}
}
}

View File

@ -1,16 +1,15 @@
<?php
/**
* @brief improve, a plugin for Dotclear 2
*
*
* @package Dotclear
* @subpackage Plugin
*
*
* @author Jean-Christian Denis and contributors
*
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class ImproveActionDcdeprecated extends ImproveAction
{
/** @var array Deprecated functions [filetype [pattern, deprecated, replacement, version]] */
@ -63,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'),
'id' => 'dcdeprecated',
'name' => __('Dotclear deprecated'),
'desc' => __('Search for use of deprecated Dotclear functions'),
'priority' => 520,
'types' => ['plugin', 'theme']
'types' => ['plugin', 'theme']
]);
return true;
@ -83,7 +82,7 @@ class ImproveActionDcdeprecated extends ImproveAction
if (!in_array($this->path_extension, array_keys(self::$deprecated))) {
return null;
}
foreach(self::$deprecated[$this->path_extension] as $d) {
foreach (self::$deprecated[$this->path_extension] as $d) {
if (preg_match('/' . $d[0] . '/i', $content)) {
$this->setWarning(sprintf(__('Use of deprecated "%s", you should use "%s" instead.'), $d[1], __($d[2])));
}
@ -91,4 +90,4 @@ class ImproveActionDcdeprecated extends ImproveAction
return true;
}
}
}

View File

@ -1,27 +1,26 @@
<?php
/**
* @brief improve, a plugin for Dotclear 2
*
*
* @package Dotclear
* @subpackage Plugin
*
*
* @author Jean-Christian Denis and contributors
*
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
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'),
'id' => 'dcstore',
'name' => __('Store file'),
'desc' => __('Re-create dcstore.xml file according to _define.php variables'),
'priority' => 420,
'config' => true,
'types' => ['plugin', 'theme']
'config' => true,
'types' => ['plugin', 'theme']
]);
return true;
@ -39,16 +38,16 @@ class ImproveActionDcstore extends ImproveAction
$this->redirect($url);
}
return
return
'<p class="info">' . __('File will be overwritten if it exists') . '</p>' .
'<p><label class="classic" for="dcstore_pattern">' .
'<p><label class="classic" for="dcstore_pattern">' .
__('Predictable URL to zip file on the external repository') . '<br />' .
form::field('dcstore_pattern', 160, 255, $this->getSetting('pattern')) . '</label>' .
'</p>' .
'<p class="form-note">' .
sprintf(__('You can use wildcards %s'), '%author%, %type%, %id%, %version%.') .
'<p class="form-note">' .
sprintf(__('You can use wildcards %s'), '%author%, %type%, %id%, %version%.') .
'<br /> ' .
__('For exemple on github https://github.com/MyGitName/%id%/releases/download/v%version%/%type%-%id%.zip') .
__('For exemple on github https://github.com/MyGitName/%id%/releases/download/v%version%/%type%-%id%.zip') .
'<br />' .
__('Note on github, you must create a release and join to it the module zip file.') . '
</p>';
@ -60,10 +59,11 @@ class ImproveActionDcstore extends ImproveAction
if ($this->hasError()) {
return false;
}
try {
files::putContent($this->module['sroot'] . '/dcstore.xml', $content);
$this->setSuccess(__('Write dcstore.xml file.'));
} catch(Exception $e) {
} catch (Exception $e) {
$this->setError(__('Failed to write dcstore.xml file'));
return false;
@ -98,7 +98,6 @@ class ImproveActionDcstore extends ImproveAction
# author
if (empty($this->module['author'])) {
$this->setError(__('unknow module author'));
}
$rsp->author($this->module['author']);
@ -128,6 +127,7 @@ class ImproveActionDcstore extends ImproveAction
}
if ($req[0] == 'core') {
$this->module['dc_min'] = $req[1];
break;
}
}
@ -187,4 +187,4 @@ class ImproveActionDcstore extends ImproveAction
$this->getSetting('pattern')
));
}
}
}

View File

@ -1,30 +1,29 @@
<?php
/**
* @brief improve, a plugin for Dotclear 2
*
*
* @package Dotclear
* @subpackage Plugin
*
*
* @author Jean-Christian Denis and contributors
*
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class ImproveActionGitshields extends ImproveAction
{
private $stop_scan = false;
private $stop_scan = false;
protected $bloc_pattern = [
'remove' => '/\[!\[Release(.*)LICENSE\)/ms',
'target' => '/^([^\n]+)[\r\n|\n]{1,}/ms'
];
protected $bloc_content = [
'release' => '[![Release](https://img.shields.io/github/v/release/%username%/%module%)](https://github.com/%username%/%module%/releases)',
'date' => '[![Date](https://img.shields.io/github/release-date/%username%/%module%)](https://github.com/%username%/%module%/releases)',
'issues' => '[![Issues](https://img.shields.io/github/issues/%username%/%module%)](https://github.com/%username%/%module%/issues)',
'dotclear' => '[![Dotclear](https://img.shields.io/badge/dotclear-v%dotclear%-blue.svg)](https://fr.dotclear.org/download)',
'release' => '[![Release](https://img.shields.io/github/v/release/%username%/%module%)](https://github.com/%username%/%module%/releases)',
'date' => '[![Date](https://img.shields.io/github/release-date/%username%/%module%)](https://github.com/%username%/%module%/releases)',
'issues' => '[![Issues](https://img.shields.io/github/issues/%username%/%module%)](https://github.com/%username%/%module%/issues)',
'dotclear' => '[![Dotclear](https://img.shields.io/badge/dotclear-v%dotclear%-blue.svg)](https://fr.dotclear.org/download)',
'dotaddict' => '[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://%type%s.dotaddict.org/dc2/details/%module%)',
'license' => '[![License](https://img.shields.io/github/license/%username%/%module%)](https://github.com/%username%/%module%/blob/master/LICENSE)'
'license' => '[![License](https://img.shields.io/github/license/%username%/%module%)](https://github.com/%username%/%module%/blob/master/LICENSE)'
];
protected function init(): bool
@ -50,7 +49,7 @@ class ImproveActionGitshields extends ImproveAction
{
if (!empty($_POST['save']) && !empty($_POST['username'])) {
$this->setSettings([
'username' => (string) $_POST['username'],
'username' => (string) $_POST['username'],
'dotaddict' => !empty($_POST['dotaddict'])
]);
$this->redirect($url);
@ -62,8 +61,8 @@ class ImproveActionGitshields extends ImproveAction
</p><p class="form-note">' . __('Used in your Github URL: http://github.com/username/module_id.') . '<br />' .
__('If you have badges not created by this tool in the README.md file you should remove them manually.') . '</p>
<p><label for="dotaddict">' .
form::checkbox('dotaddict', 1, !empty($this->getSetting('dotaddict'))) . ' '.
<p><label for="dotaddict">' .
form::checkbox('dotaddict', 1, !empty($this->getSetting('dotaddict'))) . ' ' .
__('Include Dotaddict badge') . '</label>
</p><p class="form-note">' . __('If your plugin or theme is on Dotaddict, you can add a badge to link to its details in Dotaddict.') . '</p>';
}
@ -81,8 +80,8 @@ class ImproveActionGitshields extends ImproveAction
return null;
}
$clean = $this->deleteShieldsBloc($content);
$content = $this->writeShieldsBloc($clean);
$clean = $this->deleteShieldsBloc($content);
$content = $this->writeShieldsBloc($clean);
$this->stop_scan = true;
return true;
@ -91,23 +90,23 @@ class ImproveActionGitshields extends ImproveAction
private function replaceInfo()
{
$bloc = [];
foreach($this->bloc_content as $k => $v) {
foreach ($this->bloc_content as $k => $v) {
if ($k == 'dotaddict' && empty($this->getSetting('dotaddict'))) {
continue;
}
$bloc[$k] = trim(str_replace(
[
'%username%',
'%module%',
'%dotclear%',
'%type%',
'%username%',
'%module%',
'%dotclear%',
'%type%',
"\r\n", "\n"
],
[
$this->getSetting('username'),
$this->module['id'],
$dotclear = $this->getDotclearVersion(),
$this->module['type'],
$this->getSetting('username'),
$this->module['id'],
$dotclear = $this->getDotclearVersion(),
$this->module['type'],
'', ''
],
$v
@ -127,12 +126,14 @@ class ImproveActionGitshields extends ImproveAction
}
if ($req[0] == 'core') {
$version = $req[1];
break;
}
}
} elseif (!empty($this->module['dc_min'])) {
$version = $this->module['dc_min'];
}
return $version ?: $this->core->getVersion('core');
}
@ -148,6 +149,7 @@ class ImproveActionGitshields extends ImproveAction
if ($count) {
$this->setSuccess(__('Write new shield bloc'));
}
return $res;
}
@ -163,6 +165,7 @@ class ImproveActionGitshields extends ImproveAction
if ($count) {
$this->setSuccess(__('Delete old shield bloc'));
}
return $res;
}
}
}

View File

@ -1,16 +1,15 @@
<?php
/**
* @brief improve, a plugin for Dotclear 2
*
*
* @package Dotclear
* @subpackage Plugin
*
*
* @author Jean-Christian Denis and contributors
*
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class ImproveActionLicensefile extends ImproveAction
{
protected static $license_filenames = [
@ -19,8 +18,8 @@ class ImproveActionLicensefile extends ImproveAction
'license.txt'
];
private $action_version = [];
private $action_full = [];
private $stop_scan = false;
private $action_full = [];
private $stop_scan = false;
protected function init(): bool
{
@ -46,6 +45,7 @@ class ImproveActionLicensefile extends ImproveAction
__('Add file and remove others') => 'full',
__('Remove license files') => 'remove'
];
return true;
}
@ -58,8 +58,8 @@ class ImproveActionLicensefile extends ImproveAction
{
if (!empty($_POST['save'])) {
$this->setSettings([
'action_version' => !empty($_POST['action_version']) ? $_POST['action_version'] : '',
'action_full' => !empty($_POST['action_full']) ? $_POST['action_full'] : ''
'action_version' => !empty($_POST['action_version']) ? $_POST['action_version'] : '',
'action_full' => !empty($_POST['action_full']) ? $_POST['action_full'] : ''
]);
$this->redirect($url);
}
@ -70,7 +70,7 @@ class ImproveActionLicensefile extends ImproveAction
</p>
<p class="field"><label for="action_full">' . __('Action on file:') . '</label>' .
form::combo('action_full', $this->action_full, $this->getSetting('action_full')) .
form::combo('action_full', $this->action_full, $this->getSetting('action_full')) .
'</p>';
}
@ -86,6 +86,7 @@ class ImproveActionLicensefile extends ImproveAction
$this->writeFullLicense();
}
}
return null;
}
@ -105,12 +106,13 @@ class ImproveActionLicensefile extends ImproveAction
return null;
}
return true;
}
private function deleteFullLicense($only_one = false)
{
foreach(self::fileExists($this->module['root']) as $file) {
foreach (self::fileExists($this->module['root']) as $file) {
if ($only_one && $file != 'LICENSE') {
continue;
}
@ -122,17 +124,19 @@ class ImproveActionLicensefile extends ImproveAction
$this->setSuccess(sprintf(__('Delete old license file "%s"'), $file));
}
}
return true;
}
private static function fileExists($root)
{
$existing = [];
foreach(self::$license_filenames as $file) {
foreach (self::$license_filenames as $file) {
if (file_exists($root . '/' . strtolower($file))) {
$existing[] = strtolower($file);
}
}
return $existing;
}
}
}

View File

@ -1,26 +1,25 @@
<?php
/**
* @brief improve, a plugin for Dotclear 2
*
*
* @package Dotclear
* @subpackage Plugin
*
*
* @author Jean-Christian Denis and contributors
*
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class ImproveActionTab extends ImproveAction
{
protected function init(): bool
{
$this->setProperties([
'id' => 'tab',
'name' => __('Tabulations'),
'desc' => __('Replace tabulation by four space in php files'),
'id' => 'tab',
'name' => __('Tabulations'),
'desc' => __('Replace tabulation by four space in php files'),
'priority' => 820,
'types' => ['plugin', 'theme']
'types' => ['plugin', 'theme']
]);
return true;
@ -53,20 +52,20 @@ 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'),
'id' => 'newline',
'name' => __('Newlines'),
'desc' => __('Replace bad and repetitive and empty newline by single newline in files'),
'priority' => 840,
'config' => true,
'types' => ['plugin', 'theme']
'config' => true,
'types' => ['plugin', 'theme']
]);
/*
$ext = @unserialize($this->core->blog->settings->improve->newline_extensions);
$ext = Improve::cleanExtensions($ext);
if (!empty($ext)) {
$this->extensions = $ext;
}
*/
/*
$ext = @unserialize($this->core->blog->settings->improve->newline_extensions);
$ext = Improve::cleanExtensions($ext);
if (!empty($ext)) {
$this->extensions = $ext;
}
*/
return true;
}
@ -79,7 +78,7 @@ class ImproveActionNewline extends ImproveAction
{
if (!empty($_POST['save']) && !empty($_POST['newline_extensions'])) {
$this->setSettings(
'extensions',
'extensions',
Improve::cleanExtensions($_POST['newline_extensions'])
);
$this->redirect($url);
@ -90,12 +89,12 @@ class ImproveActionNewline extends ImproveAction
$ext = [];
}
return
'<p><label class="classic" for="newline_extensions">' .
return
'<p><label class="classic" for="newline_extensions">' .
__('List of files extension to work on:') . '<br />' .
form::field('newline_extensions', 65, 255, implode(',', $ext)) .
form::field('newline_extensions', 65, 255, implode(',', $ext)) .
'</label></p><p class="form-note">' .
__('Use comma separated list of extensions without dot, recommand "php,js,xml,txt,md".') .
__('Use comma separated list of extensions without dot, recommand "php,js,xml,txt,md".') .
'</p>';
}
@ -106,14 +105,14 @@ class ImproveActionNewline extends ImproveAction
return null;
}
$clean = preg_replace(
'/(\n\s+\n)/',
"\n\n",
'/(\n\s+\n)/',
"\n\n",
preg_replace(
'/(\n\n+)/',
"\n\n",
'/(\n\n+)/',
"\n\n",
str_replace(
["\r\n", "\r"],
"\n",
["\r\n", "\r"],
"\n",
$content
)
)
@ -134,12 +133,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'),
'id' => 'endoffile',
'name' => __('End of files'),
'desc' => __('Remove php tag and empty lines from end of files'),
'priority' => 860,
'config' => true,
'types' => ['plugin', 'theme']
'config' => true,
'types' => ['plugin', 'theme']
]);
return true;
@ -157,12 +156,12 @@ class ImproveActionEndoffile extends ImproveAction
$this->redirect($url);
}
return
return
'<p><label class="classic" for="endoffile_psr2">' .
form::checkbox('endoffile_psr2', 255, $this->getSetting('psr2')) .
__('Add a blank line to the end of file') .
'</label></p><p class="form-note">' .
__('PSR2 must have a blank line, whereas PSR12 must not.') .
form::checkbox('endoffile_psr2', 255, $this->getSetting('psr2')) .
__('Add a blank line to the end of file') .
'</label></p><p class="form-note">' .
__('PSR2 must have a blank line, whereas PSR12 must not.') .
'</p>';
}
@ -172,8 +171,8 @@ class ImproveActionEndoffile extends ImproveAction
return null;
}
$clean = preg_replace(
['/(\s*)(\?>\s*)$/', '/\n+$/'],
'',
['/(\s*)(\?>\s*)$/', '/\n+$/'],
'',
$content
) . ($this->getSetting('psr2') ? "\n" : '');
if ($content != $clean) {
@ -183,4 +182,4 @@ class ImproveActionEndoffile extends ImproveAction
return true;
}
}
}

View File

@ -1,16 +1,15 @@
<?php
/**
* @brief improve, a plugin for Dotclear 2
*
*
* @package Dotclear
* @subpackage Plugin
*
*
* @author Jean-Christian Denis and contributors
*
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class ImproveActionPhpheader extends ImproveAction
{
private static $exemple = "
@ -38,7 +37,7 @@ class ImproveActionPhpheader extends ImproveAction
private $bloc_action = [];
private $bloc_content = '';
private $stop_scan = false;
private $stop_scan = false;
protected function init(): bool
{
@ -54,7 +53,7 @@ class ImproveActionPhpheader extends ImproveAction
$this->action_bloc = [
__('Do nothing') => 0,
__('Add bloc if it does not exist') => 'create',
__('Add and overwrite bloc') => 'overwrite' ,
__('Add and overwrite bloc') => 'overwrite',
__('Overwrite bloc only if it exists') => 'replace',
__('Remove existing bloc header') => 'remove'
];
@ -97,12 +96,12 @@ class ImproveActionPhpheader extends ImproveAction
<p>' . __('Bloc content:') . '</p>
<p class="area">' .
form::textarea('bloc_content', 50, 10, html::escapeHTML($this->getSetting('bloc_content'))) . '
</p><p class="form-note">' .
</p><p class="form-note">' .
sprintf(
__('You can use wildcards %s') ,
__('You can use wildcards %s'),
'%year%, %module_id%, %module_name%, %module_author%, %module_type%, %user_cn%, %user_name%, %user_email%, %user_url%'
) . '<br />' . __('Do not put structural elements to the begining of lines.') . '</p>' .
'<div class="fieldset box"><h4>' . __('Exemple') .'</h4><pre class="code">' . self::$exemple . '</pre></div>';
'<div class="fieldset box"><h4>' . __('Exemple') . '</h4><pre class="code">' . self::$exemple . '</pre></div>';
}
public function openModule(): ?bool
@ -114,7 +113,7 @@ class ImproveActionPhpheader extends ImproveAction
public function openDirectory(): ?bool
{
$skipped = $this->stop_scan;
$skipped = $this->stop_scan;
$this->stop_scan = false;
if (!empty($this->getSetting('exclude_locales')) && preg_match('/\/(locales|libs)(\/.*?|)$/', $this->path_full)) {
if (!$skipped) {
@ -128,7 +127,7 @@ class ImproveActionPhpheader extends ImproveAction
public function readFile(&$content): ?bool
{
if ($this->stop_scan || $this->path_extension !='php' || $this->hasError()) {
if ($this->stop_scan || $this->path_extension != 'php' || $this->hasError()) {
return null;
}
@ -136,7 +135,6 @@ class ImproveActionPhpheader extends ImproveAction
$content = $this->deleteOldBloc($content);
}
if (empty($this->getSetting('bloc_action'))) {
return null;
}
$clean = $this->deleteDocBloc($content);
@ -146,11 +144,9 @@ class ImproveActionPhpheader extends ImproveAction
return null;
}
if ($content != $clean && $this->getSetting('bloc_action') == 'create') {
return null;
}
if ($content == $clean && $this->getSetting('bloc_action') == 'replace') {
return null;
}
@ -174,8 +170,10 @@ class ImproveActionPhpheader extends ImproveAction
try {
$this->bloc = preg_replace_callback(
// use \u in bloc content for first_upper_case
'/(\\\u([a-z]{1}))/',
function($str) { return ucfirst($str[2]); },
'/(\\\u([a-z]{1}))/',
function ($str) {
return ucfirst($str[2]);
},
str_replace(
$this->bloc_wildcards,
[
@ -213,6 +211,7 @@ class ImproveActionPhpheader extends ImproveAction
$res = str_replace("\n * \n", "\n *\n", $res);
$this->setSuccess(__('Write new doc bloc content'));
}
return $res;
}
@ -228,6 +227,7 @@ class ImproveActionPhpheader extends ImproveAction
if ($count) {
$this->setSuccess(__('Delete old doc bloc content'));
}
return $res;
}
@ -235,7 +235,7 @@ class ImproveActionPhpheader extends ImproveAction
{
$res = preg_replace(
'/((# -- BEGIN LICENSE BLOCK ([-]+))(.*?)(# -- END LICENSE BLOCK ([-]+))([\n|\r\n]{1,}))/msi',
"",
'',
$content,
-1,
$count
@ -243,6 +243,7 @@ class ImproveActionPhpheader extends ImproveAction
if ($count) {
$this->setSuccess(__('Delete old style bloc content'));
}
return $res;
}
}
}

View File

@ -1,16 +1,15 @@
<?php
/**
* @brief improve, a plugin for Dotclear 2
*
*
* @package Dotclear
* @subpackage Plugin
*
*
* @author Jean-Christian Denis and contributors
*
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class ImproveActionZip extends ImproveAction
{
public static $exclude = [
@ -38,12 +37,12 @@ class ImproveActionZip extends ImproveAction
protected function init(): bool
{
$this->setProperties([
'id' => 'zip',
'name' => __('Zip module'),
'desc' => __('Compress module into a ready to install package'),
'id' => 'zip',
'name' => __('Zip module'),
'desc' => __('Compress module into a ready to install package'),
'priority' => 980,
'config' => true,
'types' => ['plugin', 'theme']
'config' => true,
'types' => ['plugin', 'theme']
]);
return true;
@ -75,7 +74,9 @@ class ImproveActionZip extends ImproveAction
<p><label for="pack_repository">' . __('Path to repository:') . ' ' .
form::field('pack_repository', 65, 255, $this->getSetting('pack_repository'), 'maximal') .
'</label></p>' .
'<p class="form-note">' . sprintf(__('Preconization: %s'), $this->core->blog->public_path ?
'<p class="form-note">' . sprintf(
__('Preconization: %s'),
$this->core->blog->public_path ?
path::real($this->core->blog->public_path) : __("Blog's public directory")
) . '</p>
</div>
@ -93,7 +94,7 @@ class ImproveActionZip extends ImproveAction
'</label></p>
<p class="form-note">' . sprintf(__('Preconization: %s'), '%type%-%id%-%version%') . '</p>
<p><label class="classic" for="pack_overwrite">'.
<p><label class="classic" for="pack_overwrite">' .
form::checkbox('pack_overwrite', 1, !empty($this->getSetting('pack_overwrite'))) . ' ' .
__('Overwrite existing package') . '</label></p>
@ -118,7 +119,7 @@ class ImproveActionZip extends ImproveAction
public function closeModule(): ?bool
{
$exclude = array_merge(
self::$exclude,
self::$exclude,
explode(',', $this->getSetting('pack_excludefiles'))
);
$this->setSuccess(sprintf(__('Prepare excluded files "%s"'), implode(', ', $exclude)));
@ -132,6 +133,7 @@ class ImproveActionZip extends ImproveAction
if (!empty($this->getSetting('secondpack_filename'))) {
$this->zipModule($this->getSetting('secondpack_filename'), $exclude);
}
return null;
}
@ -149,7 +151,7 @@ class ImproveActionZip extends ImproveAction
$file
);
$parts = explode('/', $file);
foreach($parts as $i => $part) {
foreach ($parts as $i => $part) {
$parts[$i] = files::tidyFileName($part);
}
$path = $this->getSetting('pack_repository') . '/' . implode('/', $parts) . '.zip';
@ -164,9 +166,9 @@ class ImproveActionZip extends ImproveAction
return null;
}
@set_time_limit(300);
$fp = fopen($path, 'wb');
$fp = fopen($path, 'wb');
$zip = new ImproveZipFileZip($fp);
foreach($exclude as $e) {
foreach ($exclude as $e) {
$e = '#(^|/)(' . str_replace(
['.', '*'],
['\.', '.*?'],
@ -209,9 +211,9 @@ class ImproveZipFileZip extends fileZip
}
$unc_len = strlen($content);
$crc = crc32($content);
$zdata = gzdeflate($content);
$c_len = strlen($zdata);
$crc = crc32($content);
$zdata = gzdeflate($content);
$c_len = strlen($zdata);
unset($content);
@ -219,8 +221,7 @@ class ImproveZipFileZip 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
@ -243,8 +244,7 @@ class ImproveZipFileZip 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
@ -260,7 +260,7 @@ class ImproveZipFileZip 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;
@ -291,6 +291,7 @@ class ImproveZipFileZip extends fileZip
$newStr .= $token;
}
}
return $newStr;
}
}
}

View File

@ -1,16 +1,15 @@
<?php
/**
* @brief improve, a plugin for Dotclear 2
*
*
* @package Dotclear
* @subpackage Plugin
*
*
* @author Jean-Christian Denis and contributors
*
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return;
}
@ -20,7 +19,7 @@ dcPage::checkSuper();
$improve = new Improve($core);
$show_filters = false;
$type = $_REQUEST['type'] ?? 'plugin';
$type = $_REQUEST['type'] ?? 'plugin';
$preferences = @unserialize($core->blog->settings->improve->preferences);
if (!is_array($preferences)) {
@ -31,7 +30,7 @@ $preferences = array_merge(['plugin' => [], 'theme' => []], $preferences);
if (!empty($_POST['save_preferences'])) {
$preferences[$type] = [];
if (!empty($_POST['actions'])) {
foreach($improve->modules() as $action) {
foreach ($improve->modules() as $action) {
if (in_array($type, $action->types) && in_array($action->id, $_POST['actions'])) {
$preferences[$type][] = $action->id;
}
@ -41,10 +40,10 @@ if (!empty($_POST['save_preferences'])) {
dcPage::addSuccessNotice(__('Configuration successfully updated'));
}
$allow_distrib = (boolean) $core->blog->settings->improve->allow_distrib;
$official = [
'plugin' => explode(',', DC_DISTRIB_PLUGINS),
'theme' => explode(',', DC_DISTRIB_THEMES)
$allow_distrib = (bool) $core->blog->settings->improve->allow_distrib;
$official = [
'plugin' => explode(',', DC_DISTRIB_PLUGINS),
'theme' => explode(',', DC_DISTRIB_THEMES)
];
if (!isset($core->themes)) {
@ -53,8 +52,8 @@ if (!isset($core->themes)) {
}
$combo_modules = [__('Select a module') => '-'];
$modules = $type == 'plugin' ? $core->plugins->getModules() : $core->themes->getModules();
foreach($modules as $id => $m) {
$modules = $type == 'plugin' ? $core->plugins->getModules() : $core->themes->getModules();
foreach ($modules as $id => $m) {
if (!$m['root_writable'] || !$allow_distrib && in_array($id, $official[$type])) {
continue;
}
@ -73,9 +72,9 @@ if (!empty($_POST['fix'])) {
} else {
try {
$time = $improve->fixModule(
$type,
$module,
$type == 'plugin' ? $core->plugins->getModules($module) : $core->themes->getModules($module),
$type,
$module,
$type == 'plugin' ? $core->plugins->getModules($module) : $core->themes->getModules($module),
$_POST['actions']
);
$log_id = $improve->writeLogs();
@ -102,21 +101,19 @@ if (!empty($_POST['fix'])) {
$breadcrumb = [];
if (!empty($_REQUEST['config'])) {
$breadcrumb = [
($type == 'plugin' ? __('Plugins') : __('Themes')) =>
$core->adminurl->get('admin.plugin.improve', ['type' => ($type == 'plugin' ? 'plugin' : 'theme')]),
'<span class="page-title">' . __('Configure module') . '</span>' => ''
($type == 'plugin' ? __('Plugins') : __('Themes')) => $core->adminurl->get('admin.plugin.improve', ['type' => ($type == 'plugin' ? 'plugin' : 'theme')]),
'<span class="page-title">' . __('Configure module') . '</span>' => ''
];
} else {
$breadcrumb = [
'<span class="page-title">' . ($type == 'plugin' ? __('Plugins') : __('Themes')) . '</span>' => '',
($type == 'theme' ? __('Plugins') : __('Themes')) =>
$core->adminurl->get('admin.plugin.improve', ['type' => ($type == 'theme' ? 'plugin' : 'theme')])
'<span class="page-title">' . ($type == 'plugin' ? __('Plugins') : __('Themes')) . '</span>' => '',
($type == 'theme' ? __('Plugins') : __('Themes')) => $core->adminurl->get('admin.plugin.improve', ['type' => ($type == 'theme' ? 'plugin' : 'theme')])
];
}
# display header
echo '<html><head><title>' . __('improve') . '</title></head><body>' .
dcPage::breadcrumb(array_merge([__('improve') => ''], $breadcrumb),['hl' => false]) .
dcPage::breadcrumb(array_merge([__('improve') => ''], $breadcrumb), ['hl' => false]) .
dcPage::notices();
if (!empty($_REQUEST['config'])) {
@ -124,14 +121,14 @@ if (!empty($_REQUEST['config'])) {
if (null !== ($action = $improve->module($_REQUEST['config']))) {
$redir = $_REQUEST['redir'] ?? $core->adminurl->get('admin.plugin.improve', ['type' => $type, 'config' => $action->id]);
$res = $action->configure($redir);
$res = $action->configure($redir);
echo '
<h3>' . sprintf(__('Configure module "%s"'), $action->name) . '</h3>
<p><a class="back" href="' . $back_url . '">' . __('Back') . '</a></p>
<p class="info">' . html::escapeHTML($action->desc) . '</p>
<form action="' . $core->adminurl->get('admin.plugin.improve') . '" method="post" id="form-actions">' .
(empty($res) ? '<p class="message">' . __('Nothing to configure'). '</p>' : $res) . '
(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->id) .
@ -143,37 +140,35 @@ if (!empty($_REQUEST['config'])) {
<p class="warning">' . __('Unknow module') . '</p>
<p><a class="back" href="' . $back_url . '">' . __('Back') . '</a></p>';
}
} else {
echo '<h3>' . ($type == 'plugin' ? __('Plugins') : __('Themes')) . '</h3>';
if (count($combo_modules) == 1) {
echo '<p class="message">' . __('No module to manage') . '</p>';
} else {
echo '<form action="' . $core->adminurl->get('admin.plugin.improve') . '" method="post" id="form-actions">';
foreach($improve->modules() as $action) {
foreach ($improve->modules() as $action) {
if (!in_array($type, $action->types)) {
continue;
}
$p = DC_DEBUG ? '<span class="debug">' . $action->priority. '</span> ' : '';
echo
'<p class="modules">' . $p . '<label for="action_' . $action->id . '" class="classic">' .
$p = DC_DEBUG ? '<span class="debug">' . $action->priority . '</span> ' : '';
echo
'<p class="modules">' . $p . '<label for="action_' . $action->id . '" class="classic">' .
form::checkbox(
['actions[]',
'action_' . $action->id],
$action->id,
in_array($action->id, $preferences[$type]) && $action->isConfigured(),
'',
'',
['actions[]',
'action_' . $action->id],
$action->id,
in_array($action->id, $preferences[$type]) && $action->isConfigured(),
'',
'',
!$action->isConfigured()
) .
$action->name . '</label>';
if (false !== $action->config) {
echo
' - <a class="module-config" href="' .
(true === $action->config ? $core->adminurl->get('admin.plugin.improve', ['type' => $type, 'config' => $action->id]) : $action->config) .
echo
' - <a class="module-config" href="' .
(true === $action->config ? $core->adminurl->get('admin.plugin.improve', ['type' => $type, 'config' => $action->id]) : $action->config) .
'" title="' . sprintf(__("Configure action '%s'"), $action->name) . '">' . __('Configure module') . '</a>';
}
echo '</p>';
@ -184,11 +179,11 @@ if (!empty($_REQUEST['config'])) {
<hr />
<p><label for="save_preferences" class="classic">' .
form::checkbox('save_preferences', 1, !empty($_POST['save_preferences'])) .
__('Save fields selection as preference') .'</label></p>
__('Save fields selection as preference') . '</label></p>
<p class="field"><label for="module" class="classic">' . __('Select a module:') . '</label>' .
form::combo('module', $combo_modules, $module) . '
</p></p>
<input type="submit" name="fix" value="' . __('Fix it') . '" />' .
<input type="submit" name="fix" value="' . __('Fix it') . '" />' .
form::hidden(['type'], $type) .
$core->formNonce() . '
</p>
@ -203,13 +198,13 @@ if (!empty($_REQUEST['config'])) {
if (!empty($logs)) {
echo '<div class="fieldset"><h4>' . __('Details') . '</h4>';
foreach($logs as $path => $types) {
echo '<h5>' . $path .'</h5>';
foreach($types as $type => $tools) {
foreach ($logs as $path => $types) {
echo '<h5>' . $path . '</h5>';
foreach ($types as $type => $tools) {
echo '<div class="' . $type . '"><ul>';
foreach($tools as $tool => $msgs) {
foreach ($tools as $tool => $msgs) {
echo '<li>' . $improve->module($tool)->name . '<ul>';
foreach($msgs as $msg) {
foreach ($msgs as $msg) {
echo '<li>' . $msg . '</li>';
}
echo '</ul></li>';
@ -224,4 +219,4 @@ if (!empty($_REQUEST['config'])) {
}
}
echo '</body></html>';
echo '</body></html>';