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