diff --git a/module/backup/control.php b/module/backup/control.php index e7581508b6..28345d825c 100644 --- a/module/backup/control.php +++ b/module/backup/control.php @@ -58,6 +58,37 @@ class backup extends control $this->view->title = $this->lang->backup->common; $this->view->backups = $backups; + if(trim($this->config->visions, ',') == 'lite') + { + $version = $this->config->liteVersion; + $versionName = $this->lang->liteName . $this->config->liteVersion; + } + else + { + $version = $this->config->version; + $versionName = ($this->config->inQuickon ? 'DevOps' : '') . $this->lang->pmsName . $this->config->version; + } + + $latestVersionList = array(); + if(isset($this->config->global->latestVersionList)) $latestVersionList = json_decode($this->config->global->latestVersionList, true); + $latestVersion = $latestVersionList && version_compare(array_reverse(array_keys($latestVersionList))[0], $version, 'gt') ? array_reverse(array_keys($latestVersionList))[0] : $version; + + $this->app->loadLang('install'); + $this->app->loadLang('instance'); + $this->app->loadLang('system'); + + $systemInfo = new stdclass(); + $systemInfo->name = $versionName; + $systemInfo->status = $this->lang->instance->statusList['running']; + $systemInfo->currentVersion = $version; + $systemInfo->versionHint = $version; + $systemInfo->latestVersion = $latestVersion; + $systemInfo->upgradeable = $version != $latestVersion; + $systemInfo->upgradeHint = $systemInfo->upgradeable ? $this->lang->system->backup->versionInfo: null; + $systemInfo->latestURL = !empty($latestVersionList[$version]->link) ? $latestVersionList[$version]->link : $this->lang->install->officeDomain; + + $this->view->systemInfo = $systemInfo; + if(!is_writable($this->backupPath)) $this->view->backupError = sprintf($this->lang->backup->error->plainNoWritable, $this->backupPath); if(!is_writable($this->app->getTmpRoot())) $this->view->backupError = sprintf($this->lang->backup->error->plainNoWritable, $this->app->getTmpRoot()); $this->display(); diff --git a/module/backup/ui/index.html.php b/module/backup/ui/index.html.php index 99cba34cd4..ca15bf24bc 100644 --- a/module/backup/ui/index.html.php +++ b/module/backup/ui/index.html.php @@ -24,8 +24,8 @@ featureBar ( li ( - set::className('nav-item'), - a(set('data-app', $app->tab), $lang->backup->history) + set::className('nav-item text-lg'), + $lang->backup->common ), set::current('all') ); @@ -58,63 +58,146 @@ if(common::hasPriv('backup', 'setting') and common::hasPriv('backup', 'backup')) ); } -/* DataTable. */ -$cols = $this->loadModel('datatable')->getSetting('backup'); -$data = initTableData($backups, $cols, $this->backup); - -$rows = array(); -foreach($data as $key => $row) -{ - $isOK = true; - $isPHP = false; - foreach($row->files as $file => $attr) - { - if(!isset($attr['allCount']) || !isset($attr['count'])) - { - unset($row->files[$file]); - continue; - } - - if(str_ends_with($file, '.php')) $isPHP = true; - if($attr['allCount'] != $attr['count']) $isOk = false; - } - - $first = true; - foreach($row->files as $file => $attr) - { - $fileName = basename($file); - $backup = new stdclass(); - $backup->file = $file; - $backup->allCount = $attr['allCount']; - $backup->count = $attr['count']; - $backup->size = helper::formatKB($attr['size']); - $backup->status = $attr['allCount'] == $attr['count'] ? $lang->backup->statusList['success'] : $lang->backup->statusList['fail']; - $backup->name = substr($fileName, 0, strpos($fileName, '.')); - - if($first) - { - $backup->time = date(DT_DATETIME1, filemtime($file)); - $backup->rowspan = count($row->files); - $backup->actions = $row->actions; - if(!$isPHP) $backup->actions[0]['disabled'] = true; - if(!$isOK) $backup->actions[1]['disabled'] = true; - } - - $rows[] = $backup; - $first = false; - } -} - -dtable +div ( - set::customCols(false), - set::cols($cols), - set::data($rows), - set::plugins(array('cellspan')), - set::getCellSpan(jsRaw('window.getCellSpan')), - set::footer(array('html' => $lang->backup->restoreTip . sprintf($lang->backup->holdDays, $config->backup->holdDays), 'className' => 'text-important')) + setClass('panel-title'), + $lang->system->backup->systemInfo ); +h::table +( + set::className('table bordered'), + h::thead + ( + h::th($lang->system->backup->name), + h::th($lang->system->backup->status), + h::th($lang->system->backup->currentVersion), + h::th($lang->system->backup->latestVersion), + h::th($lang->actions), + ), + h::tbody + ( + setClass('text-center'), + h::td($systemInfo->name), + h::td($systemInfo->status), + h::td($systemInfo->currentVersion), + h::td + ( + $systemInfo->latestVersion, + $systemInfo->upgradeHint ? a + ( + set::href($systemInfo->latestURL), + set::target('_blank'), + icon('info pl-2 pt-2', set::title($systemInfo->upgradeHint)) + ): null + ), + h::td + ( + set::className('actions-list center'), + btnGroup + ( + set::items + ( + array + ( + array('class' => 'btn text-primary ghost', 'icon' => 'refresh', 'text' => $lang->backup->common , 'onclick' => 'backup(this)'), + array('class' => 'btn text-primary ghost', 'icon' => 'arrow-up', 'text' => $lang->system->backup->upgrade, 'onclick' => 'upgrade(this)', 'disabled' => $systemInfo->upgradeable ? true : true), + ) + ) + ) + ), + ) +); + +div +( + setClass('panel-title mt-6'), + $lang->system->backup->history +); + +if($this->config->inQuickon) +{ + $this->loadModel('system'); + + foreach($backups as $backup) + { + $backup->backupPerson = isset($backup->sqlSummary['account']) ? $backup->sqlSummary['account'] : ''; + if(empty($backup->sqlSummary['backupType'])) $backup->sqlSummary['backupType'] = ''; + $backup->type = $backup->sqlSummary['backupType']; + } + + $data = initTableData($backups, $config->system->dtable->backup->fieldList, $this->system); + + dtable + ( + set::customCols(false), + set::cols($config->system->dtable->backup->fieldList), + set::data($data), + set::plugins(array('cellspan')), + set::getCellSpan(jsRaw('window.getCellSpan')), + set::footer(array('html' => sprintf($lang->backup->holdDays, $config->backup->holdDays), 'className' => 'text-important')) + ); +} +else +{ + /* DataTable. */ + $cols = $this->loadModel('datatable')->getSetting('backup'); + $data = initTableData($backups, $cols, $this->backup); + + $rows = array(); + foreach($data as $key => $row) + { + $isOK = true; + $isPHP = false; + foreach($row->files as $file => $attr) + { + if(!isset($attr['allCount']) || !isset($attr['count'])) + { + unset($row->files[$file]); + continue; + } + + if(str_ends_with($file, '.php')) $isPHP = true; + if($attr['allCount'] != $attr['count']) $isOk = false; + } + + $first = true; + foreach($row->files as $file => $attr) + { + $fileName = basename($file); + $backup = new stdclass(); + $backup->file = $file; + $backup->allCount = $attr['allCount']; + $backup->count = $attr['count']; + $backup->size = helper::formatKB($attr['size']); + $backup->status = $attr['allCount'] == $attr['count'] ? $lang->backup->statusList['success'] : $lang->backup->statusList['fail']; + $backup->name = substr($fileName, 0, strpos($fileName, '.')); + + if($first) + { + $backup->time = date(DT_DATETIME1, filemtime($file)); + $backup->rowspan = count($row->files); + $backup->actions = $row->actions; + if(!$isPHP) $backup->actions[0]['disabled'] = true; + if(!$isOK) $backup->actions[1]['disabled'] = true; + } + + $rows[] = $backup; + $first = false; + } + } + + dtable + ( + set::customCols(false), + set::cols($cols), + set::data($rows), + set::plugins(array('cellspan')), + set::getCellSpan(jsRaw('window.getCellSpan')), + set::footer(array('html' => $lang->backup->restoreTip . sprintf($lang->backup->holdDays, $config->backup->holdDays), 'className' => 'text-important')) + ); +} + modal ( setID('waiting'), diff --git a/module/system/config/dtable.php b/module/system/config/dtable.php index f948c7cb01..5bba22e5c2 100644 --- a/module/system/config/dtable.php +++ b/module/system/config/dtable.php @@ -29,16 +29,21 @@ $config->system->dtable->dbList->fieldList['actions']['list']['dblist']['url'] $config->system->dtable->backup = new stdclass(); -$config->system->dtable->backup->fieldList['time']['title'] = $lang->backup->time; -$config->system->dtable->backup->fieldList['time']['type'] = 'datetime'; +$config->system->dtable->backup->fieldList['time']['title'] = $lang->backup->time; +$config->system->dtable->backup->fieldList['time']['type'] = 'datetime'; +$config->system->dtable->backup->fieldList['time']['formatDate'] = 'yyyy-MM-dd hh::mm:ss'; + +$config->system->dtable->backup->fieldList['backupPerson']['title'] = $lang->system->backup->backupPerson; $config->system->dtable->backup->fieldList['type']['title'] = $lang->system->backup->type; $config->system->dtable->backup->fieldList['type']['map'] = $lang->system->backup->typeList; -$config->system->dtable->backup->fieldList['status']['title'] = $lang->backup->status; +$config->system->dtable->backup->fieldList['status']['title'] = $lang->backup->status; +$config->system->dtable->backup->fieldList['status']['hidden'] = true; -$config->system->dtable->backup->fieldList['comment']['title'] = $lang->comment; -$config->system->dtable->backup->fieldList['comment']['type'] = 'html'; +$config->system->dtable->backup->fieldList['comment']['title'] = $lang->comment; +$config->system->dtable->backup->fieldList['comment']['type'] = 'html'; +$config->system->dtable->backup->fieldList['comment']['hidden'] = true; $config->system->dtable->backup->fieldList['actions']['name'] = 'actions'; $config->system->dtable->backup->fieldList['actions']['title'] = $lang->actions; @@ -46,11 +51,13 @@ $config->system->dtable->backup->fieldList['actions']['type'] = 'actions'; $config->system->dtable->backup->fieldList['actions']['menu'] = array('restore', 'delete'); $config->system->dtable->backup->fieldList['actions']['list']['restore']['icon'] = 'history'; +$config->system->dtable->backup->fieldList['actions']['list']['restore']['text'] = $lang->backup->restore; $config->system->dtable->backup->fieldList['actions']['list']['restore']['hint'] = $lang->backup->restore; $config->system->dtable->backup->fieldList['actions']['list']['restore']['url'] = array('module' => 'system', 'method' => 'restoreBackup', 'params' => 'name={name}'); $config->system->dtable->backup->fieldList['actions']['list']['restore']['data-confirm'] = $lang->system->backup->confirmRestore; $config->system->dtable->backup->fieldList['actions']['list']['delete']['icon'] = 'trash'; +$config->system->dtable->backup->fieldList['actions']['list']['delete']['text'] = $lang->system->backup->delete; $config->system->dtable->backup->fieldList['actions']['list']['delete']['hint'] = $lang->delete; $config->system->dtable->backup->fieldList['actions']['list']['delete']['url'] = array('module' => 'system', 'method' => 'deleteBackup', 'params' => 'name={name}'); $config->system->dtable->backup->fieldList['actions']['list']['delete']['data-confirm'] = array('message' => $lang->system->backup->confirmDelete, 'icon' => 'icon-exclamation-sign', 'iconClass' => 'warning-pale rounded-full icon-2x');