use My class for plugin def
This commit is contained in:
parent
62acb116db
commit
061b69e803
9 changed files with 96 additions and 54 deletions
|
@ -85,7 +85,7 @@ abstract class Action
|
||||||
{
|
{
|
||||||
$this->class_name = str_replace(Utils::getActionsNS(), '', get_called_class());
|
$this->class_name = str_replace(Utils::getActionsNS(), '', get_called_class());
|
||||||
|
|
||||||
$settings = dcCore::app()->blog->settings->get(Core::id())->get('settings_' . $this->class_name);
|
$settings = dcCore::app()->blog->settings->get(My::id())->get('settings_' . $this->class_name);
|
||||||
if (null != $settings) {
|
if (null != $settings) {
|
||||||
$settings = json_decode($settings, true);
|
$settings = json_decode($settings, true);
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ abstract class Action
|
||||||
$this->init();
|
$this->init();
|
||||||
|
|
||||||
// can overload priority by settings
|
// can overload priority by settings
|
||||||
if (1 < ($p = (int) dcCore::app()->blog->settings->get(Core::id())->get('priority_' . $this->class_name))) {
|
if (1 < ($p = (int) dcCore::app()->blog->settings->get(My::id())->get('priority_' . $this->class_name))) {
|
||||||
$this->priority = $p;
|
$this->priority = $p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,7 +235,7 @@ abstract class Action
|
||||||
*/
|
*/
|
||||||
final protected function redirect(string $url): bool
|
final protected function redirect(string $url): bool
|
||||||
{
|
{
|
||||||
dcCore::app()->blog->settings->get(Core::id())->put(
|
dcCore::app()->blog->settings->get(My::id())->put(
|
||||||
'settings_' . $this->class_name,
|
'settings_' . $this->class_name,
|
||||||
json_encode($this->settings),
|
json_encode($this->settings),
|
||||||
'string',
|
'string',
|
||||||
|
|
|
@ -49,22 +49,22 @@ class Backend extends dcNsProcess
|
||||||
|
|
||||||
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs): void {
|
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs): void {
|
||||||
$favs->register(
|
$favs->register(
|
||||||
Core::id(),
|
My::id(),
|
||||||
[
|
[
|
||||||
'title' => Core::name(),
|
'title' => My::name(),
|
||||||
'url' => dcCore::app()->adminurl->get('admin.plugin.' . Core::id()),
|
'url' => dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
|
||||||
'small-icon' => dcPage::getPF(Core::id() . '/icon.svg'),
|
'small-icon' => dcPage::getPF(My::id() . '/icon.svg'),
|
||||||
'large-icon' => dcPage::getPF(Core::id() . '/icon.svg'),
|
'large-icon' => dcPage::getPF(My::id() . '/icon.svg'),
|
||||||
//'permissions' => null,
|
//'permissions' => null,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
||||||
Core::name(),
|
My::name(),
|
||||||
dcCore::app()->adminurl->get('admin.plugin.' . Core::id()),
|
dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
|
||||||
dcPage::getPF(Core::id() . '/icon.svg'),
|
dcPage::getPF(My::id() . '/icon.svg'),
|
||||||
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . Core::id())) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
|
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . My::id())) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
|
||||||
dcCore::app()->auth->isSuperAdmin()
|
dcCore::app()->auth->isSuperAdmin()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -65,14 +65,14 @@ class Config extends dcNsProcess
|
||||||
if (!empty($_POST['disabled']) && is_array($_POST['disabled'])) {
|
if (!empty($_POST['disabled']) && is_array($_POST['disabled'])) {
|
||||||
$pdisabled = implode(';', $_POST['disabled']);
|
$pdisabled = implode(';', $_POST['disabled']);
|
||||||
}
|
}
|
||||||
dcCore::app()->blog->settings->get(Core::id())->put('disabled', $pdisabled);
|
dcCore::app()->blog->settings->get(My::id())->put('disabled', $pdisabled);
|
||||||
dcCore::app()->blog->settings->get(Core::id())->put('nodetails', !empty($_POST['nodetails']));
|
dcCore::app()->blog->settings->get(My::id())->put('nodetails', !empty($_POST['nodetails']));
|
||||||
|
|
||||||
dcPage::addSuccessNotice(__('Configuration successfully updated'));
|
dcPage::addSuccessNotice(__('Configuration successfully updated'));
|
||||||
|
|
||||||
dcCore::app()->adminurl->redirect(
|
dcCore::app()->adminurl->redirect(
|
||||||
'admin.plugins',
|
'admin.plugins',
|
||||||
['module' => Core::id(), 'conf' => 1, 'chk' => 1, 'redir' => dcCore::app()->admin->__get('list')->getRedir()]
|
['module' => My::id(), 'conf' => 1, 'chk' => 1, 'redir' => dcCore::app()->admin->__get('list')->getRedir()]
|
||||||
);
|
);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
|
@ -106,7 +106,7 @@ class Config extends dcNsProcess
|
||||||
(new Fieldset())->class('fieldset')->legend(new Legend(__('List of disabled actions')))->fields($items),
|
(new Fieldset())->class('fieldset')->legend(new Legend(__('List of disabled actions')))->fields($items),
|
||||||
(new Fieldset())->class('fieldset')->legend(new Legend(__('Options')))->fields([
|
(new Fieldset())->class('fieldset')->legend(new Legend(__('Options')))->fields([
|
||||||
(new Para())->items([
|
(new Para())->items([
|
||||||
(new Checkbox('nodetails', (bool) dcCore::app()->blog->settings->get(Core::id())->get('nodetails')))->value('1'),
|
(new Checkbox('nodetails', (bool) dcCore::app()->blog->settings->get(My::id())->get('nodetails')))->value('1'),
|
||||||
(new Label(__('Hide details of rendered actions')))->class('classic')->for('nodetails'),
|
(new Label(__('Hide details of rendered actions')))->class('classic')->for('nodetails'),
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
|
|
24
src/Core.php
24
src/Core.php
|
@ -53,7 +53,7 @@ class Core
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$disabled = explode(';', (string) dcCore::app()->blog->settings->get(self::id())->get('disabled'));
|
$disabled = explode(';', (string) dcCore::app()->blog->settings->get(My::id())->get('disabled'));
|
||||||
$list = new ArrayObject();
|
$list = new ArrayObject();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -74,14 +74,14 @@ class Core
|
||||||
uasort($this->actions, [$this, 'sortModules']);
|
uasort($this->actions, [$this, 'sortModules']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function id()
|
public static function id(): string
|
||||||
{
|
{
|
||||||
return basename(dirname(__DIR__));
|
return basename(dirname(__DIR__));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function name()
|
public static function name(): string
|
||||||
{
|
{
|
||||||
return __('improve');
|
return __((string) dcCore::app()->plugins->moduleInfo(My::id(), 'name'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLogs(): array
|
public function getLogs(): array
|
||||||
|
@ -101,7 +101,7 @@ class Core
|
||||||
}
|
}
|
||||||
$cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcLog::LOG_TABLE_NAME);
|
$cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcLog::LOG_TABLE_NAME);
|
||||||
$cur->log_msg = json_encode($this->logs);
|
$cur->log_msg = json_encode($this->logs);
|
||||||
$cur->log_table = self::id();
|
$cur->log_table = My::id();
|
||||||
$id = dcCore::app()->log->addLog($cur);
|
$id = dcCore::app()->log->addLog($cur);
|
||||||
|
|
||||||
return $id;
|
return $id;
|
||||||
|
@ -109,7 +109,7 @@ class Core
|
||||||
|
|
||||||
public function readLogs(int $id): array
|
public function readLogs(int $id): array
|
||||||
{
|
{
|
||||||
$rs = dcCore::app()->log->getLogs(['log_table' => self::id(), 'log_id' => $id, 'limit' => 1]);
|
$rs = dcCore::app()->log->getLogs(['log_table' => My::id(), 'log_id' => $id, 'limit' => 1]);
|
||||||
if ($rs->isEmpty()) {
|
if ($rs->isEmpty()) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
@ -120,14 +120,14 @@ class Core
|
||||||
return is_array($res) ? $res : [];
|
return is_array($res) ? $res : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function parselogs(int $id): array
|
public function parseLogs(int $id): array
|
||||||
{
|
{
|
||||||
$logs = $this->readLogs($id);
|
$logs = $this->readLogs($id);
|
||||||
if (empty($logs)) {
|
if (empty($logs)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
$lines = [];
|
$lines = [];
|
||||||
foreach ($logs[self::id()] as $path => $tools) {
|
foreach ($logs[My::id()] as $path => $tools) {
|
||||||
$l_types = [];
|
$l_types = [];
|
||||||
foreach (['success', 'warning', 'error'] as $type) {
|
foreach (['success', 'warning', 'error'] as $type) {
|
||||||
$l_tools = [];
|
$l_tools = [];
|
||||||
|
@ -203,7 +203,7 @@ class Core
|
||||||
}
|
}
|
||||||
foreach ($workers as $action) {
|
foreach ($workers as $action) {
|
||||||
// trace all path and action in logs
|
// trace all path and action in logs
|
||||||
$this->logs[self::id()][__('Begin')][] = $action->id();
|
$this->logs[My::id()][__('Begin')][] = $action->id();
|
||||||
// info: set current module
|
// info: set current module
|
||||||
$action->setModule($module);
|
$action->setModule($module);
|
||||||
$action->setPath(__('Begin'), '', true);
|
$action->setPath(__('Begin'), '', true);
|
||||||
|
@ -220,7 +220,7 @@ class Core
|
||||||
}
|
}
|
||||||
foreach ($workers as $action) {
|
foreach ($workers as $action) {
|
||||||
// trace all path and action in logs
|
// trace all path and action in logs
|
||||||
$this->logs[self::id()][$file[0]][] = $action->id();
|
$this->logs[My::id()][$file[0]][] = $action->id();
|
||||||
// info: set current path
|
// info: set current path
|
||||||
$action->setPath($file[0], $file[1], $file[2]);
|
$action->setPath($file[0], $file[1], $file[2]);
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,7 @@ class Core
|
||||||
}
|
}
|
||||||
foreach ($workers as $action) {
|
foreach ($workers as $action) {
|
||||||
// trace all path and action in logs
|
// trace all path and action in logs
|
||||||
$this->logs[self::id()][__('End')][] = $action->id();
|
$this->logs[My::id()][__('End')][] = $action->id();
|
||||||
// info: set current module
|
// info: set current module
|
||||||
$action->setPath(__('End'), '', true);
|
$action->setPath(__('End'), '', true);
|
||||||
// action: close module
|
// action: close module
|
||||||
|
@ -313,7 +313,7 @@ class Core
|
||||||
|
|
||||||
public function getURL(array $params = []): string
|
public function getURL(array $params = []): string
|
||||||
{
|
{
|
||||||
return dcCore::app()->adminurl->get('admin.plugin.' . self::id(), $params, '&');
|
return dcCore::app()->adminurl->get('admin.plugin.' . My::id(), $params, '&');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -40,7 +40,7 @@ class Install extends dcNsProcess
|
||||||
|
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
self::$init = defined('DC_CONTEXT_ADMIN') && dcCore::app()->newVersion(Core::id(), dcCore::app()->plugins->moduleInfo(Core::id(), 'version'));
|
self::$init = defined('DC_CONTEXT_ADMIN') && dcCore::app()->newVersion(My::id(), dcCore::app()->plugins->moduleInfo(My::id(), 'version'));
|
||||||
|
|
||||||
return self::$init;
|
return self::$init;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ class Install extends dcNsProcess
|
||||||
private static function putSettings(): void
|
private static function putSettings(): void
|
||||||
{
|
{
|
||||||
foreach (self::$default_settings as $v) {
|
foreach (self::$default_settings as $v) {
|
||||||
dcCore::app()->blog->settings->get(Core::id())->put(
|
dcCore::app()->blog->settings->get(My::id())->put(
|
||||||
$v[0],
|
$v[0],
|
||||||
$v[2],
|
$v[2],
|
||||||
$v[3],
|
$v[3],
|
||||||
|
@ -81,11 +81,11 @@ class Install extends dcNsProcess
|
||||||
/** Update improve < 0.8 : action modules settings name */
|
/** Update improve < 0.8 : action modules settings name */
|
||||||
private static function update_0_8_0(): void
|
private static function update_0_8_0(): void
|
||||||
{
|
{
|
||||||
if (version_compare(dcCore::app()->getVersion(Core::id()) ?? '0', '0.8', '<')) {
|
if (version_compare(dcCore::app()->getVersion(My::id()) ?? '0', '0.8', '<')) {
|
||||||
foreach (dcCore::app()->blog->settings->get(Core::id())->dumpGlobalSettings() as $id => $values) {
|
foreach (dcCore::app()->blog->settings->get(My::id())->dumpGlobalSettings() as $id => $values) {
|
||||||
$newId = str_replace('ImproveAction', '', $id);
|
$newId = str_replace('ImproveAction', '', $id);
|
||||||
if ($id != $newId) {
|
if ($id != $newId) {
|
||||||
dcCore::app()->blog->settings->get(Core::id())->rename($id, strtolower($newId));
|
dcCore::app()->blog->settings->get(My::id())->rename($id, strtolower($newId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,11 +94,11 @@ class Install extends dcNsProcess
|
||||||
/** Update improve < 1.1 : use json_(en|de)code rather than (un)serialize */
|
/** Update improve < 1.1 : use json_(en|de)code rather than (un)serialize */
|
||||||
private static function update_1_1_0(): void
|
private static function update_1_1_0(): void
|
||||||
{
|
{
|
||||||
if (version_compare(dcCore::app()->getVersion(Core::id()) ?? '0', '1.1', '<')) {
|
if (version_compare(dcCore::app()->getVersion(My::id()) ?? '0', '1.1', '<')) {
|
||||||
foreach (['setting_', 'preferences'] as $key) {
|
foreach (['setting_', 'preferences'] as $key) {
|
||||||
$record = dcCore::app()->con->select(
|
$record = dcCore::app()->con->select(
|
||||||
'SELECT * FROM ' . dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME . ' ' .
|
'SELECT * FROM ' . dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME . ' ' .
|
||||||
"WHERE setting_ns = '" . dcCore::app()->con->escape(Core::id()) . "' " .
|
"WHERE setting_ns = '" . dcCore::app()->con->escape(My::id()) . "' " .
|
||||||
"AND setting_id LIKE '" . $key . "%' "
|
"AND setting_id LIKE '" . $key . "%' "
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ class Manage extends dcNsProcess
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (!empty(self::$type)) {
|
if (!empty(self::$type)) {
|
||||||
$preferences = dcCore::app()->blog->settings->get(Core::id())->get('preferences');
|
$preferences = dcCore::app()->blog->settings->get(My::id())->get('preferences');
|
||||||
if (is_string($preferences)) {
|
if (is_string($preferences)) {
|
||||||
$preferences = json_decode($preferences, true);
|
$preferences = json_decode($preferences, true);
|
||||||
if (is_array($preferences)) {
|
if (is_array($preferences)) {
|
||||||
|
@ -113,7 +113,7 @@ class Manage extends dcNsProcess
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dcCore::app()->blog->settings->get(Core::id())->put('preferences', json_encode($preferences), 'string', null, true, true);
|
dcCore::app()->blog->settings->get(My::id())->put('preferences', json_encode($preferences), 'string', null, true, true);
|
||||||
dcAdminNotices::addSuccessNotice(__('Configuration successfully updated'));
|
dcAdminNotices::addSuccessNotice(__('Configuration successfully updated'));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -124,7 +124,7 @@ class Manage extends dcNsProcess
|
||||||
|
|
||||||
private static function comboModules(): array
|
private static function comboModules(): array
|
||||||
{
|
{
|
||||||
$allow_distrib = (bool) dcCore::app()->blog->settings->get(Core::id())->get('allow_distrib');
|
$allow_distrib = (bool) dcCore::app()->blog->settings->get(My::id())->get('allow_distrib');
|
||||||
$official = [
|
$official = [
|
||||||
'plugin' => explode(',', DC_DISTRIB_PLUGINS),
|
'plugin' => explode(',', DC_DISTRIB_PLUGINS),
|
||||||
'theme' => explode(',', DC_DISTRIB_THEMES),
|
'theme' => explode(',', DC_DISTRIB_THEMES),
|
||||||
|
@ -208,7 +208,7 @@ class Manage extends dcNsProcess
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($done) {
|
if ($done) {
|
||||||
dcCore::app()->adminurl->redirect('admin.plugin.' . Core::id(), ['type' => self::$type, 'module' => self::$module, 'upd' => $log_id]);
|
dcCore::app()->adminurl->redirect('admin.plugin.' . My::id(), ['type' => self::$type, 'module' => self::$module, 'upd' => $log_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -221,15 +221,15 @@ class Manage extends dcNsProcess
|
||||||
}
|
}
|
||||||
|
|
||||||
dcPage::openModule(
|
dcPage::openModule(
|
||||||
Core::name(),
|
My::name(),
|
||||||
dcPage::jsModuleLoad(Core::id() . '/js/index.js') .
|
dcPage::jsModuleLoad(My::id() . '/js/index.js') .
|
||||||
(self::$action === null ? '' : self::$action->header())
|
(self::$action === null ? '' : self::$action->header())
|
||||||
);
|
);
|
||||||
|
|
||||||
echo
|
echo
|
||||||
dcPage::breadcrumb([
|
dcPage::breadcrumb([
|
||||||
__('Plugins') => '',
|
__('Plugins') => '',
|
||||||
Core::name() => '',
|
My::name() => '',
|
||||||
empty($_REQUEST['config']) ? (self::$type == 'theme' ? __('Themes actions') : __('Plugins actions')) : __('Configure module') => '',
|
empty($_REQUEST['config']) ? (self::$type == 'theme' ? __('Themes actions') : __('Plugins actions')) : __('Configure module') => '',
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices();
|
dcPage::notices();
|
||||||
|
@ -245,21 +245,21 @@ class Manage extends dcNsProcess
|
||||||
|
|
||||||
private static function displayConfigurator(): void
|
private static function displayConfigurator(): void
|
||||||
{
|
{
|
||||||
$back_url = $_REQUEST['redir'] ?? dcCore::app()->adminurl->get('admin.plugin.' . Core::id(), ['type' => self::$type]);
|
$back_url = $_REQUEST['redir'] ?? dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['type' => self::$type]);
|
||||||
|
|
||||||
if (null === self::$action) {
|
if (null === self::$action) {
|
||||||
echo '
|
echo '
|
||||||
<p class="warning">' . __('Unknow module') . '</p>
|
<p class="warning">' . __('Unknow module') . '</p>
|
||||||
<p><a class="back" href="' . $back_url . '">' . __('Back') . '</a></p>';
|
<p><a class="back" href="' . $back_url . '">' . __('Back') . '</a></p>';
|
||||||
} else {
|
} else {
|
||||||
$redir = $_REQUEST['redir'] ?? dcCore::app()->adminurl->get('admin.plugin.' . Core::id(), ['type' => self::$type, 'config' => self::$action->id()]);
|
$redir = $_REQUEST['redir'] ?? dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['type' => self::$type, 'config' => self::$action->id()]);
|
||||||
$res = self::$action->configure($redir);
|
$res = self::$action->configure($redir);
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<h3>' . sprintf(__('Configure module "%s"'), self::$action->name()) . '</h3>
|
<h3>' . sprintf(__('Configure module "%s"'), self::$action->name()) . '</h3>
|
||||||
<p><a class="back" href="' . $back_url . '">' . __('Back') . '</a></p>
|
<p><a class="back" href="' . $back_url . '">' . __('Back') . '</a></p>
|
||||||
<h4>' . html::escapeHTML(self::$action->description()) . '</h4>
|
<h4>' . html::escapeHTML(self::$action->description()) . '</h4>
|
||||||
<form action="' . dcCore::app()->adminurl->get('admin.plugin.' . Core::id()) . '" method="post" id="form-actions">' .
|
<form action="' . dcCore::app()->adminurl->get('admin.plugin.' . My::id()) . '" 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') . '" />' .
|
<p class="clear"><input type="submit" name="save" value="' . __('Save') . '" />' .
|
||||||
form::hidden('type', self::$type) .
|
form::hidden('type', self::$type) .
|
||||||
|
@ -273,18 +273,18 @@ class Manage extends dcNsProcess
|
||||||
private static function displayActions(): void
|
private static function displayActions(): void
|
||||||
{
|
{
|
||||||
echo
|
echo
|
||||||
'<form method="get" action="' . dcCore::app()->adminurl->get('admin.plugin.' . Core::id()) . '" id="improve_menu">' .
|
'<form method="get" action="' . dcCore::app()->adminurl->get('admin.plugin.' . My::id()) . '" id="improve_menu">' .
|
||||||
'<p class="anchor-nav"><label for="type" class="classic">' . __('Goto:') . ' </label>' .
|
'<p class="anchor-nav"><label for="type" class="classic">' . __('Goto:') . ' </label>' .
|
||||||
form::combo('type', [__('Plugins') => 'plugin', __('Themes') => 'theme'], self::$type) . ' ' .
|
form::combo('type', [__('Plugins') => 'plugin', __('Themes') => 'theme'], self::$type) . ' ' .
|
||||||
'<input type="submit" value="' . __('Ok') . '" />' .
|
'<input type="submit" value="' . __('Ok') . '" />' .
|
||||||
form::hidden('p', Core::id()) . '</p>' .
|
form::hidden('p', My::id()) . '</p>' .
|
||||||
'</form>';
|
'</form>';
|
||||||
|
|
||||||
$combo_modules = self::comboModules();
|
$combo_modules = self::comboModules();
|
||||||
if (count($combo_modules) == 1) {
|
if (count($combo_modules) == 1) {
|
||||||
echo '<p class="message">' . __('No module to manage') . '</p>';
|
echo '<p class="message">' . __('No module to manage') . '</p>';
|
||||||
} else {
|
} else {
|
||||||
echo '<form action="' . dcCore::app()->adminurl->get('admin.plugin.' . Core::id()) . '" method="post" id="form-actions">' .
|
echo '<form action="' . dcCore::app()->adminurl->get('admin.plugin.' . My::id()) . '" method="post" id="form-actions">' .
|
||||||
'<table><caption class="hidden">' . __('Actions') . '</caption><thead><tr>' .
|
'<table><caption class="hidden">' . __('Actions') . '</caption><thead><tr>' .
|
||||||
'<th colspan="2" class="first">' . __('Action') . '</td>' .
|
'<th colspan="2" class="first">' . __('Action') . '</td>' .
|
||||||
'<th scope="col">' . __('Description') . '</td>' .
|
'<th scope="col">' . __('Description') . '</td>' .
|
||||||
|
@ -312,7 +312,7 @@ class Manage extends dcNsProcess
|
||||||
'<td class="maximal">' . $action->description() . '</td>' .
|
'<td class="maximal">' . $action->description() . '</td>' .
|
||||||
'<td class="minimal nowrap modules">' . (
|
'<td class="minimal nowrap modules">' . (
|
||||||
false === $action->configurator() ? '' :
|
false === $action->configurator() ? '' :
|
||||||
'<a class="module-config" href="' . dcCore::app()->adminurl->get('admin.plugin.' . Core::id(), ['type' => self::$type, 'config' => $action->id()]) .
|
'<a class="module-config" href="' . dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['type' => self::$type, 'config' => $action->id()]) .
|
||||||
'" title="' . sprintf(__("Configure action '%s'"), $action->name()) . '">' . __('Configure') . '</a>'
|
'" title="' . sprintf(__("Configure action '%s'"), $action->name()) . '">' . __('Configure') . '</a>'
|
||||||
) . '</td>' .
|
) . '</td>' .
|
||||||
(DC_DEBUG ? '<td class="minimal"><span class="debug">' . $action->priority() . '</span></td>' : '') . /* @phpstan-ignore-line */
|
(DC_DEBUG ? '<td class="minimal"><span class="debug">' . $action->priority() . '</span></td>' : '') . /* @phpstan-ignore-line */
|
||||||
|
@ -334,7 +334,7 @@ class Manage extends dcNsProcess
|
||||||
<br class="clear" />
|
<br class="clear" />
|
||||||
</form>';
|
</form>';
|
||||||
|
|
||||||
if (!empty($_REQUEST['upd']) && !dcCore::app()->blog->settings->get(Core::id())->get('nodetails')) {
|
if (!empty($_REQUEST['upd']) && !dcCore::app()->blog->settings->get(My::id())->get('nodetails')) {
|
||||||
$logs = self::$improve->parseLogs((int) $_REQUEST['upd']);
|
$logs = self::$improve->parseLogs((int) $_REQUEST['upd']);
|
||||||
|
|
||||||
if (!empty($logs)) {
|
if (!empty($logs)) {
|
||||||
|
|
42
src/My.php
Normal file
42
src/My.php
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
<?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
|
||||||
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Dotclear\Plugin\improve;
|
||||||
|
|
||||||
|
use dcCore;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin definitions
|
||||||
|
*/
|
||||||
|
class My
|
||||||
|
{
|
||||||
|
/** @var string Required php version */
|
||||||
|
public const PHP_MIN = '8.1';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This module id
|
||||||
|
*/
|
||||||
|
public static function id(): string
|
||||||
|
{
|
||||||
|
return basename(dirname(__DIR__));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This module name
|
||||||
|
*/
|
||||||
|
public static function name(): string
|
||||||
|
{
|
||||||
|
return __((string) dcCore::app()->plugins->moduleInfo(self::id(), 'name'));
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,7 +16,7 @@ namespace Dotclear\Plugin\improve\Module;
|
||||||
|
|
||||||
/* improve */
|
/* improve */
|
||||||
use Dotclear\Plugin\improve\Action;
|
use Dotclear\Plugin\improve\Action;
|
||||||
use Dotclear\Plugin\improve\Core;
|
use Dotclear\Plugin\improve\My;
|
||||||
|
|
||||||
/* dotclear */
|
/* dotclear */
|
||||||
use dcCore;
|
use dcCore;
|
||||||
|
@ -126,7 +126,7 @@ class phpcsfixer extends Action
|
||||||
]),
|
]),
|
||||||
])->render() . (
|
])->render() . (
|
||||||
!self::$user_ui_colorsyntax ? '' :
|
!self::$user_ui_colorsyntax ? '' :
|
||||||
dcPage::jsModuleLoad(Core::id() . '/inc/module/phpcsfixer/phpcsfixer.improve.js') .
|
dcPage::jsModuleLoad(My::id() . '/inc/module/phpcsfixer/phpcsfixer.improve.js') .
|
||||||
dcPage::jsRunCodeMirror('editor', 'file_content', 'dotclear', self::$user_ui_colorsyntax_theme)
|
dcPage::jsRunCodeMirror('editor', 'file_content', 'dotclear', self::$user_ui_colorsyntax_theme)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace Dotclear\Plugin\improve\Module;
|
||||||
|
|
||||||
/* improve */
|
/* improve */
|
||||||
use Dotclear\Plugin\improve\Action;
|
use Dotclear\Plugin\improve\Action;
|
||||||
use Dotclear\Plugin\improve\Core;
|
use Dotclear\Plugin\improve\My;
|
||||||
|
|
||||||
/* dotclear */
|
/* dotclear */
|
||||||
use dcCore;
|
use dcCore;
|
||||||
|
@ -155,7 +155,7 @@ class phpstan extends Action
|
||||||
]),
|
]),
|
||||||
])->render() . (
|
])->render() . (
|
||||||
!self::$user_ui_colorsyntax ? '' :
|
!self::$user_ui_colorsyntax ? '' :
|
||||||
dcPage::jsModuleLoad(Core::id() . '/inc/module/phpstan/phpstan.improve.js') .
|
dcPage::jsModuleLoad(My::id() . '/inc/module/phpstan/phpstan.improve.js') .
|
||||||
dcPage::jsRunCodeMirror('editor', 'file_content', 'dotclear', self::$user_ui_colorsyntax_theme)
|
dcPage::jsRunCodeMirror('editor', 'file_content', 'dotclear', self::$user_ui_colorsyntax_theme)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue