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 {
|
||||
$favs->register(My::id(), [
|
||||
'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')),
|
||||
'large-icon' => urldecode(dcPage::getPF(My::id() . '/icon.svg')),
|
||||
//'permissions' => null,
|
||||
|
@ -53,13 +53,13 @@ class Backend extends dcNsProcess
|
|||
|
||||
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
||||
My::name(),
|
||||
dcCore::app()->adminurl->get(My::id()),
|
||||
dcCore::app()->adminurl?->get(My::id()),
|
||||
dcPage::getPF(My::id() . '/icon.svg'),
|
||||
preg_match(
|
||||
'/' . preg_quote(dcCore::app()->adminurl->get(My::id())) . '(&.*)?$/',
|
||||
'/' . preg_quote((string) dcCore::app()->adminurl?->get(My::id())) . '(&.*)?$/',
|
||||
$_SERVER['REQUEST_URI']
|
||||
),
|
||||
dcCore::app()->auth->isSuperAdmin()
|
||||
dcCore::app()->auth?->isSuperAdmin()
|
||||
);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -51,7 +51,7 @@ class BackendBehaviors
|
|||
{
|
||||
if ($list->getList() != $prop['type'] . '-activate'
|
||||
|| !self::translater()->getSetting($prop['type'] . '_menu')
|
||||
|| !dcCore::app()->auth->isSuperAdmin()
|
||||
|| !dcCore::app()->auth?->isSuperAdmin()
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ class BackendBehaviors
|
|||
return;
|
||||
}
|
||||
|
||||
dcCore::app()->adminurl->redirect(
|
||||
dcCore::app()->adminurl?->redirect(
|
||||
My::id(),
|
||||
['part' => 'module', 'type' => $type, 'module' => key($_POST['translater'])],
|
||||
'#module-lang'
|
||||
|
|
|
@ -63,7 +63,7 @@ class Config extends dcNsProcess
|
|||
dcPage::addSuccessNotice(
|
||||
__('Configuration successfully updated.')
|
||||
);
|
||||
dcCore::app()->adminurl->redirect(
|
||||
dcCore::app()->adminurl?->redirect(
|
||||
'admin.plugins',
|
||||
['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 (empty($_FILES['packfile']['name'])) {
|
||||
if (empty($current->module) || empty($_FILES['packfile']['name'])) {
|
||||
throw new Exception(__('Nothing to import'));
|
||||
}
|
||||
$current->module->importPack($_FILES['packfile']);
|
||||
|
@ -146,23 +146,23 @@ class Manage extends dcNsProcess
|
|||
|
||||
public static function render(): void
|
||||
{
|
||||
if (!self::$init) {
|
||||
if (!static::$init) {
|
||||
return;
|
||||
}
|
||||
|
||||
$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)) {
|
||||
$breadcrumb = [My::name() => ''];
|
||||
} elseif (empty($current->module)) {
|
||||
$breadcrumb[$current->type == 'plugin' ? __('Plugins') : __('Themes')] = '';
|
||||
} 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)] = '';
|
||||
} elseif (!empty($current->lang)) {
|
||||
$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[$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(sprintf(__('%s language edition'), $current->lang->name))] = '';
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ class Manage extends dcNsProcess
|
|||
|
||||
if (empty($current->module) && $current->type != '') {
|
||||
// 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 = '';
|
||||
$modules = $current->translater->getModules($current->type);
|
||||
|
@ -199,7 +199,7 @@ class Manage extends dcNsProcess
|
|||
if ($module->root_writable) {
|
||||
$res .= sprintf(
|
||||
'<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($module->id)
|
||||
);
|
||||
|
@ -215,7 +215,7 @@ class Manage extends dcNsProcess
|
|||
$codes[$code_id] = sprintf(
|
||||
'<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))),
|
||||
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),
|
||||
$code_id
|
||||
);
|
||||
|
@ -267,7 +267,7 @@ class Manage extends dcNsProcess
|
|||
if (count($codes)) {
|
||||
echo
|
||||
'<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">' .
|
||||
'<caption>' . __('Existing languages translations') . '</caption>' .
|
||||
'<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="nowrap">' .
|
||||
'<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>' .
|
||||
'</td>' .
|
||||
'<td class="nowrap maximal"> ' . $code_id . '</td>';
|
||||
|
@ -297,7 +297,7 @@ class Manage extends dcNsProcess
|
|||
echo
|
||||
'<td class="nowrap">' . count($backups[$code_id]) . '</td>' .
|
||||
'<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>';
|
||||
} else {
|
||||
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>' .
|
||||
dcCore::app()->formNonce() .
|
||||
dcCore::app()->adminurl->getHiddenFormFields(
|
||||
dcCore::app()->adminurl?->getHiddenFormFields(
|
||||
My::id(),
|
||||
['type' => $current->module->type, 'module' => $current->module->id]
|
||||
) . '
|
||||
|
@ -328,7 +328,7 @@ class Manage extends dcNsProcess
|
|||
// delete / retore backups
|
||||
if (!empty($backups)) {
|
||||
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">' .
|
||||
'<caption>' . __('Existing languages backups') . '</caption>' .
|
||||
'<tr>' .
|
||||
|
@ -360,9 +360,9 @@ class Manage extends dcNsProcess
|
|||
$backup_code['name'],
|
||||
$backup_code['code'],
|
||||
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'],
|
||||
dcCore::app()->blog->settings->get('system')->get('blog_timezone')
|
||||
dcCore::app()->blog?->settings->get('system')->get('blog_timezone')
|
||||
),
|
||||
$backup_code['path']['basename'],
|
||||
files::size($backup_code['size'])
|
||||
|
@ -381,7 +381,7 @@ class Manage extends dcNsProcess
|
|||
]) . '
|
||||
<input id="do-action" type="submit" value="' . __('ok') . '" /></p>' .
|
||||
dcCore::app()->formNonce() .
|
||||
dcCore::app()->adminurl->getHiddenFormFields(
|
||||
dcCore::app()->adminurl?->getHiddenFormFields(
|
||||
My::id(),
|
||||
['type' => $current->module->type, 'module' => $current->module->id]
|
||||
) . '
|
||||
|
@ -394,9 +394,9 @@ class Manage extends dcNsProcess
|
|||
// add language
|
||||
if (!empty($unused_codes)) {
|
||||
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>' .
|
||||
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)) {
|
||||
echo '<p>' . form::hidden(['from'], '') . '</p>';
|
||||
} else {
|
||||
|
@ -407,7 +407,7 @@ class Manage extends dcNsProcess
|
|||
echo '
|
||||
<p><input type="submit" name="save" value="' . __('Create') . '" />' .
|
||||
dcCore::app()->formNonce() .
|
||||
dcCore::app()->adminurl->getHiddenFormFields(
|
||||
dcCore::app()->adminurl?->getHiddenFormFields(
|
||||
My::id(),
|
||||
['type' => $current->module->type, 'module' => $current->module->id, 'action' => 'module_add_code']
|
||||
) . '
|
||||
|
@ -416,13 +416,13 @@ class Manage extends dcNsProcess
|
|||
|
||||
// Import
|
||||
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> ' .
|
||||
'<input id="packfile" type="file" name="packfile" /></p>
|
||||
<p>
|
||||
<input type="submit" name="save" value="' . __('Import') . '" />' .
|
||||
dcCore::app()->formNonce() .
|
||||
dcCore::app()->adminurl->getHiddenFormFields(
|
||||
dcCore::app()->adminurl?->getHiddenFormFields(
|
||||
My::id(),
|
||||
['type' => $current->module->type, 'module' => $current->module->id, 'action' => 'module_import_pack']
|
||||
) . '
|
||||
|
@ -437,7 +437,7 @@ class Manage extends dcNsProcess
|
|||
|
||||
echo
|
||||
'<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">' .
|
||||
'<caption>' . sprintf(__('List of %s localized strings'), count($lines)) . '</caption>' .
|
||||
'<tr>' .
|
||||
|
@ -475,7 +475,7 @@ class Manage extends dcNsProcess
|
|||
foreach ($v as $str) {
|
||||
$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])) {
|
||||
|
@ -519,7 +519,7 @@ class Manage extends dcNsProcess
|
|||
foreach ($v as $str) {
|
||||
$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(
|
||||
|
@ -562,9 +562,9 @@ class Manage extends dcNsProcess
|
|||
'<input id="do-action" type="submit" value="' . __('Save') . ' (s)" accesskey="s" /></p>' .
|
||||
dcCore::app()->formNonce() .
|
||||
form::hidden(['code'], $current->lang->code) .
|
||||
dcCore::app()->adminurl->getHiddenFormFields(
|
||||
dcCore::app()->adminurl?->getHiddenFormFields(
|
||||
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>' .
|
||||
'</form>' .
|
||||
|
@ -579,13 +579,13 @@ class Manage extends dcNsProcess
|
|||
'<h3><ul class="nice">%s</ul></h3>',
|
||||
sprintf(
|
||||
$line,
|
||||
dcCore::app()->adminurl->get(My::id(), ['type' => 'plugin']),
|
||||
dcCore::app()->adminurl?->get(My::id(), ['type' => 'plugin']),
|
||||
$current->type == 'plugin' ? ' class="active"' : '',
|
||||
__('Translate plugins')
|
||||
) .
|
||||
sprintf(
|
||||
$line,
|
||||
dcCore::app()->adminurl->get(My::id(), ['type' => 'theme']),
|
||||
dcCore::app()->adminurl?->get(My::id(), ['type' => 'theme']),
|
||||
$current->type == 'theme' ? ' class="active"' : '',
|
||||
__('Translate themes')
|
||||
)
|
||||
|
@ -603,13 +603,13 @@ class Manage extends dcNsProcess
|
|||
|
||||
$redir = [
|
||||
'type' => $current->type,
|
||||
'module' => $current->module->id,
|
||||
'module' => $current->module?->id,
|
||||
];
|
||||
if ($lang) {
|
||||
$redir['lang'] = $lang;
|
||||
}
|
||||
|
||||
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'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check php version
|
||||
*/
|
||||
public static function phpCompliant(): bool
|
||||
{
|
||||
return version_compare(phpversion(), self::PHP_MIN, '>=');
|
||||
}
|
||||
|
||||
/**
|
||||
* List of allowed backup folder
|
||||
*/
|
||||
|
|
|
@ -68,23 +68,23 @@ class Settings
|
|||
*/
|
||||
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->theme_menu = (bool) ($s->get('theme_menu') ?? false);
|
||||
$this->backup_auto = (bool) ($s->get('backup_auto') ?? false);
|
||||
$this->backup_limit = (int) ($s->get('backup_limit') ?? 20);
|
||||
$this->backup_folder = (string) ($s->get('backup_folder') ?? 'module');
|
||||
$this->start_page = (string) ($s->get('start_page') ?? '-');
|
||||
$this->write_langphp = (bool) ($s->get('write_langphp') ?? false);
|
||||
$this->scan_tpl = (bool) ($s->get('scan_tpl') ?? true);
|
||||
$this->parse_nodc = (bool) ($s->get('parse_nodc') ?? true);
|
||||
$this->hide_default = (bool) ($s->get('hide_default') ?? true);
|
||||
$this->parse_comment = (bool) ($s->get('parse_comment') ?? false);
|
||||
$this->parse_user = (bool) ($s->get('parse_user') ?? false);
|
||||
$this->parse_userinfo = (string) ($s->get('parse_userinfo') ?? 'displayname, email');
|
||||
$this->import_overwrite = (bool) ($s->get('import_overwrite') ?? false);
|
||||
$this->export_filename = (string) ($s->get('export_filename') ?? 'type-module-l10n-timestamp');
|
||||
$this->plugin_menu = (bool) ($s?->get('plugin_menu') ?? false);
|
||||
$this->theme_menu = (bool) ($s?->get('theme_menu') ?? false);
|
||||
$this->backup_auto = (bool) ($s?->get('backup_auto') ?? false);
|
||||
$this->backup_limit = (int) ($s?->get('backup_limit') ?? 20);
|
||||
$this->backup_folder = (string) ($s?->get('backup_folder') ?? 'module');
|
||||
$this->start_page = (string) ($s?->get('start_page') ?? '-');
|
||||
$this->write_langphp = (bool) ($s?->get('write_langphp') ?? false);
|
||||
$this->scan_tpl = (bool) ($s?->get('scan_tpl') ?? true);
|
||||
$this->parse_nodc = (bool) ($s?->get('parse_nodc') ?? true);
|
||||
$this->hide_default = (bool) ($s?->get('hide_default') ?? true);
|
||||
$this->parse_comment = (bool) ($s?->get('parse_comment') ?? false);
|
||||
$this->parse_user = (bool) ($s?->get('parse_user') ?? false);
|
||||
$this->parse_userinfo = (string) ($s?->get('parse_userinfo') ?? 'displayname, email');
|
||||
$this->import_overwrite = (bool) ($s?->get('import_overwrite') ?? false);
|
||||
$this->export_filename = (string) ($s?->get('export_filename') ?? 'type-module-l10n-timestamp');
|
||||
}
|
||||
|
||||
public function getSetting(string $key): mixed
|
||||
|
@ -103,8 +103,8 @@ class Settings
|
|||
public function writeSetting(string $key, mixed $value): bool
|
||||
{
|
||||
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())->put($key, $value, gettype($this->{$key}), '', true, true);
|
||||
dcCore::app()->blog?->settings->get(My::id())->drop($key);
|
||||
dcCore::app()->blog?->settings->get(My::id())->put($key, $value, gettype($this->{$key}), '', true, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ class Translater extends Settings
|
|||
|
||||
if (!(dcCore::app()->themes instanceof 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 ([
|
||||
|
|
|
@ -131,11 +131,11 @@ class TranslaterLang
|
|||
$msgs = [];
|
||||
# php files
|
||||
if ($extension == 'php') {
|
||||
$msgs = Translater::extractPhpMsgs($contents);
|
||||
$msgs = Translater::extractPhpMsgs((string) $contents);
|
||||
|
||||
# tpl files
|
||||
} elseif ($extension == 'html') {
|
||||
$msgs = Translater::extractTplMsgs($contents);
|
||||
$msgs = Translater::extractTplMsgs((string) $contents);
|
||||
}
|
||||
foreach ($msgs as $msg) {
|
||||
$res[] = [
|
||||
|
|
|
@ -68,7 +68,7 @@ class TranslaterModule
|
|||
$this->author = $define->get('author');
|
||||
$this->version = $define->get('version');
|
||||
$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;
|
||||
}
|
||||
|
||||
|
@ -94,15 +94,15 @@ class TranslaterModule
|
|||
case 'plugin':
|
||||
$exp = explode(PATH_SEPARATOR, DC_PLUGINS_ROOT);
|
||||
$tmp = path::real(array_pop($exp));
|
||||
if ($tmp && is_writable($tmp)) {
|
||||
if ($tmp !== false && is_writable($tmp)) {
|
||||
$dir = $tmp;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'public':
|
||||
$tmp = path::real(dcCore::app()->blog->public_path);
|
||||
if ($tmp && is_writable($tmp)) {
|
||||
$tmp = path::real((string) dcCore::app()->blog?->public_path);
|
||||
if ($tmp !== false && is_writable($tmp)) {
|
||||
$dir = $tmp;
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ class TranslaterModule
|
|||
|
||||
case 'cache':
|
||||
$tmp = path::real(DC_TPL_CACHE);
|
||||
if ($tmp && is_writable($tmp)) {
|
||||
if ($tmp !== false && is_writable($tmp)) {
|
||||
@mkDir($tmp . '/l10n');
|
||||
$dir = $tmp . '/l10n';
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ class TranslaterModule
|
|||
|
||||
case 'translater':
|
||||
$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);
|
||||
$dir = $tmp . DIRECTORY_SEPARATOR . My::LOCALES_FOLDER;
|
||||
}
|
||||
|
@ -185,8 +185,11 @@ class TranslaterModule
|
|||
public function createBackup(string $lang): bool
|
||||
{
|
||||
$backup = $this->getBackupRoot(true);
|
||||
$dir = $this->locales . DIRECTORY_SEPARATOR . $lang;
|
||||
if (!$backup) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$dir = $this->locales . DIRECTORY_SEPARATOR . $lang;
|
||||
if (!is_dir($dir)) {
|
||||
throw new Exception(sprintf(
|
||||
__('Failed to find language %s'),
|
||||
|
@ -549,7 +552,7 @@ class TranslaterModule
|
|||
|
||||
files::putContent(
|
||||
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 {
|
||||
|
@ -619,6 +622,7 @@ class TranslaterModule
|
|||
}
|
||||
|
||||
foreach ($rs as $group => $msgs) {
|
||||
$group = (string) $group;
|
||||
$this->setPoContent($lang, $group, $msgs);
|
||||
$this->setLangphpContent($lang, $group, $msgs);
|
||||
}
|
||||
|
@ -687,7 +691,7 @@ class TranslaterModule
|
|||
$search = My::defaultUserInformations();
|
||||
$replace = [];
|
||||
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));
|
||||
if (!empty($info)) {
|
||||
|
@ -702,7 +706,7 @@ class TranslaterModule
|
|||
'"Project-Id-Version: ' . $this->id . ' ' . $this->version . '\n"' . "\n" .
|
||||
'"POT-Creation-Date: \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" .
|
||||
'"MIME-Version: 1.0\n"' . "\n" .
|
||||
'"Content-Transfer-Encoding: 8bit\n"' . "\n" .
|
||||
|
@ -779,7 +783,7 @@ class TranslaterModule
|
|||
$search = My::defaultUserInformations();
|
||||
$replace = [];
|
||||
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));
|
||||
if (!empty($info)) {
|
||||
|
|
Loading…
Reference in a new issue