use abstract plugin id and settings ns
This commit is contained in:
parent
dc0902658f
commit
a11c778181
14
_admin.php
14
_admin.php
@ -26,10 +26,10 @@ dcCore::app()->addBehaviors([
|
|||||||
|
|
||||||
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
||||||
__('Translater'),
|
__('Translater'),
|
||||||
dcCore::app()->adminurl->get('translater'),
|
dcCore::app()->adminurl->get(basename(__DIR__)),
|
||||||
dcPage::getPF('translater/icon.svg'),
|
dcPage::getPF(basename(__DIR__) . '/icon.svg'),
|
||||||
preg_match(
|
preg_match(
|
||||||
'/' . preg_quote(dcCore::app()->adminurl->get('translater')) . '(&.*)?$/',
|
'/' . preg_quote(dcCore::app()->adminurl->get(basename(__DIR__))) . '(&.*)?$/',
|
||||||
$_SERVER['REQUEST_URI']
|
$_SERVER['REQUEST_URI']
|
||||||
),
|
),
|
||||||
dcCore::app()->auth->isSuperAdmin()
|
dcCore::app()->auth->isSuperAdmin()
|
||||||
@ -97,7 +97,7 @@ class translaterAdminBehaviors
|
|||||||
}
|
}
|
||||||
|
|
||||||
dcCore::app()->adminurl->redirect(
|
dcCore::app()->adminurl->redirect(
|
||||||
'translater',
|
basename(__DIR__),
|
||||||
['part' => 'module', 'type' => $type, 'module' => key($_POST['translater'])],
|
['part' => 'module', 'type' => $type, 'module' => key($_POST['translater'])],
|
||||||
'#module-lang'
|
'#module-lang'
|
||||||
);
|
);
|
||||||
@ -112,9 +112,9 @@ class translaterAdminBehaviors
|
|||||||
{
|
{
|
||||||
$favs->register('translater', [
|
$favs->register('translater', [
|
||||||
'title' => __('Translater'),
|
'title' => __('Translater'),
|
||||||
'url' => dcCore::app()->adminurl->get('translater'),
|
'url' => dcCore::app()->adminurl->get(basename(__DIR__)),
|
||||||
'small-icon' => urldecode(dcPage::getPF('translater/icon.svg')),
|
'small-icon' => urldecode(dcPage::getPF(basename(__DIR__) . '/icon.svg')),
|
||||||
'large-icon' => urldecode(dcPage::getPF('translater/icon.svg')),
|
'large-icon' => urldecode(dcPage::getPF(basename(__DIR__) . '/icon.svg')),
|
||||||
//'permissions' => null,
|
//'permissions' => null,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ if (!empty($_POST['save'])) {
|
|||||||
);
|
);
|
||||||
dcCore::app()->adminurl->redirect(
|
dcCore::app()->adminurl->redirect(
|
||||||
'admin.plugins',
|
'admin.plugins',
|
||||||
['module' => 'translater', 'conf' => 1, 'redir' => dcCore::app()->admin->__get('list')->getRedir()]
|
['module' => basename(__DIR__), 'conf' => 1, 'redir' => dcCore::app()->admin->__get('list')->getRedir()]
|
||||||
);
|
);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
|
@ -24,7 +24,7 @@ $this->registerModule(
|
|||||||
'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/' . basename(__DIR__),
|
||||||
'repository' => 'https://raw.githubusercontent.com/JcDenis/translater/master/dcstore.xml',
|
'repository' => 'https://raw.githubusercontent.com/JcDenis/' . basename(__DIR__) . '/master/dcstore.xml',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -23,5 +23,5 @@ Clearbricks::lib()->autoload([
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
if (isset(dcCore::app()->adminurl)) {
|
if (isset(dcCore::app()->adminurl)) {
|
||||||
dcCore::app()->adminurl->register('translater', 'plugin.php', ['p' => 'translater']);
|
dcCore::app()->adminurl->register(basename(__DIR__), 'plugin.php', ['p' => basename(__DIR__)]);
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ $this->addUserAction(
|
|||||||
/* action */
|
/* action */
|
||||||
'delete_all',
|
'delete_all',
|
||||||
/* ns */
|
/* ns */
|
||||||
'translater',
|
basename(__DIR__),
|
||||||
/* description */
|
/* description */
|
||||||
__('delete all settings')
|
__('delete all settings')
|
||||||
);
|
);
|
||||||
@ -31,7 +31,7 @@ $this->addUserAction(
|
|||||||
/* action */
|
/* action */
|
||||||
'delete',
|
'delete',
|
||||||
/* ns */
|
/* ns */
|
||||||
'translater',
|
basename(__DIR__),
|
||||||
/* description */
|
/* description */
|
||||||
__('delete plugin files')
|
__('delete plugin files')
|
||||||
);
|
);
|
||||||
@ -42,7 +42,7 @@ $this->addUserAction(
|
|||||||
/* action */
|
/* action */
|
||||||
'delete',
|
'delete',
|
||||||
/* ns */
|
/* ns */
|
||||||
'translater',
|
basename(__DIR__),
|
||||||
/* description */
|
/* description */
|
||||||
__('delete the version number')
|
__('delete the version number')
|
||||||
);
|
);
|
||||||
@ -53,9 +53,9 @@ $this->addDirectAction(
|
|||||||
/* action */
|
/* action */
|
||||||
'delete_all',
|
'delete_all',
|
||||||
/* ns */
|
/* ns */
|
||||||
'translater',
|
basename(__DIR__),
|
||||||
/* description */
|
/* description */
|
||||||
sprintf(__('delete all %s settings'), 'translater')
|
sprintf(__('delete all %s settings'), basename(__DIR__))
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addDirectAction(
|
$this->addDirectAction(
|
||||||
@ -64,9 +64,9 @@ $this->addDirectAction(
|
|||||||
/* action */
|
/* action */
|
||||||
'delete',
|
'delete',
|
||||||
/* ns */
|
/* ns */
|
||||||
'translater',
|
basename(__DIR__),
|
||||||
/* description */
|
/* description */
|
||||||
sprintf(__('delete %s plugin files'), 'translater')
|
sprintf(__('delete %s plugin files'), basename(__DIR__))
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addDirectAction(
|
$this->addDirectAction(
|
||||||
@ -75,7 +75,7 @@ $this->addDirectAction(
|
|||||||
/* action */
|
/* action */
|
||||||
'delete',
|
'delete',
|
||||||
/* ns */
|
/* ns */
|
||||||
'translater',
|
basename(__DIR__),
|
||||||
/* description */
|
/* description */
|
||||||
sprintf(__('delete %s version number'), 'translater')
|
sprintf(__('delete %s version number'), basename(__DIR__))
|
||||||
);
|
);
|
||||||
|
@ -106,7 +106,7 @@ class dcTranslaterModule
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'translater':
|
case 'translater':
|
||||||
$tmp = path::real(dcCore::app()->plugins->moduleRoot('translater'));
|
$tmp = path::real(dcCore::app()->plugins->moduleRoot(basename(dirname(__DIR__))));
|
||||||
if ($tmp && is_writable($tmp)) {
|
if ($tmp && is_writable($tmp)) {
|
||||||
@mkDir($tmp . '/locales');
|
@mkDir($tmp . '/locales');
|
||||||
$dir = $tmp . '/locales';
|
$dir = $tmp . '/locales';
|
||||||
@ -676,7 +676,7 @@ class dcTranslaterModule
|
|||||||
$content .= '# Author: ' . html::escapeHTML($info) . "\n";
|
$content .= '# Author: ' . html::escapeHTML($info) . "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$content .= '# Translated with translater ' . dcCore::app()->plugins->moduleInfo('translater', 'version') . "\n\n";
|
$content .= '# Translated with translater ' . dcCore::app()->plugins->moduleInfo(basename(dirname(__DIR__)), 'version') . "\n\n";
|
||||||
}
|
}
|
||||||
$content .= "msgid \"\"\n" .
|
$content .= "msgid \"\"\n" .
|
||||||
"msgstr \"\"\n" .
|
"msgstr \"\"\n" .
|
||||||
@ -767,7 +767,7 @@ class dcTranslaterModule
|
|||||||
$content .= '// Author: ' . html::escapeHTML($info) . "\n";
|
$content .= '// Author: ' . html::escapeHTML($info) . "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$content .= '// Translated with dcTranslater - ' . dcCore::app()->plugins->moduleInfo('translater', 'version') . "\n\n";
|
$content .= '// Translated with dcTranslater - ' . dcCore::app()->plugins->moduleInfo(basename(dirname(__DIR__)), 'version') . "\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
l10n::generatePhpFileFromPo($this->locales . '/' . $lang->code . '/' . $group, $content);
|
l10n::generatePhpFileFromPo($this->locales . '/' . $lang->code . '/' . $group, $content);
|
||||||
|
@ -104,7 +104,7 @@ 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') => basename(dirname(__DIR__)),
|
||||||
];
|
];
|
||||||
self::$default_distrib_modules = [
|
self::$default_distrib_modules = [
|
||||||
'plugin' => explode(',', DC_DISTRIB_PLUGINS),
|
'plugin' => explode(',', DC_DISTRIB_PLUGINS),
|
||||||
@ -120,7 +120,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 = dcCore::app()->blog->settings->get('translater')->get($key);
|
$this->$key = dcCore::app()->blog->settings->get(basename(dirname(__DIR__)))->get($key);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
settype($this->$key, gettype($value));
|
settype($this->$key, gettype($value));
|
||||||
@ -137,8 +137,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) {
|
||||||
dcCore::app()->blog->settings->get('translater')->drop($key);
|
dcCore::app()->blog->settings->get(basename(dirname(__DIR__)))->drop($key);
|
||||||
dcCore::app()->blog->settings->get('translater')->put($key, $this->$key, gettype($value), '', true, true);
|
dcCore::app()->blog->settings->get(basename(dirname(__DIR__)))->put($key, $this->$key, gettype($value), '', true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,6 +161,7 @@ class dcTranslater extends dcTranslaterDefaultSettings
|
|||||||
if (preg_match('/^translater_(.*?)$/', $record->setting_id, $match)) {
|
if (preg_match('/^translater_(.*?)$/', $record->setting_id, $match)) {
|
||||||
$cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME);
|
$cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME);
|
||||||
$cur->setting_id = $this->{$match[1]} = $match[1];
|
$cur->setting_id = $this->{$match[1]} = $match[1];
|
||||||
|
$cur->setting_ns = basename(dirname(__DIR__));
|
||||||
$cur->update(
|
$cur->update(
|
||||||
"WHERE setting_id = '" . $record->setting_id . "' and setting_ns = 'translater' " .
|
"WHERE setting_id = '" . $record->setting_id . "' and setting_ns = 'translater' " .
|
||||||
'AND blog_id ' . (null === $record->blog_id ? 'IS NULL ' : ("= '" . dcCore::app()->con->escape($record->blog_id) . "' "))
|
'AND blog_id ' . (null === $record->blog_id ? 'IS NULL ' : ("= '" . dcCore::app()->con->escape($record->blog_id) . "' "))
|
||||||
|
@ -27,7 +27,7 @@ class googleProposalTool extends translaterProposalTool
|
|||||||
|
|
||||||
protected function setup()
|
protected function setup()
|
||||||
{
|
{
|
||||||
$this->key = dcCore::app()->blog->settings->translater->translater_google_proposal_key;
|
$this->key = dcCore::app()->blog->settings->get(basename(dirname(__DIR__)))->get('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'];
|
||||||
|
|
||||||
dcCore::app()->blog->settings->translater->put('translater_google_proposal_key', $key, 'string', '', true, true);
|
dcCore::app()->blog->settings->get(basename(dirname(__DIR__)))->put('google_proposal_key', $key, 'string', '', true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function translate($str, $from, $to)
|
public function translate($str, $from, $to)
|
||||||
|
@ -27,8 +27,8 @@ class microsoftProposalTool extends translaterProposalTool
|
|||||||
protected function setup()
|
protected function setup()
|
||||||
{
|
{
|
||||||
$this->setActive(false);
|
$this->setActive(false);
|
||||||
$this->client = dcCore::app()->blog->settings->translater->translater_microsoft_proposal_client;
|
$this->client = dcCore::app()->blog->settings->get(basename(dirname(__DIR__)))->get('microsoft_proposal_client');
|
||||||
$this->secret = dcCore::app()->blog->settings->translater->translater_microsoft_proposal_secret;
|
$this->secret = dcCore::app()->blog->settings->get(basename(dirname(__DIR__)))->get('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'];
|
||||||
|
|
||||||
dcCore::app()->blog->settings->translater->put('translater_microsoft_proposal_client', $client, 'string', '', true, true);
|
dcCore::app()->blog->settings->get(basename(dirname(__DIR__)))->put('microsoft_proposal_client', $client, 'string', '', true, true);
|
||||||
dcCore::app()->blog->settings->translater->put('translater_microsoft_proposal_secret', $secret, 'string', '', true, true);
|
dcCore::app()->blog->settings->get(basename(dirname(__DIR__)))->put('microsoft_proposal_secret', $secret, 'string', '', true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function translate($str, $from, $to)
|
public function translate($str, $from, $to)
|
||||||
|
64
index.php
64
index.php
@ -45,17 +45,17 @@ if (!empty($module) && !empty($lang)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$breadcrumb = [__('Translater') => dcCore::app()->adminurl->get('translater', ['type' => '-'])];
|
$breadcrumb = [__('Translater') => dcCore::app()->adminurl->get(basename(__DIR__), ['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')] = dcCore::app()->adminurl->get('translater', ['type' => $type]);
|
$breadcrumb[$type == 'plugin' ? __('Plugins') : __('Themes')] = dcCore::app()->adminurl->get(basename(__DIR__), ['type' => $type]);
|
||||||
$breadcrumb[html::escapeHTML($module->name)] = '';
|
$breadcrumb[html::escapeHTML($module->name)] = '';
|
||||||
} elseif (!empty($lang)) {
|
} elseif (!empty($lang)) {
|
||||||
$breadcrumb[$type == 'plugin' ? __('Plugins') : __('Themes')] = dcCore::app()->adminurl->get('translater', ['type' => $type]);
|
$breadcrumb[$type == 'plugin' ? __('Plugins') : __('Themes')] = dcCore::app()->adminurl->get(basename(__DIR__), ['type' => $type]);
|
||||||
$breadcrumb[html::escapeHTML($module->name)] = dcCore::app()->adminurl->get('translater', ['type' => $type, 'module' => $module->id]);
|
$breadcrumb[html::escapeHTML($module->name)] = dcCore::app()->adminurl->get(basename(__DIR__), ['type' => $type, 'module' => $module->id]);
|
||||||
$breadcrumb[html::escapeHTML(sprintf(__('%s language edition'), $lang->name))] = '';
|
$breadcrumb[html::escapeHTML(sprintf(__('%s language edition'), $lang->name))] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ try {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dcAdminNotices::addSuccessNotice(__('Backup successfully created'));
|
dcAdminNotices::addSuccessNotice(__('Backup successfully created'));
|
||||||
dcCore::app()->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id]);
|
dcCore::app()->adminurl->redirect(basename(__DIR__), ['type' => $type, 'module' => $module->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'module_restore_backup') {
|
if ($action == 'module_restore_backup') {
|
||||||
@ -85,7 +85,7 @@ try {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dcAdminNotices::addSuccessNotice(__('Backup successfully restored'));
|
dcAdminNotices::addSuccessNotice(__('Backup successfully restored'));
|
||||||
dcCore::app()->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id]);
|
dcCore::app()->adminurl->redirect(basename(__DIR__), ['type' => $type, 'module' => $module->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'module_delete_backup') {
|
if ($action == 'module_delete_backup') {
|
||||||
@ -99,7 +99,7 @@ try {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dcAdminNotices::addSuccessNotice(__('Backup successfully deleted'));
|
dcAdminNotices::addSuccessNotice(__('Backup successfully deleted'));
|
||||||
dcCore::app()->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id]);
|
dcCore::app()->adminurl->redirect(basename(__DIR__), ['type' => $type, 'module' => $module->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'module_export_pack') {
|
if ($action == 'module_export_pack') {
|
||||||
@ -109,7 +109,7 @@ try {
|
|||||||
$module->exportPack($_POST['codes']);
|
$module->exportPack($_POST['codes']);
|
||||||
|
|
||||||
dcAdminNotices::addSuccessNotice(__('Language successfully exported'));
|
dcAdminNotices::addSuccessNotice(__('Language successfully exported'));
|
||||||
dcCore::app()->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id]);
|
dcCore::app()->adminurl->redirect(basename(__DIR__), ['type' => $type, 'module' => $module->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'module_import_pack') {
|
if ($action == 'module_import_pack') {
|
||||||
@ -119,7 +119,7 @@ try {
|
|||||||
$module->importPack($_FILES['packfile']);
|
$module->importPack($_FILES['packfile']);
|
||||||
|
|
||||||
dcAdminNotices::addSuccessNotice(__('Language successfully imported'));
|
dcAdminNotices::addSuccessNotice(__('Language successfully imported'));
|
||||||
dcCore::app()->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id]);
|
dcCore::app()->adminurl->redirect(basename(__DIR__), ['type' => $type, 'module' => $module->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'module_add_code') {
|
if ($action == 'module_add_code') {
|
||||||
@ -129,7 +129,7 @@ try {
|
|||||||
$module->addLang($_POST['code'], $_POST['from'] ?? '');
|
$module->addLang($_POST['code'], $_POST['from'] ?? '');
|
||||||
|
|
||||||
dcAdminNotices::addSuccessNotice(__('Language successfully added'));
|
dcAdminNotices::addSuccessNotice(__('Language successfully added'));
|
||||||
dcCore::app()->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id, 'lang' => $_POST['code']]);
|
dcCore::app()->adminurl->redirect(basename(__DIR__), ['type' => $type, 'module' => $module->id, 'lang' => $_POST['code']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'module_delete_codes') {
|
if ($action == 'module_delete_codes') {
|
||||||
@ -143,7 +143,7 @@ try {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dcAdminNotices::addSuccessNotice(__('Language successfully deleted'));
|
dcAdminNotices::addSuccessNotice(__('Language successfully deleted'));
|
||||||
dcCore::app()->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id, 'lang' => $_POST['code']]);
|
dcCore::app()->adminurl->redirect(basename(__DIR__), ['type' => $type, 'module' => $module->id, 'lang' => $_POST['code']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'module_update_code') {
|
if ($action == 'module_update_code') {
|
||||||
@ -160,7 +160,7 @@ try {
|
|||||||
$module->updLang($_POST['code'], $_POST['entries']);
|
$module->updLang($_POST['code'], $_POST['entries']);
|
||||||
|
|
||||||
dcAdminNotices::addSuccessNotice(__('Language successfully updated'));
|
dcAdminNotices::addSuccessNotice(__('Language successfully updated'));
|
||||||
dcCore::app()->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id, 'lang' => $_POST['code']]);
|
dcCore::app()->adminurl->redirect(basename(__DIR__), ['type' => $type, 'module' => $module->id, 'lang' => $_POST['code']]);
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
@ -169,13 +169,13 @@ try {
|
|||||||
echo
|
echo
|
||||||
'<html><head><title>' . __('Translater') . '</title>' .
|
'<html><head><title>' . __('Translater') . '</title>' .
|
||||||
dcPage::jsPageTabs() .
|
dcPage::jsPageTabs() .
|
||||||
dcPage::cssModuleLoad('translater/css/translater.css')) .
|
dcPage::cssModuleLoad(basename(__DIR__) . '/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(basename(__DIR__) . '/img/field.png'),
|
||||||
'image_toggle' => dcPage::getPF('translater/img/toggle.png'),
|
'image_toggle' => dcPage::getPF(basename(__DIR__) . '/img/toggle.png'),
|
||||||
]) .
|
]) .
|
||||||
dcPage::jsModuleLoad('translater/js/translater.js') .
|
dcPage::jsModuleLoad(basename(__DIR__) . '/js/translater.js') .
|
||||||
|
|
||||||
# --BEHAVIOR-- translaterAdminHeaders
|
# --BEHAVIOR-- translaterAdminHeaders
|
||||||
dcCore::app()->callBehavior('translaterAdminHeaders') .
|
dcCore::app()->callBehavior('translaterAdminHeaders') .
|
||||||
@ -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="' . dcCore::app()->adminurl->get('translater', ['type' => 'plugin']) . '">';
|
echo '<form id="theme-form" method="post" action="' . dcCore::app()->adminurl->get(basename(__DIR__), ['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>',
|
||||||
dcCore::app()->adminurl->get('translater', ['type' => $module->type, 'module' => $module->id]),
|
dcCore::app()->adminurl->get(basename(__DIR__), ['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))),
|
||||||
dcCore::app()->adminurl->get('translater', ['type' => $module->type, 'module' => $module->id, 'lang' => $code_id]),
|
dcCore::app()->adminurl->get(basename(__DIR__), ['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="' . dcCore::app()->adminurl->get('translater') . '">' .
|
'<form id="module-translations-form" method="post" action="' . dcCore::app()->adminurl->get(basename(__DIR__)) . '">' .
|
||||||
'<table class="clear maximal">' .
|
'<table class="clear maximal">' .
|
||||||
'<caption>' . __('Existing languages translations') . '</caption>' .
|
'<caption>' . __('Existing languages translations') . '</caption>' .
|
||||||
'<tr>' .
|
'<tr>' .
|
||||||
@ -283,7 +283,7 @@ 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="' .
|
||||||
dcCore::app()->adminurl->get('translater', ['type' => $module->type, 'module' => $module->id, 'lang' => $code_id])
|
dcCore::app()->adminurl->get(basename(__DIR__), ['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>';
|
||||||
@ -317,7 +317,7 @@ if (empty($module) && $type != '') {
|
|||||||
<input id="do-action" type="submit" value="' . __('ok') . '" /></p>' .
|
<input id="do-action" type="submit" value="' . __('ok') . '" /></p>' .
|
||||||
dcCore::app()->formNonce() .
|
dcCore::app()->formNonce() .
|
||||||
dcCore::app()->adminurl->getHiddenFormFields(
|
dcCore::app()->adminurl->getHiddenFormFields(
|
||||||
'translater',
|
basename(__DIR__),
|
||||||
['type' => $module->type, 'module' => $module->id]
|
['type' => $module->type, 'module' => $module->id]
|
||||||
) . '
|
) . '
|
||||||
</p></div></form><p> </p></div>';
|
</p></div></form><p> </p></div>';
|
||||||
@ -328,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="' . dcCore::app()->adminurl->get('translater') . '">' .
|
'<form id="module-backups-form" method="post" action="' . dcCore::app()->adminurl->get(basename(__DIR__)) . '">' .
|
||||||
'<table class="clear">' .
|
'<table class="clear">' .
|
||||||
'<caption>' . __('Existing languages backups') . '</caption>' .
|
'<caption>' . __('Existing languages backups') . '</caption>' .
|
||||||
'<tr>' .
|
'<tr>' .
|
||||||
@ -382,7 +382,7 @@ if (empty($module) && $type != '') {
|
|||||||
<input id="do-action" type="submit" value="' . __('ok') . '" /></p>' .
|
<input id="do-action" type="submit" value="' . __('ok') . '" /></p>' .
|
||||||
dcCore::app()->formNonce() .
|
dcCore::app()->formNonce() .
|
||||||
dcCore::app()->adminurl->getHiddenFormFields(
|
dcCore::app()->adminurl->getHiddenFormFields(
|
||||||
'translater',
|
basename(__DIR__),
|
||||||
['type' => $module->type, 'module' => $module->id]
|
['type' => $module->type, 'module' => $module->id]
|
||||||
) . '
|
) . '
|
||||||
</p></div></form><p> </p></div>';
|
</p></div></form><p> </p></div>';
|
||||||
@ -394,7 +394,7 @@ 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="' . dcCore::app()->adminurl->get('translater') . '">
|
<form id="muodule-code-create-form" method="post" action="' . dcCore::app()->adminurl->get(basename(__DIR__)) . '">
|
||||||
<p class="field"><label for="code">' . __('Select language:') . '</label>' .
|
<p class="field"><label for="code">' . __('Select language:') . '</label>' .
|
||||||
form::combo(['code'], array_merge(['-' => '-'], $unused_codes), dcCore::app()->auth->getInfo('user_lang')) . '</p>';
|
form::combo(['code'], array_merge(['-' => '-'], $unused_codes), dcCore::app()->auth->getInfo('user_lang')) . '</p>';
|
||||||
if (empty($codes)) {
|
if (empty($codes)) {
|
||||||
@ -408,7 +408,7 @@ if (empty($module) && $type != '') {
|
|||||||
<p><input type="submit" name="save" value="' . __('Create') . '" />' .
|
<p><input type="submit" name="save" value="' . __('Create') . '" />' .
|
||||||
dcCore::app()->formNonce() .
|
dcCore::app()->formNonce() .
|
||||||
dcCore::app()->adminurl->getHiddenFormFields(
|
dcCore::app()->adminurl->getHiddenFormFields(
|
||||||
'translater',
|
basename(__DIR__),
|
||||||
['type' => $module->type, 'module' => $module->id, 'action' => 'module_add_code']
|
['type' => $module->type, 'module' => $module->id, 'action' => 'module_add_code']
|
||||||
) . '
|
) . '
|
||||||
</p></form><p> </p></div>';
|
</p></form><p> </p></div>';
|
||||||
@ -416,14 +416,14 @@ 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="' . dcCore::app()->adminurl->get('translater') . '" enctype="multipart/form-data">
|
<form id="module-pack-import-form" method="post" action="' . dcCore::app()->adminurl->get(basename(__DIR__)) . '" enctype="multipart/form-data">
|
||||||
<p><label for="packfile">' . __('Select languages package to import:') . '<label> ' .
|
<p><label for="packfile">' . __('Select languages package to import:') . '<label> ' .
|
||||||
'<input id="packfile" type="file" name="packfile" /></p>
|
'<input id="packfile" type="file" name="packfile" /></p>
|
||||||
<p>
|
<p>
|
||||||
<input type="submit" name="save" value="' . __('Import') . '" />' .
|
<input type="submit" name="save" value="' . __('Import') . '" />' .
|
||||||
dcCore::app()->formNonce() .
|
dcCore::app()->formNonce() .
|
||||||
dcCore::app()->adminurl->getHiddenFormFields(
|
dcCore::app()->adminurl->getHiddenFormFields(
|
||||||
'translater',
|
basename(__DIR__),
|
||||||
['type' => $module->type, 'module' => $module->id, 'action' => 'module_import_pack']
|
['type' => $module->type, 'module' => $module->id, 'action' => 'module_import_pack']
|
||||||
) . '
|
) . '
|
||||||
</p></form><p> </p></div>';
|
</p></form><p> </p></div>';
|
||||||
@ -437,7 +437,7 @@ if (empty($module) && $type != '') {
|
|||||||
|
|
||||||
echo
|
echo
|
||||||
'<div id="lang-form">' .
|
'<div id="lang-form">' .
|
||||||
'<form id="lang-edit-form" method="post" action="' . dcCore::app()->adminurl->get('translater') . '">' .
|
'<form id="lang-edit-form" method="post" action="' . dcCore::app()->adminurl->get(basename(__DIR__)) . '">' .
|
||||||
'<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>' .
|
||||||
@ -564,7 +564,7 @@ if (empty($module) && $type != '') {
|
|||||||
dcCore::app()->formNonce() .
|
dcCore::app()->formNonce() .
|
||||||
form::hidden(['code'], $lang->code) .
|
form::hidden(['code'], $lang->code) .
|
||||||
dcCore::app()->adminurl->getHiddenFormFields(
|
dcCore::app()->adminurl->getHiddenFormFields(
|
||||||
'translater',
|
basename(__DIR__),
|
||||||
['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']
|
||||||
) .
|
) .
|
||||||
'</p></div>' .
|
'</p></div>' .
|
||||||
@ -580,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,
|
||||||
dcCore::app()->adminurl->get('translater', ['type' => 'plugin']),
|
dcCore::app()->adminurl->get(basename(__DIR__), ['type' => 'plugin']),
|
||||||
$type == 'plugin' ? ' class="active"' : '',
|
$type == 'plugin' ? ' class="active"' : '',
|
||||||
__('Translate plugins')
|
__('Translate plugins')
|
||||||
) .
|
) .
|
||||||
sprintf(
|
sprintf(
|
||||||
$line,
|
$line,
|
||||||
dcCore::app()->adminurl->get('translater', ['type' => 'theme']),
|
dcCore::app()->adminurl->get(basename(__DIR__), ['type' => 'theme']),
|
||||||
$type == 'theme' ? ' class="active"' : '',
|
$type == 'theme' ? ' class="active"' : '',
|
||||||
__('Translate themes')
|
__('Translate themes')
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user