From d607508135a7b87a6010d40e90fe56f8086fda1f Mon Sep 17 00:00:00 2001 From: JcDenis Date: Thu, 19 Aug 2021 22:29:52 +0200 Subject: [PATCH] move settings to _config file --- _config.php | 26 ++++++++- index.php | 155 ---------------------------------------------------- 2 files changed, 25 insertions(+), 156 deletions(-) diff --git a/_config.php b/_config.php index 9a086f8..359365f 100644 --- a/_config.php +++ b/_config.php @@ -42,12 +42,36 @@ $combo_backup_folder = [ ]; $combo_start_page = [ - 'setting' => __('Settings'), 'modules_plugin' => __('Plugins'), 'modules_theme' => __('Themes'), 'pack' => __('Import/Export') ]; +# -- Set settings -- +if (!empty($_POST['save'])) { + try { + if (empty($_POST['translater_write_po']) + && empty($_POST['translater_write_langphp'])) { + throw new Exception('You must choose one file format at least'); + } + foreach($translater->getDefaultSettings() as $k => $v) { + $translater->set($k, (isset($_POST['translater_' . $k]) ? $_POST['translater_' . $k] : '')); + } + foreach($translater->proposal->getTools() AS $k => $v) { + $v->save(); + } + dcPage::addSuccessNotice( + __('Configuration has been successfully updated.') + ); + http::redirect( + $list->getURL('module=translater&conf=1&redir=' . + $list->getRedir()) + ); + } catch (Exception $e) { + $core->error->add(sprintf($errors[$action], $e->getMessage())); + } +} + # -- Display form -- echo '
diff --git a/index.php b/index.php index ecda5f3..1f9adda 100644 --- a/index.php +++ b/index.php @@ -23,30 +23,6 @@ dcPage::checkSuper(); $translater = new dcTranslater($core); -$combo_start_page = [ - 'setting' => __('Settings'), - 'modules_plugin' => __('Plugins'), - 'modules_theme' => __('Themes'), - 'pack' => __('Import/Export') -]; - -$combo_backup_limit = [ - 5 => 5, - 10 => 10, - 15 => 15, - 20 => 20, - 40 => 40, - 60 => 60 -]; - -$combo_backup_folder = [ - 'module' => __('locales folders of each module'), - 'plugin' => __('plugins folder root'), - 'public' => __('public folder root'), - 'cache' => __('cache folder of Dotclear'), - 'translater' =>__('locales folder of translater') -]; - $succes = [ 'save_setting' => __('Configuration successfully updated'), 'update_lang' => __('Translation successfully updated'), @@ -306,30 +282,6 @@ switch ($action) { } break; - /** - * Save settings - */ - case 'save_setting': - try { - if (empty($_POST['translater_write_po']) - && empty($_POST['translater_write_langphp'])) { - throw new Exception('You must choose one file format at least'); - } - - foreach($translater->getDefaultSettings() as $k => $v) { - $translater->set($k,(isset($_POST['translater_' . $k]) ? $_POST['translater_' . $k] : '')); - } - - foreach($translater->proposal->getTools() AS $k => $v) { - $v->save(); - } - - http::redirect($p_url . '&part=setting&msg=' . $action); - } catch (Exception $e) { - $core->error->add(sprintf($errors[$action], $e->getMessage())); - } - break; - /** * Modules / Unknow / None */ @@ -423,14 +375,6 @@ switch ($part) { case 'pack': $title = '' . __('Import/Export') . ''; break; - - /** - * Settings - */ - case 'setting': - default: - $title = '' . __('Settings') . ''; - break; } # @@ -1118,105 +1062,6 @@ switch ($part) {
'; break; - - /** - * Settings - */ - case 'setting': - default: - echo ' -
- -
-

-

-

-

-

-

-


- ' . form::field('translater_parse_userinfo', 65, 255, $translater->parse_userinfo) . '

-
- -
-

- -

' . __('Select and configure the tool to use to translate strings:') . '

'; - - foreach($translater->proposal->getTools() AS $k => $v) { - $form = $v->form(); - - echo ' -
-
' . - (empty($form) ? - '

' . sprintf(__('Nothing to configure for %s tool . '), $v->getName()) . '

' : - $form - ) . '
'; - } - - echo ' -
- -
-

-

-
- -
-

-

-

-
- -
-

-

-

-
- -
-

' . - $core->formNonce() . - form::hidden(array('p'), 'translater') . - form::hidden(array('part'), 'setting') . - form::hidden(array('action'), 'save_setting') . ' -

-
'; - break; } dcPage::helpBlock('translater');