fix install and behaviors
This commit is contained in:
parent
c8b0cba5ec
commit
3a18325a62
@ -44,7 +44,7 @@ class translaterAdminBehaviors
|
||||
private static function translater($core)
|
||||
{
|
||||
if (!(self::$translater instanceof dcTranslater)) {
|
||||
self::$translater = new dcTranslater($core);
|
||||
self::$translater = new dcTranslater($core, false);
|
||||
}
|
||||
return self::$translater;
|
||||
}
|
||||
@ -69,7 +69,7 @@ class translaterAdminBehaviors
|
||||
return
|
||||
' <input type="submit" name="translater[' .
|
||||
html::escapeHTML($id) .
|
||||
']" value="' . _('Translate') . '" /> ';
|
||||
']" value="' . __('Translate') . '" /> ';
|
||||
}
|
||||
|
||||
/**
|
||||
|
16
_install.php
16
_install.php
@ -14,19 +14,17 @@
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$id = 'translater';
|
||||
try {
|
||||
if (version_compare($core->getVersion($id), $this->moduleInfo($id, 'version'), '>=')) {
|
||||
if (version_compare($core->getVersion($id), $core->plugins->moduleInfo($id, 'version'), '>=')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$t = new dcTranslater($core);
|
||||
$s = $t->getDefaultSettings();
|
||||
foreach($s as $v) {
|
||||
$t->setSetting($v[0], $v[1], false);
|
||||
$translater = new dcTranslater($core, false);
|
||||
$settings = $translater->getDefaultSettings();
|
||||
foreach($settings as $key => $setting) {
|
||||
$translater->setSetting($key, $setting['value'], false);
|
||||
}
|
||||
|
||||
$core->setVersion($id, $this->moduleInfo($id, 'version'));
|
||||
$core->setVersion($id, $core->plugins->moduleInfo($id, 'version'));
|
||||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
|
@ -57,7 +57,7 @@ class dcTranslater
|
||||
],
|
||||
'start_page' => [
|
||||
'id' => 'translater_start_page',
|
||||
'value' => 'setting',
|
||||
'value' => '-',
|
||||
'type' => 'string',
|
||||
'label' => 'Page to start on'
|
||||
],
|
||||
@ -151,15 +151,18 @@ class dcTranslater
|
||||
/**
|
||||
* translater instance
|
||||
*
|
||||
* @param dcCore $core dcCore instance
|
||||
* @param dcCore $core dcCore instance
|
||||
* @param boolean $core Also load modules
|
||||
*/
|
||||
public function __construct($core)
|
||||
public function __construct(dcCore $core, bool $full = true)
|
||||
{
|
||||
$this->core = $core;
|
||||
$core->blog->settings->addNamespace('translater');
|
||||
$this->loadModules();
|
||||
|
||||
// fill with translated string
|
||||
if ($full) {
|
||||
$this->loadModules();
|
||||
}
|
||||
|
||||
self::$allowed_backup_folders = [
|
||||
__('locales folders of each module') => 'module',
|
||||
__('plugins folder root') => 'plugin',
|
||||
@ -167,8 +170,6 @@ class dcTranslater
|
||||
__('cache folder of Dotclear') => 'cache',
|
||||
__('locales folder of translater') => 'translater'
|
||||
];
|
||||
|
||||
// fill distrib modules list
|
||||
self::$default_distrib_modules = [
|
||||
'plugin' => explode(',', DC_DISTRIB_PLUGINS),
|
||||
'theme' => explode(',', DC_DISTRIB_THEMES)
|
||||
@ -215,20 +216,14 @@ class dcTranslater
|
||||
* @param mixed $overwrite Overwrite settings if exists
|
||||
* @return boolean Success
|
||||
*/
|
||||
public function setSetting(string $id, $value, $overwrite = true)
|
||||
public function setSetting(string $id, $value, $overwrite = true): bool
|
||||
{
|
||||
if (!array_key_exists($id, self::$default_settings)) {
|
||||
return false;
|
||||
}
|
||||
$this->core->blog->settings->translater->drop(self::$default_settings[$id]['id']);
|
||||
$this->core->blog->settings->translater->put(
|
||||
self::$default_settings[$id]['id'],
|
||||
$value,
|
||||
self::$default_settings[$id]['type'],
|
||||
self::$default_settings[$id]['label'],
|
||||
$overwrite,
|
||||
true
|
||||
);
|
||||
$s = self::$default_settings[$id];
|
||||
$this->core->blog->settings->translater->drop($s['id']);
|
||||
$this->core->blog->settings->translater->put($s['id'], $value, $s['type'], $s['label'], $overwrite, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user