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