fix some phpstan warnings
This commit is contained in:
parent
6b70f9b7fb
commit
47e37c7924
9 changed files with 82 additions and 70 deletions
|
@ -43,7 +43,7 @@ class Backend extends dcNsProcess
|
||||||
'adminDashboardFavoritesV2' => function (dcFavorites $favs): void {
|
'adminDashboardFavoritesV2' => function (dcFavorites $favs): void {
|
||||||
$favs->register(My::id(), [
|
$favs->register(My::id(), [
|
||||||
'title' => My::name(),
|
'title' => My::name(),
|
||||||
'url' => dcCore::app()->adminurl->get(My::id()),
|
'url' => dcCore::app()->adminurl?->get(My::id()),
|
||||||
'small-icon' => urldecode(dcPage::getPF(My::id() . '/icon.svg')),
|
'small-icon' => urldecode(dcPage::getPF(My::id() . '/icon.svg')),
|
||||||
'large-icon' => urldecode(dcPage::getPF(My::id() . '/icon.svg')),
|
'large-icon' => urldecode(dcPage::getPF(My::id() . '/icon.svg')),
|
||||||
//'permissions' => null,
|
//'permissions' => null,
|
||||||
|
@ -53,13 +53,13 @@ class Backend extends dcNsProcess
|
||||||
|
|
||||||
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
||||||
My::name(),
|
My::name(),
|
||||||
dcCore::app()->adminurl->get(My::id()),
|
dcCore::app()->adminurl?->get(My::id()),
|
||||||
dcPage::getPF(My::id() . '/icon.svg'),
|
dcPage::getPF(My::id() . '/icon.svg'),
|
||||||
preg_match(
|
preg_match(
|
||||||
'/' . preg_quote(dcCore::app()->adminurl->get(My::id())) . '(&.*)?$/',
|
'/' . preg_quote((string) dcCore::app()->adminurl?->get(My::id())) . '(&.*)?$/',
|
||||||
$_SERVER['REQUEST_URI']
|
$_SERVER['REQUEST_URI']
|
||||||
),
|
),
|
||||||
dcCore::app()->auth->isSuperAdmin()
|
dcCore::app()->auth?->isSuperAdmin()
|
||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -51,7 +51,7 @@ class BackendBehaviors
|
||||||
{
|
{
|
||||||
if ($list->getList() != $prop['type'] . '-activate'
|
if ($list->getList() != $prop['type'] . '-activate'
|
||||||
|| !self::translater()->getSetting($prop['type'] . '_menu')
|
|| !self::translater()->getSetting($prop['type'] . '_menu')
|
||||||
|| !dcCore::app()->auth->isSuperAdmin()
|
|| !dcCore::app()->auth?->isSuperAdmin()
|
||||||
) {
|
) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ class BackendBehaviors
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dcCore::app()->adminurl->redirect(
|
dcCore::app()->adminurl?->redirect(
|
||||||
My::id(),
|
My::id(),
|
||||||
['part' => 'module', 'type' => $type, 'module' => key($_POST['translater'])],
|
['part' => 'module', 'type' => $type, 'module' => key($_POST['translater'])],
|
||||||
'#module-lang'
|
'#module-lang'
|
||||||
|
|
|
@ -63,7 +63,7 @@ class Config extends dcNsProcess
|
||||||
dcPage::addSuccessNotice(
|
dcPage::addSuccessNotice(
|
||||||
__('Configuration successfully updated.')
|
__('Configuration successfully updated.')
|
||||||
);
|
);
|
||||||
dcCore::app()->adminurl->redirect(
|
dcCore::app()->adminurl?->redirect(
|
||||||
'admin.plugins',
|
'admin.plugins',
|
||||||
['module' => My::id(), 'conf' => 1, 'redir' => dcCore::app()->admin->__get('list')->getRedir()]
|
['module' => My::id(), 'conf' => 1, 'redir' => dcCore::app()->admin->__get('list')->getRedir()]
|
||||||
);
|
);
|
||||||
|
|
|
@ -92,7 +92,7 @@ class Manage extends dcNsProcess
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($current->action == 'module_import_pack') {
|
if ($current->action == 'module_import_pack') {
|
||||||
if (empty($_FILES['packfile']['name'])) {
|
if (empty($current->module) || empty($_FILES['packfile']['name'])) {
|
||||||
throw new Exception(__('Nothing to import'));
|
throw new Exception(__('Nothing to import'));
|
||||||
}
|
}
|
||||||
$current->module->importPack($_FILES['packfile']);
|
$current->module->importPack($_FILES['packfile']);
|
||||||
|
@ -146,23 +146,23 @@ class Manage extends dcNsProcess
|
||||||
|
|
||||||
public static function render(): void
|
public static function render(): void
|
||||||
{
|
{
|
||||||
if (!self::$init) {
|
if (!static::$init) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$current = ManageVars::init();
|
$current = ManageVars::init();
|
||||||
|
|
||||||
$breadcrumb = [My::name() => dcCore::app()->adminurl->get(My::id(), ['type' => '-'])];
|
$breadcrumb = [My::name() => dcCore::app()->adminurl?->get(My::id(), ['type' => '-'])];
|
||||||
if (empty($current->type)) {
|
if (empty($current->type)) {
|
||||||
$breadcrumb = [My::name() => ''];
|
$breadcrumb = [My::name() => ''];
|
||||||
} elseif (empty($current->module)) {
|
} elseif (empty($current->module)) {
|
||||||
$breadcrumb[$current->type == 'plugin' ? __('Plugins') : __('Themes')] = '';
|
$breadcrumb[$current->type == 'plugin' ? __('Plugins') : __('Themes')] = '';
|
||||||
} elseif (empty($current->lang)) {
|
} elseif (empty($current->lang)) {
|
||||||
$breadcrumb[$current->type == 'plugin' ? __('Plugins') : __('Themes')] = dcCore::app()->adminurl->get(My::id(), ['type' => $current->type]);
|
$breadcrumb[$current->type == 'plugin' ? __('Plugins') : __('Themes')] = dcCore::app()->adminurl?->get(My::id(), ['type' => $current->type]);
|
||||||
$breadcrumb[html::escapeHTML($current->module->name)] = '';
|
$breadcrumb[html::escapeHTML($current->module->name)] = '';
|
||||||
} elseif (!empty($current->lang)) {
|
} elseif (!empty($current->lang)) {
|
||||||
$breadcrumb[$current->type == 'plugin' ? __('Plugins') : __('Themes')] = dcCore::app()->adminurl->get(My::id(), ['type' => $current->type]);
|
$breadcrumb[$current->type == 'plugin' ? __('Plugins') : __('Themes')] = dcCore::app()->adminurl?->get(My::id(), ['type' => $current->type]);
|
||||||
$breadcrumb[html::escapeHTML($current->module->name)] = dcCore::app()->adminurl->get(My::id(), ['type' => $current->type, 'module' => $current->module->id]);
|
$breadcrumb[html::escapeHTML($current->module->name)] = dcCore::app()->adminurl?->get(My::id(), ['type' => $current->type, 'module' => $current->module->id]);
|
||||||
$breadcrumb[html::escapeHTML(sprintf(__('%s language edition'), $current->lang->name))] = '';
|
$breadcrumb[html::escapeHTML(sprintf(__('%s language edition'), $current->lang->name))] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ class Manage extends dcNsProcess
|
||||||
|
|
||||||
if (empty($current->module) && $current->type != '') {
|
if (empty($current->module) && $current->type != '') {
|
||||||
// modules list
|
// modules list
|
||||||
echo '<form id="theme-form" method="post" action="' . dcCore::app()->adminurl->get(My::id(), ['type' => 'plugin']) . '">';
|
echo '<form id="theme-form" method="post" action="' . dcCore::app()->adminurl?->get(My::id(), ['type' => 'plugin']) . '">';
|
||||||
|
|
||||||
$res = '';
|
$res = '';
|
||||||
$modules = $current->translater->getModules($current->type);
|
$modules = $current->translater->getModules($current->type);
|
||||||
|
@ -199,7 +199,7 @@ class Manage extends dcNsProcess
|
||||||
if ($module->root_writable) {
|
if ($module->root_writable) {
|
||||||
$res .= sprintf(
|
$res .= sprintf(
|
||||||
'<tr class="line"><td class="nowrap minimal"><a href="%s" title="%s">%s</a></td>',
|
'<tr class="line"><td class="nowrap minimal"><a href="%s" title="%s">%s</a></td>',
|
||||||
dcCore::app()->adminurl->get(My::id(), ['type' => $module->type, 'module' => $module->id]),
|
dcCore::app()->adminurl?->get(My::id(), ['type' => $module->type, 'module' => $module->id]),
|
||||||
html::escapeHTML(sprintf(__('Translate module %s'), __($module->name))),
|
html::escapeHTML(sprintf(__('Translate module %s'), __($module->name))),
|
||||||
html::escapeHTML($module->id)
|
html::escapeHTML($module->id)
|
||||||
);
|
);
|
||||||
|
@ -215,7 +215,7 @@ class Manage extends dcNsProcess
|
||||||
$codes[$code_id] = sprintf(
|
$codes[$code_id] = sprintf(
|
||||||
'<a class="wait maximal nowrap" title="%s" href="%s">%s (%s)</a>',
|
'<a class="wait maximal nowrap" title="%s" href="%s">%s (%s)</a>',
|
||||||
html::escapeHTML(sprintf(__('Edit language %s of module %s'), html::escapeHTML($code_name), __($module->name))),
|
html::escapeHTML(sprintf(__('Edit language %s of module %s'), html::escapeHTML($code_name), __($module->name))),
|
||||||
dcCore::app()->adminurl->get(My::id(), ['type' => $module->type, 'module' => $module->id, 'lang' => $code_id]),
|
dcCore::app()->adminurl?->get(My::id(), ['type' => $module->type, 'module' => $module->id, 'lang' => $code_id]),
|
||||||
html::escapeHTML($code_name),
|
html::escapeHTML($code_name),
|
||||||
$code_id
|
$code_id
|
||||||
);
|
);
|
||||||
|
@ -267,7 +267,7 @@ class Manage extends dcNsProcess
|
||||||
if (count($codes)) {
|
if (count($codes)) {
|
||||||
echo
|
echo
|
||||||
'<div class="clear fieldset"><h3>' . __('Translations') . '</h3>' .
|
'<div class="clear fieldset"><h3>' . __('Translations') . '</h3>' .
|
||||||
'<form id="module-translations-form" method="post" action="' . dcCore::app()->adminurl->get(My::id()) . '">' .
|
'<form id="module-translations-form" method="post" action="' . dcCore::app()->adminurl?->get(My::id()) . '">' .
|
||||||
'<table class="clear maximal">' .
|
'<table class="clear maximal">' .
|
||||||
'<caption>' . __('Existing languages translations') . '</caption>' .
|
'<caption>' . __('Existing languages translations') . '</caption>' .
|
||||||
'<tr>' .
|
'<tr>' .
|
||||||
|
@ -283,7 +283,7 @@ class Manage extends dcNsProcess
|
||||||
'<td class="minimal">' . form::checkbox(['codes[]', 'existing_code_' . $code_id], $code_id, '', '', '', false) . '</td>' .
|
'<td class="minimal">' . form::checkbox(['codes[]', 'existing_code_' . $code_id], $code_id, '', '', '', false) . '</td>' .
|
||||||
'<td class="nowrap">' .
|
'<td class="nowrap">' .
|
||||||
'<a href="' .
|
'<a href="' .
|
||||||
dcCore::app()->adminurl->get(My::id(), ['type' => $current->module->type, 'module' => $current->module->id, 'lang' => $code_id])
|
dcCore::app()->adminurl?->get(My::id(), ['type' => $current->module->type, 'module' => $current->module->id, 'lang' => $code_id])
|
||||||
. '" title="' . sprintf(__('Edit %s language'), html::escapeHTML($code_name)) . '">' . $code_name . '</a>' .
|
. '" title="' . sprintf(__('Edit %s language'), html::escapeHTML($code_name)) . '">' . $code_name . '</a>' .
|
||||||
'</td>' .
|
'</td>' .
|
||||||
'<td class="nowrap maximal"> ' . $code_id . '</td>';
|
'<td class="nowrap maximal"> ' . $code_id . '</td>';
|
||||||
|
@ -297,7 +297,7 @@ class Manage extends dcNsProcess
|
||||||
echo
|
echo
|
||||||
'<td class="nowrap">' . count($backups[$code_id]) . '</td>' .
|
'<td class="nowrap">' . count($backups[$code_id]) . '</td>' .
|
||||||
'<td class="nowrap"> ' .
|
'<td class="nowrap"> ' .
|
||||||
dt::str('%Y-%m-%d %H:%M', (int) $time[$code_id], dcCore::app()->blog->settings->get('system')->get('blog_timezone')) .
|
dt::str('%Y-%m-%d %H:%M', (int) $time[$code_id], (string) dcCore::app()->blog?->settings->get('system')->get('blog_timezone')) .
|
||||||
'</td>';
|
'</td>';
|
||||||
} else {
|
} else {
|
||||||
echo '<td class="nowrap">' . __('no backups') . '</td><td class="maximal nowrap">-</td>';
|
echo '<td class="nowrap">' . __('no backups') . '</td><td class="maximal nowrap">-</td>';
|
||||||
|
@ -316,7 +316,7 @@ class Manage extends dcNsProcess
|
||||||
]) . '
|
]) . '
|
||||||
<input id="do-action" type="submit" value="' . __('ok') . '" /></p>' .
|
<input id="do-action" type="submit" value="' . __('ok') . '" /></p>' .
|
||||||
dcCore::app()->formNonce() .
|
dcCore::app()->formNonce() .
|
||||||
dcCore::app()->adminurl->getHiddenFormFields(
|
dcCore::app()->adminurl?->getHiddenFormFields(
|
||||||
My::id(),
|
My::id(),
|
||||||
['type' => $current->module->type, 'module' => $current->module->id]
|
['type' => $current->module->type, 'module' => $current->module->id]
|
||||||
) . '
|
) . '
|
||||||
|
@ -328,7 +328,7 @@ class Manage extends dcNsProcess
|
||||||
// delete / retore backups
|
// delete / retore backups
|
||||||
if (!empty($backups)) {
|
if (!empty($backups)) {
|
||||||
echo '<div class="fieldset"><h3>' . __('Backups') . '</h3>' .
|
echo '<div class="fieldset"><h3>' . __('Backups') . '</h3>' .
|
||||||
'<form id="module-backups-form" method="post" action="' . dcCore::app()->adminurl->get(My::id()) . '">' .
|
'<form id="module-backups-form" method="post" action="' . dcCore::app()->adminurl?->get(My::id()) . '">' .
|
||||||
'<table class="clear">' .
|
'<table class="clear">' .
|
||||||
'<caption>' . __('Existing languages backups') . '</caption>' .
|
'<caption>' . __('Existing languages backups') . '</caption>' .
|
||||||
'<tr>' .
|
'<tr>' .
|
||||||
|
@ -360,9 +360,9 @@ class Manage extends dcNsProcess
|
||||||
$backup_code['name'],
|
$backup_code['name'],
|
||||||
$backup_code['code'],
|
$backup_code['code'],
|
||||||
dt::str(
|
dt::str(
|
||||||
dcCore::app()->blog->settings->get('system')->get('date_format') . ' ' . dcCore::app()->blog->settings->get('system')->get('time_format'),
|
dcCore::app()->blog?->settings->get('system')->get('date_format') . ' ' . dcCore::app()->blog?->settings->get('system')->get('time_format'),
|
||||||
(int) $backup_code['time'],
|
(int) $backup_code['time'],
|
||||||
dcCore::app()->blog->settings->get('system')->get('blog_timezone')
|
dcCore::app()->blog?->settings->get('system')->get('blog_timezone')
|
||||||
),
|
),
|
||||||
$backup_code['path']['basename'],
|
$backup_code['path']['basename'],
|
||||||
files::size($backup_code['size'])
|
files::size($backup_code['size'])
|
||||||
|
@ -381,7 +381,7 @@ class Manage extends dcNsProcess
|
||||||
]) . '
|
]) . '
|
||||||
<input id="do-action" type="submit" value="' . __('ok') . '" /></p>' .
|
<input id="do-action" type="submit" value="' . __('ok') . '" /></p>' .
|
||||||
dcCore::app()->formNonce() .
|
dcCore::app()->formNonce() .
|
||||||
dcCore::app()->adminurl->getHiddenFormFields(
|
dcCore::app()->adminurl?->getHiddenFormFields(
|
||||||
My::id(),
|
My::id(),
|
||||||
['type' => $current->module->type, 'module' => $current->module->id]
|
['type' => $current->module->type, 'module' => $current->module->id]
|
||||||
) . '
|
) . '
|
||||||
|
@ -394,9 +394,9 @@ class Manage extends dcNsProcess
|
||||||
// add language
|
// add language
|
||||||
if (!empty($unused_codes)) {
|
if (!empty($unused_codes)) {
|
||||||
echo '<div class="col fieldset"><h3>' . __('Add language') . '</h3>
|
echo '<div class="col fieldset"><h3>' . __('Add language') . '</h3>
|
||||||
<form id="muodule-code-create-form" method="post" action="' . dcCore::app()->adminurl->get(My::id()) . '">
|
<form id="muodule-code-create-form" method="post" action="' . dcCore::app()->adminurl?->get(My::id()) . '">
|
||||||
<p class="field"><label for="code">' . __('Select language:') . '</label>' .
|
<p class="field"><label for="code">' . __('Select language:') . '</label>' .
|
||||||
form::combo(['code'], array_merge(['-' => '-'], $unused_codes), dcCore::app()->auth->getInfo('user_lang')) . '</p>';
|
form::combo(['code'], array_merge(['-' => '-'], $unused_codes), (string) dcCore::app()->auth?->getInfo('user_lang')) . '</p>';
|
||||||
if (empty($codes)) {
|
if (empty($codes)) {
|
||||||
echo '<p>' . form::hidden(['from'], '') . '</p>';
|
echo '<p>' . form::hidden(['from'], '') . '</p>';
|
||||||
} else {
|
} else {
|
||||||
|
@ -407,7 +407,7 @@ class Manage extends dcNsProcess
|
||||||
echo '
|
echo '
|
||||||
<p><input type="submit" name="save" value="' . __('Create') . '" />' .
|
<p><input type="submit" name="save" value="' . __('Create') . '" />' .
|
||||||
dcCore::app()->formNonce() .
|
dcCore::app()->formNonce() .
|
||||||
dcCore::app()->adminurl->getHiddenFormFields(
|
dcCore::app()->adminurl?->getHiddenFormFields(
|
||||||
My::id(),
|
My::id(),
|
||||||
['type' => $current->module->type, 'module' => $current->module->id, 'action' => 'module_add_code']
|
['type' => $current->module->type, 'module' => $current->module->id, 'action' => 'module_add_code']
|
||||||
) . '
|
) . '
|
||||||
|
@ -416,13 +416,13 @@ class Manage extends dcNsProcess
|
||||||
|
|
||||||
// Import
|
// Import
|
||||||
echo '<div class="col fieldset"><h3>' . __('Import') . '</h3>
|
echo '<div class="col fieldset"><h3>' . __('Import') . '</h3>
|
||||||
<form id="module-pack-import-form" method="post" action="' . dcCore::app()->adminurl->get(My::id()) . '" enctype="multipart/form-data">
|
<form id="module-pack-import-form" method="post" action="' . dcCore::app()->adminurl?->get(My::id()) . '" enctype="multipart/form-data">
|
||||||
<p><label for="packfile">' . __('Select languages package to import:') . '<label> ' .
|
<p><label for="packfile">' . __('Select languages package to import:') . '<label> ' .
|
||||||
'<input id="packfile" type="file" name="packfile" /></p>
|
'<input id="packfile" type="file" name="packfile" /></p>
|
||||||
<p>
|
<p>
|
||||||
<input type="submit" name="save" value="' . __('Import') . '" />' .
|
<input type="submit" name="save" value="' . __('Import') . '" />' .
|
||||||
dcCore::app()->formNonce() .
|
dcCore::app()->formNonce() .
|
||||||
dcCore::app()->adminurl->getHiddenFormFields(
|
dcCore::app()->adminurl?->getHiddenFormFields(
|
||||||
My::id(),
|
My::id(),
|
||||||
['type' => $current->module->type, 'module' => $current->module->id, 'action' => 'module_import_pack']
|
['type' => $current->module->type, 'module' => $current->module->id, 'action' => 'module_import_pack']
|
||||||
) . '
|
) . '
|
||||||
|
@ -437,7 +437,7 @@ class Manage extends dcNsProcess
|
||||||
|
|
||||||
echo
|
echo
|
||||||
'<div id="lang-form">' .
|
'<div id="lang-form">' .
|
||||||
'<form id="lang-edit-form" method="post" action="' . dcCore::app()->adminurl->get(My::id()) . '">' .
|
'<form id="lang-edit-form" method="post" action="' . dcCore::app()->adminurl?->get(My::id()) . '">' .
|
||||||
'<table class="table-outer">' .
|
'<table class="table-outer">' .
|
||||||
'<caption>' . sprintf(__('List of %s localized strings'), count($lines)) . '</caption>' .
|
'<caption>' . sprintf(__('List of %s localized strings'), count($lines)) . '</caption>' .
|
||||||
'<tr>' .
|
'<tr>' .
|
||||||
|
@ -475,7 +475,7 @@ class Manage extends dcNsProcess
|
||||||
foreach ($v as $str) {
|
foreach ($v as $str) {
|
||||||
$res[] = sprintf($table_li, html::escapeHTML($str['module'] . ':' . $str['file']));
|
$res[] = sprintf($table_li, html::escapeHTML($str['module'] . ':' . $str['file']));
|
||||||
}
|
}
|
||||||
$t_msgstr[] = sprintf($table_ul, html::escapeHTML($k), implode('', $res));
|
$t_msgstr[] = sprintf($table_ul, html::escapeHTML((string) $k), implode('', $res));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($rs['files'][0])) {
|
if (!empty($rs['files'][0])) {
|
||||||
|
@ -519,7 +519,7 @@ class Manage extends dcNsProcess
|
||||||
foreach ($v as $str) {
|
foreach ($v as $str) {
|
||||||
$res[] = sprintf($table_li, html::escapeHTML($str['module'] . ':' . $str['file']));
|
$res[] = sprintf($table_li, html::escapeHTML($str['module'] . ':' . $str['file']));
|
||||||
}
|
}
|
||||||
$t_msgstr[] = sprintf($table_ul, html::escapeHTML($k), implode('', $res));
|
$t_msgstr[] = sprintf($table_ul, html::escapeHTML((string) $k), implode('', $res));
|
||||||
}
|
}
|
||||||
|
|
||||||
echo sprintf(
|
echo sprintf(
|
||||||
|
@ -562,9 +562,9 @@ class Manage extends dcNsProcess
|
||||||
'<input id="do-action" type="submit" value="' . __('Save') . ' (s)" accesskey="s" /></p>' .
|
'<input id="do-action" type="submit" value="' . __('Save') . ' (s)" accesskey="s" /></p>' .
|
||||||
dcCore::app()->formNonce() .
|
dcCore::app()->formNonce() .
|
||||||
form::hidden(['code'], $current->lang->code) .
|
form::hidden(['code'], $current->lang->code) .
|
||||||
dcCore::app()->adminurl->getHiddenFormFields(
|
dcCore::app()->adminurl?->getHiddenFormFields(
|
||||||
My::id(),
|
My::id(),
|
||||||
['type' => $current->module->type, 'module' => $current->module->id, 'lang' => $current->lang->code, 'action' => 'module_update_code']
|
['type' => $current->module?->type, 'module' => $current->module?->id, 'lang' => $current->lang->code, 'action' => 'module_update_code']
|
||||||
) .
|
) .
|
||||||
'</p></div>' .
|
'</p></div>' .
|
||||||
'</form>' .
|
'</form>' .
|
||||||
|
@ -579,13 +579,13 @@ class Manage extends dcNsProcess
|
||||||
'<h3><ul class="nice">%s</ul></h3>',
|
'<h3><ul class="nice">%s</ul></h3>',
|
||||||
sprintf(
|
sprintf(
|
||||||
$line,
|
$line,
|
||||||
dcCore::app()->adminurl->get(My::id(), ['type' => 'plugin']),
|
dcCore::app()->adminurl?->get(My::id(), ['type' => 'plugin']),
|
||||||
$current->type == 'plugin' ? ' class="active"' : '',
|
$current->type == 'plugin' ? ' class="active"' : '',
|
||||||
__('Translate plugins')
|
__('Translate plugins')
|
||||||
) .
|
) .
|
||||||
sprintf(
|
sprintf(
|
||||||
$line,
|
$line,
|
||||||
dcCore::app()->adminurl->get(My::id(), ['type' => 'theme']),
|
dcCore::app()->adminurl?->get(My::id(), ['type' => 'theme']),
|
||||||
$current->type == 'theme' ? ' class="active"' : '',
|
$current->type == 'theme' ? ' class="active"' : '',
|
||||||
__('Translate themes')
|
__('Translate themes')
|
||||||
)
|
)
|
||||||
|
@ -603,13 +603,13 @@ class Manage extends dcNsProcess
|
||||||
|
|
||||||
$redir = [
|
$redir = [
|
||||||
'type' => $current->type,
|
'type' => $current->type,
|
||||||
'module' => $current->module->id,
|
'module' => $current->module?->id,
|
||||||
];
|
];
|
||||||
if ($lang) {
|
if ($lang) {
|
||||||
$redir['lang'] = $lang;
|
$redir['lang'] = $lang;
|
||||||
}
|
}
|
||||||
|
|
||||||
dcPage::addSuccessNotice($msg);
|
dcPage::addSuccessNotice($msg);
|
||||||
dcCore::app()->adminurl->redirect(My::id(), $redir);
|
dcCore::app()->adminurl?->redirect(My::id(), $redir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,14 @@ class My
|
||||||
return __((string) dcCore::app()->plugins->moduleInfo(self::id(), 'name'));
|
return __((string) dcCore::app()->plugins->moduleInfo(self::id(), 'name'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check php version
|
||||||
|
*/
|
||||||
|
public static function phpCompliant(): bool
|
||||||
|
{
|
||||||
|
return version_compare(phpversion(), self::PHP_MIN, '>=');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of allowed backup folder
|
* List of allowed backup folder
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -68,23 +68,23 @@ class Settings
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$s = dcCore::app()->blog->settings->get(My::id());
|
$s = dcCore::app()->blog?->settings->get(My::id());
|
||||||
|
|
||||||
$this->plugin_menu = (bool) ($s->get('plugin_menu') ?? false);
|
$this->plugin_menu = (bool) ($s?->get('plugin_menu') ?? false);
|
||||||
$this->theme_menu = (bool) ($s->get('theme_menu') ?? false);
|
$this->theme_menu = (bool) ($s?->get('theme_menu') ?? false);
|
||||||
$this->backup_auto = (bool) ($s->get('backup_auto') ?? false);
|
$this->backup_auto = (bool) ($s?->get('backup_auto') ?? false);
|
||||||
$this->backup_limit = (int) ($s->get('backup_limit') ?? 20);
|
$this->backup_limit = (int) ($s?->get('backup_limit') ?? 20);
|
||||||
$this->backup_folder = (string) ($s->get('backup_folder') ?? 'module');
|
$this->backup_folder = (string) ($s?->get('backup_folder') ?? 'module');
|
||||||
$this->start_page = (string) ($s->get('start_page') ?? '-');
|
$this->start_page = (string) ($s?->get('start_page') ?? '-');
|
||||||
$this->write_langphp = (bool) ($s->get('write_langphp') ?? false);
|
$this->write_langphp = (bool) ($s?->get('write_langphp') ?? false);
|
||||||
$this->scan_tpl = (bool) ($s->get('scan_tpl') ?? true);
|
$this->scan_tpl = (bool) ($s?->get('scan_tpl') ?? true);
|
||||||
$this->parse_nodc = (bool) ($s->get('parse_nodc') ?? true);
|
$this->parse_nodc = (bool) ($s?->get('parse_nodc') ?? true);
|
||||||
$this->hide_default = (bool) ($s->get('hide_default') ?? true);
|
$this->hide_default = (bool) ($s?->get('hide_default') ?? true);
|
||||||
$this->parse_comment = (bool) ($s->get('parse_comment') ?? false);
|
$this->parse_comment = (bool) ($s?->get('parse_comment') ?? false);
|
||||||
$this->parse_user = (bool) ($s->get('parse_user') ?? false);
|
$this->parse_user = (bool) ($s?->get('parse_user') ?? false);
|
||||||
$this->parse_userinfo = (string) ($s->get('parse_userinfo') ?? 'displayname, email');
|
$this->parse_userinfo = (string) ($s?->get('parse_userinfo') ?? 'displayname, email');
|
||||||
$this->import_overwrite = (bool) ($s->get('import_overwrite') ?? false);
|
$this->import_overwrite = (bool) ($s?->get('import_overwrite') ?? false);
|
||||||
$this->export_filename = (string) ($s->get('export_filename') ?? 'type-module-l10n-timestamp');
|
$this->export_filename = (string) ($s?->get('export_filename') ?? 'type-module-l10n-timestamp');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSetting(string $key): mixed
|
public function getSetting(string $key): mixed
|
||||||
|
@ -103,8 +103,8 @@ class Settings
|
||||||
public function writeSetting(string $key, mixed $value): bool
|
public function writeSetting(string $key, mixed $value): bool
|
||||||
{
|
{
|
||||||
if (property_exists($this, $key) && settype($value, gettype($this->{$key})) === true) {
|
if (property_exists($this, $key) && settype($value, gettype($this->{$key})) === true) {
|
||||||
dcCore::app()->blog->settings->get(My::id())->drop($key);
|
dcCore::app()->blog?->settings->get(My::id())->drop($key);
|
||||||
dcCore::app()->blog->settings->get(My::id())->put($key, $value, gettype($this->{$key}), '', true, true);
|
dcCore::app()->blog?->settings->get(My::id())->put($key, $value, gettype($this->{$key}), '', true, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ class Translater extends Settings
|
||||||
|
|
||||||
if (!(dcCore::app()->themes instanceof dcThemes)) {
|
if (!(dcCore::app()->themes instanceof dcThemes)) {
|
||||||
dcCore::app()->themes = new dcThemes();
|
dcCore::app()->themes = new dcThemes();
|
||||||
dcCore::app()->themes->loadModules(dcCore::app()->blog->themes_path, null);
|
dcCore::app()->themes->loadModules((string) dcCore::app()->blog?->themes_path, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ([
|
foreach ([
|
||||||
|
|
|
@ -131,11 +131,11 @@ class TranslaterLang
|
||||||
$msgs = [];
|
$msgs = [];
|
||||||
# php files
|
# php files
|
||||||
if ($extension == 'php') {
|
if ($extension == 'php') {
|
||||||
$msgs = Translater::extractPhpMsgs($contents);
|
$msgs = Translater::extractPhpMsgs((string) $contents);
|
||||||
|
|
||||||
# tpl files
|
# tpl files
|
||||||
} elseif ($extension == 'html') {
|
} elseif ($extension == 'html') {
|
||||||
$msgs = Translater::extractTplMsgs($contents);
|
$msgs = Translater::extractTplMsgs((string) $contents);
|
||||||
}
|
}
|
||||||
foreach ($msgs as $msg) {
|
foreach ($msgs as $msg) {
|
||||||
$res[] = [
|
$res[] = [
|
||||||
|
|
|
@ -68,7 +68,7 @@ class TranslaterModule
|
||||||
$this->author = $define->get('author');
|
$this->author = $define->get('author');
|
||||||
$this->version = $define->get('version');
|
$this->version = $define->get('version');
|
||||||
$this->root_writable = $define->get('root_writable');
|
$this->root_writable = $define->get('root_writable');
|
||||||
$this->root = path::real($define->get('root'));
|
$this->root = (string) path::real($define->get('root'), false);
|
||||||
$this->locales = $this->root . DIRECTORY_SEPARATOR . My::LOCALES_FOLDER;
|
$this->locales = $this->root . DIRECTORY_SEPARATOR . My::LOCALES_FOLDER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,15 +94,15 @@ class TranslaterModule
|
||||||
case 'plugin':
|
case 'plugin':
|
||||||
$exp = explode(PATH_SEPARATOR, DC_PLUGINS_ROOT);
|
$exp = explode(PATH_SEPARATOR, DC_PLUGINS_ROOT);
|
||||||
$tmp = path::real(array_pop($exp));
|
$tmp = path::real(array_pop($exp));
|
||||||
if ($tmp && is_writable($tmp)) {
|
if ($tmp !== false && is_writable($tmp)) {
|
||||||
$dir = $tmp;
|
$dir = $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'public':
|
case 'public':
|
||||||
$tmp = path::real(dcCore::app()->blog->public_path);
|
$tmp = path::real((string) dcCore::app()->blog?->public_path);
|
||||||
if ($tmp && is_writable($tmp)) {
|
if ($tmp !== false && is_writable($tmp)) {
|
||||||
$dir = $tmp;
|
$dir = $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ class TranslaterModule
|
||||||
|
|
||||||
case 'cache':
|
case 'cache':
|
||||||
$tmp = path::real(DC_TPL_CACHE);
|
$tmp = path::real(DC_TPL_CACHE);
|
||||||
if ($tmp && is_writable($tmp)) {
|
if ($tmp !== false && is_writable($tmp)) {
|
||||||
@mkDir($tmp . '/l10n');
|
@mkDir($tmp . '/l10n');
|
||||||
$dir = $tmp . '/l10n';
|
$dir = $tmp . '/l10n';
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ class TranslaterModule
|
||||||
|
|
||||||
case 'translater':
|
case 'translater':
|
||||||
$tmp = path::real(dcCore::app()->plugins->moduleRoot(My::id()));
|
$tmp = path::real(dcCore::app()->plugins->moduleRoot(My::id()));
|
||||||
if ($tmp && is_writable($tmp)) {
|
if ($tmp !== false && is_writable($tmp)) {
|
||||||
@mkDir($tmp . DIRECTORY_SEPARATOR . My::LOCALES_FOLDER);
|
@mkDir($tmp . DIRECTORY_SEPARATOR . My::LOCALES_FOLDER);
|
||||||
$dir = $tmp . DIRECTORY_SEPARATOR . My::LOCALES_FOLDER;
|
$dir = $tmp . DIRECTORY_SEPARATOR . My::LOCALES_FOLDER;
|
||||||
}
|
}
|
||||||
|
@ -185,8 +185,11 @@ class TranslaterModule
|
||||||
public function createBackup(string $lang): bool
|
public function createBackup(string $lang): bool
|
||||||
{
|
{
|
||||||
$backup = $this->getBackupRoot(true);
|
$backup = $this->getBackupRoot(true);
|
||||||
$dir = $this->locales . DIRECTORY_SEPARATOR . $lang;
|
if (!$backup) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$dir = $this->locales . DIRECTORY_SEPARATOR . $lang;
|
||||||
if (!is_dir($dir)) {
|
if (!is_dir($dir)) {
|
||||||
throw new Exception(sprintf(
|
throw new Exception(sprintf(
|
||||||
__('Failed to find language %s'),
|
__('Failed to find language %s'),
|
||||||
|
@ -549,7 +552,7 @@ class TranslaterModule
|
||||||
|
|
||||||
files::putContent(
|
files::putContent(
|
||||||
implode(DIRECTORY_SEPARATOR, [$this->locales, $lang, $file]),
|
implode(DIRECTORY_SEPARATOR, [$this->locales, $lang, $file]),
|
||||||
file_get_contents(implode(DIRECTORY_SEPARATOR, [$this->locales, $from_lang, $file]))
|
(string) file_get_contents(implode(DIRECTORY_SEPARATOR, [$this->locales, $from_lang, $file]))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -619,6 +622,7 @@ class TranslaterModule
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($rs as $group => $msgs) {
|
foreach ($rs as $group => $msgs) {
|
||||||
|
$group = (string) $group;
|
||||||
$this->setPoContent($lang, $group, $msgs);
|
$this->setPoContent($lang, $group, $msgs);
|
||||||
$this->setLangphpContent($lang, $group, $msgs);
|
$this->setLangphpContent($lang, $group, $msgs);
|
||||||
}
|
}
|
||||||
|
@ -687,7 +691,7 @@ class TranslaterModule
|
||||||
$search = My::defaultUserInformations();
|
$search = My::defaultUserInformations();
|
||||||
$replace = [];
|
$replace = [];
|
||||||
foreach ($search as $n) {
|
foreach ($search as $n) {
|
||||||
$replace[] = dcCore::app()->auth->getInfo('user_' . $n);
|
$replace[] = dcCore::app()->auth?->getInfo('user_' . $n);
|
||||||
}
|
}
|
||||||
$info = trim(str_replace($search, $replace, $this->translater->parse_userinfo));
|
$info = trim(str_replace($search, $replace, $this->translater->parse_userinfo));
|
||||||
if (!empty($info)) {
|
if (!empty($info)) {
|
||||||
|
@ -702,7 +706,7 @@ class TranslaterModule
|
||||||
'"Project-Id-Version: ' . $this->id . ' ' . $this->version . '\n"' . "\n" .
|
'"Project-Id-Version: ' . $this->id . ' ' . $this->version . '\n"' . "\n" .
|
||||||
'"POT-Creation-Date: \n"' . "\n" .
|
'"POT-Creation-Date: \n"' . "\n" .
|
||||||
'"PO-Revision-Date: ' . date('c') . '\n"' . "\n" .
|
'"PO-Revision-Date: ' . date('c') . '\n"' . "\n" .
|
||||||
'"Last-Translator: ' . dcCore::app()->auth->getInfo('user_cn') . '\n"' . "\n" .
|
'"Last-Translator: ' . dcCore::app()->auth?->getInfo('user_cn') . '\n"' . "\n" .
|
||||||
'"Language-Team: \n"' . "\n" .
|
'"Language-Team: \n"' . "\n" .
|
||||||
'"MIME-Version: 1.0\n"' . "\n" .
|
'"MIME-Version: 1.0\n"' . "\n" .
|
||||||
'"Content-Transfer-Encoding: 8bit\n"' . "\n" .
|
'"Content-Transfer-Encoding: 8bit\n"' . "\n" .
|
||||||
|
@ -779,7 +783,7 @@ class TranslaterModule
|
||||||
$search = My::defaultUserInformations();
|
$search = My::defaultUserInformations();
|
||||||
$replace = [];
|
$replace = [];
|
||||||
foreach ($search as $n) {
|
foreach ($search as $n) {
|
||||||
$replace[] = dcCore::app()->auth->getInfo('user_' . $n);
|
$replace[] = dcCore::app()->auth?->getInfo('user_' . $n);
|
||||||
}
|
}
|
||||||
$info = trim(str_replace($search, $replace, $this->translater->parse_userinfo));
|
$info = trim(str_replace($search, $replace, $this->translater->parse_userinfo));
|
||||||
if (!empty($info)) {
|
if (!empty($info)) {
|
||||||
|
|
Loading…
Reference in a new issue