diff --git a/index.php b/index.php index 5390f18..9172d9f 100644 --- a/index.php +++ b/index.php @@ -61,9 +61,9 @@ if (empty($type)) { } try { - if ($action == 'module_create_backup') { + if ($action == 'module_create_backups') { if (empty($module) || empty($_POST['codes'])) { - throw new Exception(__('No lang to backup')); + throw new Exception(__('Nothing to backup')); } $module_codes = $module->getUsedlangs(); foreach($module_codes as $code_id) { @@ -72,12 +72,12 @@ try { } } dcPage::addSuccessNotice(__('Backup successfully created')); - $core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id], '#module-backup'); + $core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id]); } if ($action == 'module_restore_backup') { if (empty($module) || empty($_POST['files'])) { - throw New Exception(__('No backup to restore')); + throw New Exception(__('Nothing to restore')); } $module_backups = $module->getBackups(true); foreach($module_backups as $backup_file) { @@ -86,12 +86,12 @@ try { } } dcPage::addSuccessNotice(__('Backup successfully restored')); - $core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id], '#module-backup'); + $core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id]); } if ($action == 'module_delete_backup') { if (empty($module) || empty($_POST['files'])) { - throw New Exception(__('No backup to delete')); + throw New Exception(__('Nothing to delete')); } $module_backups = $module->getBackups(true); foreach($module_backups as $backup_file) { @@ -100,7 +100,7 @@ try { } } dcPage::addSuccessNotice(__('Backup successfully deleted')); - $core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id], '#module-backup'); + $core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id]); } if ($action == 'module_export_pack') { @@ -109,8 +109,8 @@ try { } $module->exportPack($_POST['codes']); - dcPage::addSuccessNotice(__('Package successfully exported')); - $core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id], '#module-pack'); + dcPage::addSuccessNotice(__('Language successfully exported')); + $core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id]); } if ($action == 'module_import_pack') { @@ -119,33 +119,37 @@ try { } $module->importPack($_FILES['packfile']); - dcPage::addSuccessNotice(__('Package successfully imported')); - $core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id], '#module-pack'); + dcPage::addSuccessNotice(__('Language successfully imported')); + $core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id]); } if ($action == 'module_add_code') { if (empty($module) || empty($_POST['code'])) { - throw new Exception(__('No lang to create')); + throw new Exception(__('Nothing to create')); } $module->addLang($_POST['code'], $_POST['from'] ?? ''); - dcPage::addSuccessNotice(__('Lang successfully added')); + dcPage::addSuccessNotice(__('Language successfully added')); $core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id, 'lang' => $_POST['code']]); } - if ($action == 'module_delete_code') { - if (empty($module) || empty($_POST['code'])) { - throw new Exception(__('No lang to delete')); + if ($action == 'module_delete_codes') { + if (empty($module) || empty($_POST['codes'])) { + throw new Exception(__('Nothing to delete')); } - $module->delLang($_POST['code']); - - dcPage::addSuccessNotice(__('Lang successfully deleted')); + $module_codes = $module->getUsedlangs(); + foreach($module_codes as $code_id) { + if (in_array($code_id, $_POST['codes'])) { + $module->delLang($code_id); + } + } + dcPage::addSuccessNotice(__('Language successfully deleted')); $core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id, 'lang' => $_POST['code']]); } if ($action == 'module_update_code') { if (empty($module) || empty($_POST['code']) || empty($_POST['entries'])) { - throw new Exception(__('No lang to update')); + throw new Exception(__('Nothing to update')); } if (!empty($_POST['update_group'])) { foreach($_POST['entries'] as $i => $entry) { @@ -156,7 +160,7 @@ try { } $module->updLang($_POST['code'], $_POST['entries']); - dcPage::addSuccessNotice(__('Lang successfully updated')); + dcPage::addSuccessNotice(__('Language successfully updated')); $core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id, 'lang' => $_POST['code']]); } @@ -211,7 +215,7 @@ if (empty($module) && $type != '') { if ($module->root_writable) { $codes[$code_id] = sprintf( '%s (%s)', - html::escapeHTML(sprintf(__('Edit translation %s of the module %s'), html::escapeHTML($code_name), __($module->name))), + 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]), html::escapeHTML($code_name), $code_id @@ -233,10 +237,10 @@ if (empty($module) && $type != '') {
' . __('Name') . ' | -' . __('Languages') . ' | -' . __('Id') . ' | -' . __('Version') . ' | +' . __('Name') . ' | +' . __('Languages') . ' | +' . __('Id') . ' | +' . __('Version') . ' |
---|
' . __('Name') . ' | ' . $module->name . ' | -
' . __('Version') . ' | ' . $module->version . ' | -
' . __('Author') . ' | ' . $module->author . ' | -
' . __('Type') . ' | ' . $module->type . ' | -
' . __('Root') . ' | ' . $module->root . ' | -
' . __('Locales') . ' | ' . $module->locales . ' | -
' . __('Backups') . ' | ' . $module->getBackupRoot() . ' | -
'; + + // existing languages if (count($codes)) { echo - '
'; +
'; - } - - // delete langs - if (!empty($codes)) { - echo '
'; - } - echo '
'; - } - // delete / retore backups if (!empty($backups)) { - echo '