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')]; 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_backup') { if (empty($module) || empty($_POST['codes'])) { throw new Exception(__('No lang 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], '#module-backup'); } if ($action == 'module_restore_backup') { if (empty($module) || empty($_POST['files'])) { throw New Exception(__('No backup 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], '#module-backup'); } if ($action == 'module_delete_backup') { if (empty($module) || empty($_POST['files'])) { throw New Exception(__('No backup 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], '#module-backup'); } if ($action == 'module_export_pack') { if (empty($module) || empty($_POST['codes'])) { throw new Exception(__('Nothing to export')); } $module->exportPack($_POST['codes']); dcPage::addSuccessNotice(__('Package successfully exported')); $core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id], '#module-pack'); } if ($action == 'module_import_pack') { if (empty($_FILES['packfile']['name'])) { throw new Exception(__('Nothing to import')); } $module->importPack($_FILES['packfile']); dcPage::addSuccessNotice(__('Package successfully imported')); $core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id], '#module-pack'); } if ($action == 'module_add_code') { if (empty($module) || empty($_POST['code'])) { throw new Exception(__('No lang to create')); } $module->addLang($_POST['code'], $_POST['from'] ?? ''); dcPage::addSuccessNotice(__('Lang 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')); } $module->delLang($_POST['code']); dcPage::addSuccessNotice(__('Lang 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')); } 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(__('Lang successfully updated')); $core->adminurl->redirect('translater', ['type' => $type, 'module' => $module->id, 'lang' => $_POST['code']]); } } catch (Exception $e) { $core->error->add($e->getMessage()); } echo '
' . __('Name') . ' | ' . $module->name . ' |
' . __('Version') . ' | ' . $module->version . ' |
' . __('Author') . ' | ' . $module->author . ' |
' . __('Type') . ' | ' . $module->type . ' |
' . __('Root') . ' | ' . $module->root . ' |
' . __('Locales') . ' | ' . $module->locales . ' |
' . __('Backups') . ' | ' . $module->getBackupRoot() . ' |
'; if (count($codes)) { echo '
' . __('Languages') . ' | ' . '' . __('Code') . ' | ' . '' . __('Backups') . ' | ' . '' . __('Last backup') . ' | ' . '||
---|---|---|---|---|---|
' . '' . $code_name . '' . ' | ' . '' . $code_id . ' | '; if (isset($backups[$code_id])) { foreach($backups[$code_id] AS $file => $info) { $time[$code_id] = isset($time[$code_id]) && $time[$code_id] > $info['time'] ? $time[$code_id] : $info['time']; } echo '' . count($backups[$code_id]) . ' | ' . '' . dt::str('%Y-%m-%d %H:%M', $time[$code_id], $core->blog->settings->system->blog_timezone) . ' | '; } else { echo '' . __('no backup') . ' | - | '; } echo '
'; } // add lang if (!empty($unused_codes)) { echo '
'; } // delete langs if (!empty($codes)) { echo '
'; } echo '
'; } // delete / retore backups if (!empty($backups)) { echo '
'; } echo '
'; // Export if (!empty($codes)) { echo '
'; } echo '
' . '