auth->isSuperAdmin() && version_compare(phpversion(), My::PHP_MIN, '>='); } return self::$init; } public static function process(): bool { if (!self::$init) { return false; } $current = ManageContainer::init(); // execute action try { if ($current->action == 'module_create_backups') { if (empty($current->module) || empty($_POST['codes'])) { throw new Exception(__('Nothing to backup')); } foreach ($current->module->getUsedlangs() as $code_id) { if (in_array($code_id, $_POST['codes'])) { $current->module->createBackup($code_id); } } self::redirect(__('Backup successfully created')); } if ($current->action == 'module_restore_backup') { if (empty($current->module) || empty($_POST['files'])) { throw new Exception(__('Nothing to restore')); } foreach ($current->module->getBackups(true) as $backup_file) { if (in_array($backup_file, $_POST['files'])) { $current->module->restoreBackup($backup_file); } } self::redirect(__('Backup successfully restored')); } if ($current->action == 'module_delete_backup') { if (empty($current->module) || empty($_POST['files'])) { throw new Exception(__('Nothing to delete')); } foreach ($current->module->getBackups(true) as $backup_file) { if (in_array($backup_file, $_POST['files'])) { $current->module->deleteBackup($backup_file); } } self::redirect(__('Backup successfully deleted')); } if ($current->action == 'module_export_pack') { if (empty($current->module) || empty($_POST['codes'])) { throw new Exception(__('Nothing to export')); } $current->module->exportPack($_POST['codes']); self::redirect(__('Language successfully exported')); } if ($current->action == 'module_import_pack') { if (empty($_FILES['packfile']['name'])) { throw new Exception(__('Nothing to import')); } $current->module->importPack($_FILES['packfile']); self::redirect(__('Language successfully imported')); } if ($current->action == 'module_add_code') { if (empty($current->module) || empty($_POST['code'])) { throw new Exception(__('Nothing to create')); } $current->module->addLang($_POST['code'], $_POST['from'] ?? ''); self::redirect(__('Language successfully added'), $_POST['code']); } if ($current->action == 'module_delete_codes') { if (empty($current->module) || empty($_POST['codes'])) { throw new Exception(__('Nothing to delete')); } foreach ($current->module->getUsedlangs() as $code_id) { if (in_array($code_id, $_POST['codes'])) { $current->module->delLang($code_id); } } self::redirect(__('Language successfully deleted'), $_POST['code']); } if ($current->action == 'module_update_code') { if (empty($current->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']; } } } $current->module->updLang($_POST['code'], $_POST['entries']); self::redirect(__('Language successfully updated'), $_POST['code']); } } catch (Exception $e) { dcCore::app()->error->add($e->getMessage()); } return true; } public static function render(): void { if (!self::$init) { return; } $current = ManageContainer::init(); $breadcrumb = [My::name() => dcCore::app()->adminurl->get(My::id(), ['type' => '-'])]; if (empty($current->type)) { $breadcrumb = [My::name() => '']; } elseif (empty($current->module)) { $breadcrumb[$current->type == 'plugin' ? __('Plugins') : __('Themes')] = ''; } elseif (empty($current->lang)) { $breadcrumb[$current->type == 'plugin' ? __('Plugins') : __('Themes')] = dcCore::app()->adminurl->get(My::id(), ['type' => $current->type]); $breadcrumb[html::escapeHTML($current->module->name)] = ''; } elseif (!empty($current->lang)) { $breadcrumb[$current->type == 'plugin' ? __('Plugins') : __('Themes')] = dcCore::app()->adminurl->get(My::id(), ['type' => $current->type]); $breadcrumb[html::escapeHTML($current->module->name)] = dcCore::app()->adminurl->get(My::id(), ['type' => $current->type, 'module' => $current->module->id]); $breadcrumb[html::escapeHTML(sprintf(__('%s language edition'), $current->lang->name))] = ''; } dcPage::openModule( My::name(), dcPage::jsPageTabs() . dcPage::cssModuleLoad(My::id() . '/css/backend.css') . dcPage::jsJson('translater', [ 'title_add_detail' => __('Use this text'), 'image_field' => dcPage::getPF(My::id() . '/img/field.png'), 'image_toggle' => dcPage::getPF(My::id() . '/img/toggle.png'), ]) . dcPage::jsModuleLoad(My::id() . '/js/backend.js') . # --BEHAVIOR-- translaterAdminHeaders dcCore::app()->callBehavior('translaterAdminHeaders') ); echo dcPage::breadcrumb($breadcrumb) . dcPage::notices(); if (empty($current->module) && $current->type != '') { // modules list echo '
'; dcPage::helpBlock('translater.type'); } elseif (!empty($current->module) && empty($current->lang)) { $codes = $current->module->getUsedLangs(); $backups = $current->module->getBackups(); $unused_codes = $current->module->getUnusedLangs(); // module summary echo ''; // existing languages if (count($codes)) { echo '
' . '