start_page ?: ''; $module = $_REQUEST['module'] ?? ''; $lang = $_REQUEST['lang'] ?? ''; $action = $_POST['action'] ?? ''; if (!in_array($type, ['plugin', 'theme'])) { $type = ''; } if (!empty($type) && !empty($module)) { try { $module = $translater->getModule($type, $module); } catch(Exception $e) { $core->error->add($e->getMessage()); $module = ''; } } if (!empty($module) && !empty($lang)) { try { $lang = $translater->getLang($module, $lang); } catch(Exception $e) { $core->error->add($e->getMessage()); $lang = ''; } } $breadcrumb = [__('Translater') => $core->adminurl->get('translater', ['type' => '-'])]; if (empty($type)) { $breadcrumb = [__('Translater') => '']; } elseif (empty($module)) { $breadcrumb[$type == 'plugin' ? __('Plugins') : __('Themes')] = ''; } elseif (empty($lang)) { $breadcrumb[$type == 'plugin' ? __('Plugins') : __('Themes')] = $core->adminurl->get('translater', ['type' => $type]); $breadcrumb[html::escapeHTML($module->name)] = ''; } elseif (!empty($lang)) { $breadcrumb[$type == 'plugin' ? __('Plugins') : __('Themes')] = $core->adminurl->get('translater', ['type' => $type]); $breadcrumb[html::escapeHTML($module->name)] = $core->adminurl->get('translater', ['type' => $type, 'module' => $module->id]); $breadcrumb[html::escapeHTML(sprintf(__('%s language edition'), $lang->name))] = ''; } try { if ($action == 'module_create_backups') { if (empty($module) || empty($_POST['codes'])) { throw new Exception(__('Nothing to backup')); } $module_codes = $module->getUsedlangs(); foreach($module_codes as $code_id) { if (in_array($code_id, $_POST['codes'])) { $module->createBackup($code_id); } } dcPage::addSuccessNotice(__('Backup successfully created')); $core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id]); } if ($action == 'module_restore_backup') { if (empty($module) || empty($_POST['files'])) { throw New Exception(__('Nothing to restore')); } $module_backups = $module->getBackups(true); foreach($module_backups as $backup_file) { if (in_array($backup_file, $_POST['files'])) { $module->restoreBackup($backup_file); } } dcPage::addSuccessNotice(__('Backup successfully restored')); $core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id]); } if ($action == 'module_delete_backup') { if (empty($module) || empty($_POST['files'])) { throw New Exception(__('Nothing to delete')); } $module_backups = $module->getBackups(true); foreach($module_backups as $backup_file) { if (in_array($backup_file, $_POST['files'])) { $module->deleteBackup($backup_file); } } dcPage::addSuccessNotice(__('Backup successfully deleted')); $core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id]); } if ($action == 'module_export_pack') { if (empty($module) || empty($_POST['codes'])) { throw new Exception(__('Nothing to export')); } $module->exportPack($_POST['codes']); dcPage::addSuccessNotice(__('Language successfully exported')); $core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id]); } if ($action == 'module_import_pack') { if (empty($_FILES['packfile']['name'])) { throw new Exception(__('Nothing to import')); } $module->importPack($_FILES['packfile']); 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(__('Nothing to create')); } $module->addLang($_POST['code'], $_POST['from'] ?? ''); dcPage::addSuccessNotice(__('Language successfully added')); $core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id, 'lang' => $_POST['code']]); } if ($action == 'module_delete_codes') { if (empty($module) || empty($_POST['codes'])) { throw new Exception(__('Nothing to delete')); } $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(__('Nothing to update')); } if (!empty($_POST['update_group'])) { foreach($_POST['entries'] as $i => $entry) { if (isset($entry['check']) && isset($_POST['multigroup'])) { $_POST['entries'][$i]['group'] = $_POST['multigroup']; } } } $module->updLang($_POST['code'], $_POST['entries']); dcPage::addSuccessNotice(__('Language successfully updated')); $core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id, 'lang' => $_POST['code']]); } } catch (Exception $e) { $core->error->add($e->getMessage()); } echo '
'; // existing languages if (count($codes)) { echo '
' . '