prepare to DC 2.24
This commit is contained in:
parent
47c4c47654
commit
f2adddec5e
35
_admin.php
35
_admin.php
@ -14,19 +14,19 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$core->addBehavior('adminModulesListGetActions', ['translaterAdminBehaviors', 'adminModulesGetActions']);
|
dcCore::app()->addBehavior('adminModulesListGetActions', ['translaterAdminBehaviors', 'adminModulesGetActions']);
|
||||||
$core->addBehavior('adminModulesListDoActions', ['translaterAdminBehaviors', 'adminModulesDoActions']);
|
dcCore::app()->addBehavior('adminModulesListDoActions', ['translaterAdminBehaviors', 'adminModulesDoActions']);
|
||||||
$core->addBehavior('adminDashboardFavorites', ['translaterAdminBehaviors', 'adminDashboardFavorites']);
|
dcCore::app()->addBehavior('adminDashboardFavoritesV2', ['translaterAdminBehaviors', 'adminDashboardFavorites']);
|
||||||
|
|
||||||
$_menu['Plugins']->addItem(
|
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
||||||
__('Translater'),
|
__('Translater'),
|
||||||
$core->adminurl->get('translater'),
|
dcCore::app()->adminurl->get('translater'),
|
||||||
dcPage::getPF('translater/icon.png'),
|
dcPage::getPF('translater/icon.png'),
|
||||||
preg_match(
|
preg_match(
|
||||||
'/' . preg_quote($core->adminurl->get('translater')) . '(&.*)?$/',
|
'/' . preg_quote(dcCore::app()->adminurl->get('translater')) . '(&.*)?$/',
|
||||||
$_SERVER['REQUEST_URI']
|
$_SERVER['REQUEST_URI']
|
||||||
),
|
),
|
||||||
$core->auth->isSuperAdmin()
|
dcCore::app()->auth->isSuperAdmin()
|
||||||
);
|
);
|
||||||
|
|
||||||
class translaterAdminBehaviors
|
class translaterAdminBehaviors
|
||||||
@ -37,14 +37,12 @@ class translaterAdminBehaviors
|
|||||||
/**
|
/**
|
||||||
* Create instance of dcTranslater once
|
* Create instance of dcTranslater once
|
||||||
*
|
*
|
||||||
* @param dcCore $core dcCore instance
|
|
||||||
*
|
|
||||||
* @return dcTranslater dcTranslater instance
|
* @return dcTranslater dcTranslater instance
|
||||||
*/
|
*/
|
||||||
private static function translater(dcCore $core): dcTranslater
|
private static function translater(): dcTranslater
|
||||||
{
|
{
|
||||||
if (!is_a(self::$translater, 'dcTranslater')) {
|
if (!is_a(self::$translater, 'dcTranslater')) {
|
||||||
self::$translater = new dcTranslater($core, false);
|
self::$translater = new dcTranslater(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::$translater;
|
return self::$translater;
|
||||||
@ -62,12 +60,12 @@ class translaterAdminBehaviors
|
|||||||
public static function adminModulesGetActions(adminModulesList $list, string $id, array $prop): ?string
|
public static function adminModulesGetActions(adminModulesList $list, string $id, array $prop): ?string
|
||||||
{
|
{
|
||||||
if ($list->getList() != $prop['type'] . '-activate'
|
if ($list->getList() != $prop['type'] . '-activate'
|
||||||
|| !self::translater($list->core)->{$prop['type'] . '_menu'}
|
|| !self::translater()->{$prop['type'] . '_menu'}
|
||||||
|| !$list->core->auth->isSuperAdmin()
|
|| !dcCore::app()->auth->isSuperAdmin()
|
||||||
) {
|
) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (self::translater($list->core)->hide_default
|
if (self::translater()->hide_default
|
||||||
&& in_array($id, dcTranslater::$default_distrib_modules[$prop['type']])
|
&& in_array($id, dcTranslater::$default_distrib_modules[$prop['type']])
|
||||||
) {
|
) {
|
||||||
return null;
|
return null;
|
||||||
@ -92,7 +90,7 @@ class translaterAdminBehaviors
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$list->core->adminurl->redirect(
|
dcCore::app()->adminurl->redirect(
|
||||||
'translater',
|
'translater',
|
||||||
['part' => 'module', 'type' => $type, 'module' => key($_POST['translater'])],
|
['part' => 'module', 'type' => $type, 'module' => key($_POST['translater'])],
|
||||||
'#module-lang'
|
'#module-lang'
|
||||||
@ -102,17 +100,16 @@ class translaterAdminBehaviors
|
|||||||
/**
|
/**
|
||||||
* Add dashboard favorites icon
|
* Add dashboard favorites icon
|
||||||
*
|
*
|
||||||
* @param dcCore $core dcCore instance
|
|
||||||
* @param dcFavorites $favs dcFavorites instance
|
* @param dcFavorites $favs dcFavorites instance
|
||||||
*/
|
*/
|
||||||
public static function adminDashboardFavorites(dcCore $core, dcFavorites$favs): void
|
public static function adminDashboardFavorites(dcFavorites$favs): void
|
||||||
{
|
{
|
||||||
$favs->register('translater', [
|
$favs->register('translater', [
|
||||||
'title' => __('Translater'),
|
'title' => __('Translater'),
|
||||||
'url' => $core->adminurl->get('translater'),
|
'url' => dcCore::app()->adminurl->get('translater'),
|
||||||
'small-icon' => urldecode(dcPage::getPF('translater/icon.png')),
|
'small-icon' => urldecode(dcPage::getPF('translater/icon.png')),
|
||||||
'large-icon' => urldecode(dcPage::getPF('translater/icon-big.png')),
|
'large-icon' => urldecode(dcPage::getPF('translater/icon-big.png')),
|
||||||
'permissions' => $core->auth->isSuperAdmin()
|
'permissions' => dcCore::app()->auth->isSuperAdmin(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
_config.php
12
_config.php
@ -14,7 +14,7 @@ if (!defined('DC_CONTEXT_MODULE')) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$translater = new dcTranslater($core);
|
$translater = new dcTranslater();
|
||||||
|
|
||||||
if (!empty($_POST['save'])) {
|
if (!empty($_POST['save'])) {
|
||||||
try {
|
try {
|
||||||
@ -22,15 +22,15 @@ if (!empty($_POST['save'])) {
|
|||||||
$translater->$key = $_POST[$key] ?? '';
|
$translater->$key = $_POST[$key] ?? '';
|
||||||
}
|
}
|
||||||
$translater->writeSettings();
|
$translater->writeSettings();
|
||||||
dcPage::addSuccessNotice(
|
dcAdminNotices::addSuccessNotice(
|
||||||
__('Configuration successfully updated.')
|
__('Configuration successfully updated.')
|
||||||
);
|
);
|
||||||
$core->adminurl->redirect(
|
dcCore::app()->adminurl->redirect(
|
||||||
'admin.plugins',
|
'admin.plugins',
|
||||||
['module' => 'translater', 'conf' => 1, 'redir' => $list->getRedir()]
|
['module' => 'translater', 'conf' => 1, 'redir' => dcCore::app()->admin->list->getRedir()]
|
||||||
);
|
);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$core->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ form::combo('backup_folder', $translater::$allowed_backup_folders, $translater->
|
|||||||
form::combo('start_page', [
|
form::combo('start_page', [
|
||||||
__('Plugins') => 'plugin',
|
__('Plugins') => 'plugin',
|
||||||
__('Themes') => 'theme',
|
__('Themes') => 'theme',
|
||||||
__('Home') => '-'
|
__('Home') => '-',
|
||||||
], $translater->start_page) . '</p>
|
], $translater->start_page) . '</p>
|
||||||
<p><label for="plugin_menu">' .
|
<p><label for="plugin_menu">' .
|
||||||
form::checkbox('plugin_menu', '1', $translater->plugin_menu) .
|
form::checkbox('plugin_menu', '1', $translater->plugin_menu) .
|
||||||
|
@ -18,13 +18,13 @@ $this->registerModule(
|
|||||||
'Translater',
|
'Translater',
|
||||||
'Translate your Dotclear plugins and themes',
|
'Translate your Dotclear plugins and themes',
|
||||||
'Jean-Christian Denis & contributors',
|
'Jean-Christian Denis & contributors',
|
||||||
'2021.11.06',
|
'2022.11.12',
|
||||||
[
|
[
|
||||||
'requires' => [['core', '2.19']],
|
'requires' => [['core', '2.24']],
|
||||||
'permissions' => null,
|
'permissions' => null,
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
'support' => 'http://forum.dotclear.org/viewtopic.php?id=39220',
|
'support' => 'http://forum.dotclear.org/viewtopic.php?id=39220',
|
||||||
'details' => 'https://plugins.dotaddict.org/dc2/details/translater',
|
'details' => 'https://plugins.dotaddict.org/dc2/details/translater',
|
||||||
'repository' => 'https://raw.githubusercontent.com/JcDenis/translater/master/dcstore.xml'
|
'repository' => 'https://raw.githubusercontent.com/JcDenis/translater/master/dcstore.xml',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -16,16 +16,16 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
|||||||
$id = 'translater';
|
$id = 'translater';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (version_compare($core->getVersion($id), $core->plugins->moduleInfo($id, 'version'), '>=')) {
|
if (version_compare(dcCore::app()->getVersion($id), dcCore::app()->plugins->moduleInfo($id, 'version'), '>=')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$translater = new dcTranslater($core, false);
|
$translater = new dcTranslater(false);
|
||||||
$translater->writeSettings(false);
|
$translater->writeSettings(false);
|
||||||
$core->setVersion($id, $core->plugins->moduleInfo($id, 'version'));
|
dcCore::app()->setVersion($id, dcCore::app()->plugins->moduleInfo($id, 'version'));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$core->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
16
_prepend.php
16
_prepend.php
@ -14,14 +14,14 @@ if (!defined('DC_RC_PATH')) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$d = dirname(__FILE__) . '/inc/';
|
$d = __DIR__ . '/inc/';
|
||||||
|
|
||||||
$__autoload['dcTranslater'] = $d . 'class.dc.translater.php';
|
Clearbricks::lib()->autoload(['dcTranslater' => $d . 'class.dc.translater.php']);
|
||||||
$__autoload['dcTranslaterDefaultSettings'] = $d . 'class.dc.translater.php';
|
Clearbricks::lib()->autoload(['dcTranslaterDefaultSettings' => $d . 'class.dc.translater.php']);
|
||||||
$__autoload['dcTranslaterModule'] = $d . 'class.dc.translater.module.php';
|
Clearbricks::lib()->autoload(['dcTranslaterModule' => $d . 'class.dc.translater.module.php']);
|
||||||
$__autoload['dcTranslaterLang'] = $d . 'class.dc.translater.lang.php';
|
Clearbricks::lib()->autoload(['dcTranslaterLang' => $d . 'class.dc.translater.lang.php']);
|
||||||
$__autoload['translaterRest'] = $d . 'class.translater.rest.php';
|
Clearbricks::lib()->autoload(['translaterRest' => $d . 'class.translater.rest.php']);
|
||||||
|
|
||||||
if (isset($core->adminurl)) {
|
if (isset(dcCore::app()->adminurl)) {
|
||||||
$core->adminurl->register('translater', 'plugin.php', ['p' => 'translater']);
|
dcCore::app()->adminurl->register('translater', 'plugin.php', ['p' => 'translater']);
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
*/
|
*/
|
||||||
class dcTranslaterLang
|
class dcTranslaterLang
|
||||||
{
|
{
|
||||||
/** @var dCore dcCore instance */
|
|
||||||
public $core = null;
|
|
||||||
/** @var dcTranslater dcTranslater instance */
|
/** @var dcTranslater dcTranslater instance */
|
||||||
public $translater = null;
|
public $translater = null;
|
||||||
/** @var dcTranslaterModule dcTranslaterModule instance */
|
/** @var dcTranslaterModule dcTranslaterModule instance */
|
||||||
@ -24,7 +22,6 @@ class dcTranslaterLang
|
|||||||
|
|
||||||
public function __construct(dcTranslaterModule $module, string $lang)
|
public function __construct(dcTranslaterModule $module, string $lang)
|
||||||
{
|
{
|
||||||
$this->core = $module->core;
|
|
||||||
$this->translater = $module->translater;
|
$this->translater = $module->translater;
|
||||||
$this->module = $module;
|
$this->module = $module;
|
||||||
|
|
||||||
@ -69,7 +66,7 @@ class dcTranslaterLang
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$dc_module = new dcTranslaterModule($this->translater, ['id' => 'dotclear', 'root' => DC_ROOT]);
|
$dc_module = new dcTranslaterModule($this->translater, ['id' => 'dotclear', 'root' => DC_ROOT]);
|
||||||
$dc_lang = new dctranslaterLang($dc_module, $this->code);
|
$dc_lang = new dcTranslaterLang($dc_module, $this->code);
|
||||||
$m_o_msgstrs['dotclear'] = $dc_lang->getMsgStrs();
|
$m_o_msgstrs['dotclear'] = $dc_lang->getMsgStrs();
|
||||||
|
|
||||||
# From id list
|
# From id list
|
||||||
@ -105,7 +102,7 @@ class dcTranslaterLang
|
|||||||
$res[$rs['msgid']]['o_msgstrs'][] = [
|
$res[$rs['msgid']]['o_msgstrs'][] = [
|
||||||
'msgstr' => is_array($rs['msgstr']) ? $rs['msgstr'] : [$rs['msgstr']],
|
'msgstr' => is_array($rs['msgstr']) ? $rs['msgstr'] : [$rs['msgstr']],
|
||||||
'module' => $o_module,
|
'module' => $o_module,
|
||||||
'file' => $rs['file']
|
'file' => $rs['file'],
|
||||||
];
|
];
|
||||||
if ($o_module == 'dotclear') {
|
if ($o_module == 'dotclear') {
|
||||||
$res[$rs['msgid']]['in_dc'] = true;
|
$res[$rs['msgid']]['in_dc'] = true;
|
||||||
@ -136,6 +133,7 @@ class dcTranslaterLang
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$contents = file_get_contents($this->module->root . '/' . $file);
|
$contents = file_get_contents($this->module->root . '/' . $file);
|
||||||
|
$msgs = [];
|
||||||
# php files
|
# php files
|
||||||
if ($extension == 'php') {
|
if ($extension == 'php') {
|
||||||
$msgs = dcTranslater::extractPhpMsgs($contents);
|
$msgs = dcTranslater::extractPhpMsgs($contents);
|
||||||
@ -149,7 +147,7 @@ class dcTranslaterLang
|
|||||||
'msgid' => dcTranslater::encodeMsg($msg[0][0]),
|
'msgid' => dcTranslater::encodeMsg($msg[0][0]),
|
||||||
'msgid_plural' => empty($msg[0][1]) ? '' : dcTranslater::encodeMsg($msg[0][1]),
|
'msgid_plural' => empty($msg[0][1]) ? '' : dcTranslater::encodeMsg($msg[0][1]),
|
||||||
'file' => $file,
|
'file' => $file,
|
||||||
'line' => $msg[1]
|
'line' => $msg[1],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,7 +193,7 @@ class dcTranslaterLang
|
|||||||
'type' => 'po',
|
'type' => 'po',
|
||||||
'path' => $path,
|
'path' => $path,
|
||||||
'file' => basename($file),
|
'file' => basename($file),
|
||||||
'group' => str_replace('.po', '', basename($file))
|
'group' => str_replace('.po', '', basename($file)),
|
||||||
];
|
];
|
||||||
$exists[] = $entry['msgid'];
|
$exists[] = $entry['msgid'];
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,6 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
|||||||
*/
|
*/
|
||||||
class dcTranslaterModule
|
class dcTranslaterModule
|
||||||
{
|
{
|
||||||
/** @var dCore dcCore instance */
|
|
||||||
public $core = null;
|
|
||||||
/** @var dcTranslater dcTranslater instance */
|
/** @var dcTranslater dcTranslater instance */
|
||||||
public $translater = null;
|
public $translater = null;
|
||||||
|
|
||||||
@ -35,7 +33,6 @@ class dcTranslaterModule
|
|||||||
|
|
||||||
public function __construct(dcTranslater $translater, array $module)
|
public function __construct(dcTranslater $translater, array $module)
|
||||||
{
|
{
|
||||||
$this->core = $translater->core;
|
|
||||||
$this->translater = $translater;
|
$this->translater = $translater;
|
||||||
$this->prop = $module;
|
$this->prop = $module;
|
||||||
|
|
||||||
@ -81,7 +78,7 @@ class dcTranslaterModule
|
|||||||
$dir = $this->prop['locales'];
|
$dir = $this->prop['locales'];
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'plugin':
|
case 'plugin':
|
||||||
$tmp = path::real(array_pop(explode(PATH_SEPARATOR, DC_PLUGINS_ROOT)));
|
$tmp = path::real(array_pop(explode(PATH_SEPARATOR, DC_PLUGINS_ROOT)));
|
||||||
@ -89,15 +86,15 @@ class dcTranslaterModule
|
|||||||
$dir = $tmp;
|
$dir = $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'public':
|
case 'public':
|
||||||
$tmp = path::real($this->core->blog->public_path);
|
$tmp = path::real(dcCore::app()->blog->public_path);
|
||||||
if ($tmp && is_writable($tmp)) {
|
if ($tmp && is_writable($tmp)) {
|
||||||
$dir = $tmp;
|
$dir = $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'cache':
|
case 'cache':
|
||||||
$tmp = path::real(DC_TPL_CACHE);
|
$tmp = path::real(DC_TPL_CACHE);
|
||||||
@ -106,21 +103,21 @@ class dcTranslaterModule
|
|||||||
$dir = $tmp . '/l10n';
|
$dir = $tmp . '/l10n';
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'translater':
|
case 'translater':
|
||||||
$tmp = path::real($this->core->plugins->moduleRoot('translater'));
|
$tmp = path::real(dcCore::app()->plugins->moduleRoot('translater'));
|
||||||
if ($tmp && is_writable($tmp)) {
|
if ($tmp && is_writable($tmp)) {
|
||||||
@mkDir($tmp . '/locales');
|
@mkDir($tmp . '/locales');
|
||||||
$dir = $tmp . '/locales';
|
$dir = $tmp . '/locales';
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!$dir && $throw) {
|
if (!$dir && $throw) {
|
||||||
throw new Exception(sprintf(
|
throw new Exception(sprintf(
|
||||||
__('Failed to find backups folder for module %s'),
|
__('Failed to find backups folder for module %s'),
|
||||||
$id
|
$this->prop['basename']
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,7 +192,7 @@ class dcTranslaterModule
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($res)) {
|
if (!empty($res)) {
|
||||||
dcTranslater::isBackupLimit($this->prop['id'] , $backup, $this->translater->backup_limit, true);
|
dcTranslater::isBackupLimit($this->prop['id'], $backup, $this->translater->backup_limit, true);
|
||||||
|
|
||||||
@set_time_limit(300);
|
@set_time_limit(300);
|
||||||
$fp = fopen($backup . '/l10n-' . $this->prop['id'] . '-' . $lang . '-' . time() . '.bck.zip', 'wb');
|
$fp = fopen($backup . '/l10n-' . $this->prop['id'] . '-' . $lang . '-' . time() . '.bck.zip', 'wb');
|
||||||
@ -305,7 +302,7 @@ class dcTranslaterModule
|
|||||||
$res[] = [
|
$res[] = [
|
||||||
'from' => $file,
|
'from' => $file,
|
||||||
'root' => $this->prop['locales'] . '/' . $f['lang'],
|
'root' => $this->prop['locales'] . '/' . $f['lang'],
|
||||||
'to' => $this->prop['locales'] . '/' . $f['lang'] . '/' . $f['group'] . $f['ext']
|
'to' => $this->prop['locales'] . '/' . $f['lang'] . '/' . $f['group'] . $f['ext'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,7 +322,7 @@ class dcTranslaterModule
|
|||||||
__('Some languages has not been overwrited %s'),
|
__('Some languages has not been overwrited %s'),
|
||||||
implode(', ', $not_overwrited)
|
implode(', ', $not_overwrited)
|
||||||
));
|
));
|
||||||
} elseif (!$done) {
|
} elseif (!$imported) {
|
||||||
throw new Exception(sprintf(
|
throw new Exception(sprintf(
|
||||||
__('Nothing to import from %s'),
|
__('Nothing to import from %s'),
|
||||||
$zip_file['name']
|
$zip_file['name']
|
||||||
@ -414,8 +411,8 @@ class dcTranslaterModule
|
|||||||
if ($is_file) {
|
if ($is_file) {
|
||||||
$module = $f[1] == $this->prop['id'] ? $f[1] : false;
|
$module = $f[1] == $this->prop['id'] ? $f[1] : false;
|
||||||
$lang = l10n::isCode($f[2]) ? $f[2] : false;
|
$lang = l10n::isCode($f[2]) ? $f[2] : false;
|
||||||
$group = in_array($f[3], dctranslater::$allowed_l10n_groups) ? $f[3] : false;
|
$group = in_array($f[3], dcTranslater::$allowed_l10n_groups) ? $f[3] : false;
|
||||||
$ext = dctranslater::isLangphpFile($f[4]) || dctranslater::isPoFile($f[4]) ? $f[4] : false;
|
$ext = dcTranslater::isLangphpFile($f[4]) || dcTranslater::isPoFile($f[4]) ? $f[4] : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$is_file || !$module || !$lang || !$group || !$ext) {
|
if (!$is_file || !$module || !$lang || !$group || !$ext) {
|
||||||
@ -433,7 +430,7 @@ class dcTranslaterModule
|
|||||||
'module' => $module,
|
'module' => $module,
|
||||||
'lang' => $lang,
|
'lang' => $lang,
|
||||||
'group' => $group,
|
'group' => $group,
|
||||||
'ext' => $ext
|
'ext' => $ext,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
//@}
|
//@}
|
||||||
@ -670,16 +667,16 @@ class dcTranslaterModule
|
|||||||
'# Date: ' . dt::str('%Y-%m-%d %H:%M:%S') . "\n";
|
'# Date: ' . dt::str('%Y-%m-%d %H:%M:%S') . "\n";
|
||||||
|
|
||||||
if ($this->translater->parse_user && $this->translater->parse_userinfo != '') {
|
if ($this->translater->parse_user && $this->translater->parse_userinfo != '') {
|
||||||
$search = dctranslater::$allowed_user_informations;
|
$search = dcTranslater::$allowed_user_informations;
|
||||||
foreach ($search as $n) {
|
foreach ($search as $n) {
|
||||||
$replace[] = $this->core->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)) {
|
||||||
$content .= '# Author: ' . html::escapeHTML($info) . "\n";
|
$content .= '# Author: ' . html::escapeHTML($info) . "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$content .= '# Translated with translater ' . $this->core->plugins->moduleInfo('translater', 'version') . "\n\n";
|
$content .= '# Translated with translater ' . dcCore::app()->plugins->moduleInfo('translater', 'version') . "\n\n";
|
||||||
}
|
}
|
||||||
$content .= "msgid \"\"\n" .
|
$content .= "msgid \"\"\n" .
|
||||||
"msgstr \"\"\n" .
|
"msgstr \"\"\n" .
|
||||||
@ -687,7 +684,7 @@ class dcTranslaterModule
|
|||||||
'"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: ' . $this->core->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" .
|
||||||
@ -724,7 +721,7 @@ class dcTranslaterModule
|
|||||||
$file = $this->locales . '/' . $lang->code . '/' . $group . '.po';
|
$file = $this->locales . '/' . $lang->code . '/' . $group . '.po';
|
||||||
$path = path::info($file);
|
$path = path::info($file);
|
||||||
if (is_dir($path['dirname']) && !is_writable($path['dirname'])
|
if (is_dir($path['dirname']) && !is_writable($path['dirname'])
|
||||||
|| file_exists($file) && !is_writable($file)) {
|
|| file_exists($file) && !is_writable($file)) {
|
||||||
throw new Exception(sprintf(
|
throw new Exception(sprintf(
|
||||||
__('Failed to grant write acces on file %s'),
|
__('Failed to grant write acces on file %s'),
|
||||||
$file
|
$file
|
||||||
@ -763,14 +760,14 @@ class dcTranslaterModule
|
|||||||
if ($this->translater->parse_user && !empty($this->translater->parse_userinfo)) {
|
if ($this->translater->parse_user && !empty($this->translater->parse_userinfo)) {
|
||||||
$search = dcTranslater::$allowed_user_informations;
|
$search = dcTranslater::$allowed_user_informations;
|
||||||
foreach ($search as $n) {
|
foreach ($search as $n) {
|
||||||
$replace[] = $this->core->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)) {
|
||||||
$content .= '// Author: ' . html::escapeHTML($info) . "\n";
|
$content .= '// Author: ' . html::escapeHTML($info) . "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$content .= '// Translated with dcTranslater - ' . $this->core->plugins->moduleInfo('translater', 'version') . "\n\n";
|
$content .= '// Translated with dcTranslater - ' . dcCore::app()->plugins->moduleInfo('translater', 'version') . "\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
l10n::generatePhpFileFromPo($this->locales . '/' . $lang->code . '/' . $group, $content);
|
l10n::generatePhpFileFromPo($this->locales . '/' . $lang->code . '/' . $group, $content);
|
||||||
|
@ -67,20 +67,17 @@ class dcTranslaterDefaultSettings
|
|||||||
*/
|
*/
|
||||||
class dcTranslater extends dcTranslaterDefaultSettings
|
class dcTranslater extends dcTranslaterDefaultSettings
|
||||||
{
|
{
|
||||||
/** @var dcCore dcCore instance */
|
|
||||||
public $core;
|
|
||||||
|
|
||||||
/** @var array $allowed_backup_folders List of allowed backup folder */
|
/** @var array $allowed_backup_folders List of allowed backup folder */
|
||||||
public static $allowed_backup_folders = [];
|
public static $allowed_backup_folders = [];
|
||||||
|
|
||||||
/** @var array $allowed_l10n_groups List of place of tranlsations */
|
/** @var array $allowed_l10n_groups List of place of tranlsations */
|
||||||
public static $allowed_l10n_groups = [
|
public static $allowed_l10n_groups = [
|
||||||
'main', 'public', 'theme', 'admin', 'date', 'error'
|
'main', 'public', 'theme', 'admin', 'date', 'error',
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var array $allowed_user_informations List of user info can be parsed */
|
/** @var array $allowed_user_informations List of user info can be parsed */
|
||||||
public static $allowed_user_informations = [
|
public static $allowed_user_informations = [
|
||||||
'firstname', 'displayname', 'name', 'email', 'url'
|
'firstname', 'displayname', 'name', 'email', 'url',
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var array $default_distrib_modules List of distributed plugins and themes */
|
/** @var array $default_distrib_modules List of distributed plugins and themes */
|
||||||
@ -92,13 +89,11 @@ class dcTranslater extends dcTranslaterDefaultSettings
|
|||||||
/**
|
/**
|
||||||
* translater instance
|
* translater instance
|
||||||
*
|
*
|
||||||
* @param dcCore $core dcCore instance
|
|
||||||
* @param boolean $full Also load modules
|
* @param boolean $full Also load modules
|
||||||
*/
|
*/
|
||||||
public function __construct(dcCore $core, bool $full = true)
|
public function __construct(bool $full = true)
|
||||||
{
|
{
|
||||||
$this->core = $core;
|
dcCore::app()->blog->settings->addNamespace('translater');
|
||||||
$core->blog->settings->addNamespace('translater');
|
|
||||||
|
|
||||||
$this->loadSettings();
|
$this->loadSettings();
|
||||||
|
|
||||||
@ -111,11 +106,11 @@ class dcTranslater extends dcTranslaterDefaultSettings
|
|||||||
__('plugins folder root') => 'plugin',
|
__('plugins folder root') => 'plugin',
|
||||||
__('public folder root') => 'public',
|
__('public folder root') => 'public',
|
||||||
__('cache folder of Dotclear') => 'cache',
|
__('cache folder of Dotclear') => 'cache',
|
||||||
__('locales folder of translater') => 'translater'
|
__('locales folder of translater') => 'translater',
|
||||||
];
|
];
|
||||||
self::$default_distrib_modules = [
|
self::$default_distrib_modules = [
|
||||||
'plugin' => explode(',', DC_DISTRIB_PLUGINS),
|
'plugin' => explode(',', DC_DISTRIB_PLUGINS),
|
||||||
'theme' => explode(',', DC_DISTRIB_THEMES)
|
'theme' => explode(',', DC_DISTRIB_THEMES),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +122,7 @@ class dcTranslater extends dcTranslaterDefaultSettings
|
|||||||
public function loadSettings(): void
|
public function loadSettings(): void
|
||||||
{
|
{
|
||||||
foreach ($this->getDefaultSettings() as $key => $value) {
|
foreach ($this->getDefaultSettings() as $key => $value) {
|
||||||
$this->$key = $this->core->blog->settings->translater->get('translater_' . $key);
|
$this->$key = dcCore::app()->blog->settings->translater->get('translater_' . $key);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
settype($this->$key, gettype($value));
|
settype($this->$key, gettype($value));
|
||||||
@ -144,8 +139,8 @@ class dcTranslater extends dcTranslaterDefaultSettings
|
|||||||
public function writeSettings($overwrite = true): void
|
public function writeSettings($overwrite = true): void
|
||||||
{
|
{
|
||||||
foreach ($this->getDefaultSettings() as $key => $value) {
|
foreach ($this->getDefaultSettings() as $key => $value) {
|
||||||
$this->core->blog->settings->translater->drop('translater_' . $key);
|
dcCore::app()->blog->settings->translater->drop('translater_' . $key);
|
||||||
$this->core->blog->settings->translater->put('translater_' . $key, $this->$key, gettype($value), '', true, true);
|
dcCore::app()->blog->settings->translater->put('translater_' . $key, $this->$key, gettype($value), '', true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//@}
|
//@}
|
||||||
@ -159,12 +154,12 @@ class dcTranslater extends dcTranslaterDefaultSettings
|
|||||||
{
|
{
|
||||||
$this->modules['theme'] = $this->modules['plugin'] = [];
|
$this->modules['theme'] = $this->modules['plugin'] = [];
|
||||||
|
|
||||||
$themes = new dcThemes($this->core);
|
$themes = new dcThemes();
|
||||||
$themes->loadModules($this->core->blog->themes_path, null);
|
$themes->loadModules(dcCore::app()->blog->themes_path, null);
|
||||||
|
|
||||||
$list = [
|
$list = [
|
||||||
'theme' => $themes->getModules(),
|
'theme' => $themes->getModules(),
|
||||||
'plugin' => $this->core->plugins->getModules()
|
'plugin' => dcCore::app()->plugins->getModules(),
|
||||||
];
|
];
|
||||||
foreach ($list as $type => $modules) {
|
foreach ($list as $type => $modules) {
|
||||||
foreach ($modules as $id => $info) {
|
foreach ($modules as $id => $info) {
|
||||||
@ -182,7 +177,7 @@ class dcTranslater extends dcTranslaterDefaultSettings
|
|||||||
* Return array of modules infos by type of modules
|
* Return array of modules infos by type of modules
|
||||||
*
|
*
|
||||||
* @param string $type The modules type
|
* @param string $type The modules type
|
||||||
*
|
*
|
||||||
* @return array The list of modules infos
|
* @return array The list of modules infos
|
||||||
*/
|
*/
|
||||||
public function getModules(string $type = ''): array
|
public function getModules(string $type = ''): array
|
||||||
@ -197,7 +192,7 @@ class dcTranslater extends dcTranslaterDefaultSettings
|
|||||||
*
|
*
|
||||||
* @param string $type The module type
|
* @param string $type The module type
|
||||||
* @param string $id The module id
|
* @param string $id The module id
|
||||||
*
|
*
|
||||||
* @return dcTranslaterModule The dcTranslaterModule instance
|
* @return dcTranslaterModule The dcTranslaterModule instance
|
||||||
*/
|
*/
|
||||||
public function getModule(string $type, string $id)
|
public function getModule(string $type, string $id)
|
||||||
@ -216,7 +211,7 @@ class dcTranslater extends dcTranslaterDefaultSettings
|
|||||||
*
|
*
|
||||||
* @param dcTranslaterModule $module dcTranslaterModule instance
|
* @param dcTranslaterModule $module dcTranslaterModule instance
|
||||||
* @param string $lang The lang iso code
|
* @param string $lang The lang iso code
|
||||||
*
|
*
|
||||||
* @return dcTranslaterLang dcTranslaterLang instance or false
|
* @return dcTranslaterLang dcTranslaterLang instance or false
|
||||||
*/
|
*/
|
||||||
public function getLang(dcTranslaterModule $module, string $lang)
|
public function getLang(dcTranslaterModule $module, string $lang)
|
||||||
|
@ -15,16 +15,12 @@
|
|||||||
*/
|
*/
|
||||||
class translaterProposals
|
class translaterProposals
|
||||||
{
|
{
|
||||||
public $core;
|
|
||||||
|
|
||||||
private $stack = [];
|
private $stack = [];
|
||||||
|
|
||||||
public function __construct($core)
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->core = $core;
|
|
||||||
|
|
||||||
# --BEHAVIOR-- addTranslaterProposalTool
|
# --BEHAVIOR-- addTranslaterProposalTool
|
||||||
$core->callBehavior('addTranslaterProposalTool', $this);
|
dcCore::app()->callBehavior('addTranslaterProposalTool', $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addTool($id)
|
public function addTool($id)
|
||||||
@ -40,7 +36,7 @@ class translaterProposals
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->stack[$id] = new $id($this->core);
|
$this->stack[$id] = new $id();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTools()
|
public function getTools()
|
||||||
|
@ -22,7 +22,7 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
|||||||
*/
|
*/
|
||||||
class translaterRest
|
class translaterRest
|
||||||
{
|
{
|
||||||
public static function getProposal($core, $get)
|
public static function getProposal($get)
|
||||||
{
|
{
|
||||||
$from = !empty($get['langFrom']) ? trim($get['langFrom']) : '';
|
$from = !empty($get['langFrom']) ? trim($get['langFrom']) : '';
|
||||||
$to = !empty($get['langTo']) ? trim($get['langTo']) : '';
|
$to = !empty($get['langTo']) ? trim($get['langTo']) : '';
|
||||||
@ -40,7 +40,7 @@ class translaterRest
|
|||||||
throw new Exception(__('Missing params'));
|
throw new Exception(__('Missing params'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$translater = new dcTranslater($core);
|
$translater = new dcTranslater();
|
||||||
|
|
||||||
if (!empty($str_in)) {
|
if (!empty($str_in)) {
|
||||||
if (!$translater->proposal->hasTool($tool)) {
|
if (!$translater->proposal->hasTool($tool)) {
|
||||||
@ -61,7 +61,7 @@ class translaterRest
|
|||||||
$x->str_to = text::toUTF8(html::decodeEntities($str_out));
|
$x->str_to = text::toUTF8(html::decodeEntities($str_out));
|
||||||
$rsp->insertNode($x);
|
$rsp->insertNode($x);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$core->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $rsp;
|
return $rsp;
|
||||||
|
@ -27,7 +27,7 @@ class googleProposalTool extends translaterProposalTool
|
|||||||
|
|
||||||
protected function setup()
|
protected function setup()
|
||||||
{
|
{
|
||||||
$this->key = $this->core->blog->settings->translater->translater_google_proposal_key;
|
$this->key = dcCore::app()->blog->settings->translater->translater_google_proposal_key;
|
||||||
|
|
||||||
$this->setName(__('Google'));
|
$this->setName(__('Google'));
|
||||||
$this->setDesc(__('Google Translation Tool API'));
|
$this->setDesc(__('Google Translation Tool API'));
|
||||||
@ -53,7 +53,7 @@ class googleProposalTool extends translaterProposalTool
|
|||||||
$key = empty($_POST['translater_google_proposal_key']) ?
|
$key = empty($_POST['translater_google_proposal_key']) ?
|
||||||
'' : $_POST['translater_google_proposal_key'];
|
'' : $_POST['translater_google_proposal_key'];
|
||||||
|
|
||||||
$this->core->blog->settings->translater->put('translater_google_proposal_key', $key, 'string', '', true, true);
|
dcCore::app()->blog->settings->translater->put('translater_google_proposal_key', $key, 'string', '', true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function translate($str, $from, $to)
|
public function translate($str, $from, $to)
|
||||||
@ -63,7 +63,7 @@ class googleProposalTool extends translaterProposalTool
|
|||||||
'key' => $this->key,
|
'key' => $this->key,
|
||||||
'q' => $str,
|
'q' => $str,
|
||||||
'source' => $from,
|
'source' => $from,
|
||||||
'target' => $to
|
'target' => $to,
|
||||||
];
|
];
|
||||||
|
|
||||||
$path = '';
|
$path = '';
|
||||||
|
@ -27,8 +27,8 @@ class microsoftProposalTool extends translaterProposalTool
|
|||||||
protected function setup()
|
protected function setup()
|
||||||
{
|
{
|
||||||
$this->setActive(false);
|
$this->setActive(false);
|
||||||
$this->client = $this->core->blog->settings->translater->translater_microsoft_proposal_client;
|
$this->client = dcCore::app()->blog->settings->translater->translater_microsoft_proposal_client;
|
||||||
$this->secret = $this->core->blog->settings->translater->translater_microsoft_proposal_secret;
|
$this->secret = dcCore::app()->blog->settings->translater->translater_microsoft_proposal_secret;
|
||||||
|
|
||||||
$this->setName(__('Bing'));
|
$this->setName(__('Bing'));
|
||||||
$this->setDesc(__('Microsoft Bing translation tool'));
|
$this->setDesc(__('Microsoft Bing translation tool'));
|
||||||
@ -61,8 +61,8 @@ class microsoftProposalTool extends translaterProposalTool
|
|||||||
$secret = empty($_POST['translater_microsoft_proposal_secret']) ?
|
$secret = empty($_POST['translater_microsoft_proposal_secret']) ?
|
||||||
'' : $_POST['translater_microsoft_proposal_secret'];
|
'' : $_POST['translater_microsoft_proposal_secret'];
|
||||||
|
|
||||||
$this->core->blog->settings->translater->put('translater_microsoft_proposal_client', $client, 'string', '', true, true);
|
dcCore::app()->blog->settings->translater->put('translater_microsoft_proposal_client', $client, 'string', '', true, true);
|
||||||
$this->core->blog->settings->translater->put('translater_microsoft_proposal_secret', $secret, 'string', '', true, true);
|
dcCore::app()->blog->settings->translater->put('translater_microsoft_proposal_secret', $secret, 'string', '', true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function translate($str, $from, $to)
|
public function translate($str, $from, $to)
|
||||||
@ -152,7 +152,7 @@ class microsoftProposalTool extends translaterProposalTool
|
|||||||
'grant_type' => $grantType,
|
'grant_type' => $grantType,
|
||||||
'scope' => $scopeUrl,
|
'scope' => $scopeUrl,
|
||||||
'client_id' => $clientID,
|
'client_id' => $clientID,
|
||||||
'client_secret' => $clientSecret
|
'client_secret' => $clientSecret,
|
||||||
];
|
];
|
||||||
//Create an Http Query.//
|
//Create an Http Query.//
|
||||||
$paramArr = http_build_query($paramArr);
|
$paramArr = http_build_query($paramArr);
|
||||||
|
@ -17,8 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
abstract class translaterProposalTool
|
abstract class translaterProposalTool
|
||||||
{
|
{
|
||||||
public $core;
|
|
||||||
|
|
||||||
private $active = false;
|
private $active = false;
|
||||||
private $name = 'unknow';
|
private $name = 'unknow';
|
||||||
private $desc = 'no description';
|
private $desc = 'no description';
|
||||||
@ -26,16 +24,15 @@ abstract class translaterProposalTool
|
|||||||
/**
|
/**
|
||||||
Constructor
|
Constructor
|
||||||
*/
|
*/
|
||||||
final public function __construct($core)
|
final public function __construct()
|
||||||
{
|
{
|
||||||
$this->core = $core;
|
|
||||||
$this->setup();
|
$this->setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Set name of this tool
|
Set name of this tool
|
||||||
|
|
||||||
@param string Tool's name
|
@param string $name Tool's name
|
||||||
*/
|
*/
|
||||||
final protected function setName($name)
|
final protected function setName($name)
|
||||||
{
|
{
|
||||||
@ -55,7 +52,7 @@ abstract class translaterProposalTool
|
|||||||
/**
|
/**
|
||||||
Set description of this tool
|
Set description of this tool
|
||||||
|
|
||||||
@param string Tool's description
|
@param string $desc Tool's description
|
||||||
*/
|
*/
|
||||||
final protected function setDesc($desc)
|
final protected function setDesc($desc)
|
||||||
{
|
{
|
||||||
@ -75,7 +72,7 @@ abstract class translaterProposalTool
|
|||||||
/**
|
/**
|
||||||
Set tool as (un)active
|
Set tool as (un)active
|
||||||
|
|
||||||
@param boolean $active True to set it as active
|
@param boolean $active True to set it as active
|
||||||
*/
|
*/
|
||||||
final protected function setActive($active)
|
final protected function setActive($active)
|
||||||
{
|
{
|
||||||
@ -100,7 +97,7 @@ abstract class translaterProposalTool
|
|||||||
/**
|
/**
|
||||||
Get configuration interface
|
Get configuration interface
|
||||||
|
|
||||||
@return Form field
|
@return string Form field
|
||||||
*/
|
*/
|
||||||
abstract public function form();
|
abstract public function form();
|
||||||
|
|
||||||
@ -114,8 +111,8 @@ abstract class translaterProposalTool
|
|||||||
|
|
||||||
@param string $str Trimed UTF-8 string to translate
|
@param string $str Trimed UTF-8 string to translate
|
||||||
@param string $from Source language code
|
@param string $from Source language code
|
||||||
@param string to Destination language code
|
@param string $to Destination language code
|
||||||
@return Translated string
|
@return string Translated string
|
||||||
*/
|
*/
|
||||||
abstract public function translate($str, $from, $to);
|
abstract public function translate($str, $from, $to);
|
||||||
}
|
}
|
||||||
|
114
index.php
114
index.php
@ -16,7 +16,7 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
|||||||
|
|
||||||
dcPage::checkSuper();
|
dcPage::checkSuper();
|
||||||
|
|
||||||
$translater = new dcTranslater($core);
|
$translater = new dcTranslater();
|
||||||
|
|
||||||
$type = $_REQUEST['type'] ?? $translater->start_page ?: '';
|
$type = $_REQUEST['type'] ?? $translater->start_page ?: '';
|
||||||
$module = $_REQUEST['module'] ?? '';
|
$module = $_REQUEST['module'] ?? '';
|
||||||
@ -31,7 +31,7 @@ if (!empty($type) && !empty($module)) {
|
|||||||
try {
|
try {
|
||||||
$module = $translater->getModule($type, $module);
|
$module = $translater->getModule($type, $module);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$core->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
$module = '';
|
$module = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -40,22 +40,22 @@ if (!empty($module) && !empty($lang)) {
|
|||||||
try {
|
try {
|
||||||
$lang = $translater->getLang($module, $lang);
|
$lang = $translater->getLang($module, $lang);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$core->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
$lang = '';
|
$lang = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$breadcrumb = [__('Translater') => $core->adminurl->get('translater', ['type' => '-'])];
|
$breadcrumb = [__('Translater') => dcCore::app()->adminurl->get('translater', ['type' => '-'])];
|
||||||
if (empty($type)) {
|
if (empty($type)) {
|
||||||
$breadcrumb = [__('Translater') => ''];
|
$breadcrumb = [__('Translater') => ''];
|
||||||
} elseif (empty($module)) {
|
} elseif (empty($module)) {
|
||||||
$breadcrumb[$type == 'plugin' ? __('Plugins') : __('Themes')] = '';
|
$breadcrumb[$type == 'plugin' ? __('Plugins') : __('Themes')] = '';
|
||||||
} elseif (empty($lang)) {
|
} elseif (empty($lang)) {
|
||||||
$breadcrumb[$type == 'plugin' ? __('Plugins') : __('Themes')] = $core->adminurl->get('translater', ['type' => $type]);
|
$breadcrumb[$type == 'plugin' ? __('Plugins') : __('Themes')] = dcCore::app()->adminurl->get('translater', ['type' => $type]);
|
||||||
$breadcrumb[html::escapeHTML($module->name)] = '';
|
$breadcrumb[html::escapeHTML($module->name)] = '';
|
||||||
} elseif (!empty($lang)) {
|
} elseif (!empty($lang)) {
|
||||||
$breadcrumb[$type == 'plugin' ? __('Plugins') : __('Themes')] = $core->adminurl->get('translater', ['type' => $type]);
|
$breadcrumb[$type == 'plugin' ? __('Plugins') : __('Themes')] = dcCore::app()->adminurl->get('translater', ['type' => $type]);
|
||||||
$breadcrumb[html::escapeHTML($module->name)] = $core->adminurl->get('translater', ['type' => $type, 'module' => $module->id]);
|
$breadcrumb[html::escapeHTML($module->name)] = dcCore::app()->adminurl->get('translater', ['type' => $type, 'module' => $module->id]);
|
||||||
$breadcrumb[html::escapeHTML(sprintf(__('%s language edition'), $lang->name))] = '';
|
$breadcrumb[html::escapeHTML(sprintf(__('%s language edition'), $lang->name))] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,8 +70,8 @@ try {
|
|||||||
$module->createBackup($code_id);
|
$module->createBackup($code_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dcPage::addSuccessNotice(__('Backup successfully created'));
|
dcAdminNotices::addSuccessNotice(__('Backup successfully created'));
|
||||||
$core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id]);
|
dcCore::app()->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'module_restore_backup') {
|
if ($action == 'module_restore_backup') {
|
||||||
@ -84,8 +84,8 @@ try {
|
|||||||
$module->restoreBackup($backup_file);
|
$module->restoreBackup($backup_file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dcPage::addSuccessNotice(__('Backup successfully restored'));
|
dcAdminNotices::addSuccessNotice(__('Backup successfully restored'));
|
||||||
$core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id]);
|
dcCore::app()->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'module_delete_backup') {
|
if ($action == 'module_delete_backup') {
|
||||||
@ -98,8 +98,8 @@ try {
|
|||||||
$module->deleteBackup($backup_file);
|
$module->deleteBackup($backup_file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dcPage::addSuccessNotice(__('Backup successfully deleted'));
|
dcAdminNotices::addSuccessNotice(__('Backup successfully deleted'));
|
||||||
$core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id]);
|
dcCore::app()->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'module_export_pack') {
|
if ($action == 'module_export_pack') {
|
||||||
@ -108,8 +108,8 @@ try {
|
|||||||
}
|
}
|
||||||
$module->exportPack($_POST['codes']);
|
$module->exportPack($_POST['codes']);
|
||||||
|
|
||||||
dcPage::addSuccessNotice(__('Language successfully exported'));
|
dcAdminNotices::addSuccessNotice(__('Language successfully exported'));
|
||||||
$core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id]);
|
dcCore::app()->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'module_import_pack') {
|
if ($action == 'module_import_pack') {
|
||||||
@ -118,8 +118,8 @@ try {
|
|||||||
}
|
}
|
||||||
$module->importPack($_FILES['packfile']);
|
$module->importPack($_FILES['packfile']);
|
||||||
|
|
||||||
dcPage::addSuccessNotice(__('Language successfully imported'));
|
dcAdminNotices::addSuccessNotice(__('Language successfully imported'));
|
||||||
$core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id]);
|
dcCore::app()->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'module_add_code') {
|
if ($action == 'module_add_code') {
|
||||||
@ -128,8 +128,8 @@ try {
|
|||||||
}
|
}
|
||||||
$module->addLang($_POST['code'], $_POST['from'] ?? '');
|
$module->addLang($_POST['code'], $_POST['from'] ?? '');
|
||||||
|
|
||||||
dcPage::addSuccessNotice(__('Language successfully added'));
|
dcAdminNotices::addSuccessNotice(__('Language successfully added'));
|
||||||
$core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id, 'lang' => $_POST['code']]);
|
dcCore::app()->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id, 'lang' => $_POST['code']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'module_delete_codes') {
|
if ($action == 'module_delete_codes') {
|
||||||
@ -142,8 +142,8 @@ try {
|
|||||||
$module->delLang($code_id);
|
$module->delLang($code_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dcPage::addSuccessNotice(__('Language successfully deleted'));
|
dcAdminNotices::addSuccessNotice(__('Language successfully deleted'));
|
||||||
$core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id, 'lang' => $_POST['code']]);
|
dcCore::app()->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id, 'lang' => $_POST['code']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'module_update_code') {
|
if ($action == 'module_update_code') {
|
||||||
@ -159,26 +159,26 @@ try {
|
|||||||
}
|
}
|
||||||
$module->updLang($_POST['code'], $_POST['entries']);
|
$module->updLang($_POST['code'], $_POST['entries']);
|
||||||
|
|
||||||
dcPage::addSuccessNotice(__('Language successfully updated'));
|
dcAdminNotices::addSuccessNotice(__('Language successfully updated'));
|
||||||
$core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id, 'lang' => $_POST['code']]);
|
dcCore::app()->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id, 'lang' => $_POST['code']]);
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$core->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
echo
|
echo
|
||||||
'<html><head><title>' . __('Translater') . '</title>' .
|
'<html><head><title>' . __('Translater') . '</title>' .
|
||||||
dcPage::jsPageTabs() .
|
dcPage::jsPageTabs() .
|
||||||
dcPage::cssLoad(dcPage::getPF('translater/css/translater.css')) .
|
dcPage::cssLoad(dcPage::getPF('translater/css/translater.css')) .
|
||||||
dcpage::jsJson('translater', [
|
dcPage::jsJson('translater', [
|
||||||
'title_add_detail' => __('Use this text'),
|
'title_add_detail' => __('Use this text'),
|
||||||
'image_field' => dcPage::getPF('translater/img/field.png'),
|
'image_field' => dcPage::getPF('translater/img/field.png'),
|
||||||
'image_toggle' => dcPage::getPF('translater/img/toggle.png')
|
'image_toggle' => dcPage::getPF('translater/img/toggle.png'),
|
||||||
]) .
|
]) .
|
||||||
dcPage::jsLoad(dcPage::getPF('translater/js/translater.js')) .
|
dcPage::jsLoad(dcPage::getPF('translater/js/translater.js')) .
|
||||||
|
|
||||||
# --BEHAVIOR-- translaterAdminHeaders
|
# --BEHAVIOR-- translaterAdminHeaders
|
||||||
$core->callBehavior('translaterAdminHeaders') .
|
dcCore::app()->callBehavior('translaterAdminHeaders') .
|
||||||
|
|
||||||
'</head><body>' .
|
'</head><body>' .
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ dcPage::notices();
|
|||||||
|
|
||||||
if (empty($module) && $type != '') {
|
if (empty($module) && $type != '') {
|
||||||
// modules list
|
// modules list
|
||||||
echo '<form id="theme-form" method="post" action="' . $core->adminurl->get('translater', ['type' => 'plugin']) . '">';
|
echo '<form id="theme-form" method="post" action="' . dcCore::app()->adminurl->get('translater', ['type' => 'plugin']) . '">';
|
||||||
|
|
||||||
$res = '';
|
$res = '';
|
||||||
$modules = $translater->getModules($type);
|
$modules = $translater->getModules($type);
|
||||||
@ -199,7 +199,7 @@ if (empty($module) && $type != '') {
|
|||||||
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>',
|
||||||
$core->adminurl->get('translater', ['type' => $module->type, 'module' => $module->id]),
|
dcCore::app()->adminurl->get('translater', ['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 @@ if (empty($module) && $type != '') {
|
|||||||
$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))),
|
||||||
$core->adminurl->get('translater', ['type' => $module->type, 'module' => $module->id, 'lang' => $code_id]),
|
dcCore::app()->adminurl->get('translater', ['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 @@ if (empty($module) && $type != '') {
|
|||||||
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="' . $core->adminurl->get('translater') . '">' .
|
'<form id="module-translations-form" method="post" action="' . dcCore::app()->adminurl->get('translater') . '">' .
|
||||||
'<table class="clear maximal">' .
|
'<table class="clear maximal">' .
|
||||||
'<caption>' . __('Existing languages translations') . '</caption>' .
|
'<caption>' . __('Existing languages translations') . '</caption>' .
|
||||||
'<tr>' .
|
'<tr>' .
|
||||||
@ -283,12 +283,13 @@ if (empty($module) && $type != '') {
|
|||||||
'<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="' .
|
||||||
$core->adminurl->get('translater', ['type' => $module->type, 'module' => $module->id, 'lang' => $code_id])
|
dcCore::app()->adminurl->get('translater', ['type' => $module->type, 'module' => $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>';
|
||||||
|
|
||||||
if (isset($backups[$code_id])) {
|
if (isset($backups[$code_id])) {
|
||||||
|
$time[$code_id] = 'UTC';
|
||||||
foreach ($backups[$code_id] as $file => $info) {
|
foreach ($backups[$code_id] as $file => $info) {
|
||||||
$time[$code_id] = isset($time[$code_id]) && $time[$code_id] > $info['time'] ?
|
$time[$code_id] = isset($time[$code_id]) && $time[$code_id] > $info['time'] ?
|
||||||
$time[$code_id] : $info['time'];
|
$time[$code_id] : $info['time'];
|
||||||
@ -296,7 +297,7 @@ if (empty($module) && $type != '') {
|
|||||||
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', $time[$code_id], $core->blog->settings->system->blog_timezone) .
|
dt::str('%Y-%m-%d %H:%M', $time[$code_id], dcCore::app()->blog->settings->system->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>';
|
||||||
@ -311,11 +312,11 @@ if (empty($module) && $type != '') {
|
|||||||
form::combo('action', [
|
form::combo('action', [
|
||||||
__('Backup languages') => 'module_create_backups',
|
__('Backup languages') => 'module_create_backups',
|
||||||
__('Delete languages') => 'module_delete_codes',
|
__('Delete languages') => 'module_delete_codes',
|
||||||
__('Export languages') => 'module_export_pack'
|
__('Export languages') => 'module_export_pack',
|
||||||
]) . '
|
]) . '
|
||||||
<input id="do-action" type="submit" value="' . __('ok') . '" /></p>' .
|
<input id="do-action" type="submit" value="' . __('ok') . '" /></p>' .
|
||||||
$core->formNonce() .
|
dcCore::app()->formNonce() .
|
||||||
$core->adminurl->getHiddenFormFields(
|
dcCore::app()->adminurl->getHiddenFormFields(
|
||||||
'translater',
|
'translater',
|
||||||
['type' => $module->type, 'module' => $module->id]
|
['type' => $module->type, 'module' => $module->id]
|
||||||
) . '
|
) . '
|
||||||
@ -327,7 +328,7 @@ if (empty($module) && $type != '') {
|
|||||||
// 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="' . $core->adminurl->get('translater') . '">' .
|
'<form id="module-backups-form" method="post" action="' . dcCore::app()->adminurl->get('translater') . '">' .
|
||||||
'<table class="clear">' .
|
'<table class="clear">' .
|
||||||
'<caption>' . __('Existing languages backups') . '</caption>' .
|
'<caption>' . __('Existing languages backups') . '</caption>' .
|
||||||
'<tr>' .
|
'<tr>' .
|
||||||
@ -359,9 +360,9 @@ if (empty($module) && $type != '') {
|
|||||||
$backup_code['name'],
|
$backup_code['name'],
|
||||||
$backup_code['code'],
|
$backup_code['code'],
|
||||||
dt::str(
|
dt::str(
|
||||||
$core->blog->settings->system->date_format . ' ' . $core->blog->settings->system->time_format,
|
dcCore::app()->blog->settings->system->date_format . ' ' . dcCore::app()->blog->settings->system->time_format,
|
||||||
$backup_code['time'],
|
$backup_code['time'],
|
||||||
$core->blog->settings->system->blog_timezone
|
dcCore::app()->blog->settings->system->blog_timezone
|
||||||
),
|
),
|
||||||
$backup_code['path']['basename'],
|
$backup_code['path']['basename'],
|
||||||
files::size($backup_code['size'])
|
files::size($backup_code['size'])
|
||||||
@ -376,11 +377,11 @@ if (empty($module) && $type != '') {
|
|||||||
<p class="col right">' . __('Selected backups action:') . ' ' .
|
<p class="col right">' . __('Selected backups action:') . ' ' .
|
||||||
form::combo('action', [
|
form::combo('action', [
|
||||||
__('Restore backups') => 'module_restore_backup',
|
__('Restore backups') => 'module_restore_backup',
|
||||||
__('Delete backups') => 'module_delete_backup'
|
__('Delete backups') => 'module_delete_backup',
|
||||||
]) . '
|
]) . '
|
||||||
<input id="do-action" type="submit" value="' . __('ok') . '" /></p>' .
|
<input id="do-action" type="submit" value="' . __('ok') . '" /></p>' .
|
||||||
$core->formNonce() .
|
dcCore::app()->formNonce() .
|
||||||
$core->adminurl->getHiddenFormFields(
|
dcCore::app()->adminurl->getHiddenFormFields(
|
||||||
'translater',
|
'translater',
|
||||||
['type' => $module->type, 'module' => $module->id]
|
['type' => $module->type, 'module' => $module->id]
|
||||||
) . '
|
) . '
|
||||||
@ -393,9 +394,9 @@ if (empty($module) && $type != '') {
|
|||||||
// 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="' . $core->adminurl->get('translater') . '">
|
<form id="muodule-code-create-form" method="post" action="' . dcCore::app()->adminurl->get('translater') . '">
|
||||||
<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), $core->auth->getInfo('user_lang')) . '</p>';
|
form::combo(['code'], array_merge(['-' => '-'], $unused_codes), 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 {
|
||||||
@ -405,8 +406,8 @@ if (empty($module) && $type != '') {
|
|||||||
}
|
}
|
||||||
echo '
|
echo '
|
||||||
<p><input type="submit" name="save" value="' . __('Create') . '" />' .
|
<p><input type="submit" name="save" value="' . __('Create') . '" />' .
|
||||||
$core->formNonce() .
|
dcCore::app()->formNonce() .
|
||||||
$core->adminurl->getHiddenFormFields(
|
dcCore::app()->adminurl->getHiddenFormFields(
|
||||||
'translater',
|
'translater',
|
||||||
['type' => $module->type, 'module' => $module->id, 'action' => 'module_add_code']
|
['type' => $module->type, 'module' => $module->id, 'action' => 'module_add_code']
|
||||||
) . '
|
) . '
|
||||||
@ -415,13 +416,13 @@ if (empty($module) && $type != '') {
|
|||||||
|
|
||||||
// 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="' . $core->adminurl->get('translater') . '" enctype="multipart/form-data">
|
<form id="module-pack-import-form" method="post" action="' . dcCore::app()->adminurl->get('translater') . '" 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') . '" />' .
|
||||||
$core->formNonce() .
|
dcCore::app()->formNonce() .
|
||||||
$core->adminurl->getHiddenFormFields(
|
dcCore::app()->adminurl->getHiddenFormFields(
|
||||||
'translater',
|
'translater',
|
||||||
['type' => $module->type, 'module' => $module->id, 'action' => 'module_import_pack']
|
['type' => $module->type, 'module' => $module->id, 'action' => 'module_import_pack']
|
||||||
) . '
|
) . '
|
||||||
@ -432,10 +433,11 @@ if (empty($module) && $type != '') {
|
|||||||
dcPage::helpBlock('translater.module');
|
dcPage::helpBlock('translater.module');
|
||||||
} elseif (!empty($lang)) {
|
} elseif (!empty($lang)) {
|
||||||
$lines = $lang->getMessages();
|
$lines = $lang->getMessages();
|
||||||
|
$allowed_l10n_groups = [];
|
||||||
|
|
||||||
echo
|
echo
|
||||||
'<div id="lang-form">' .
|
'<div id="lang-form">' .
|
||||||
'<form id="lang-edit-form" method="post" action="' . $core->adminurl->get('translater') . '">' .
|
'<form id="lang-edit-form" method="post" action="' . dcCore::app()->adminurl->get('translater') . '">' .
|
||||||
'<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>' .
|
||||||
@ -461,7 +463,7 @@ if (empty($module) && $type != '') {
|
|||||||
foreach ($lines as $msgid => $rs) {
|
foreach ($lines as $msgid => $rs) {
|
||||||
$in_dc = ($rs['in_dc'] && $translater->parse_nodc);
|
$in_dc = ($rs['in_dc'] && $translater->parse_nodc);
|
||||||
$allowed_l10n_groups = array_combine($translater::$allowed_l10n_groups, $translater::$allowed_l10n_groups);
|
$allowed_l10n_groups = array_combine($translater::$allowed_l10n_groups, $translater::$allowed_l10n_groups);
|
||||||
$t_msgstr = $t_files = $strin = [];
|
$t_msgstr = $t_files = $strin = [];
|
||||||
|
|
||||||
foreach ($rs['o_msgstrs'] as $o_msgstr) {
|
foreach ($rs['o_msgstrs'] as $o_msgstr) {
|
||||||
if (!isset($strin[$o_msgstr['msgstr'][0]])) {
|
if (!isset($strin[$o_msgstr['msgstr'][0]])) {
|
||||||
@ -528,7 +530,7 @@ if (empty($module) && $type != '') {
|
|||||||
sprintf(__('Plural "%s"'), $plural),
|
sprintf(__('Plural "%s"'), $plural),
|
||||||
sprintf(__('Plural form of "%s"'), $rs['plural']),
|
sprintf(__('Plural form of "%s"'), $rs['plural']),
|
||||||
form::hidden(['entries[' . $i . '][msgid_plural]'], html::escapeHTML($rs['plural'])) .
|
form::hidden(['entries[' . $i . '][msgid_plural]'], html::escapeHTML($rs['plural'])) .
|
||||||
form::field(['entries[' . $i . '][msgstr][' . $j + 1 . ']'], 48, 255, html::escapeHTML($rs['msgstr'][$j + 1] ?? ''), '', '', $in_dc),
|
form::field(['entries[' . $i . '][msgstr][' . ($j + 1) . ']'], 48, 255, html::escapeHTML($rs['msgstr'][$j + 1] ?? ''), '', '', $in_dc),
|
||||||
implode('', $t_msgstr),
|
implode('', $t_msgstr),
|
||||||
''
|
''
|
||||||
);
|
);
|
||||||
@ -559,9 +561,9 @@ if (empty($module) && $type != '') {
|
|||||||
'</div>' .
|
'</div>' .
|
||||||
'<p class="col right">' .
|
'<p class="col right">' .
|
||||||
'<input id="do-action" type="submit" value="' . __('Save') . ' (s)" accesskey="s" /></p>' .
|
'<input id="do-action" type="submit" value="' . __('Save') . ' (s)" accesskey="s" /></p>' .
|
||||||
$core->formNonce() .
|
dcCore::app()->formNonce() .
|
||||||
form::hidden(['code'], $lang->code) .
|
form::hidden(['code'], $lang->code) .
|
||||||
$core->adminurl->getHiddenFormFields(
|
dcCore::app()->adminurl->getHiddenFormFields(
|
||||||
'translater',
|
'translater',
|
||||||
['type' => $module->type, 'module' => $module->id, 'lang' => $lang->code, 'action' => 'module_update_code']
|
['type' => $module->type, 'module' => $module->id, 'lang' => $lang->code, 'action' => 'module_update_code']
|
||||||
) .
|
) .
|
||||||
@ -578,13 +580,13 @@ if (empty($module) && $type != '') {
|
|||||||
'<h3><ul class="nice">%s</ul></h3>',
|
'<h3><ul class="nice">%s</ul></h3>',
|
||||||
sprintf(
|
sprintf(
|
||||||
$line,
|
$line,
|
||||||
$core->adminurl->get('translater', ['type' => 'plugin']),
|
dcCore::app()->adminurl->get('translater', ['type' => 'plugin']),
|
||||||
$type == 'plugin' ? ' class="active"' : '',
|
$type == 'plugin' ? ' class="active"' : '',
|
||||||
__('Translate plugins')
|
__('Translate plugins')
|
||||||
) .
|
) .
|
||||||
sprintf(
|
sprintf(
|
||||||
$line,
|
$line,
|
||||||
$core->adminurl->get('translater', ['type' => 'theme']),
|
dcCore::app()->adminurl->get('translater', ['type' => 'theme']),
|
||||||
$type == 'theme' ? ' class="active"' : '',
|
$type == 'theme' ? ' class="active"' : '',
|
||||||
__('Translate themes')
|
__('Translate themes')
|
||||||
)
|
)
|
||||||
|
@ -15,5 +15,5 @@ if (!defined('DC_RC_PATH')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach (['index', 'type', 'module', 'lang', 'config'] as $v) {
|
foreach (['index', 'type', 'module', 'lang', 'config'] as $v) {
|
||||||
$__resources['help']['translater.' . $v] = dirname(__FILE__) . '/help/translater.' . $v . '.html';
|
dcCore::app()->resources['help']['translater.' . $v] = __DIR__ . '/help/translater.' . $v . '.html';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user